Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [q] SX
- [
- [
- li;c 1+ li:c # (c(i) = c(i)++) i
- ] SC
- [
- li 12=X # (exit if i = 12) top
- 2~ # top -> top%2 top/2
- 1=C # (top%2 = 1) top/2
- li 1+ si # (i--) top/2
- lIx # loop, next top = top/2
- ] SI
- z 0 =X # stop when stack empty
- 0si lIx # i = 0, run loop
- s. # pop remains of top
- lLx # loop
- ] SL
- #
- # Mainline start
- #
- 1010i # back to decimal
- z 2/ sn # n = half size of input
- # Initialize counts
- [
- 1- # i--
- d 0 r:c # 0 i i -> (c(i) = 0) i
- d 0=X # (exit if i = 0)
- lIx # loop
- ] SI
- 12 lIx s. # push i, run loop, pop i
- lLx # start loop
- # Calculate gamma and epsilon (XOR via subtraction)
- 0 sg # init gamma, epsilon
- [ 1+ ] SS
- [
- 0 lb;c ln >S # (n > c(b)) 0, S changes 0 to 1
- 2 lb ^ * lg+ sg # (0|1) -> (g = g + 2^b * (0|1))
- lb 1+ d sb 12=X
- lBx # loop
- ] SB
- 0 sb lBx
- [Part 1: ]n lg 4095 lg-* p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement