memGAP is a language designed to be odd to work in. A surprise, I know.
Programs consists of md5 hashes, which are then brute forced to return individual commands. The following commands are available at your disposal:
size
- popsS
; pushes the size ofS
.add
- popsB
thenA
; pushesA + B
.neg
- popsN
; pushes-N
.rep
- popsN
; pushes"1"
repeatedN
times.swap
- swaps the top two members of the stack.bub
- popsN
; rotates the topN
members once to the left. (e.g.1 2 3 4 4 bub
becomes2 3 4 1
)char
- popsN
; pushes the character with charcodeN
.out
- popsX
; printsX
.dup
- duplicates the top element on the stack.pop
- pops the top element of the stack.nil
- pushes0
.len
- pushes the number of elements in the stack.open
- starts a loop while the top element is neither 0 nor the empty string.shut
- closes that loop.?
- used for debugging in the program.in
- pushes a string from STDIN#
- inputs a numberbtwn
- popsU
thenL
thenN
; pushesL <= N <= U
.get
- popsN
thenA
; pushesA
, then pushesA[n]
.
All other commands are pushed verbatim to the stack.