MWC '15 #8 P3: Draw Down
View as PDFOne of 's favourite pastimes is to play a card game named Draw Down. In this game, each card is decorated with one of three colours, with each colour denoted by integers 1, 2 and 3.  
 players are lined up (not including ), waiting to receive a card at the front of the line.
The card distribution is dictated as follows: the person at the front of the line will either be given a card of random colour for all to see, or will be secretly given a card of unknown card colour.
However, has been playing this game for a while and knows that the card given out secretly will have the colour which has been given out the least to players in line so far. If there is a tie for which card colour has been given out least, the player could receive any of those colours.
For example, if the first two players in line both receive a random card of colour 1, the next player who receives a card secretly could receive a card of colour 2 or 3, as zero players have been given a card with one of those colours. Note that the player cannot receive a card of colour 1 secretly, as less players have a card of colour 2 or 3.
Knowing is the last player to receive a card and that his card will be given out secretly, help him determine all the possible card colours he could get!
Input Specification
On the first line will be one integer , denoting the number of players in front of .
On the second line will be 
 characters. Each character will either be an integer 
 
, representing the card colour that the 
 player got, or 
~, representing a secret distribution.
Output Specification
Output all the possible card colours that could get, one per line in ascending order.
Sample Input 1
3
1~2
Sample Output 1
1
2
3
Explanation of Sample Output 1
The second person in line will get the colour 2 or 3. If they get colour 2, then  will get a card with colour 1 or 3.
If the second person in line gets colour 3, then  can get colours 1, 2 or 3.
Sample Input 2
14
2222~~1~~~12~3
Sample Output 2
1
Comments
When I submit my code on Python 3, I get an Invalid Return on case 4, but when I submit the same code on PyPy3 I get Invalid Return on case 5 instead. Is there an error in my code that's causing this or is it the judge?
your code exceeded pythons recursion limit
Oh I should've thought of that. Thanks!