Skip to content

Instantly share code, notes, and snippets.

@rpinkerton
Created October 13, 2015 05:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpinkerton/46358e117a7ca227445b to your computer and use it in GitHub Desktop.
Save rpinkerton/46358e117a7ca227445b to your computer and use it in GitHub Desktop.
> +++++ ++ [< +++++ +++++ > -] < +++++ ++++ letter O
These are 0 flags/extra space for whether letters are in the bag or not
>>>
>
> +++++ ++ [< +++++ +++++ > -] < +++ letter I
>>>
>
> +++++ +++ [< +++++ +++++ > -] < +++ letter S
>>>
>
> +++++ ++++ [< +++++ +++++ > -] < letter Z
>>>
>
> +++++ ++ [< +++++ +++++ > -] < +++++ + letter L
>>>
>
> +++++ ++ [< +++++ +++++ > -] < ++++ letter J
>>>
>
> +++++ +++ [< +++++ +++++ > -] < ++++ letter T
>>>
>
>>> We leave three spaces here for controlling indexing into the list
>> Pass over the space we need for inputs
We'll use an 8bit linear congruential generator with summand 1 and
multiplicand 141
> + [< +++++ +++++ > -] < + a = 141
<< Move back into input space
,>, Get inputs: (n; random seed)
This is the main loop of the whole program: n times:
< [
Multiply x by a
>
[
Copy 141 into next slot
> [>+>+<<-]
> [-]
> [<+<+>>-] <
Add copied 141 into sum cell
[>>+<<-]
Subtract one from x to multiply
<<-
]
move multiplication result as new x and to modulo space
>>>> + [-<<<<+>>>>>+<] >
Compute this value mod 7
>> +++++ ++ <<
[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]
> [-] > [-] > [-<<<+>>>] > [-] <<<<
move this value to array indexing cell
[-<<<<<<<<<+>>>>>>>>>]<<<<<<<<<
check that there are pieces in the bag
<<<
[>+>+<<-] > [<+>-] > [<< if there is no T
<<<<
[>+>+<<-] > [<+>-] > [<< if there is no J
<<<<
[>+>+<<-] > [<+>-] > [<< if there is no L
<<<<
[>+>+<<-] > [<+>-] > [<< if there is no Z
<<<<
[>+>+<<-] > [<+>-] > [<< if there is no S
<<<<
[>+>+<<-] > [<+>-] > [<< if there is no I
<<<<
[>+>+<<-] > [<+>-] > [<< if there is no O
reset flags
->>>>->>>>->>>>->>>>->>>>->>>>-<<<<< <<<<< <<<<< <<<<< <<<<
>>-]<<
>>>>
>>-]<<
>>>>
>>-]<<
>>>>
>>-]<<
>>>>
>>-]<<
>>>>
>>-]<<
>>>>
>>-]<<
>>>
index into array
print value and decrement n if flag not set
if index is 0
> + < [>-] > [<
<<<
if flag is 0
> + < [>-] > [<
+ < . >>>>> >> - <<<<< <
> - >]<<
>>>
> - >]<<
if index is 1
- > + < [>-] > [<
<<<<< <<
if flag is 0
> + < [>-] > [<
+ < . >>>>> >>>>> > - <<<<< <<<<<
> - >]<<
>>>>> >>
> - >]<< +
if index is 2
-- > + < [>-] > [<
<<<<< <<<<< <
if flag is 0
> + < [>-] > [<
+ < . >>>>> >>>>> >>>>> - <<<<< <<<<< <<<<
> - >]<<
>>>>> >>>>> >
> - >]<< ++
if index is 3
--- > + < [>-] > [<
<<<<< <<<<< <<<<<
if flag is 0
> + < [>-] > [<
+ < . >>>>> >>>>> >>>>> >>>> - <<<<< <<<<< <<<<< <<<
> - >]<<
>>>>> >>>>> >>>>>
> - >]<< +++
if index is 4
---- > + < [>-] > [<
<<<<< <<<<< <<<<< <<<<
if flag is 0
> + < [>-] > [<
+ < . >>>>> >>>>> >>>>> >>>>> >>> - <<<<< <<<<< <<<<< <<<<< <<
> - >]<<
>>>>> >>>>> >>>>> >>>>
> - >]<< ++++
if index is 5
----- > + < [>-] > [<
<<<<< <<<<< <<<<< <<<<< <<<
if flag is 0
> + < [>-] > [<
+ < . >>>>> >>>>> >>>>> >>>>> >>>>> >> - <<<<< <<<<< <<<<< <<<<< <<<<< <
> - >]<<
>>>>> >>>>> >>>>> >>>>> >>>
> - >]<< +++++
if index is 6
------ > + < [>-] > [<
<<<<< <<<<< <<<<< <<<<< <<<<< <<
if flag is 0
> + < [>-] > [<
+ < . >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> > - <<<<< <<<<< <<<<< <<<<< <<<<< <<<<<
> - >]<<
>>>>> >>>>> >>>>> >>>>> >>>>> >>
> - >]<< ++++++
[-]
>>>
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment