Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Skillenza Common subjects
#python 3.5.2 from collections import defaultdict as dd import operator subjects = ['Maths 16:00 18:00','ComputerScience 12:00 13:00','Physics 12:30 14:00','Chemistry 14:00 16:30'] temp = (subjects[0].split())[1].replace(':','') #print(int(temp)) conflict = dd(int) sub = dd(list) for each in subjects: temp = each.split() sub[temp[0]] .append(int(temp[1].replace(':',''))) sub[temp[0]] .append(int(temp[2].replace(':',''))) #sub[temp[0]] += temp[2] #print(int(temp[1].replace(':',''))) conflict[temp[0]]+= 0 #print(sub) for item in sub.items(): for s in sub.items(): if(item[0] != s[0] and (item[1][0]<=s[1][0]<item[1][1] or item[1][0]<s[1][1]<=item[1][1])): conflict[item[0]] += 1 #print(item) #print(s) #print(s[1][0]) #print('====') sorted_x = sorted(conflict.items(), key=operator.itemgetter(1)) #print(sorted_x) #print(conflict) perma = [] perma.append(sorted_x[0][0]) for item in sorted_x[1:]: temp = [] for s in perma: #print(sub.get(item[0])[0]) if(sub.get(s)[0] <= sub.get(item[0])[1] or sub.get(s)[1] >= sub.get(item[0])[0]): #print('HI') #temp = temp.append(item[0]) perma.extend(temp) print(perma)
run
|
edit
|
history
|
help
0
main_game
Iam hungry
Example for striping string
Pure Python Square root without using Math.sqrt()
Regular falsi
PyRegCapGroup
sendi
vocabulary
Insert a sequence of same numbers, unpacking
Ozan Taşdemir 9/B 499