2 ms·
I've refined the program so that it isn't so much of an offense against all that is good and holy in programming practices. It is now only an offense against m
by patio11 17y ago
I've refined the program so that it isn't so much of an offense against all that is good and holy in programming practices. It is now only an offense against most programming practices. (cough Millions of executions of eval. cough 14 levels of nested for loops.)
The comments now explain what it is actually doing.
http://pastie.org/765992 http://pastie.org/765992
The new and improved version of the program generates solutions for upwards of 2080 of the years between 0 and 2100, including everything from the last century except 1911.
It is also disgustingly parallel, and would make a good case study if you want to try your hand at a Map/Reduce or similar distributed approach. (That is the only feasible way to brute force this problem if you go up to 5 or 6 operators, unless you have a supercomputer handy. Even with only 4 operators it pegs JRuby for upwards of five minutes on my laptop, and the complexity is bounded by n^n where n is the number of operators.)
- Shamiq 17y agoLines 349 to 387 made me laugh. A little bit of recursion can hide a lot of deeply nested looping :)
- deleted 17y ago[deleted]
- 3pt14159 17y agoYEAH! 1.0-2.0x3.0+(4x(5+(6x(7+8x(9))))) = 1911 :D Edit: So I have a program running now that is calculating them all in a cough extremely hack way. I'll post the code once I get all 200 of them between 1900 and 2100.
- patio11 17y agoYou have just made my day. I shudder to think what the search space for nested parentheses is like -- egads.