-
Notifications
You must be signed in to change notification settings - Fork 0
/
bilateral-projects.py
executable file
·49 lines (37 loc) · 1.22 KB
/
bilateral-projects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/env python
import sys
def main():
# Get number of projects being presented
lines = int(sys.stdin.readline().replace('\n', ''))
# Initialize lists
stockholm = []
london = []
invitees = []
# Parse the input
for i in range(0,lines):
line = sys.stdin.readline().replace('\n', '').split(' ')
stockholm.append(int(line[0]))
london.append(int(line[1]))
# Determine invitee list
for i in range(0, lines):
# If an employee is already attending, default to them
if invitees.count(stockholm[i]) > 0 or invitees.count(london[i]) > 0:
pass
# If the Stockholm employee works on more projects, select that employee
elif stockholm.count(stockholm[i]) > london.count(london[i]):
invitees.append(stockholm[i])
# If the London employee works on more projects, select that employee
elif stockholm.count(stockholm[i]) < london.count(london[i]):
invitees.append(london[i])
# Select the friend if possible
elif stockholm[i] == 1009:
invitees.append(1009)
# Default to the London employee
else:
invitees.append(london[i])
# Print results
print len(invitees) # Number of employees invited
for i in invitees: # Employee numbers
print i
if __name__ == '__main__':
main()