3 ms·
It is almost like a magic trick. You probably know some of them along the lines of : think of a number, then do a series of operations, and then I can guess th
by GuB-42 6y ago
It is almost like a magic trick.
You probably know some of them along the lines of : think of a number, then do a series of operations, and then I can guess the result. It can be done with cards too. In reality no matter what your initial choice is, the end result is always the same. The trick is to combine relatively complex functions (ex: "take the sum all digits of the number", "add 1 if odd") in a way that produce something simple (ex: "the result is 5").
Here the trick is to express the function "pos(x,y)=(0, y+1)" in term of the functions "pos(x,y)=(0,y)" and "pos(x,y)=if x<$column then (x+1,y) else (0,y+1).
It is also the basis of the "abstraction inversion" anti-pattern.
- messe 6y agoThis is almost certainly going to be somebody's horrific programming interview question at some point in the next six months.