Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 16i # Working in base 16
- # Load input onto reg i stack
- 0Sl # Push sentinel 0 to mark bottom
- ?
- [
- rd # bid hand hand
- 0 Sc # Clear cards and group arrays with push
- [
- 10~ # remaining card
- d;c 1+ r:c # count(c)++
- d0<C # loop while remaining>0
- ] dsCx
- E # bid hand groups=0 i=E
- [
- d;c # g i count(i)
- 10r^ # g i 10^c(i)
- 3R+ # i g+10^c(i)
- r1- d1<I # g i--
- ] dsIx
- * # clear i (*1)
- 10 5^*+ 1000*+ # bid hand groups -> combined groups-hand-bid
- Sl # store hand in register stack for sorting
- ?z 0<L
- ] dsLx
- # Sort hands
- [rq] sQ
- Ll Ll # next (ASSUME: at least 2 hands to sort)
- [
- [
- d3R d3R # next top -> next top top next
- !>Q # if top >= next, rotate next on top and quit J loop
- Sl # push top back on input stack
- z 1<J # quit if out next left on stack
- ] dsJx # next rest
- Ll d 0<S
- ] dsSx
- # stack: sorted-hands 0
- 1 # hands lowest-hand sum=0 i=1
- [
- d4R # sum i i low
- 1000%* # sum i i*bid
- 3R+ # i sum
- r1+ z2<M
- ] dsMx
- rp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement