나는 이렇게 학습한다/Algorithm & SQL

Categorize New Member

daco2020 2022. 5. 3. 23:52
반응형

The Western Suburbs Croquet Club has two categories of membership, Senior and Open. They would like your help with an application form that will tell prospective members which category they will be placed.

To be a senior, a member must be at least 55 years old and have a handicap greater than 7. In this croquet club, handicaps range from -2 to +26; the better the player the lower the handicap.

Input

Input will consist of a list of pairs. Each pair contains information for a single potential member. Information consists of an integer for the person's age and an integer for the person's handicap.

Output

Output will consist of a list of string values (in Haskell and C: Open or Senior) stating whether the respective member is to be placed in the senior or open category.

Example

input =  [[18, 20], [45, 2], [61, 12], [37, 6], [21, 21], [78, 9]]
output = ["Open", "Open", "Senior", "Open", "Open", "Senior"]

 

 

 

Solution:

1. Fetch the elements of a two-dimensional array.
2. If the first number of elements is more than 55 and the second number is more than 8, put 'Senior' in the array.
3. If not, put 'Open' in the array.

4. Return an array.

 

def open_or_senior(data):
    return [x > 54 and y > 7 and "Senior" or "Open" for x, y in data]

 

 

 

 

반응형

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

Number of People in the Bus  (0) 2022.05.05
Disemvowel Trolls  (0) 2022.05.05
Are You Playing Banjo?  (0) 2022.05.02
Find the vowels  (0) 2022.05.01
Odd or Even?  (0) 2022.04.30