Skip to content

Instantly share code, notes, and snippets.

@danielcristofani
danielcristofani / pearson.b
Created April 10, 2024 11:39
This implements Pearson hashing using the table from Pearson's original paper, and outputs the hash as a byte. Verbose but fairly fast.
>>,[
[[>>]++[-<<]>>]
++++++++[>[>-<-]>[<+>+[-]]<<-[>>+<<-]+>>]
<[-<
<[-<
<[-<
<[-<
<[-<
<[-<
<[-<
@danielcristofani
danielcristofani / day9a.b
Last active December 29, 2022 13:47
Advent of Code, Day 9 part 1, handcoded in brainfuck
[day9a.b -- 2022 Advent of Code Day 9 Part 1
(c) 2022 Daniel B. Cristofani
http://brainfuck.org/
This program is licensed under a Creative Commons Attribution-ShareAlike 4.0
International License (http://creativecommons.org/licenses/by-sa/4.0/).]
[This program solves Advent of Code 2022, Day 9, Part 1.
(https://adventofcode.com/2022/day/9/)
Basic data layout is, roughly:
@danielcristofani
danielcristofani / siercarpet.b
Created April 20, 2021 06:05
Sierpinski Carpet program
[siercarpet.b -- Sierpinski Carpet
(c) 2021 Daniel B. Cristofani
http://brainfuck.org/]
>-->->->>>>>(>>>>>>>>>)+++++[>++++++<-]>+[>+>+++<<-]>+[
[<]<++[<++]--<[>>[-->]>..<<<]>>[[-->]>>--.++.<<]<<<<<<<+[
[--->++++++<[+++>--------->>[->>>]->>>]+<<<+]
>[<->>>[->>>]++++++++++.[-]<<+>+++[-]]<
]>>>->>
]
@danielcristofani
danielcristofani / quine.ook
Created April 2, 2021 09:53
Quine in Ook! (core part taken directly from Erik Bosman's 410-byte brainfuck quine)
Ook! Ook! Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook
@danielcristofani
danielcristofani / life.b
Last active March 6, 2024 01:21
Game of Life program.
[life.b -- John Horton Conway's Game of Life
(c) 2021 Daniel B. Cristofani
http://brainfuck.org/]
>>>->+>+++++>(++++++++++)[[>>>+<<<-]>+++++>+>>+[<<+>>>>>+<<<-]<-]>>>>[
[>>>+>+<<<<-]+++>>+[<+>>>+>+<<<-]>>[>[[>>>+<<<-]<]<<++>+>>>>>>-]<-
]+++>+>[[-]<+<[>+++++++++++++++++<-]<+]>>[
[+++++++++brainfuck.org-------->>>]+[-<<<]>>>[>>,----------[>]<]<<[
<<<[
>--[<->>+>-<<-]<[[>>>]+>-[+>>+>-]+[<<<]<-]>++>[<+>-]
@danielcristofani
danielcristofani / ackermann.b
Created January 8, 2021 14:14
Ackermann–Péter function
>,>+>>>,+<++++++++[<<<------>>>>------<-]>-[+<]<<[>]<[
<[
->>>>[
<+[->-[[>>]>-<]++++++++++>+]<[-]<<-[+>>]<<
[[>>+<<-]<<]
<<[>+<-]->[<+>>+<-]+>>+>>>>
]<<<[
>>>++<<
]
]>[
@danielcristofani
danielcristofani / brainfuck_function_tutorial.b
Last active March 27, 2021 12:20
A way to do functions in brainfuck.
[How to do functions in brainfuck.
Okay. We'll translate the following program into brainfuck, with no thought of efficiency:
char fib (char a){
switch(a):
case 0: return 0
case 1: return 1
default: return fib(a-2)+fib(a-1)
}
@danielcristofani
danielcristofani / tictactoe.b
Last active December 3, 2020 13:50
Tic-tac-toe player
--->--->>>>->->->>>>>-->>>>>>>>>>>>>>>>>>+>>++++++++++[ initialization
<<++[ output board
--<+<<+<<+>>>>[
>[<->>+++>>[-]<<<+[<++>>+>>-<<<--]]+>+++++[>>++++++++++<<-]
>>-.[-]>>+[<<<<+>>+>>-]<<<<<<[>+<-]<<
]++++++++++.[-]>++
]-->>[-->[-]>]<<[ if game not over
>>--[ while stack isn't empty
-[
-[ fn 0: get move from user
@danielcristofani
danielcristofani / sort.rui
Created August 9, 2020 02:39
Sort bytes in ascending order
=256 R +4 . +1
:2
=2 . . . =0 . .
-256 *5 !
-0 +7 . . +6 . . . *5 !
-0 W *3 !
-0 *8 !
-0 +9 . . *3 :5
-256 =1 +3 ~
@danielcristofani
danielcristofani / pi.rui
Last active August 10, 2020 09:55
Compute pi by Bailey-Borwein-Plouffe formula
+7 +4 +3 :10
=2:2
=3:3
=4:4
=5:5
=6:6
=7:7
=8:8
=9:9
-8 =120 +12 *11 . =151 *11 . =47 *11 -3 $ *3 -7 $ *7 . -0 *8 :13