In a slightly different vein, here are some smaller brainteasers for you to try!
- Create an algorithm which divides any two numbers of different bases together.
Does your algorithm work with negative numbers?
How about negative bases?
- How would you find a cycle in a linked list?
Can you do it iteratively?
- Multiply a number by 7 without using the multiplication operator.
Can it be done without addition?
Goal: Flip tuples in a doubly linked list.
Example: Given A <-> B <-> C <-> D, have an algorithm produce B <-> A <-> D <-> C.
Constraints: All manipulations must be made to the original linked list, and minimize use of external data structures as much as possible.
Hmmm of the day: The ideal solution is fairly brief and elegant, so don’t try to over-think it unless you need to!
Goal: Design and implement an algorithm to detect certain hands in a game of Poker. You are given your parameters as 5 ints [0-13] representing each value of the card. The hands to check are:
- Four of a kind (ex: 5,4,5,5,5)
- Full house (ex: 5,4,4,5,5)
- Three of a kind (ex: 5,4,5,5,1)
- Two pair (ex: 8,4,4,5,5)
- Pair (ex: 7,1,2,5,5)
- High card (ex: 1,2,3,4,5)
Constraints:
- Return the String value or enum code (to your specification) representing each case
Hmmm of the day: Are there any poker hands which could fall into more than one category?