Skip to content

Instantly share code, notes, and snippets.

@mlajx
Created May 28, 2021 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlajx/bf61e7151c2641b5022a42b9b9578c17 to your computer and use it in GitHub Desktop.
Save mlajx/bf61e7151c2641b5022a42b9b9578c17 to your computer and use it in GitHub Desktop.
CPF Validator in Brainfuck
CPF
>+
>++
>+++
>++++
>+++++
>++++++
>+++++++
>++++++++
>+++++++++
>>>>>>
Qty Digits
+++++++++
Flag Spot To Move CPF
<+>
Move CPF and add one
[<[<]<<<<[>>>>+<<<<-]>>>>+[>]<-]
Reset Flag Spot
<->
Add Logic For Big Loop
<<[<]<<<++
Start Big Loop
[
>>>>[>]>
Define the Multiplier
++++++++++
<<[<]>
Start Loop
[
Copy Next Digit
[<<+>>>[>]>>+<<<[<]>-]
Make a flag
+
[>]>>>>>
Define de Divider
+++++++++++
<<<
Make the multiplication
[<[<+>>>+<<-]<[>+<-]>>-]
Add the division in multiplication result
>>>[<+<+>>-]<<
Sub one time the multiplier
<<[<+>>>-<<-]<[>+<-]
>>>
Make the Mod and present only the mod
[>->+<[>]>[<+>-]<<[<]>-]>[-]
Move mod to next sum
>+[<<+>>-]<<-
Sub one in multiplier
<<-
<<[<]>
Remove flag
-
>
End Loop
]
Reset Multiplier
>[-]
<+>>+
Add One To Avoid 0
+>+
Copy the If B
[>+>+<<-]>[<+>-]<<
Make the if(A GorE B)
[->-[>]<<]
<[-
<<+>>
]
<[-<
<+++++++++++++>>>>>>>
[<<<<<<<->>>>>>>-]
<<<<<<
]
Reset If
>>>>[-]>>[-]
<<<<<<<
Move digits to correct spot
[[>>+<<-]<]
Add one in next multiply
>>>[>]>+
End Big Loop
<<[<]<<<-]
Remove the one extra in multiply
>>>>[>]>-
<<[<]>
Move back to start
[[<<<<<+>>>>>-]<<<<<->>>>>>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment