Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Puzzle

Options
  • 18-04-2008 3:41pm
    #1
    Closed Accounts Posts: 2,267 ✭✭✭


    Ok lets have some fun, you may have gotten this puzzle before,
    but here the idea is to write a program that will do the work for you..
    I dont mean brute force the spread sheet itself, but code an algorithm in a language of your choice to to brute a code based on the following rules:

    "'A man wanted to get into his work building, but he had forgotten his
    code. However, he did remember five clues. These are what those clues were:
    The fifth number plus the third number equals fourteen.
    The fourth number is one more than the second number.
    The first number is one less than twice the second number.
    The second number plus the third number equals ten.
    The sum of all five numbers is 30.'
    What were the five numbers and in what order?
    The answer unlocks the attachment above!
    If you will open the file, write your name on the list inside, and send
    this email to your friends to let them solve this rid."



    I have done a C source, I'll post it up later as I dont want to spoil yet.

    GOOGLE and die.


Comments

  • Registered Users Posts: 5,379 ✭✭✭DublinDilbert


    Ok lets have some fun, you may have gotten this puzzle before,
    but here the idea is to write a program that will do the work for you..
    I dont mean brute force the spread sheet itself, but code an algorithm in a language of your choice to to brute a code based on the following rules:

    "'A man wanted to get into his work building, but he had forgotten his
    code. However, he did remember five clues. These are what those clues were:
    The fifth number plus the third number equals fourteen.
    The fourth number is one more than the second number.
    The first number is one less than twice the second number.
    The second number plus the third number equals ten.
    The sum of all five numbers is 30.'
    What were the five numbers and in what order?
    The answer unlocks the attachment above!
    If you will open the file, write your name on the list inside, and send
    this email to your friends to let them solve this rid."



    I have done a C source, I'll post it up later as I dont want to spoil yet.

    GOOGLE and die.


    jebus you need a C compiler to figure that one out :eek:


    5th + 3rd = 14
    4th = 2nd +1
    1st -1 = 2nd x 2
    2nd + 3rd = 10
    sum of all 5 = 30

    Assign Letter to number based on position.....

    C + E = 14
    D = B + 1
    A - 1 = 2B
    B + C = 10

    A + B + C + D + E = 30



    C = 10-B

    E = 14-(10-B)
    E = B+4


    B = D-1
    B = (A-1)/2
    B = C-10
    B = 30 - A - C - D - E

    B = 30 - (2B+1) -(10-B) - (B + 1) -(B+4)
    B = 30 - 2B -1 -10 + B - B -1 - B -4
    B = 30 - 16 +B(-2+1-2)
    B = 14 -B3
    B + 3B = 14


    B = 3.5
    A = 8
    C = 6.5
    D = 4.5
    E = 7.5


  • Moderators, Science, Health & Environment Moderators Posts: 10,079 Mod ✭✭✭✭marco_polo


    Slow day at work so I needed something to do.

    It is a masterpiece in decryption ;)
    
    
    public class Brute {
    	
       public static void main(String[] args) {	
            int code=0;
            while(!checkResult(intToArray(code))){
            code++;
            System.out.println("Not " + code);	
            }
            System.out.println("Code: " + code);
       }
    	
       public static boolean checkResult(int[] code){	
            return code[4]+code[2] == 14 && code[3] == code[1] +1 && code[0]+1 == code[1]*2
                    && code[0]+code[1]+code[2]+code[3]+code[4]==30 && code[1]+code[2]==10;
       }
    
       static int[] intToArray(int number){
            int[] result=new int[5];
            int power=1;
            for (int i=result.length-1;i>=0; i--){
                    result[i]= (int) ((number % Math.pow(10, power)) 
                            - (int) (number % Math.pow(10, power-1))) 
                            / (int)Math.pow(10, power-1);			
                    power++;
            }
            
            return result;	
       }
    }
    
    
    
    

    Answer I get is
    Code: 74658


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    3rd doesn't exceed 10, and used with 5th to calculate 14
    the 2nd doesn't exceed 10 either, and is used with 3rd to calculate 10

    1st = (2nd * 2) - 1
    4th = (2nd + 1)


    [PHP]int a,b,c,d,e;

    for(c = 1;c < 10;c++) {

    e = (14 - c);
    b = (10 - c);

    a = (b * 2) - 1;
    d = (b + 1);

    if((a + b + c + d + e) == 30) {
    printf("\nKey found: %d,%d,%d,%d,%d",a,b,c,d,e);
    }
    }[/PHP]

    i know this isn't the "proper" solution.
    jebus you need a C compiler to figure that one out

    its about how it would be solved using code..your algorithm looks quite complex ;)
    but no doubt the right way to do it.


  • Closed Accounts Posts: 2,267 ✭✭✭h57xiucj2z946q


    ok it has been solved so i'll post my solution:
    #include <stdio.h>
    
    main() {
    
    int a, b, c, d, e;
    
    printf("1st No. = A, 2nd No. = B, 3rd No. = C, 4th No. = D, 5th No. = E\n\n");
    printf("The fifth number plus the third number equals fourteen. C + E = 14?\n");
    printf("The fourth number is one more than the second number. D = B + 1?\n");
    printf("The first number is one less than twice the second number. A = (B * 2) + 1?\n");
    printf("The second number plus the third number equals ten. B + C = 10?\n");
    printf("The sum of all five numbers is 30. A + B + C + D + E = 30?\n\n");
    printf("lets go? hit enter...");
    getchar();
    
           for (a = 0; a < 10; a++) {
               for (b = 0; b < 10; b++) {
                   for (c = 0; c < 10; c++) {
                       for (d = 0; d < 10; d++) {
                           for (e = 0; e < 10; e++) {
    
                                printf("Trying: [&#37;d] [%d] [%d] [%d] [%d]\n",a,b,c,d,e);
    
                               if (c + e == 14)
                                     if (d == b + 1)
                                           if (a == (b * 2)-1)
                                                 if (b + c == 10)
                                                       if (a + b + c + d + e == 30) {
                                                             printf("Answer is: %d%d%d%d%d\n\n",a,b,c,d,e);
                                                             printf("Hit enter to exit...\n");
                                                             getchar();
                                                             exit(0);
                                                       }
                           /* end of for loops */
                           }
                       }
                   }
               }
           }
    }
    


    Result:
    74658


  • Registered Users Posts: 1,119 ✭✭✭Donald-Duck


    jebus you need a C compiler to figure that one out :eek:


    5th + 3rd = 14
    4th = 2nd +1
    1st = (2nd x 2)-1
    2nd + 3rd = 10
    sum of all 5 = 30

    Assign Letter to number based on position.....

    C + E = 14
    D = B + 1
    A = 2B -1
    B + C = 10

    A + B + C + D + E = 30



    C = 10-B

    E = 14-(10-B)
    E = B+4


    B = D-1
    B = (A-1)/2
    B = C-10
    B = 30 - A - C - D - E

    B = 30 - (2B-1) -(10-B) - (B + 1) -(B+4)
    B = 30 - 2B +1 -10 + B - B -1 - B -4
    B = 30 -3B -10 -4
    B = 16 -3B
    B + 3B = 16


    B = 4
    A = 7
    C = 6
    D = 5
    E = 8
    I fixed your maths :)


  • Advertisement
  • Registered Users Posts: 538 ✭✭✭cuppa


    "'A man wanted to get into his work building, but he had forgotten his
    code. However, he did remember five clues. These are what those clues were:
    1.mate get you in.
    2.shout at secuirty guard
    3.mobile
    4.carry hammer
    5.go home,,take the day off.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,718 Mod ✭✭✭✭Capt'n Midnight


    Diophantus of Alexandria

    Διόφαντος ο Αλεξανδρεύς

    We know almost nothing about Diophantus, except that he lived, in Alexandria. We know that he quotes Hypsicles (150 BC) and he is quoted by Theon of Alexandria (whose date is fixed by the solar eclipse of June 16, 364 AD ).

    This tomb holds Diophantus. Ah, what a marvel! And the tomb tells scientifically the measure of his life. God vouchsafed that he should be a boy for the sixth part of his life; when a twelfth was added, his cheeks acquired a beard; He kindled for him the light of marriage after a seventh, and in the fifth year after his marriage He granted him a son. Alas! late-begotten and miserable child, when he had reached the measure of half his father's life, the chill grave took him. After consoling his grief by this science of numbers for four years, he reached the end of his life.


  • Registered Users Posts: 1,456 ✭✭✭FSL


    By my reckoning Diophantus was 84 which for that era was a remarkable age.


Advertisement