Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What's wrong with this code?

    Hey everyone, quick question about my code.

    Encoding of "THISISATEST"

    * Chop the message into blocks of size 6:
    THISIS (6 char)
    ATEST (5 char)

    * Encode using the permuation:
    (0->1, 1->3, 2->5, 3->4, 4->0, 5->2)

    ** In the first case, we have enough characters and encode as:

    ITSHSI
    Add the number of # appended to the beginning:
    0ITSHSI
    ** In the second case, we need to append #:
    ATEST#

    Permute and get
    TA#TSE

    Add the number of # appended to the beginning:
    1TA#TSE

    The final encoding is: 0ITSHSI1TA#TSE
    That's a basic example of what I want to do.
    I can't seem to figure out how to get each substring (0-5) , (6-11), (12-17) etc.
    Once I can figure that out, I'll be able to concatenate these substrings together.

    Here's my code:

    PHP Code:
    public class Test 
    {

       public static 
    void main(String[]args)
     {
         
    int start=0;
         
    String input "hello how are doing today?";
         
        while(
    start input.length())
      {
        
    String inputSubstring input.substring(startstart+5);
        
        if(
    inputSubstring.length() < 6)
        { 
          
    int a = (inputSubstring.length());
          for(
    int i 0ai++)
          {
            
    inputSubstring += "#";
          }
           
    inputSubstring =   a+inputSubstring;
        }
        
        
    start++;
      }
     }
        

    Thanks so much!
    Last edited by superduper; 11-11-2007 at 11:28 PM.

  • #2
    New Coder
    Join Date
    Oct 2007
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Deleted.
    Last edited by superduper; 11-12-2007 at 10:56 PM.

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Deleted.
    Last edited by superduper; 11-12-2007 at 10:56 PM.

  • #4
    New Coder
    Join Date
    Oct 2007
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Deleted.
    Last edited by superduper; 11-12-2007 at 10:56 PM.

  • #5
    New Coder
    Join Date
    Oct 2007
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hah, okay well I figured that out too.
    Here's my fixed code:
    PHP Code:
    import java.util.Random;
    public class 
    Test5
    {
        public static 
    void main(String[]args)
        {
            
    int number 0;
            
    int [] ranks = {1,2,3,4,5};
            
    int serialID;
        
    Random randomNumber = new Random();

    for(
    int i 0<= ranks.length-1i++)
    {
           
    number randomNumber.nextInt(1000);
              
    number number/10;
           
    number number*10;
      while(
    number 100 || number ==1000)
    {
        
    number randomNumber.nextInt(1000);
        
    //System.out.println("Original: " +number);
        
         
    if(number >= 100)
        {
             
    number number/10;
             
    number number*10;
             break;
             
           }
           else if (
    number <100)
           {
              
    number randomNumber.nextInt(1000);
              
    number number/10;
           
    number number*10;
           }
       }
       
      
    // System.out.println(number);
       
    serialID 202000 number ranks[i];
       
    System.out.println("Serial ID "+(i+1)+ " :" +serialID);
    }

        
    System.out.println("Done");
        
        
        
        }

    Although how would I make an array out of the five serialIDs?

    such as

    int [] ID = {the first serial, the second serial, etc, etc, etc,}

    the first serial would of course be the serialID generated from the first loop, how would I do this?

    Please help, thank you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •