Of course I later realized that it would take more data to store the starting position than it would to actually store the program. In the spirit of the idea, I decided to make a little example.
Binary Pattern to Find:
When I originally thought of this method as a child I imagined finding the pattern for a program in PI, but for the sake of speed, this example uses Fibonacci sequences to generate a string of binary data that doesn't repeat. It's way faster since all you need to do is a simple addition to find the next number, and as you can tell from the pattern finding below, speed is quite important.
I turn each digit of the Fibonacci numbers generated into binary with the following conversion:
Digit | Binary |
0 | 000 |
1 | 001 |
2 | 010 |
3 | 011 |
4 | 100 |
5 | 101 |
6 | 110 |
7 | 111 |
8 | 0 |
9 | 1 |
For example, the begining of the sequence 1,2,3 gives us the binary string 001010011 so searching for: "100" would give us starint position 5. The idea to is have the same possibilities for "0" as I do for "1", hence 8 and 9. My theory is already off since Fibonacci number sequences have more odds than evens.
After 1400 and some fibonacci numbers, the next Fibonacci number becomes too large to be stored as a double(3.something times e raised to the 308th power is the last in javascript), so I restart the equation with the next seeds. For example, if the first series was 1,1,2,3,5... then I start the next series with 1,3,4,7,11... and then after that gets too large, 1,4,5,9...
Could you clarify the last paragraph?
ReplyDeleteAfter 1400 and some fibonacci numbers, the next Fibonacci number becomes too large to be stored as a double(3.something times e raised to the 308th power is the last), so i restart the equation with the next seeds. For example, if the first series was 1,1,2,3,5... then i start the next series with 1,3,4,7,11... and then after that gets too large, 1,4,5,9...
ReplyDeleteNice post! for binary representation, you could also have used something like "0, 1, 00, 01, 10, 11, 000, 010, 101, 111" instead, correct?
ReplyDeleteRight, I just wanted an easy way to make a binary string with a relatively normal distribution of 1s and 0s. Any series such as the one you mentioned would work. Thanks for the comment.
ReplyDelete