Friday, 15 February 2013

Four fours

The "Four fours" problem has probably wasted many people's time... As I recently rediscovered the fun in solving this, but I didn't have the patience to figure out how to get more than 2 or 3 values, I started writing a program for it instead. Supposedly, computers are better at number crunching.

It takes about 2 15 seconds to compute five fours on my super-speedy 1.0 GHz AMD not-even-sure-it's-Turing-complete thing. However, trying with seven fours is only for the brave and the patient. The algorithm stores partial results in some huge matrix to reduce computation time, but I have a feeling that this has consequences (especially in JavaScript).

I want to see all
0 = (((4 - 4) * 4) * 4)
1 = (((4 - 4) + 4) / 4)
2 = ((4 / (4 + 4)) * 4)
3 = (((4 + 4) + 4) / 4)
4 = (((4 - 4) * 4) + 4)
5 = (((4 * 4) + 4) / 4)
6 = (((4 + 4) / 4) + 4)
7 = ((4 - (4 / 4)) + 4)
8 = (((4 + 4) / 4) * 4)
9 = (((4 / 4) + 4) + 4)
10 = (((4 / 4) + 4) * √4)
12 = ((4 - (4 / 4)) * 4)
14 = (((√4 + 4) + 4) + 4)
15 = ((4 * 4) - (4 / 4))
16 = (((4 - 4) + 4) * 4)
17 = ((4 / 4) + (4 * 4))
18 = (((4 * 4) - √4) + 4)
20 = (((4 / 4) + 4) * 4)
22 = (((4 * 4) + √4) + 4)
24 = (((4 * 4) + 4) + 4)
26 = (((√4 + 4) * 4) + √4)
28 = (((4 + 4) * 4) - 4)
30 = (((4 + 4) * 4) - √4)
32 = ((4 * 4) + (4 * 4))
34 = (((4 + 4) * 4) + √4)
36 = (((4 + 4) * 4) + 4)
40 = (((√4 + 4) + 4) * 4)
48 = (((4 + 4) + 4) * 4)
56 = (((4 * 4) - √4) * 4)
60 = (((4 * 4) * 4) - 4)
62 = (((4 * 4) * 4) - √4)
64 = ((4 + 4) * (4 + 4))
66 = (((4 * 4) * 4) + √4)
68 = (((4 * 4) * 4) + 4)
72 = (((4 * 4) + √4) * 4)
80 = (((4 * 4) + 4) * 4)
96 = (((√4 + 4) * 4) * 4)
128 = (((4 + 4) * 4) * 4)
256 = (((4 * 4) * 4) * 4)

No comments:

Post a Comment