Problem Statement:
House Stark of Winterfell is a Great House of Westeros and the royal house of the Kingdom of the North. Every once a year, the king offers 5 people from his kingdom a visit to this house. But there are certain conditions,
1. these 5 people should not be below or equal to 50. The group will be rejected if this condition is not satisfied for even a single person.
2. Each of the people is allowed to visit only one floor. The floor is decided on the basis of their age.
The remainder left after dividing the age by 5 will be the floor a person can visit.
3. If two or more person allotted the same floor, then only one person can get that floor, the rest will be allocated vacant floors.
Remember the indexing starts from 0.
Given the ages of 5 people, determine which floor each individual can visit.
Example:
Input1:
Enter the ages of 5 people:
54 57 53 59 59
Output1:
Age: 59, Floor: 0
Age: 59, Floor: 1
Age: 57, Floor: 2
Age: 53, Floor: 3
Age: 54, Floor: 4
Input2:
Enter the ages of 5 people:
51 52 53 50 54
Output2:
This group is rejected.
Code for Starks Adventure in Python:
'''determine floors''' def floor(ages): n = len(ages) left = list() floors = [-1]*n for i in range(n): num = ages[i]%5 if(floors[num]==-1): floors[num] = ages[i] else: left.append(ages[i]) k=0 for i in range(n): if(floors[i]==-1): floors[i]=left[k] k+=1 return floors '''check if the group is valid''' def isValid(ages): flag = 0 for each in ages: if(each<=50): flag=1 break if(flag==1): return 0 else: return 1 '''input''' print("Enter the ages of 5 people: ") ages = list(map(int,input().split())) '''output''' if(isValid(ages)): floors = floor(ages) for i in range(5): print(f"Age: {floors[i]}, Floor: {i}") else: print("This group is rejected.")
Input and Output 1:

Input and Output 2:

Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Composite Number in Python
- Greatest Among Four Numbers in Python
- Reverse the sentence in Python
- Denominations in Python
- Min and max values in an array in JavaScript
- Keyboard events in JavaScript
- Reaching Ground Floor in Python
- Number of Moves in Python
- Starks Adventure in Python
- Neutralization in Python | Assignment Expert
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- First Place in Python
- Triples with Properties in Python
- Nested list Indexing Python
- Team Points in Python
- Two words combination in Python
- ID Card in Python
- Cipher with a key in Python | Assignment Expert
- Multiple of 5 in Python
- Sandglass Star in Python
- Multiple of 3 in Python | Assignment Expert
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Sum of List Elements in Python
- All possible subsets in Python
- Names and Nicknames in Python