Well, the title is a hyperbole, but it was a fun experiment. I quickly put together a little program to guess a sequence, like the old MasterMind puzzle. The computer will guess your sequence, usually in 8 attempts or less.
Note that this is more difficult than the standard version with 6 colors. Here there are 10 “colors”, with repetitions.
The program is pure CS, including 10000 lines to create the initial array of combinations, and is compiled from my meta-language to help with loops and functions. Feel free to have a peak behind the curtains!
Yes, the first iteration is a little slow, I have not tried to optimize it. Let me have your thoughts! My thoughts are that we really need arrays, loops and functions in CS!
Update: Given the interest, a few comments on my tools. The startup.txt file is compiled from a source file in my extended language. A few commands I added are:
// Unrolls to a sequence of *create commands.
*array combos 10000 0
// Loop from 0-9. The @i is replaced with a unique symbol.
// Mapped to goto, if, increment.
*for @i 0 10
// Creates a block where the params are replaced with unique
// identifier to prevent conflicts.
*function compare @guess @combo
Woah… I used 1776 and it guessed it in 5 tries. Then I used 0000 and it guessed it in 6 tries. That’s crazy. I don’t know how you did it, but this is really cool!
The generated code is very confusing - it’s like machine language with goto and jumps. The source that goes into my preprocessor is here, and should be much easier to follow.