''' shipdays--for knb shipping needs. literally just lists of lists and an iterator wow written by @lemaireality April 2016. if you wish to use/edit for your own purposes go ahead but DO NOT CLAIM YOU WROTE ALL OF IT handles error cases, no selfcest by default but you can toggle it by setting the third argument to true for a whole month with selfcest: shipday(<yourmonth>,0,True) OR shipday(<yourmonth>,selfcest=True) update june 2016: now with shipbycharas function, which takes an input character names AS THEY APPEAR IN THE LISTS WHICH INCLUDES QUOTATION MARKS AROUND THE NAME & CASE=SENSITIVE (so to find out when all the imakaga days are you would type in shipbycharas("taiga","imayoshi"). order of the names does not matter! (ie for the above example you'd get both 10/4 and 4/10) ''' Four = ["imayoshi","hanamiya","hyuuga","akashi","nijimura","okamura","tatsuya","wakamatsu","ootsubo","yuuya","kasamatsu","hayakawa","teppei","eiji","ishida","mochida","tanimura","iwamura","narumi"] Five = ["aomine","seto","murasakibara","fukui","izuki","mayuzumi","kimura","nakatani","moriyama","papa","higuchi","kasuga"] Six = ["aomine","wakamatsu","koganei","reo","midorima","haizaki","miyaji"] Seven = ["kise","furuhashi","susa","alex","kagetora","teppei","kotarou","midorima","kasamatsu","ogiwara","sakamoto"] Eight = ["kobori","yamazaki","kise","haizaki","masako","miyaji","harasawa","mitobe","eikichi","okamura","omuro"] Nine = ["tsuchida","nakamura","akashi","nijimura","takeuchi","murasakibara","sakurai"] Ten = ["hayakawa","taiga","hara","takao","tsugawa","kubota"] Eleven = ["kuroko","liu","mochizuki","sekiguchi"] Twelve = ["tatsuya","furihata","matsumoto","hyuuga"] Thirteen = ["fukuda","wakamatsu"] Fourteen = ["takao"] Fifteen = ["kuroko","kawahara"] inx = [[],[],[],[],Four,Five,Six,Seven,Eight,Nine,Ten,Eleven,Twelve,Thirteen,Fourteen,Fifteen] def shipday(month,day = 0,selfcest = False): if (day < 4 and day != 0) or day > 15 or month < 4 or month > 12: print("no ship days for this time: " + str(month) + "/" + str(day)) return if day == 0: mon = str(month) for j in inx[4:]: for i in inx[month]: jjj = ": " + mon + "/" + str(inx.index(j)) for k in j: if i != k: print(i + "&" + k + jjj) elif selfcest: print (i + "&" + i + jjj) print("\n") #for readability return print("Shipdays for " + str(month) + "/" + str(day)) for i in inx[month]: for j in inx[day]: if i != j: print(i + "&" + j) #now without selfcest elif selfcest: print (i + "&" + i) def shipbycharas(chara,ochara): for j in range(4,13): for k in range(len(inx[j])): if inx[j][k] == chara: for x in range(4,16): for y in range(len(inx[x])): if inx[x][y] == ochara: dayy = ": " + str(j) + "/" + str(x) print(chara + "&" + ochara + dayy) elif inx[j][k] == ochara: for x in range(4,16): for y in range(len(inx[x])): if inx[x][y] == chara and chara not in inx[j]: dayy = ": " + str(j) + "/" + str(x) print(ochara + "&" + chara + dayy) #testing the shipbycharas function #shipbycharas("aomine","murasakibara") print("\n") '''actual case that runs''' shipday(7) #test cases below, left for reference ''' shipday(8) #a whole month print("\n") shipday(7,2) #invalid date print("\n") shipday(4,14) #a day print("\n") shipday(5,5,True) #selfcest example print("\n") shipday(9,selfcest=True) #another selfcest '''
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question