Some trading cards have real value and can be sold for money. Bending the cards is frowned upon because it takes away their value and makes them look less new. Say you have a deck of trading cards (Pokemon, Magic, etc.) and you want to shuffle them. Instead of doing the bridge that bends all of the cards, another simple way to shuffle cards is to put them into piles. Here's what I mean.
With a 60 card deck in need of shuffling, you could separate the 60 cards into three piles of 20 cards. There are multiple ways to do this, the most plain being to put a card into pile A, then one into pile B, then one into pile C. Another way is to put a card into pile C, then B, then A. There are also ways to spread the cards across the piles unevenly. Here's one: put a card in pile A, put another card in A, then put a card in pile B, then put a card in pile C.
Create a full program that will output
even if a certain way to shuffle into piles spreads the cards in the piles evenly, and outputs
uneven and the number of cards in each pile otherwise.
Input will be taken through STDIN or the closest alternative (no functions).
[sequence] [deck size]
sequenceis a string of characters. It tells the pattern the cards are laid down into the piles. Each different character corresponds to a single pile. This string will always be under the deck size and will contain only capital letters A-Z.
deck sizeis an integer that specifies how many cards are in the deck. If deck size is 60, the number of cards in the deck is 60.
If the number of cards in each pile at the end of the shuffle are the same, your program should output this.
uneven [pile1] [pile2] [...]
If the number cards in each pile at the end of the shuffles are the not the same, your program should output
uneven and the number of cards in each pile like this:
uneven 20 30 if pile A contains 20 canrds and pile B contains 30. The order of the pile numbers does not matter.
- This is a code golf challenge, so the shortest code in bytes on September 25 wins. If there is a tie in byte counts, the code that was submitted first wins.
- Your program must be a program, not a function.
- If possible, please include a link to an online interpreter or a link to a place where I can download an interpreter for your language in your answer.
- Anything I do not specify within this challenge is fair game, meaning if I don't say it, it's up to you. If anything is vague, tell me and I will edit the answer accordingly. (Hopefully this goes more smoothly than my last challenge.)
Input | Output | Alternate outputs (if uneven) | ABC 30 | even ABC 31 | uneven 11 10 10 | uneven 10 11 10 | uneven 10 10 11 BCA 60 | even BBA 24 | uneven 8 16 | uneven 16 8 ABACBC 120 | even BBABA 50 | uneven 20 30 | uneven 30 20 AABBB 12 | even