Created
September 10, 2014 16:41
-
-
Save selevit/547efa0b72865baa3177 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
def main(): | |
"""Вычисляет коллизии вариантов у студентов | |
Вариант определяется по сумме двух последних цифр | |
номера зачетки | |
""" | |
filename = 'list_auz_studbook.txt' | |
students = [] | |
file_content = None | |
with open(filename) as f: | |
file_content = f.read() | |
students = file_content.split('\n') | |
students_data = [] | |
for student in students: | |
entities = student.split(' '); | |
if len(entities) != 4: | |
continue | |
book_number = entities[3] | |
variant = (int(book_number[-2]) + int(book_number[-1])) % 30 | |
students_data.append([entities, variant]) | |
students_data.sort(key=lambda x: x[1]) | |
for student in students_data: | |
outline = '{0} {1} {2} {3}'.format( | |
student[0][0], | |
student[0][1], | |
student[0][2], | |
student[1], | |
) | |
print(outline) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment