Skip to content

Instantly share code, notes, and snippets.

@Shungy
Created August 24, 2023 19:09
Show Gist options
  • Save Shungy/5913d660b578ac94ede727469605a102 to your computer and use it in GitHub Desktop.
Save Shungy/5913d660b578ac94ede727469605a102 to your computer and use it in GitHub Desktop.
For Solving Curta Puzzle - Elohim
// Used to solve Puzzle 16 https://www.curta.wtf/puzzle/16 in God mode (aka chainlight mode).
#define constant EVA_CONFIG = 0x03306963 // ensure no restricted opcds here
#define macro MAIN() = takes (0) returns (0) {
0x00 calldataload 0xfc shr
dup1 0x0f eq eva_eight jumpi
dup1 0x08 eq eva_nine jumpi
0x06 eq eva_ten jumpi
// eva_seven
0x07 // exp
[EVA_CONFIG] 0xe0 shl 0xf8 shr
exp 0x00 mstore
0x20 0x00 return
eva_eight:
0x08 // exp
[EVA_CONFIG] 0xe8 shl 0xf8 shr
exp 0x00 mstore
0x20 0x00 return
eva_nine:
0x09 // exp
[EVA_CONFIG] 0xf0 shl 0xf8 shr
exp 0x00 mstore
0x20 0x00 return
eva_ten:
0x00
eva_ten_loop:
gas
dup2 sload pop
gas swap1 sub
0xfd lt eva_ten_loop_exit jumpi
0x01 add
eva_ten_loop jump
eva_ten_loop_exit:
dup1 0x01 eq direct_sixteen jumpi
0x05 dup2 mod iszero
0x03 dup3 mod iszero or
mul iszero iszero
0x06 mul 0x0a add
[EVA_CONFIG] 0xf8 shl 0xf8 shr
exp 0x00 mstore
0x20 0x00 return
direct_sixteen:
0x10 // exp
[EVA_CONFIG] 0xf8 shl 0xf8 shr
exp 0x00 mstore
0x20 0x00 return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment