Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [q] sQ
- 0 # sum
- ?
- [
- # ASSUME: numbers on a card are unique (as are winning numbers)
- # This means checking either way works correctly.
- 0 Sh # clear have table with push
- [
- 1r:h # have(top) = 1
- d 0<L # loop while next > 0 (0 is divider)
- ] dsLx
- # use divider (0) for count of wins
- [
- r;h+ # wins++ if have(top)
- z3<L
- ] dsLx
- # Stack: sum i=cardNum j=wins
- rd;c 1+ # sum j i cards(i) (+1 for inital)
- d5R+_4R sc # c = cards(i); a += cards(i)
- r # i j
- [
- d0=Q # quit if j=0
- d3R d3R+ d;c # j i i+j numCards(i+j)
- lc+ r:c # cards(i+j) = numCards(i+j) + c
- r1- lLx # i j--
- ] dsLx
- +s. # clear i and j
- ? z1<M
- ] dsMx
- [Part 2: ]np
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement