4 ms·
Interestingly related to the author's point of teaching using cards. When I used to give coding interviews one of my favorite tasks was to implement the scorin
by maerF0x0 5y ago
Interestingly related to the author's point of teaching using cards.
When I used to give coding interviews one of my favorite tasks was to implement the scoring rules of poker[1]. People would often ask "why ask them about poker?" and I'd show them that there is a ton of skill coverage
1. Decomposition of requirements into sub problems
2. pattern matching for code reuse and composition
3. seeing if they can come up with a decent algorithm to communicate to and from sub functions the results
4. seeing if they can come up with an ordering mechanism for cards
5. seeing if they can come up with a for loop that counts if there are 5 of something
6. String parsing to their own intermediate representation of cards
All these skills are used basically daily (at least in my workplace)
[1]: a good description of the rules, sample IOs, and myself as an oracle (ask me anything, no expectation of knowing poker itself) served to help keep "poker" from being the subject matter tested
- ramses0 5y agoIf you truly believe that "poker" isn't the subject matter being tested, run the same interview question (this weekend) with a friend, blind, on scoring hands of cribbage. I'll wait. https://bicyclecards.com/how-to-play/cribbage/ https://bicyclecards.com/how-to-play/cribbage/
- maerF0x0 5y agoA bit of a nuanced problem here. I've played a lot of crib too. I hear your point, I guess my point is that serious measures are taken to dampen the difference between someone who knows poker and someone who doesnt. I've actually found largely candidates do not know the game so the calibrated comparisons is mostly between people who don't know the game. Crib may actually be a better option -- the more esoteric the game, the less pre-knowledge plays a factor. Edit: also NB: the only part that was to be implemented was the relative rank of a hand (ie, which hand won) . So the analogous equivalent in the crib example would be just the scoring of each hand.
- shagie 5y agoThe scoring poker is indeed an interesting problem - and its Project Euler #54 ( https://projecteuler.net/problem=54 https://projecteuler.net/problem=54 ) Starting from high card on gets to some interesting increasingly complex "can I identify it rules"
- maerF0x0 5y agoI actually ran the interview on some coworkers for fun (they volunteered) and it was interesting to see the more senior (& IMO brighter) folks quickly recognize code reuse. !@! SPOILER BELOW !@! !@! SPOILER BELOW !@! high card -> sort cards by value return cards[4] Count cards (map[value]->int) --> Pair, pairs, triples, four of a kind For each card is first token match? --> flush sort cards , card[0] == card[4] + 4? --> straight straight flush --> straight && flush royal flush --> highcard == A && straight && flush
- deleted 5y ago[deleted]