! It's not quite as fast as your hard-coded version, probably due to having to ! generate the combinations, but it will also work for any number of cards (6+) : parse-cards ( str -- seq ) " " split [ >ckf ] map ; : best-hand ( str -- hand ) parse-cards 5 all-combinations [ dup hand-value hand boa ] map infimum ; ( scratchpad - auto ) "As Kd Jc Kh 2d 2s Kh" best-hand dup >value --- Data stack: T{ hand f ~array~ 190 } "Full House"