Starks Adventure in Python

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.

Enter the ages of 5 people:
54 57 53 59 59
Age: 59, Floor: 0
Age: 59, Floor: 1
Age: 57, Floor: 2
Age: 53, Floor: 3
Age: 54, Floor: 4

Enter the ages of 5 people:
51 52 53 50 54
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
            floors[num] = ages[i]
    for i in range(n):
    return floors

'''check if the group is valid'''
def isValid(ages):
    flag = 0
    for each in ages:
        return 0
        return 1

print("Enter the ages of 5 people: ")
ages = list(map(int,input().split()))

    floors = floor(ages)
    for i in range(5):
        print(f"Age: {floors[i]}, Floor: {i}")
    print("This group is rejected.")

Input and Output 1:

Input and output 1 of Starks Adventure in Python

Input and Output 2:

Input and output 2 of Starks Adventure in Python

Also Read:


Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at Thank you