cards. Split the whole deck into piles so that:
- every pile holds the same number of cards k, with k ≥ 2;
- all cards within a pile show the same number.
Every card must go into exactly one pile. Return True if such a split exists, and False otherwise.cards=[5, 2, 5, 2, 2, 5, 2, 5, 5, 5] → True
There are six 5s and four 2s. Both counts divide by 2, giving five piles of 2 cards.
cards=[7, 7, 7, 1, 1] → False
There are three 7s and two 1s. No number greater than 1 divides both 3 and 2, so it cannot be done.
cards=[4] → False
cards=[5, 2, 5, 2, 2, 5, 2, 5, 5, 5]
True
Run checks the first 3 tests in your browser. Submit checks all 116 tests on the server, hidden ones included.