Created
September 7, 2016 16:20
-
-
Save shkesar/55346eb575877aec9d4a93d08fb98681 to your computer and use it in GitHub Desktop.
Hacker rank problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
no = int(input()) | |
students = [] | |
for i in range(no): | |
name = str(raw_input("Enter name: ")) | |
marks = float(raw_input("Enter marks: ")) | |
students.append([name, marks]) | |
smallest = min(students, key=lambda x: x[1]) | |
def give_key(x): | |
if x[1] != smallest[1]: | |
x[1] | |
else: | |
9999 | |
smallest2 = min(students, key=give_key)[1] | |
filtered_students = [] | |
for student in students: | |
if student[1] == smallest2: | |
filtered_students.append(student) | |
filtered_students = sorted(filtered_students, key=lambda x: x[0]) | |
print "" | |
for student in filtered_students: | |
print student |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment