Solution to Continuous Cards from Jobdu

11 Sep

Question (in Chinese):

Question Name: Continuous Cards

Question Description: For a set of cards, Ace is treated as 1. J is 11, Q 12, and K 13. Jokers, up to four jokers, is represented as 0, and could be used as any card OR not used at all. Given some cards, check whether they are a consecutive sequence, such as 1 2 3 4 5.

Input: the input might contain multiple test cases. In each test case, the first line is an integer N (0 <= N <= 14). If N is 0, quite the program. Otherwise, the next line contains N integers as the content of the cards.

Output: if the cards could be a sequence, print “So Lucky!”; or print “Oh My God!” otherwise.

The solution is:

Leave a Reply

Your email address will not be published. Required fields are marked *