• Buddy (unregistered) in reply to Buddy

    Correction!

    Buddy:
    Revise:
    	long count = pow(size - 1, OPERATORS);
    To:
    	long count = pow(size, OPERATORS);
    

    This will handle cases like:

    echo '4 6' | ./_24 4 6 * 6 4 *

  • Juenemann (unregistered)

    My solution to this: don't fret about lost nickels and just learn poker.

  • Buddy (unregistered) in reply to Buddy

    Ahh f**k it, the line should be:

    long count = pow(OPERATORS, size - 1);

    As long as it's big enough, it will work...

  • monkeyPushButton (unregistered)

    For those talking about other games with a similar idea, there is an Avalon Hill dice game from 1967, Tuf, but that included dice for the operators.

  • Vilx- (unregistered)

    In highschool one of my best friends came up with a similar game which we refined a bit later on. The idea was to add arithmetic operators to the numbers on the licence plates of the passing cars. There was a bit of a rule list to keep the game challenging yet not impossible.

  • Vilx- (unregistered)

    Oh, I think I wrote that a bit badly. I meant that you had to add mathematical operators AND a single equality sign and get a valid equation.

  • Free RAID (unregistered) in reply to YeahRight

    I'd gather they are married to each other...

  • (cs) in reply to unekdoud
    unekdoud:
    I tried this once. Failed because the code couldn't solve 2,7,7,10 for 24.

    Hint/Spoiler: Problem difficulty may increase severalfold at this point, depending on what language you're using.

    I guess my bonus points go to you, sir ;-)

  • jrh (unregistered)

    TRWTF is how much of my work day I spent on this.

    I have generated all the possible formulas, but I'm not going to bother going to the trouble of writing a math evaluator in C#. If I only cared a bit more there are some freeware evaluators available, but then if I'm going to start downloading stuff there is probably a solution for this problem too...

  • me (unregistered)

    Where's the WTF?

    I've got enough programming exercises at work thank you.

  • (cs) in reply to tentative
    tentative:
    3 * (7 + 9 / 9) = 24

    Sorry for the newb question, but why would I want to do this elementary coding exercise?

    FORTY-TWO!

    No, doesn't fit. DAMN!

  • deejayvee (unregistered) in reply to Flatline
    Flatline:
    Ahem, 'me and you' or 'you and I'.

    Actually, he was correct. The best way to tell is if the sentence reads correctly without the "you" and the "and".

    "super-genius coders like I" is not correct. Therefore, the full sentence should be "Presumably not all of the readers of this site are super-genius coders like you and me"

  • stu (unregistered) in reply to pete
    pete:
    There are a couple of other differences, in countdown any divisions can't be fractions so you can't do (9/2) + 1 = 5.5 * 10 = 55 and in countdown not all numbers must be used.
    Good day sir, I would like to notify you that you have failed maths class.
  • stu (unregistered) in reply to stu
    stu:
    pete:
    There are a couple of other differences, in countdown any divisions can't be fractions so you can't do (9/2) + 1 = 5.5 * 10 = 55 and in countdown not all numbers must be used.
    Good day sir, I would like to notify you that you have failed maths class.
    And I have failed attention class. Please disregard this post.
  • Swedish tard (unregistered) in reply to cellocgw
    cellocgw:
    Evo:
    Booooooooooooooooooooooooooooring.

    Though I like the 24 game... Bonus points for the person who can come up with the hardest 24 game puzzle.

    OK, but first: bonus points for someone who can define "hardest" in this context.

    I'd go for "impossible": 1 1 1 1 1
  • PinkyAndTheBrainFan187 (unregistered)

    inb4 one-line perl/python/ruby implementation

  • Mr.'; Drop Database -- (unregistered)

    I came up with a "hard" solution in Python. It's rather long, so refer to Pastebin. Example usage:

    >>> solve([3,7,9,9], 24)
    (3+9)(9-7)
    3(7+9/9)
    (7*9+9)/3
    In response to the fellow who asked what the hardest 24 puzzle is, I always thought of 1,3,4,6 as the hardest. I won't spoil it here but if you get stuck you can always run my solver. :)

  • G (unregistered) in reply to Machtyn
    Machtyn:
    My high school girlfriend and I would play this game on occasion. She introduced it to me. She was awesome, valedictorian in HS, top honors at her engineering program at a major university (she was #1 or 2 of her class), and she's currently married and a stay-at-home mom... she is awesome.

    Married to who?

    Captcha: damnum

  • (cs) in reply to Mr.'; Drop Database --
    Mr.'; Drop Database --:
    I came up with a "hard" solution in Python. It's rather long, so refer to Pastebin. Example usage:
    >>> solve([3,7,9,9], 24)
    (3+9)*(9-7)
    3*(7+9/9)
    (7*9+9)/3
    In response to the fellow who asked what the hardest 24 puzzle is, I always thought of 1,3,4,6 as the hardest. I won't spoil it here but if you get stuck you can always run my solver. :)

    I get "TypeError: 'Fraction' object cannot be interpreted as an index". And I suck at python, so I have no idea what to do there :P.

  • Mr.'; Drop Database -- (unregistered) in reply to Evo
    Evo:
    Mr.'; Drop Database --:
    I came up with a "hard" solution in Python. It's rather long, so refer to Pastebin. Example usage:
    >>> solve([3,7,9,9], 24)
    (3+9)*(9-7)
    3*(7+9/9)
    (7*9+9)/3
    In response to the fellow who asked what the hardest 24 puzzle is, I always thought of 1,3,4,6 as the hardest. I won't spoil it here but if you get stuck you can always run my solver. :)
    I get "TypeError: 'Fraction' object cannot be interpreted as an index". And I suck at python, so I have no idea what to do there :P.
    Looks like the rules for the Fraction constructor changed recently. Try this code instead; I've checked that it works in Python 2.6.
  • (cs)

    I loved Krypto as a kid. My problem was that I could never find anyone willing to play with me*.

    *Seems to be an ailment that has spilled over to adult life!

  • (cs) in reply to MiffTheFox
    MiffTheFox:
    Wasn't Krypto Superman's dog?
    No. That was Krypto-Knight.
  • Alex (unregistered)

    I (ab)used Lua for a 24 line, 734 byte Medium-Hard implementation. A lot of duplicate solutions are removed, and all solutions are found from any length string. For good measure it also includes power and modulo operators.

    http://pastebin.com/VxcpdnrL

    If your lua binary is called lua.exe and the file "stupid.lua", run with the param string "lua.exe stupid.lua 5 5 8 2 10 24" to solve alex's 24 card problem.

  • Alex (unregistered) in reply to Alex

    I knew I should have previewed that first.

    Code.

    Damn spamblockers.

  • asdf (unregistered) in reply to Mr.'; Drop Database --
    Mr.'; Drop Database --:
    Evo:
    Mr.'; Drop Database --:
    I came up with a "hard" solution in Python. It's rather long, so refer to Pastebin. Example usage:
    >>> solve([3,7,9,9], 24)
    (3+9)*(9-7)
    3*(7+9/9)
    (7*9+9)/3
    In response to the fellow who asked what the hardest 24 puzzle is, I always thought of 1,3,4,6 as the hardest. I won't spoil it here but if you get stuck you can always run my solver. :)
    I get "TypeError: 'Fraction' object cannot be interpreted as an index". And I suck at python, so I have no idea what to do there :P.
    Looks like the rules for the Fraction constructor changed recently. Try this code instead; I've checked that it works in Python 2.6.

    1,3,4,6 = 24 has no solution using the four operators and paranthesis. Here is a brute force solution in your favorite language, vb6:

    Public Sub Solve(ByVal a1 As Integer, ByVal a2 As Integer, ByVal a3 As Integer, ByVal a4 As Integer, ByVal a5 As Integer, ByVal Answer As Integer)

    Dim n As Long Dim x As Long Dim y As Long

    Dim operator(3) As String Dim pos(3) As String Dim z As Long Dim s(44) As String Dim a(4) As Long

    a(0) = a1 a(1) = a2 a(2) = a3 a(3) = a4 a(4) = a5

    operator(0) = "+" operator(1) = "-" operator(2) = "*" operator(3) = "/"

    s(0) = " " 'two s(1) = "( ) " s(2) = " ( ) " s(3) = " ( ) " s(4) = " ( )" s(5) = "( )( ) " s(6) = "( ) ( )" s(7) = " ( )( )"

    s(8) = "( ) " 'three s(9) = " ( ) " s(10) = " ( )"

    s(11) = "[ ) ) " 'first three s(12) = "( ( ] " s(13) = " [ ) ) " 'middle three s(14) = " ( ( ] " s(15) = " [ ) )" 'last three s(16) = " ( ( ]"

    s(17) = "( )( )" 'three and two s(18) = " ) )( )" s(19) = "( ( "

    s(20) = "( )( )" 'two and three s(21) = "( )[ ) )" s(22) = "( )( ( ]"

    s(23) = "( ) " 'first four s(24) = "[ ) ) " 'first four and two s(25) = "( ( ) ) " s(26) = "( ( ] " s(27) = "[ )( ] "

    s(28) = "[ ) ) " 'first four and first three s(29) = "{ ) ) ) " s(30) = "[ ( ] ) "

    s(31) = "( ( ] " 'first four and last three s(32) = "( [ ) ] " s(33) = "( ( ( } "

    s(34) = " ( )" 'last four s(35) = " [ ) )" 'last four and two s(36) = " ( ( ) )" s(37) = " ( ( ]" s(38) = " [ )( ]"

    s(39) = " [ ) )" 'last four and first three s(40) = " { ) ) )" s(41) = " [ ( ] )"

    s(42) = " ( ( ]" 'last four and last three s(43) = " ( [ ) ]" s(44) = " ( ( ( }"

    For n = 0 To 255 z = n For x = 0 To 3 pos(x) = operator(3 And z) z = z \ 4 Next x For z = 0 To 44 Dim ss As String ss = "" For y = 0 To 4 Dim zz zz = Mid(s(z), y * 2 + 1, 1) If zz = "[" Then zz = "((" ElseIf zz = "{" Then zz = "(((" End If ss = ss & zz & a(y) zz = Mid(s(z), y * 2 + 2, 1) If zz = "]" Then zz = "))" ElseIf zz = "}" Then zz = ")))" End If ss = ss & zz If y <> 4 Then ss = ss & " " & pos(y) & " " End If Next y Dim ans As Double On Error Resume Next ans = script.Eval(ss) On Error GoTo 0 Debug.Print ss & " = " & ans

      If ans = CLng(ans) And ans > 0 And ans < 25 Then
        Dim col As New Collection
        On Error Resume Next
        col.Add ss & " = " & ans, CStr(ans)
        On Error GoTo 0
        Debug.Print ss & " = " & ans
        Dim bFoundAnswer As Boolean
        If Not bFoundAnswer Then
          If ans = Answer Then
            bFoundAnswer = True
            If MsgBox("Continuue? " & vbCrLf & vbCrLf & ss & " = " & ans, vbYesNo) <> vbYes Then
              Exit Sub
            End If
          End If
        End If
      End If
    Next z
    

    Next n

    If Not bFoundAnswer Then MsgBox "No solution." End If

    Dim v For Each v In col 'show all unique possible positive integer solutions < 25 Debug.Print v Next

    End Sub

  • asdf (unregistered) in reply to asdf

    Unless you are assuming 1 may equal 1 OR 11:

    11 + 3 + 4 + 6 = 24

  • (cs)

    Actually there is a legitimate way to get 1,3,4,6 to 24 within the rules of the game, but it requires some out of the box thinking...

    6 / (1 - (3/4)) = 24

    i.e. 6 / 0.25 = 24

    Disclaimer: I didn't figure this out myself.

  • asdf (unregistered) in reply to Iain Collins

    Good job, I'm sorry, I did not look at the cards to see that they could be re-ordered. I also don't know if and didn't assume you could 'group cards' without multiplication; e.g., "8s 5d" could be used as "85"

  • grammarnazi (unregistered) in reply to deejayvee
    deejayvee:
    Flatline:
    Ahem, 'me and you' or 'you and I'.

    Actually, he was correct. The best way to tell is if the sentence reads correctly without the "you" and the "and".

    "super-genius coders like I" is not correct. Therefore, the full sentence should be "Presumably not all of the readers of this site are super-genius coders like you and me"

    Actually the very first person was correct. The real trick is to add the missing verb. "Presumably not all of the readers of this site are super-genius coders like you and I are." And then take out the "are": "Presumably not all of the readers of this site are super-genius coders like you and I."

  • (cs)

    Let's see... given n cards, there's a total of n!*4^(n-1)*fibonacci(n) possible patterns, that's 153600 different patterns for n=5... for n=10, it's 52319748096000... a brute force algorithm checking all patterns might not scale so easily.

  • Buddy (unregistered)

    _24.cc. Handles harder problems like 1, 3, 4, 6 using a swap hack (labelled r as in the Unix utility dc) at the expense of many more duplicate solutions!

    echo '1 3 4 6' | ./_24 3 4 / 1 r - 6 r / 4 3 r / 1 r - 6 r /

    First solution illustrated:

    3 4 / 1 r - 6 r / 0.75 1 r - 6 r / 1 0.75 - 6 r / 0.25 6 r / 6 0.25 / 24

    Overall, I found the challenge interesting. Obviously next_permutation is the workhorse here, and the reason I used C++. I haven't touched C++ in a while, so got to flex some old brain muscles...

  • Dylan (unregistered)
    grammarnazi:
    Actually the very first person was correct. The real trick is to add the missing verb. "Presumably not all of the readers of this site are super-genius coders like you and I are." And then take out the "are": "Presumably not all of the readers of this site are super-genius coders like you and I."
    I are? You're turning an object into a subject with your 'missing' verb. And I'm pretty sure switching two words around an 'and' doesn't change which pronoun you choose. No matter how they toss the dice.

    And I'll throw in an actual reference I found when double checking the song lyrics. http://grammar.quickanddirtytips.com/between-you-and-me.aspx

    Odd, posting comments breaks when javascript is off.

  • Danny V (unregistered)

    Easy! We just need "something" that has all the cards, and then something that deals cards randomly. Then "something else" to look at how those somethings could be put together mathematically.

    It doesn't take Someone like Kevin to solve this problem. Sheesh!

  • asdf (unregistered) in reply to derula

    I agree. After recoding for n cards in any order; for 5 (unique) cards I get the following:

    Card Count: 5 Card permutations count: 120 Parenthesis permutations count: 38 Operator permutations count: 256 Total equation count: 1167360

    The only thing not shown by this is elimating parenthesis where commutative property is true.

  • anon (unregistered) in reply to grammarnazi
    grammarnazi:
    deejayvee:
    Flatline:
    Ahem, 'me and you' or 'you and I'.

    Actually, he was correct. The best way to tell is if the sentence reads correctly without the "you" and the "and".

    "super-genius coders like I" is not correct. Therefore, the full sentence should be "Presumably not all of the readers of this site are super-genius coders like you and me"

    Actually the very first person was correct. The real trick is to add the missing verb. "Presumably not all of the readers of this site are super-genius coders like you and I are." And then take out the "are": "Presumably not all of the readers of this site are super-genius coders like you and I."

    Here's a pop quiz for you:

    1. Tony is very smart. I wish I was smart like a) he b) him

    2. Paula is brilliant. I'm glad I'm not brilliant like a) she b) her

    3. You and I are strong. Everybody wishes they were strong like a) you and I b) you and me

    4. The would-be grammarians who offered their improvements to the original post were a) wrong b) completely off base c) trying so hard to show off their cleverness it makes you wonder a little about their self-esteem, the poor dears. Maybe someone should have praised them more when they were children, or something.

    (choose all that apply)

    (captcha: uxor - like XOR, only more so)

  • Mr.'; Drop Database -- (unregistered) in reply to Alex
    Alex:
    I (ab)used Lua for a 24 line, 734 byte Medium-Hard implementation. A lot of duplicate solutions are removed, and all solutions are found from any length string. For good measure it also includes power and modulo operators.

    http://pastebin.com/VxcpdnrL

    If your lua binary is called lua.exe and the file "stupid.lua", run with the param string "lua.exe stupid.lua 5 5 8 2 10 24" to solve alex's 24 card problem.

    That might need some more work. It tends to produce a lot of duplicatesThe duplicate detection could do with some improvement (It produces a lot of duplicates with only minor differences, such as X+Y+Z and X+(Y+Z), and misses a lot of solutions, including (510+8)/2-5, (2-10)/8+55, (2*10-5)8/5, (5/2+5/10)8, (2+5+5)(10-8) and 2(5+5+10-8).

    I tried it on the 1,3,4,6 = 24 problem and it didn't find the answer (there's exactly one solution not using power or mod).

  • Mr.'; Drop Database -- (unregistered) in reply to Alex

    Submitted previous comment prematurely...

    Alex:
    I (ab)used Lua for a 24 line, 734 byte Medium-Hard implementation. A lot of duplicate solutions are removed, and all solutions are found from any length string. For good measure it also includes power and modulo operators.

    http://pastebin.com/VxcpdnrL

    If your lua binary is called lua.exe and the file "stupid.lua", run with the param string "lua.exe stupid.lua 5 5 8 2 10 24" to solve alex's 24 card problem.

    That might need some more work. It tends to produce a lot of duplicates with only minor differences, such as X+Y+Z and X+(Y+Z), and misses a lot of solutions, including (510+8)/2-5, (2-10)/8+55, (2*10-5)8/5, (5/2+5/10)8, (2+5+5)(10-8) and 2(5+5+10-8).

    I tried it on the 1,3,4,6 = 24 problem and it didn't find the answer (there's exactly one solution not using power or mod).

  • Matt (unregistered)

    A couple years ago I was programming for an insurance company. On fridays, a couple actuaries and I would spend an hour at a local elementary school teaching math to kids.

    One game we played was 24. The class would be divided into teams, and a member from each team would go to the board. 4 numbers were called out and the first person to use all four numbers to make 24 would get a point.

    One day, we decided to play a game where the kids all played against the actuaries. I was a programmer, so I argued to be on my own team. I immediately pulled out my laptop and began hacking together a ruby a script. I ignored the first few rounds, but 5 minutes later I was ready to start playing.

    I taught those kids an important lesson in the power of automation that day.

  • Mr.'; Drop Database -- (unregistered)

    I wrote a script to run my solver over all 4- and 5-digit input arrays and pick out the inputs that are "hardest", judging by the number of solutions and the operators used. One seems to stand out above all others:

    6,7,7,7,8 = 24 has two solutions. One is 678/(7+7). What's the other one?

    Another interesting problem is 5,5,5,5,5 = 24. One solution is (555-5)/5. What's the other one?

  • Alex (unregistered) in reply to Mr.'; Drop Database --
    Mr.'; Drop Database --:
    I tried it on the 1,3,4,6 = 24 problem and it didn't find the answer (there's exactly one solution not using power or mod).
    Oops, reading comprehension fail late last night. I'll continue the brute force approach, now 1018 bytes, 37 lines. It gets the solution 6/(1 - 3/4) = 24.

    As for removing duplicates - it does a pretty poor job on this I know. It's hard to do better then that though without writing good code, which I was trying to avoid.

    Akismet swears this is spam.

  • Alex (unregistered) in reply to Mr.'; Drop Database --
    Mr.'; Drop Database --:
    I wrote a script to run my solver over all 4- and 5-digit input arrays and pick out the inputs that are "hardest", judging by the number of solutions and the operators used. One seems to stand out above all others:

    6,7,7,7,8 = 24 has two solutions. One is 678/(7+7). What's the other one?

    Another interesting problem is 5,5,5,5,5 = 24. One solution is (555-5)/5. What's the other one?

    I won't spoil both, but the second is (5-5/5/5)*5. ;)

  • Alex (unregistered)

    Agh, have to stop rushing these posts. Here's the correct pastebin. 932 bytes, 32 lines.

  • fonji (unregistered)

    I'm disappointed no one tried using prolog.

  • Alex (unregistered)

    Go ahead, I for one would like to see a prolog solution..

    And my final submission. 3rd time's the charm..

  • n00b (unregistered)

    Here is PHP code with eval, division by 0, global variables and of course random! See it in action!

    <?php
    header('Content-Type: text/plain');
    $arr=array(8,5,2,10,5,3);
    game($arr);
    game($arr, 24);
    function game($arr, $var='Krypto'){
    	if($var!=24)
    		$ans=array_pop($arr);
    	else
    		$ans=24;
    	for ($i=0; $i<50000; $i++){
    		if (guess($arr, $ans)===true){
    			echo"\nI tried $i combinations before I got the answer for $var.\n\n";
    			break;
    		}
    	}
    }
    
    function guess($arr, $ans){
    global $pcount;
    	$pcount=0;
    	shuffle($arr);
    	for($i=0; $i<count($arr); $i++){
    		if($i==(count($arr)-1))
    			$last=true;
    		else
    			$last=false;
    		$line.=construct($arr[$i], $last);
    	}
    	eval('$result=@('.$line.');');
    	if($ans==$result){
    		echo $line.' = '.$result;
    		return true;
    	}
    	else{
    		return false;
    	}
    }
    function construct($num, $last){
    global $pcount;
    	$op=array('+', '-', '*', '/');
    	if($last===true){
    		while($pcount>0){
    			$num="$num)";
    			$pcount--;
    		}
    	}
    	else if(rand(1, 4)>3){
    		if(rand(1, 3)<3 && $pcount>0){
    			$num="$num)";
    			$pcount--;
    		}
    		else{
    			$num="($num";
    			$pcount++;
    		}
    	}
    	if(!$last===true){
    		$num.=$op[array_rand($op)];
    	}
    	return $num;
    }
    ?>
  • Jerry (unregistered) in reply to Michael Mol

    Great site.

    However, recursion is the more elegant solution to this sort of problem to me.

  • (cs)

    You guys don't try hard enough. Here's a fragment I wrote in C. It's incomplete, but I'm sure you get the idea.

    define TWENTYFIVE 24
    
    /* for clean code we use a function!!!! */
    boolean chceck_result(float candidate) {
    if (round(candidate) == TWENTYFIVE) {
        return true;
    }
    return false;
    }
    
    int main(/* arguments... */) {
    int n1, n2, n3, n4, n5; 
    /* ... */
    
    if (chceck_result(n1 + n2 + n3 + n4 + n5)) {
        printf("The solution is %d + %d + %d + %d + %d!!!!\n", n1, n2, n3, n4, n5);
    } else if (chceck_result(n1 + n2 + n3 + n4 - n5)) {
        printf("The solution is %d + %d + %d + %d - %d!!!!\n", n1, n2, n3, n4, n5);
    } else if (chceck_result(n1 + n2 + n3 - n4 + n5)) {
        printf("The solution is %d + %d + %d - %d + %d!!!!\n", n1, n2, n3, n4, n5);
    }
    
    /* snip rest of substraction, multiplication, division for given number order!!!! */
    
    else if (chceck_result(n1 + n2 + n3 + n5 + n4)) {
        printf("The solution is %d + %d + %d + %d + %d!!!!\n", n1, n2, n3, n5, n4);
    } else if (chceck_result(n1 + n2 + n3 + n5 - n4)) {
        printf("The solution is %d + %d + %d + %d - %d!!!!\n", n1, n2, n3, n5, n4);
    } else if (chceck_result(n1 + n2 + n3 - n5 + n4)) {
        printf("The solution is %d + %d + %d - %d + %d!!!!\n", n1, n2, n3, n5, n4);
    }
    
    
    /* remember to try all combinations!!!! */
    else if (chceck_result(((n1 /n2) / (n3 / n4) /n5)) {
        printf("The solution is (%d / %d) / (%d /%d) /%d!!!!\n", n5, n4, n3, n2, n1);
    } else {
        printf("There is no solution!!!!\n");
    }
    
    return 0;
    }
  • DaveC (unregistered)

    I wrote essentially the "Hard" version many years ago (in C, later in ML and the Prolog) to find all the solutions to the "Numbers" game from the British intellectual TV show Countdown.

    It works like this:

    • there is a board with 24 face down cards, arranged in one row of 4, and the rest in 3 other rows
    • each card has a number - the top row of 4 is the numbers 25, 50, 75, 100, and the other 20 cards are 2 copies each of the numbers 1-10
    • 6 cards are chosen. The contest whose turn it is to pick requests which rows they come from.
    • the canonical choice is "one from the top, five from the others" but to make it harder, skillful contestants will ask for "6 small ones"
    • once the cards have been drawn and displayed, a random number generator picks a number between 100 and 999
    • the contestants then have 30 seconds to come up with a formula using the 4 basic operations to generate an integer result that gets as close to that number as possible

    On a computer, this is very easy to do by exhaustive search - even with mid 1980's desktop tech it takes about 2-3 seconds if coded well.

    http://en.wikipedia.org/wiki/Countdown_%28game_show%29

  • asdf (unregistered) in reply to Mr.'; Drop Database --
    Mr.'; Drop Database --:
    I wrote a script to run my solver over all 4- and 5-digit input arrays and pick out the inputs that are "hardest", judging by the number of solutions and the operators used. One seems to stand out above all others:

    6,7,7,7,8 = 24 has two solutions. One is 678/(7+7). What's the other one?

    Another interesting problem is 5,5,5,5,5 = 24. One solution is (555-5)/5. What's the other one?

    (5 - (5 / (5 * 5))) * 5 = 24

  • asdf (unregistered) in reply to Mr.'; Drop Database --
    Mr.'; Drop Database --:
    I wrote a script to run my solver over all 4- and 5-digit input arrays and pick out the inputs that are "hardest", judging by the number of solutions and the operators used. One seems to stand out above all others:

    6,7,7,7,8 = 24 has two solutions. One is 678/(7+7). What's the other one?

    Another interesting problem is 5,5,5,5,5 = 24. One solution is (555-5)/5. What's the other one?

    Which of these do you like?

    6 / ((7 + 7) / 7) * 8 = 24 6 * 7 / ((7 + 7) / 8) = 24 6 / ((7 + 7) / 7 / 8) = 24 6 / ((7 + 7) / 8) * 7 = 24 6 / ((7 + 7) / 8 / 7) = 24 6 * 8 / ((7 + 7) / 7) = 24 7 * 6 / ((7 + 7) / 8) = 24 7 / ((7 + 7) / 6) * 8 = 24 7 / ((7 + 7) / 6 / 8) = 24 7 / ((7 + 7) / 8) * 6 = 24 7 / ((7 + 7) / 8 / 6) = 24 7 * 8 / ((7 + 7) / 6) = 24 8 * 6 / ((7 + 7) / 7) = 24 8 / ((7 + 7) / 6) * 7 = 24 8 / ((7 + 7) / 7) * 6 = 24 8 * 7 / ((7 + 7) / 6) = 24 8 / ((7 + 7) / 7 / 6) = 24

Leave a comment on “Krypto and 24”

Log In or post as a guest

Replying to comment #:

« Return to Article