TransWikia.com

A brain[expletive] sudoku

Puzzling Asked on July 6, 2021

Sudoku

This is a Sudoku that is also a Brainfuck program.

The standard rules of Sudoku apply. The same symbol can not appear twice in the same row, column, or 3×3 box.

The grid should also form a functioning Brainfuck program. There are two requirements, the program must halt, and it must produce the correct output. Here is an online interpreter for testing.

The program should, when given the input "BrainFuck", output "Crÿinl".

Input:
Char B   r   a   i   n   F   u   c   k
Hex  42  72  61  69  6E  46  75  63  6B
Dec  66 114  97 105 110  70 117  99 107

Output:
Char C   r   ÿ   i   n   l
Hex  43  72  FF  69  6E  6C
Dec  67 114 256 105 110 108

For visibility, the period are replaced with an exclamation mark, and a comma with a question mark.

Also, brackets cannot be balanced by the constraints of sudoku, so I am using the symbols [{. Whichever one appears first on a line is treated as an open bracket, and the second one is treated as a closing bracket.

# is not a valid command, so it is a no-op and does nothing.

Brainfuck operates on an infinite* array of memory cells, each initially set to zero. There is a pointer, initially pointing to the first memory cell. The commands are:

Command Description
> Move the pointer to the right
< Move the pointer to the left
+ Increment the memory cell at the pointer
Decrement the memory cell at the pointer
. ! Output the character signified by the cell at the pointer
, ? Input a character and store it in the cell at the pointer
[ Jump past the matching ] if the cell at the pointer is 0
] Jump back to the matching [ if the cell at the pointer is nonzero
# Do nothing and continue to the next command

* May only be 30,000 bytes

One Answer

I believe this is the solution (apologies in advance, not sure how best to format this):

Edited to include explanation of how I arrived at the solution:

Correct answer by SQLnoob on July 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP