Numberfuck
Numberfuck is a esolang made by Mihai Popa. It's Brainfuck, but you only use numbers instead of symbols to make programs.
Table
| Command | Brainfuck equivalent | Description |
|---|---|---|
1 |
>
|
Move the pointer to the right |
2 |
<
|
Move the pointer to the left |
3 |
+
|
Increment the memory cell at the pointer |
4 |
-
|
Decrement the memory cell at the pointer |
5 |
.
|
Output the character signified by the cell at the pointer |
6 |
,
|
Input a character and store it in the cell at the pointer |
7 |
[
|
Jump past the matching 8 if the cell at the pointer is 0
|
8 |
]
|
Jump back to the matching 7 if the cell at the pointer is nonzero
|
Everything other than these numbers is a comment and it's ignored. But if you comment with numbers, you should replace that with words or Roman numbers. Or else will not work. Except for 9 and 0!
Examples
Hello, World!
333333337133333333248133333333513333333371333333333333248133333533333335533351333333337133333248133335444444444444522223333333333333335115333544444454444444451135
Rickrolling, by printing all the lyrics of "Never Gonna Give You Up"
Too long. See here: Numberfuck/Rickroll
99 Bottles Of Beer
Quite long. See here: Numberfuck/99 Bottles Of Beer
Implementer
Python
Note: coded by ChatGPT. Optimized for everything, including printing the full lyrics of the song Never Gonna Give You Up.
def interpret():
code = input("Enter Numberfuck code: ")
memory = [0] * 30000
pointer = 0
output_string = ""
code_length = len(code)
code_pointer = 0
loop_stack = []
commands = {
'1': lambda: nonlocal_pointer('+'),
'2': lambda: nonlocal_pointer('-'),
'3': lambda: increment_memory(),
'4': lambda: decrement_memory(),
'5': lambda: output_to_string(),
'6': lambda: take_input(),
'7': lambda: start_loop(),
'8': lambda: end_loop()
}
def nonlocal_pointer(op):
nonlocal pointer
if op == '+':
pointer += 1
else:
pointer -= 1
def increment_memory():
nonlocal memory, pointer
memory[pointer] = (memory[pointer] + 1) % 256
def decrement_memory():
nonlocal memory, pointer
memory[pointer] = (memory[pointer] - 1) % 256
def output_to_string():
nonlocal memory, pointer, output_string
output_string += chr(memory[pointer])
def take_input():
nonlocal memory, pointer
user_input = input("Enter input (1 character): ")
memory[pointer] = ord(user_input[0])
def start_loop():
nonlocal memory, pointer, code_pointer, loop_stack
if memory[pointer] == 0:
count = 1
while count != 0 and code_pointer < code_length - 1:
code_pointer += 1
if code[code_pointer] == '7':
count += 1
elif code[code_pointer] == '8':
count -= 1
else:
loop_stack.append(code_pointer)
def end_loop():
nonlocal code_pointer, loop_stack
if memory[pointer] != 0:
code_pointer = loop_stack[-1]
else:
loop_stack.pop()
while code_pointer < code_length:
command = code[code_pointer]
if command in commands:
commands[command]()
code_pointer += 1
print("Output:", output_string)
interpret()
Computational class
Numberfuck is turing-complete because Brainfuck is also turing-complete!