Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 16i # Working in base 16
- [rq] sQ
- # track maximum group: hand card count
- [
- r d1=Q
- dsc # max-card = card
- rdss # max-seen = count
- ] sM
- 0 Sl # Sentinel 0 at bottom of l stack
- ?
- [
- rd # bid hand hand
- 2 Sc 0ss # Clear count array (push) and max-trackers
- [
- 10~ # split card from rest of hand: hand card
- d;c 1+ # hand card count(c)+1
- d ls<M # if count > max-seen, track max
- r:c # store count(c)
- d0<C # loop while remaining>0
- ] dsCx
- # stack: bid hand 0
- lc d;c 1;c+ r:c # count(max-card) += count(wild)
- 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
- Ll Ll # next (ASSUME: at least 2 hands to sort)
- [
- [
- d3R d3R # top next -> 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
- 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