Created
February 24, 2012 14:08
-
-
Save LCamel/1901135 to your computer and use it in GitHub Desktop.
Search 2012
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (var n = 0; 1; n++) | |
| if (ok(n)) | |
| show(n); | |
| function ok(n) { | |
| var v = 2011 + 7; | |
| while (1) { | |
| var x = n % 4; | |
| if (x == 0) v = (v + 7) / 2; | |
| else if (x == 1) v = (v / 2) + 7; | |
| else if (x == 2) v = (v * 3) - 5; | |
| else if (x == 3) v = (v - 5) * 3; | |
| if (! (n >>= 2)) | |
| return v - 5 == 2012; | |
| } | |
| } | |
| function show(n) { | |
| var v = '2011 + 7'; | |
| while (1) { | |
| var x = n % 4; | |
| if (x == 0) v += ' + 7 / 2'; | |
| else if (x == 1) v += ' / 2 + 7'; | |
| else if (x == 2) v += ' * 3 - 5'; | |
| else if (x == 3) v += ' - 5 * 3'; | |
| if (! (n >>= 2)) | |
| return console.log(v + ' - 5 = 2012'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment