0.0% ≤ diff ≤ 10.0% 31 clusters, 93 submissionsall: cluster #1 (3)
# 6330162421 (2020-09-27 20:03) %diff = 0.0 70.0% # Prog-07: COVID-19 # 6330162421 นาย ณัฐนิวิทย์ เชาวกิจเจริญ # I do by myself def steepest_countries(df, t, n): a = get_all_countries(df) s = [] name = [] for i in range(len(a)): b = get_confirmed_cases(df,a[i]) for o in range(len(b)): if b[o] > t and o+n <= len(b)-1 : noy = b[o] marx = b[o+n] s.append(slope(marx,noy,n)) name.append(a[i]) break one = [] q = max(s) for i in range(len(s)): if s[i] == q : one.append(name[i]) return one def most_similar_countries(df, country, t, n): a = get_all_countries(df) s = [] name = [] for i in range(len(a)): b = get_confirmed_cases(df,a[i]) for o in range(len(b)): if b[o] > t and o+n <= len(b)-1 : noy = b[o] marx = b[o+n] s.append(slope(marx,noy,n)) name.append(a[i]) break j = name.index(country) g = s[j] pol = [] sim = [] for i in range(len(s)): if i != j: pol.append(abs(g-s[i])) most = min(pol) name.remove(country) for i in range(len(pol)): if pol[i] == most: sim.append(name[i]) return sim def top_k_similar_countries(df, country, t, n, k): a = get_all_countries(df) s = [] name = [] for i in range(len(a)): b = get_confirmed_cases(df,a[i]) for o in range(len(b)): if b[o] > t and o+n <= len(b)-1 : noy = b[o] marx = b[o+n] s.append(slope(marx,noy,n)) name.append(a[i]) break j = name.index(country) g = s[j] pol = [] for i in range(len(s)): if i != j: pol.append(abs(g-s[i])) coppol = pol.copy() pol.sort() rope = 1 index = 0 result = [pol[0]] while rope<k : if pol[index] in result: pass else: result.append(pol[index]) rope += 1 index += 1 name.remove(country) returnlist = [] for element in result: for i in range(len(coppol)): if coppol[i] == element : returnlist.append(name[i]) return returnlist #------------------------------------------------- def slope(y,x,n): return (y-x)/n | # 6330153821 (2020-09-27 22:19) %diff = 0.0 70.0% # Prog-07: COVID-19 # 6330153821 ณัฐกันต์ สนธิเดชกุล # นั่งทำกับเพื่อนครับ แต่ทำเองครับ def steepest_countries(df, t, n): a = get_all_countries(df) s = [] name = [] for i in range(len(a)): b = get_confirmed_cases(df,a[i]) for o in range(len(b)): if b[o] > t and o+n <= len(b)-1 : noy = b[o] marx = b[o+n] s.append(slope(marx,noy,n)) name.append(a[i]) break one = [] q = max(s) for i in range(len(s)): if s[i] == q : one.append(name[i]) return one def most_similar_countries(df, country, t, n): a = get_all_countries(df) s = [] name = [] for i in range(len(a)): b = get_confirmed_cases(df,a[i]) for o in range(len(b)): if b[o] > t and o+n <= len(b)-1 : noy = b[o] marx = b[o+n] s.append(slope(marx,noy,n)) name.append(a[i]) break j = name.index(country) g = s[j] pol = [] sim = [] for i in range(len(s)): if i != j: pol.append(abs(g-s[i])) most = min(pol) name.remove(country) for i in range(len(pol)): if pol[i] == most: sim.append(name[i]) return sim def top_k_similar_countries(df, country, t, n, k): a = get_all_countries(df) s = [] name = [] for i in range(len(a)): b = get_confirmed_cases(df,a[i]) for o in range(len(b)): if b[o] > t and o+n <= len(b)-1 : noy = b[o] marx = b[o+n] s.append(slope(marx,noy,n)) name.append(a[i]) break j = name.index(country) g = s[j] pol = [] for i in range(len(s)): if i != j: pol.append(abs(g-s[i])) coppol = pol.copy() pol.sort() rope = 1 index = 0 result = [pol[0]] while rope<k : if pol[index] in result: pass else: result.append(pol[index]) rope += 1 index += 1 name.remove(country) returnlist = [] for element in result: for i in range(len(coppol)): if coppol[i] == element : returnlist.append(name[i]) return returnlist #------------------------------------------------- def slope(y,x,n): return (y-x)/n | # 6330107021 (2020-09-27 23:56) %diff = 1.37 70.0% # Prog-07: COVID-19 # 6330107021 ชานน ทรรศนกุลพันธ์ # that I do this by myself def steepest_countries(df, t, n): u=get_all_countries(df) s=[] name=[] for i in range(len(u)): v=get_confirmed_cases(df,u[i]) for m in range(len(v)): if v[m]>t and m+n<=len(v)-1: few=v[m] very=v[m+n] s.append(slope(very,few,n)) name.append(u[i]) break one=[] q=max(s) for i in range(len(s)): if s[i]==q: one.append(name[i]) return one def most_similar_countries(df, country, t, n): u=get_all_countries(df) s=[] name=[] for i in range(len(u)): v=get_confirmed_cases(df,u[i]) for m in range(len(v)): if v[m]>t and m+n<=len(v)-1: few=v[m] very=v[m+n] s.append(slope(very,few,n)) name.append(u[i]) break a=name.index(country) b=s[a] pol=[] sim=[] for i in range(len(s)): if i !=a: pol.append(abs(b-s[i])) most=min(pol) name.remove(country) for i in range(len(pol)): if pol[i]==most: sim.append(name[i]) return sim def top_k_similar_countries(df, country, t, n, k): u=get_all_countries(df) s=[] name=[] for i in range(len(u)): v=get_confirmed_cases(df,u[i]) for m in range(len(v)): if v[m]>t and m+n<=len(v)-1: few=v[m] very=v[m+n] s.append(slope(very,few,n)) name.append(u[i]) break a=name.index(country) b=s[a] pol=[] for i in range(len(s)): if i !=a: pol.append(abs(b-s[i])) coppol=pol.copy() pol.sort() rope=1 index=0 result=[pol[0]] while rope<=k: if pol[index] in result: pass else: result.append(pol[index]) rope +=1 index +=1 name.remove(country) returnlist=[] for element in result: for i in range(len(coppol)): if coppol[i]==element: returnlist.append(name[i]) return returnlist #------------------------------------------------- def slope(y,x,n): return(y-x)/n |
all: cluster #2 (18)
# 6331210021 (2020-09-27 12:43) %diff = 0.0 40.0% # Prog-07: COVID-19 # ID : 6331210021 Name : ณัฐพล รัตนะวิศ # ... # ผมยืนยันว่าผมเป็นผู้เขียนโค้ดนี้ด้วยตนเองโดยนำความรู้ที่เรียนมาประยุกต์ใช้ def steepest_countries(df, t, n): steepcon = [] allcon = get_all_countries(df) for c in allcon: gcf = get_confirmed_cases(df,c) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): steepcon.append([((gcf[i + n] - gcf[i]) / n), c]) break steepcon.sort() return [steepcon[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 sml = [] m = [] x = [] allcon = get_all_countries(df) gcf = get_confirmed_cases(df,country) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): ref = (gcf[i + n] - gcf[i]) / n break for c in allcon: gcf = get_confirmed_cases(df,c) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): m = [((gcf[i + n] - gcf[i]) / n), c] break x.append([abs(m[0] - ref),c]) x.sort() for i in range(len(x)): if x[i][0] != 0: sml = (x[i]) break return [sml[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 sml = [] m = [] x = [] allcon = get_all_countries(df) gcf = get_confirmed_cases(df,country) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): ref = (gcf[i + n] - gcf[i]) / n break for c in allcon: gcf = get_confirmed_cases(df,c) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): m = [((gcf[i + n] - gcf[i]) / n), c] break x.append([abs(m[0] - ref),c]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : sml.append(x[i][1]) a += 1 else: sml.append(x[i][1]) if country in sml: sml.remove(country) return sml | # 6331215221 (2020-09-27 18:52) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331215221 นภัชสรณ์ หทัยวุฒิพันธ์ # ฉันเป็นผู้คิดและเขียนโปรแกรมนี้ด้วยตนเอง # Declare that you do this by yourself def steepest_countries(df, t, n): steepc = [] allcount = get_all_countries(df) for ct in allcount: getcc = get_confirmed_cases(df,ct) for i in range(len(getcc)): if getcc[i] > t: if i + n < len(getcc): steepc.append([((getcc[i + n] - getcc[i]) / n), ct]) break steepc.sort() return [steepc[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] allcount = get_all_countries(df) getcc = get_confirmed_cases(df,country) for i in range(len(getcc)): if getcc[i] > t: if i + n < len(getcc): ref = (getcc[i + n] - getcc[i]) / n break for ct in allcount: getcc = get_confirmed_cases(df,ct) for i in range(len(getcc)): if getcc[i] > t: if i + n < len(getcc): slope = [((getcc[i + n] - getcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] allcount = get_all_countries(df) getcc = get_confirmed_cases(df,country) for i in range(len(getcc)): if getcc[i] > t: if i + n < len(getcc): ref = (getcc[i + n] - getcc[i]) / n break for ct in allcount: getcc = get_confirmed_cases(df,ct) for i in range(len(getcc)): if getcc[i] > t: if i + n < len(getcc): slope = [((getcc[i + n] - getcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar | # 6331220321 (2020-09-27 19:41) %diff = 0.16 20.0% # Prog-07: COVID-19 # 6331220321 พชธกร หวังเทอดเกียรติ # ผมเป็นผู้พัฒนาโปรแกรมนี้ด้วยตนเอง # ผมแก้ไขและพัฒนาโปรแกรมนี้ด้วยตัวเอง def steepest_countries(df, t, n): spc = [] gac = get_all_countries(df) for ct in gac: gcf = get_confirmed_cases(df,ct) for i in range(len(gac)): if gcf[i] > t: if i + n < len(gac): spc.append([((gcf[i + n] - gcf[i]) / n), ct]) break spc.sort() return [spc[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] gac = get_all_countries(df) gcf = get_confirmed_cases(df,country) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): ref = (gcf[i + n] - gcf[i]) / n break for ct in gac: gcf = get_confirmed_cases(df,ct) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): slope = [((gcf[i + n] - gcf[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] gac = get_all_countries(df) gcf = get_confirmed_cases(df,country) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): ref = (gcf[i + n] - gcf[i]) / n break for ct in gac: gcf = get_confirmed_cases(df,ct) for i in range(len(gcf)): if gcf[i] > t: if i + n < len(gcf): slope = [((gcf[i + n] - gcf[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar | # 6331223221 (2020-09-27 19:45) %diff = 0.82 40.0% # Prog-07: COVID-19 # 6331223221 ภรัณยู แสงพัฒนากรกิจ # ผมเป็นผู้คิดค้นและพัฒนาปรแกรมนี้ด้วยตัวเอง # Declare that you do this by yourself def steepest_countries(df, t, n): steepest_count = [] all_count = get_all_countries(df) for ct in all_count: getcfc = get_confirmed_cases(df,ct) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): steepest_count.append([((getcfc[i + n] - getcfc[i]) / n), ct]) break steepest_count.sort() return [steepest_count[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] allc = get_all_countries(df) getcfc = get_confirmed_cases(df,country) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): ref = (getcfc[i + n] - getcfc[i]) / n break for ct in allc: getcfc = get_confirmed_cases(df,ct) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): slope = [((getcfc[i + n] - getcfc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] allc = get_all_countries(df) getcfc = get_confirmed_cases(df,country) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): ref = (getcfc[i + n] - getcfc[i]) / n break for ct in allc: getcfc = get_confirmed_cases(df,ct) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): slope = [((getcfc[i + n] - getcfc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar | # 6331211721 (2020-09-27 19:49) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331211721 ธนพล ปรีนคร # ผมเป็นผู้คิดค้นโปรแกรมนี้ด้วยตัวเอง # Declare that you do this by yourself def steepest_countries(df, t, n): steepest_count = [] allc = get_all_countries(df) for ct in allc: getcfc = get_confirmed_cases(df,ct) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): steepest_count.append([((getcfc[i + n] - getcfc[i]) / n), ct]) break steepest_count.sort() return [steepest_count[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] allc = get_all_countries(df) getcfc = get_confirmed_cases(df,country) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): ref = (getcfc[i + n] - getcfc[i]) / n break for ct in allc: getcfc = get_confirmed_cases(df,ct) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): slope = [((getcfc[i + n] - getcfc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] allc = get_all_countries(df) getcfc = get_confirmed_cases(df,country) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): ref = (getcfc[i + n] - getcfc[i]) / n break for ct in allc: getcfc = get_confirmed_cases(df,ct) for i in range(len(getcfc)): if getcfc[i] > t: if i + n < len(getcfc): slope = [((getcfc[i + n] - getcfc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar | # 6331235821 (2020-09-27 20:41) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331235821 อภิชาติ อัศวทรัพย์ทวี # ... # ผมเป็นคนเขียนโปรแกรมนี้ด้วยตัวผมเอง def steepest_countries(df, t, n): stp = [] ac = get_all_countries(df) for ct in ac: gcc = get_confirmed_cases(df,ct) for k in range(len(gcc)): if gcc[k] > t: if k + n < len(gcc):stp.append([((gcc[k + n] - gcc[k]) / n), ct]) break stp.sort() return [stp[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] ac = get_all_countries(df) gcc = get_confirmed_cases(df,country) for k in range(len(gcc)): if gcc[k] > t: if k + n < len(gcc):ref = (gcc[k + n] - gcc[k]) / n break for ct in ac: gcc = get_confirmed_cases(df,ct) for k in range(len(gcc)): if gcc[k] > t: if k + n < len(gcc):slope = [((gcc[k + n] - gcc[k]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for k in range(len(x)): if x[k][0] != 0: similar = (x[k]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] ac = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc):ref = (gcc[i + n] - gcc[i]) / n break for ct in ac: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc):slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else:similar.append(x[i][1]) if country in similar:similar.remove(country) return similar | # 6331518421 (2020-09-27 21:50) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331518421 นายอัครวิทย์ ศรีวิเชียร # ..... # กระผมขอยืนยันว่าเป็นผู้ปรับปรุงและเขียนโค้ดด้วยนี้ตนเอง def steepest_countries(df, t, n): stpct = [] allct = get_all_countries(df) for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): stpct.append([((gcc[i + n] - gcc[i]) / n), ct]) break stpct.sort() return [stpct[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] allct = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] allct = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar #------------------------------------------------- | # 6331508121 (2020-09-27 21:59) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331508121 นายฐานวัฒน์ อมรางกูร # ... # ผมขอยืนยันว่า เป็นผู้ปรับและเขียนโค้ดด้วยตนเอง def steepest_countries(df, t, n): stpct = [] allct = get_all_countries(df) for ct in allct: cc = get_confirmed_cases(df,ct) for i in range(len(cc)): if cc[i] > t: if i + n < len(cc): stpct.append([((cc[i + n] - cc[i]) / n), ct]) break stpct.sort() return [stpct[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] allct = get_all_countries(df) cc = get_confirmed_cases(df,country) for i in range(len(cc)): if cc[i] > t: if i + n < len(cc): ref = (cc[i + n] - cc[i]) / n break for ct in allct: cc = get_confirmed_cases(df,ct) for i in range(len(cc)): if cc[i] > t: if i + n < len(cc): slope = [((cc[i + n] - cc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] allct = get_all_countries(df) cc = get_confirmed_cases(df,country) for i in range(len(cc)): if cc[i] > t: if i + n < len(cc): ref = (cc[i + n] - cc[i]) / n break for ct in allct: cc = get_confirmed_cases(df,ct) for i in range(len(cc)): if cc[i] > t: if i + n < len(cc): slope = [((cc[i + n] - cc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar #------------------------------------------------- | # 6331507521 (2020-09-27 22:10) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331507521 โชษณ เรืองศรี # กระผมขอยืนยันว่ากระผมเป็นผู้เขียนโค้ดด้วยตัวเอง def steepest_countries(df, t, n): stpct = [ ] allct = get_all_countries(df) for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): stpct.append([((gcc[i + n] - gcc[i]) / n), ct]) break stpct.sort( ) return [stpct[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [ ] slope = [ ] x = [ ] allct = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [ ] slope = [ ] x = [ ] allct = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort( ) a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar #------------------------------------------------- | # 6330048621 (2020-09-27 22:57) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6330048621 คุณานนต์ สุพรรณพงษ์ # ผมเป็นผู้เขียนโปรแกรมนี้ด้วยตนเอง # Declare that you do this by yourself def steepest_countries(df, t, n): sc = [] gac = get_all_countries(df) for ct in gac: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): sc.append([((gcc[i + n] - gcc[i]) / n), ct]) break sc.sort() return [sc[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] gac = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in gac: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] gac = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in gac: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar | # 6331214621 (2020-09-27 23:04) %diff = 4.66 40.0% # Prog-07: COVID-19 # 6331214621 นนทเดช ดิษยธรรม # ใช้เนื้อหาจากเรื่อง def บทที่ 6 มาประยุกต์ใช้กับการโจทย์ในครั้งนี้ด้วยตัวเอง def steepest_countries(df, t, n): steep_ = [] getall = get_all_countries(df) for ct in getall: confirm = get_confirmed_cases(df,ct) for i in range(len(confirm)): if confirm[i] > t: if i + n < len(confirm): steep_.append([((confirm[i + n] - confirm[i]) / n), ct]) break steep_.sort() return [steep_[-1][1]] def most_similar_countries(df, country, t, n): m = [];x = [];ref = 0;similar = [] getall = get_all_countries(df) confirm = get_confirmed_cases(df,country) for i in range(len(confirm)): if confirm[i] > t: if i + n < len(confirm): ref = (confirm[i + n] - confirm[i]) / n break for ct in getall: confirm = get_confirmed_cases(df,ct) for i in range(len(confirm)): if confirm[i] > t: if i + n < len(confirm): m = [((confirm[i + n] - confirm[i]) / n), ct] break x.append([abs(m[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): m = [];x = [];ref = 0;similar = [] getall = get_all_countries(df) confirm = get_confirmed_cases(df,country) for i in range(len(confirm)): if confirm[i] > t: if i + n < len(confirm): ref = (confirm[i + n] - confirm[i]) / n break for ct in getall: confirm = get_confirmed_cases(df,ct) for i in range(len(confirm)): if confirm[i] > t: if i + n < len(confirm): m = [((confirm[i + n] - confirm[i]) / n), ct] break x.append([abs(m[0] - ref),ct]) x.sort() z = 0 for i in range(len(x)): if z == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) z += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar | # 6331218121 (2020-09-27 23:06) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331218121 ผิวไผ่ ขวัญหะวัญ # ผมเป็นคนทำและแก้ไขการบ้านงานนี้ด้วยตนเอง def steepest_countries(df, t, n): s = [] ac = get_all_countries(df) for countreies in ac: gcc = get_confirmed_cases(df,countreies) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): s.append([((gcc[i + n] - gcc[i]) / n), countreies]) break s.sort() return [s[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] a = [] ac = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for countreies in ac: gcc = get_confirmed_cases(df,countreies) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), countreies] break a.append([abs(slope[0] - ref),countreies]) a.sort() for i in range(len(a)): if a[i][0] != 0: similar = (a[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] a = [] ac = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for countreies in ac: gcc = get_confirmed_cases(df,countreies) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), countreies] break a.append([abs(slope[0] - ref),countreies]) a.sort() x = 0 for i in range(len(a)): if x == k: break if a[i][0] != a[i+1][0] : similar.append(a[i][1]) x += 1 else: similar.append(a[i][1]) if country in similar: similar.remove(country) return similar #------------------------------------------------- | # 6330015921 (2020-09-27 23:14) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6330015921 นายกษิดิ์ญุตม์ เจริญลาภ # ... # ผมขอยืนยันว่า เป็นผู้ปรับและเขียนโค้ดด้วยตนเอง def steepest_countries(df, t, n): stpct = [] allct = get_all_countries(df) for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): stpct.append([((gcc[i + n] - gcc[i]) / n), ct]) break stpct.sort() return [stpct[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] allct = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] allct = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar #------------------------------------------------- | # 6331221021 (2020-09-27 23:42) %diff = 2.04 40.0% # Prog-07: COVID-19 # 6331221021 พศุตม์ วุฒิเดชกำจร # ... # ผมเป็นคนเขียนโปรแกรมนี้ด้วยตัวเองครับ def steepest_countries(df, t, n): ste = [] allc = get_all_countries(df) for ct in allc: get = get_confirmed_cases(df,ct) for i in range(len(get)): if get[i] > t: if i + n < len(get): ste.append([((get[i + n] - get[i]) / n), ct]) break ste.sort() return [ste[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] allc = get_all_countries(df) get = get_confirmed_cases(df,country) for i in range(len(get)): if get[i] > t: if i + n < len(get):ref = (get[i + n] - get[i]) / n break for ct in allc: get = get_confirmed_cases(df,ct) for i in range(len(get)): if get[i] > t: if i + n < len(get):slope = [((get[i + n] - get[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] allc = get_all_countries(df) get = get_confirmed_cases(df,country) for i in range(len(get)): if get[i] > t: if i + n < len(get):ref = (get[i + n] - get[i]) / n break for ct in allc: get = get_confirmed_cases(df,ct) for i in range(len(get)): if get[i] > t: if i + n < len(get):slope = [((get[i + n] - get[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar:similar.remove(country) return similar | # 6330056621 (2020-09-27 23:47) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6330056621 นายจิรัฏฐ์ ชลเกตุ # ข้าพเจ้าแก้ไขและพัฒนาโปรแกรมนี้ด้วยตัวเอง def steepest_countries(df, t, n): steepest_cs = [] # cs = countries get_all_cs = get_all_countries(df) for count in get_all_cs: get_confirmed_c = get_confirmed_cases(df, count) # c = cases for i in range(len(get_confirmed_c)): if get_confirmed_c[i] > t: if i + n < len(get_confirmed_c): steepest_cs.append([((get_confirmed_c[i + n] - get_confirmed_c[i]) / n), count]) break steepest_cs.sort() return [steepest_cs[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] d = [] get_all_cs = get_all_countries(df) # cs = countries get_confirmed_c = get_confirmed_cases(df, country) # c = cases for i in range(len(get_confirmed_c)): if get_confirmed_c[i] > t: if i + n < len(get_confirmed_c): ref = (get_confirmed_c[i + n] - get_confirmed_c[i]) / n break for count in get_all_cs: get_confirmed_c = get_confirmed_cases(df, count) for i in range(len(get_confirmed_c)): if get_confirmed_c[i] > t: if i + n < len(get_confirmed_c): slope = [((get_confirmed_c[i + n] - get_confirmed_c[i]) / n), count] break d.append([abs(slope[0] - ref), count]) d.sort() for i in range(len(d)): if d[i][0] != 0: similar = (d[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] d = [] get_all_cs = get_all_countries(df) # cs = countries get_confirmed_c = get_confirmed_cases(df, country) # c = cases for i in range(len(get_confirmed_c)): if get_confirmed_c[i] > t: if i + n < len(get_confirmed_c): ref = (get_confirmed_c[i + n] - get_confirmed_c[i]) / n break for count in get_all_cs: get_confirmed_c = get_confirmed_cases(df, count) for i in range(len(get_confirmed_c)): if get_confirmed_c[i] > t: if i + n < len(get_confirmed_c): slope = [((get_confirmed_c[i + n] - get_confirmed_c[i]) / n), count] break d.append([abs(slope[0] - ref), count]) d.sort() a = 0 for i in range(len(d)): if a == k: break if d[i][0] != d[i+1][0] : similar.append(d[i][1]) a += 1 else: similar.append(d[i][1]) if country in similar: similar.remove(country) return similar | # 6330058921 (2020-09-27 23:52) %diff = 4.66 40.0% # Prog-07: COVID-19 # 6330058921 จิราภัทร ลามศรีจันทร์ # วิธีการเขียนทั้งหมดนี้ผมได้ทำการเรียนรู้มาด้วยตัวเอง # ยืนยันว่าทำการพัฒนาโปรแกรมครั้งนี้ด้วยตัวเอง def steepest_countries(df, t, n) : steep = [] al = get_all_countries(df) for ct in al : c = get_confirmed_cases(df,ct) for e in range(len(c)) : if c[e] > t : if e + n < len(c) : steep.append([((c[e + n] - c[e])/n),ct]) break steep.sort() return[steep[-1][1]] def most_similar_countries(df, country, t, n) : a = [] al = get_all_countries(df) c = get_confirmed_cases(df,country) for e in range(len(c)) : if c[e] > t : if e + n < len(c) : r = (c[e + n] - c[e]) / n break for ct in al: c = get_confirmed_cases(df,ct) for e in range(len(c)) : if c[e] > t : if e + n < len(c) : m = [((c[e + n] - c[e]) / n), ct] break a.append([abs(m[0] - r),ct]) a.sort() for e in range(len(a)) : if a[e][0] != 0 : s = (a[e]) break return [s[1]] def top_k_similar_countries(df, country, t, n, k) : s = [] a = [] al = get_all_countries(df) c = get_confirmed_cases(df,country) for e in range(len(c)) : if c[e] > t : if e + n < len(c) : r = (c[e + n] - c[e]) / n break for ct in al: c = get_confirmed_cases(df,ct) for e in range(len(c)) : if c[e] > t : if e + n < len(c) : m = [((c[e + n] - c[e]) / n), ct] break a.append([abs(m[0] - r),ct]) a.sort() b = 0 for e in range(len(a)) : if b == k : break if a[e][0] != a[e+1][0] : s.append(a[e][1]) b += 1 else: s.append(a[e][1]) if country in s: s.remove(country) return s #------------------------------------------------- | # 6331233521 (2020-09-27 23:54) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331233521 อนิก หงษ์ทอง # ผมนายอนิก หงษ์ทองเป็นคนเขียนโปรแกรมนี้ด้วยตนเอง def steepest_countries(df, t, n): stp = [] ac = get_all_countries(df) for ct in ac: gcc = get_confirmed_cases(df,ct) for k in range(len(gcc)): if gcc[k] > t: if k + n < len(gcc):stp.append([((gcc[k + n] - gcc[k]) / n), ct]) break stp.sort() return [stp[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] ac = get_all_countries(df) gcc = get_confirmed_cases(df,country) for k in range(len(gcc)): if gcc[k] > t: if k + n < len(gcc):ref = (gcc[k + n] - gcc[k]) / n break for ct in ac: gcc = get_confirmed_cases(df,ct) for k in range(len(gcc)): if gcc[k] > t: if k + n < len(gcc):slope = [((gcc[k + n] - gcc[k]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for k in range(len(x)): if x[k][0] != 0: similar = (x[k]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] ac = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc):ref = (gcc[i + n] - gcc[i]) / n break for ct in ac: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc):slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else:similar.append(x[i][1]) if country in similar:similar.remove(country) return similar #------------------------------------------------- | # 6331502321 (2020-09-27 23:59) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6331502321 กษิดิศ จุฑาสันติกุล # ... # กระผมได้เขียนโค้ดนี้ด้วยตัวเองครับ def steepest_countries(df, t, n): stpct = [] allct = get_all_countries(df) for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): stpct.append([((gcc[i + n] - gcc[i]) / n), ct]) break stpct.sort() return [stpct[-1][1]] def most_similar_countries(df, country, t, n): ref = 0 similar = [] slope = [] x = [] allct = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() for i in range(len(x)): if x[i][0] != 0: similar = (x[i]) break return [similar[1]] def top_k_similar_countries(df, country, t, n, k): ref = 0 similar = [] slope = [] x = [] allct = get_all_countries(df) gcc = get_confirmed_cases(df,country) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): ref = (gcc[i + n] - gcc[i]) / n break for ct in allct: gcc = get_confirmed_cases(df,ct) for i in range(len(gcc)): if gcc[i] > t: if i + n < len(gcc): slope = [((gcc[i + n] - gcc[i]) / n), ct] break x.append([abs(slope[0] - ref),ct]) x.sort() a = 0 for i in range(len(x)): if a == k: break if x[i][0] != x[i+1][0] : similar.append(x[i][1]) a += 1 else: similar.append(x[i][1]) if country in similar: similar.remove(country) return similar #------------------------------------------------- |
all: cluster #3 (2)
# 6331128321 (2020-09-27 22:37) %diff = 0.0 50.0% # Prog-07: COVID-19 # 6331128321 วิศรุต สุดชาติ # ผมยืนยันว่าผมเขียนโปรแกรมนี้ด้วยความภาคภูมิใจยิ่งที่สุดเลยค้าบ def steepest_countries(df, t, n): maximum_slope = -1e9 result = [] countries = get_all_countries(df) for country in countries: confirmed_cases = get_confirmed_cases(df, country) slope = calculate_slope(df, country, t, n) if slope != -1: if slope > maximum_slope: maximum_slope = slope result = [country] elif slope == maximum_slope: result.append(country) return result def most_similar_countries(df, country, t, n): country_slope = calculate_slope(df, country, t, n) if country_slope == -1: return [] result = [] minimum_diff = 1e9 countries = get_all_countries(df) for ct in countries: if ct != country: slope = calculate_slope(df, ct, t, n) if slope != -1: diff = abs(country_slope - slope) if diff < minimum_diff: minimum_diff = diff result = [ct] elif diff == minimum_diff: result.append(ct) return result def top_k_similar_countries(df, country, t, n, k): country_slope = calculate_slope(df, country, t, n) if country_slope == -1: return [] diff_by_country = [] countries = get_all_countries(df) for ct in countries: if ct != country: slope = calculate_slope(df, ct, t, n) if slope != -1: diff = abs(country_slope - slope) diff_by_country.append((ct, diff, slope)) diff_by_country = sorted(diff_by_country, key = lambda x:x[1]) result = [diff_by_country[0][0]] cnt = 1 last_diff = diff_by_country[0][1] for ct, diff, slope in diff_by_country[1:]: if cnt >= k and diff != last_diff: break if diff == last_diff: result.append(ct) else: result.append(ct) last_diff = diff cnt += 1 return result #------------------------------------------------- def calculate_slope(df, country, t, n): confirmed_cases = get_confirmed_cases(df, country) for idx, confirmed_case in enumerate(confirmed_cases): if confirmed_case >= t and idx+n < len(confirmed_cases): return (confirmed_cases[idx+n] + confirmed_cases[idx])/n return -1 | # 6330065221 (2020-09-27 23:45) %diff = 0.0 50.0% # Prog-07: COVID-19 # 6330065221 เจษรินทร์ เกณฑ์ขุนทด # ผมขอยืนยันว่าผมเป็นผู้เขียนโปรแกรมนี้ด้วยตนเอง def steepest_countries(df, t, n): maximum_slope = -1e9 result = [] countries = get_all_countries(df) for country in countries: confirmed_cases = get_confirmed_cases(df, country) slope = calculate_slope(df, country, t, n) if slope != -1: if slope > maximum_slope: maximum_slope = slope result = [country] elif slope == maximum_slope: result.append(country) return result def most_similar_countries(df, country, t, n): country_slope = calculate_slope(df, country, t, n) if country_slope == -1: return [] result = [] minimum_diff = 1e9 countries = get_all_countries(df) for ct in countries: if ct != country: slope = calculate_slope(df, ct, t, n) if slope != -1: diff = abs(country_slope - slope) if diff < minimum_diff: minimum_diff = diff result = [ct] elif diff == minimum_diff: result.append(ct) return result def top_k_similar_countries(df, country, t, n, k): country_slope = calculate_slope(df, country, t, n) if country_slope == -1: return [] diff_by_country = [] countries = get_all_countries(df) for ct in countries: if ct != country: slope = calculate_slope(df, ct, t, n) if slope != -1: diff = abs(country_slope - slope) diff_by_country.append((ct, diff, slope)) diff_by_country = sorted(diff_by_country, key = lambda x:x[1]) result = [diff_by_country[0][0]] cnt = 1 last_diff = diff_by_country[0][1] for ct, diff, slope in diff_by_country[1:]: if cnt >= k and diff != last_diff: break if diff == last_diff: result.append(ct) else: result.append(ct) last_diff = diff cnt += 1 return result #------------------------------------------------- def calculate_slope(df, country, t, n): confirmed_cases = get_confirmed_cases(df, country) for idx, confirmed_case in enumerate(confirmed_cases): if confirmed_case >= t and idx+n < len(confirmed_cases): return (confirmed_cases[idx+n] + confirmed_cases[idx])/n return -1 |
all: cluster #4 (2)
# 6231018921 (2020-09-25 21:41) %diff = 0.0 40.0% # Prog-07: COVID-19 # Fill in your ID & Name # 6231018921 Wannarong Chusrichai # Declare that you do this by yourself def steepest_countries(df, t, n): countries = get_all_countries(df) result = list() maxSlope = 0.0 for country in countries: slope = find_slope(df,country,t,n) if (slope > maxSlope): maxSlope = slope result = list() result.append(country) elif (slope == maxSlope): result.append(country) return result def most_similar_countries(df, country, t, n): countries = get_all_countries(df) slope = find_slope(df,country,t,n) result = list() diff = slope for c in countries: if (c != country): otherSlope = find_slope(df,c,t,n) if (diff > abs(otherSlope - slope)): diff = abs(otherSlope - slope) result = list() result.append(c) elif (diff == abs(otherSlope - slope)): result.append(c) return result def top_k_similar_countries(df, country, t, n, k): countries = get_all_countries(df) slope = find_slope(df,country,t,n) result = list() for i in range(k): diff = slope countriesList = list() for c in countries: if (c != country): otherSlope = find_slope(df,c,t,n) if (diff > abs(otherSlope - slope)): diff = abs(otherSlope - slope) countriesList = list() countriesList.append(c) elif (diff == abs(otherSlope - slope)): countriesList.append(c) for e in countriesList: result.append(e) countries.remove(e) return result #------------------------------------------------- def find_slope(df,country,t,n): case = get_confirmed_cases(df,country) slope = 0.0 for i in range(len(case)): if (case[i] >= t) and (i+n < len(case)): slope = case[i+n] - case[i] slope /= n slope = round(slope,2) break return slope | # 6231016621 (2020-09-27 15:33) %diff = 0.0 40.0% # Prog-07: COVID-19 # 6231016621 นางสาวมีน เพียรคำพร # หนูขอยืนยันว่าเป็นผู้เขียนโปรแกรมนี้ด้วยตนเองค่ะ def steepest_countries(df, t, n): countries = get_all_countries(df) result = list() maxSlope = 0.0 for country in countries: slope = find_slope(df,country,t,n) if (slope > maxSlope): maxSlope = slope result = list() result.append(country) elif (slope == maxSlope): result.append(country) return result def most_similar_countries(df, country, t, n): countries = get_all_countries(df) slope = find_slope(df,country,t,n) result = list() diff = slope for c in countries: if (c != country): otherSlope = find_slope(df,c,t,n) if (diff > abs(otherSlope - slope)): diff = abs(otherSlope - slope) result = list() result.append(c) elif (diff == abs(otherSlope - slope)): result.append(c) return result def top_k_similar_countries(df, country, t, n, k): countries = get_all_countries(df) slope = find_slope(df,country,t,n) result = list() for i in range(k): diff = slope countriesList = list() for c in countries: if (c != country): otherSlope = find_slope(df,c,t,n) if (diff > abs(otherSlope - slope)): diff = abs(otherSlope - slope) countriesList = list() countriesList.append(c) elif (diff == abs(otherSlope - slope)): countriesList.append(c) for e in countriesList: result.append(e) countries.remove(e) return result #------------------------------------------------- def find_slope(df,country,t,n): case = get_confirmed_cases(df,country) slope = 0.0 for i in range(len(case)): if (case[i] >= t) and (i+n < len(case)): slope = case[i+n] - case[i] slope /= n slope = round(slope,2) break return slope |
all: cluster #5 (3)
# 6331117421 (2020-09-26 10:07) %diff = 0.0 80.0% # Prog-07: COVID-19 # 6331117421 นวพล เนื่องจำนงค์ # ... # ขอยืนยันว่าได้เขียนโปรแกรมด้วยตัวเอง def steepest_countries(df, t, n): Max = -1 Countries = [] for country in get_all_countries(df): slope = find_slope(df, country, t, n) if slope == None : continue if Max < slope : Max = slope Countries = [country] elif Max == slope: Countries.append(country) return Countries def most_similar_countries(df, country, t, n): slope_of_this_country = find_slope(df, country, t, n) minDiff = None Countries = [] for temp in get_all_countries(df): if temp == country: continue slope = find_slope(df, temp, t, n) if slope == None : continue if minDiff == None or minDiff > abs(slope-slope_of_this_country) : minDiff = abs(slope-slope_of_this_country) Countries = [temp] elif minDiff == abs(slope-slope_of_this_country) : Countries.append(temp) return Countries def top_k_similar_countries(df, country, t, n, k): slope_of_this_country = find_slope(df, country, t, n) Countries = {} for temp in get_all_countries(df): if temp == country: continue slope = find_slope(df, temp, t, n) if slope == None : continue if Countries.get(abs(slope-slope_of_this_country)) == None: Countries[abs(slope-slope_of_this_country)] = [] Countries[abs(slope-slope_of_this_country)].append(temp) L = [] for c,l in sorted(Countries.items()): L += l if len(L) > k: break return L #------------------------------------------------- def find_slope(df, country, t, n): confirmed_cases = get_confirmed_cases(df, country) i = 0 while i<len(confirmed_cases) and confirmed_cases[i] <= t : i+=1 if i == len(confirmed_cases): return None return confirmed_cases[i+n if i+n < len(confirmed_cases) else -1] - confirmed_cases[i] | # 6331126021 (2020-09-27 13:16) %diff = 0.0 80.0% # Prog-07: COVID-19 # 6331126021 วรโชติ ไพจินดา # i do this work with myself. def steepest_countries(df, t, n): Max = -1 Countries = [] for country in get_all_countries(df): slope = find_slope(df, country, t, n) if slope == None : continue if Max < slope : Max = slope Countries = [country] elif Max == slope: Countries.append(country) return Countries def most_similar_countries(df, country, t, n): slope_of_this_country = find_slope(df, country, t, n) minDiff = None Countries = [] for temp in get_all_countries(df): if temp == country: continue slope = find_slope(df, temp, t, n) if slope == None : continue if minDiff == None or minDiff > abs(slope-slope_of_this_country) : minDiff = abs(slope-slope_of_this_country) Countries = [temp] elif minDiff == abs(slope-slope_of_this_country) : Countries.append(temp) return Countries def top_k_similar_countries(df, country, t, n, k): slope_of_this_country = find_slope(df, country, t, n) Countries = {} for temp in get_all_countries(df): if temp == country: continue slope = find_slope(df, temp, t, n) if slope == None : continue if Countries.get(abs(slope-slope_of_this_country)) == None: Countries[abs(slope-slope_of_this_country)] = [] Countries[abs(slope-slope_of_this_country)].append(temp) L = [] for c,l in sorted(Countries.items()): L += l if len(L) > k: break return L #------------------------------------------------- def find_slope(df, country, t, n): confirmed_cases = get_confirmed_cases(df, country) i = 0 while i<len(confirmed_cases) and confirmed_cases[i] <= t : i+=1 if i == len(confirmed_cases): return None return confirmed_cases[i+n if i+n < len(confirmed_cases) else -1] - confirmed_cases[i] | # 6331132821 (2020-09-27 23:56) %diff = 5.9 50.0% # Prog-07: COVID-19 # 6331132821 สุพิชชา ปานบุญ # ... # ยืนยันว่าทำด้วยตัวเองค่ะ def steepest_countries(df, t, n): Fai = -1 Countries = [] for country in get_all_countries(df): slope = find_slope(df, country, t, n) if slope == None : continue if slope > Fai : slope = Fai Countries = [country] elif Fai == slope: Countries.append(country) return Countries def most_similar_countries(df, country, t, n): slope_of_this_country = find_slope(df, country, t, n) minDiff = None Countries = [] for ako in get_all_countries(df): if ako == country: continue slope = find_slope(df, ako, t, n) if slope == None : continue if minDiff == None or minDiff > abs(slope-slope_of_this_country) : minDiff = abs(slope-slope_of_this_country) Countries = [ako] elif minDiff == abs(slope-slope_of_this_country) : Countries.append(ako) return Countries def top_k_similar_countries(df, country, t, n, k): slope_of_this_country = find_slope(df, country, t, n) Countries = {} for Pooh in get_all_countries(df): if Pooh == country: continue slope = find_slope(df, Pooh, t, n) if slope == None : continue if Countries.get(abs(slope-slope_of_this_country)) == None: Countries[abs(slope-slope_of_this_country)] = [] Countries[abs(slope-slope_of_this_country)].append(Pooh) L = [] for c,l in sorted(Countries.items()): L += l if len(L) > k: break return L #------------------------------------------------- def find_slope(df, country, t, n): a = get_confirmed_cases(df, country) i = 0 while i<len(a) and a[i] <= t : i+=1 if i == len(a): return None return a[i+n if i+n < len(a) else -1] - a[i] |
all: cluster #6 (2)
# 6330023921 (2020-09-27 22:59) %diff = 0.0 30.0% # Prog-07: COVID-19 # 6330023921 Kantaphon Liengmahawong # ... # I code this by myself. def steepest_countries(df, t, n): V=["g"] highest_slope=float(0) slope=float(0) for e in contries : case= get_confirmed_cases(df,e) for i in range(0,len(case)-n,1) : if int(case[i]) >= t : slope= (case[i+n]-case[i])/n break if slope> highest_slope : V[0]=e highest_slope=slope return(V) def most_similar_countries(df, country, t, n): that_contry=get_confirmed_cases(df,country) delta_slope=float(0) closest_delta_slope=float(9999999) V=['g'] for i in range(0,len(that_contry)-n,1) : if int(that_contry[i]) >= t : slope_that_contry= (that_contry[i+n]-that_contry[i])/n break for e in contries : if e!=country : case= get_confirmed_cases(df,e) for i in range(0,len(case)-n,1) : if int(case[i]) >= t : slope= (case[i+n]-case[i])/n break delta_slope= slope_that_contry-slope delta_slope= abs(delta_slope) slope_that_contr=abs(slope_that_contry) if delta_slope<closest_delta_slope : closest_delta_slope=delta_slope V[0]=e return(V) def top_k_similar_countries(df, country, t, n, k): y = get_all_countries(df) a=slope_of_country(df,country, t, n) slopelist=[] cc=[] cmax=0 for i in range(len(y)): if slope_of_country(df,y[i], t ,n) > cmax: cmax = slope_of_country(df,y[i], t ,n) slopelist.append(slope_of_country(df,y[i], t ,n)) for i in range(len(slopelist)): cc.append([abs(a-slopelist[i]),y[i]]) cc.sort() cc.remove([0.0,country]) l=0 for i in range(k,len(cc)): if cc[i][0] == cc[i-1][0] : l+=1 else: break return [e[1]for e in cc[:k+l]] #------------------------------------------------- def slope_of_country(df,country, t, n): num = get_confirmed_cases(df,country) slope =0 for i in range(len(num)): if num[i] > t and i+n < len(num) : slope = (num[i+n]-num[i])/n break return slope | # 6231517721 (2020-09-27 23:32) %diff = 0.0 30.0% # Prog-07: COVID-19 # 6231517721 Apichart Chomjandr # ผมขอยืนยันว่าได้สละเวลาอย่างในการทำหลายชั่วโมง def steepest_countries(df, t, n): V=["g"] highest_slope=float(0) slope=float(0) for e in contries : case= get_confirmed_cases(df,e) for i in range(0,len(case)-n,1) : if int(case[i]) >= t : slope= (case[i+n]-case[i])/n break if slope> highest_slope : V[0]=e highest_slope=slope return(V) def most_similar_countries(df, country, t, n): that_contry=get_confirmed_cases(df,country) delta_slope=float(0) closest_delta_slope=float(9999999) V=['g'] for i in range(0,len(that_contry)-n,1) : if int(that_contry[i]) >= t : slope_that_contry= (that_contry[i+n]-that_contry[i])/n break for e in contries : if e!=country : case= get_confirmed_cases(df,e) for i in range(0,len(case)-n,1) : if int(case[i]) >= t : slope= (case[i+n]-case[i])/n break delta_slope= slope_that_contry-slope delta_slope= abs(delta_slope) slope_that_contr=abs(slope_that_contry) if delta_slope<closest_delta_slope : closest_delta_slope=delta_slope V[0]=e return(V) def top_k_similar_countries(df, country, t, n, k): y = get_all_countries(df) a=slope_country(df,country, t, n) slopelist=[] cc=[] highest=0 for i in range(len(y)): if slope_country(df,y[i], t ,n) > highest: highest = slope_country(df,y[i], t ,n) slopelist.append(slope_country(df,y[i], t ,n)) for i in range(len(slopelist)): cc.append([abs(a-slopelist[i]),y[i]]) cc.sort() cc.remove([0.0,country]) l=0 for i in range(k,len(cc)): if cc[i][0] == cc[i-1][0] : l+=1 else: break return [e[1]for e in cc[:k+l]] #------------------------------------------------- def slope_country(df,country, t, n): num = get_confirmed_cases(df,country) slope =0 for i in range(len(num)): if num[i] > t and i+n < len(num) : slope = (num[i+n]-num[i])/n break return slope |
all: cluster #7 (3)
# 6330092121 (2020-09-27 12:41) %diff = 0.0 70.0% # Prog-07: COVID-19 # 6330092121 ชยุตม์ สิงห์ลอ # ข้าพเจ้ายืนยันว่าเขียนโปรแกรมนี้ด้วยตนเอง def steepest_countries(df, t, n): list_ans = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() return [((list_ans)[-1])[1]] def most_similar_countries(df, country, t, n): list_ans = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() for i in range(len(list_ans)): if (list_ans[i])[1] == country : if list_ans[i] == list_ans[-1]: return [(list_ans[i-1])[1]] else: if abs((list_ans[i-1])[0] - (list_ans[i])[0]) >= abs((list_ans[i+1])[0] - (list_ans[i])[0]): return [(list_ans[i+1])[1]] elif abs((list_ans[i-1])[0] - (list_ans[i])[0]) < abs((list_ans[i+1])[0] - (list_ans[i])[0]): return [(list_ans[i-1])[1]] def top_k_similar_countries(df, country, t, n, k): list_ans = [] list_pre = [] list_final = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() a = get_confirmed_cases(df, country) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n break ind = list_ans.index([m, country]) list_ans.pop(ind) for i in range(len(list_ans)): list_pre.append([abs(m-(list_ans[i])[0]) , (list_ans[i])[1]]) list_pre.sort() for i in range(len(list_pre)): if i < k: list_final.append((list_pre[i])[1]) elif (list_pre[i])[0] != (list_pre[i-1])[0]: break elif (list_pre[i])[0] == (list_pre[i-1])[0]: list_final.append((list_pre[i])[1]) return list_final #------------------------------------------------- | # 6330086421 (2020-09-27 21:52) %diff = 0.0 70.0% # Prog-07: COVID-19 # 6330086421 ชยากร สีวลีพันธ์ # ผมทำเองครับ def steepest_countries(df, t, n): list_ans = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() return [((list_ans)[-1])[1]] def most_similar_countries(df, country, t, n): list_ans = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() for i in range(len(list_ans)): if (list_ans[i])[1] == country : if list_ans[i] == list_ans[-1]: return [(list_ans[i-1])[1]] else: if abs((list_ans[i-1])[0] - (list_ans[i])[0]) >= abs((list_ans[i+1])[0] - (list_ans[i])[0]): return [(list_ans[i+1])[1]] elif abs((list_ans[i-1])[0] - (list_ans[i])[0]) < abs((list_ans[i+1])[0] - (list_ans[i])[0]): return [(list_ans[i-1])[1]] def top_k_similar_countries(df, country, t, n, k): list_ans = [] list_pre = [] list_final = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() a = get_confirmed_cases(df, country) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n break ind = list_ans.index([m, country]) list_ans.pop(ind) for i in range(len(list_ans)): list_pre.append([abs(m-(list_ans[i])[0]) , (list_ans[i])[1]]) list_pre.sort() for i in range(len(list_pre)): if i < k: list_final.append((list_pre[i])[1]) elif (list_pre[i])[0] != (list_pre[i-1])[0]: break elif (list_pre[i])[0] == (list_pre[i-1])[0]: list_final.append((list_pre[i])[1]) return list_final #------------------------------------------------- | # 6330002721 (2020-09-27 23:07) %diff = 2.29 70.0% # Prog-07: COVID-19 # 6330002721 กณิศ สิงห์บูรณา # ผมขอยืนยันว่าผมได้ทำงานนี้ด้วยตนเอง def steepest_countries(df, t, n): l = [] for i in range(len(get_all_countries(df))): cases = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(cases)): if cases[-1] > t and len(cases[j::]) > n and cases[j] > t: m = (cases[j+n]-cases[j])/n l.append([m,(get_all_countries(df))[i]]) break l.sort() return [((l)[-1])[1]] def most_similar_countries(df, country, t, n): l = [] for i in range(len(get_all_countries(df))): cases = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(cases)): if cases[-1] > t and len(cases[j::]) > n and cases[j] > t: m = (cases[j+n]-cases[j])/n l.append([m,(get_all_countries(df))[i]]) break l.sort() for i in range(len(l)): if (l[i])[1] == country : if l[i] == l[-1]: return [(l[i-1])[1]] else: if abs((l[i-1])[0] - (l[i])[0]) >= abs((l[i+1])[0] - (l[i])[0]): return [(list_ans[i+1])[1]] elif abs((l[i-1])[0] - (l[i])[0]) < abs((l[i+1])[0] - (l[i])[0]): return [(l[i-1])[1]] def top_k_similar_countries(df, country, t, n, k): l1 = [] l2 = [] l3 = [] for i in range(len(get_all_countries(df))): cases = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(cases )): if cases [-1] > t and len(cases [j::]) > n and cases [j] > t: m = (cases [j+n]-cases [j])/n l1.append([m,(get_all_countries(df))[i]]) break l1.sort() cases = get_confirmed_cases(df, country) for j in range(len(cases)): if cases [-1] > t and len(cases [j::]) > n and cases [j] > t: m = (cases [j+n]-cases [j])/n break ind = l1.index([m, country]) l1.pop(ind) for i in range(len(l1)): l2.append([abs(m-(l1[i])[0]) , (l1[i])[1]]) l2.sort() for i in range(len(l2)): if i < k: l3.append((l2[i])[1]) elif (l2[i])[0] != (l2[i-1])[0]: break elif (l2[i])[0] == (l2[i-1])[0]: l3.append((l2[i])[1]) return l3 #------------------------------------------------- |
all: cluster #8 (2)
# 6331207221 (2020-09-26 21:14) %diff = 0.0 100.0% # Prog-07: COVID-19 # 6331207221 ชานน เนติขจร # ผมขอยืนยันว่าผมเขียนโปรแกรมนี้ด้วยตนเอง def steepest_countries(df, t, n): m = [] for e in get_all_countries(df): a = get_confirmed_cases(df,e) for i in range(len(a)): if a[i] > t and i+n < len(a): m.append([abs((a[i+n]-a[i])/n),e]) break m.sort() o = [] max_m = m[-1][0] for i in m[::-1]: if i[0] == max_m: o.append(i[1]) return o def most_similar_countries(df, country, t, n): a = [] b = get_confirmed_cases(df,country) for i in range(len(b)): if b[i] > t and i+n < len(b): m = abs((b[i+n]-b[i])/n) break r = m for e in get_all_countries(df): if e != country: c = get_confirmed_cases(df,e) for i in range(len(c)): if c[i] > t and i+n < len(c): p = abs((c[i+n]-c[i])/n) if abs(p - m) < r: r = abs(p - m) a = [e] elif abs(p - m) == r: a.append(e) break return a def top_k_similar_countries(df, country, t, n, k): a = [] b = get_confirmed_cases(df,country) for i in range(len(b)): if b[i] > t and i+n < len(b): m = abs((b[i+n]-b[i])/n) break r = m for e in get_all_countries(df): if e != country: c = get_confirmed_cases(df,e) for i in range(len(c)): if c[i] > t and i+n < len(c): p = abs((c[i+n]-c[i])/n) r = abs(p - m) a.append([r,e]) break a.sort() f = [] i = 0 while i != k: if i == k-1 and a[i][0] == a[i+1][0]: k += 1 f.append(a[i][1]) i += 1 return f #------------------------------------------------- | # 6331209521 (2020-09-27 23:38) %diff = 0.0 100.0% # Prog-07: COVID-19 # 6331209521 ณวรัฏฐ์ นาราคราม # ... # Declare that you do this by yourself def steepest_countries(df, t, n): q = [] for e in get_all_countries(df): h = get_confirmed_cases(df,e) for i in range(len(h)): if h[i] > t and i+n < len(h): q.append([abs((h[i+n]-h[i])/n),e]) break q.sort() w = [] max_q = q[-1][0] for i in q[::-1]: if i[0] == max_q: w.append(i[1]) return w def most_similar_countries(df, country, t, n): h = [] j = get_confirmed_cases(df,country) for i in range(len(j)): if j[i] > t and i+n < len(j): q = abs((j[i+n]-j[i])/n) break r = q for e in get_all_countries(df): if e != country: c = get_confirmed_cases(df,e) for i in range(len(c)): if c[i] > t and i+n < len(c): p = abs((c[i+n]-c[i])/n) if abs(p - q) < r: r = abs(p - q) h = [e] elif abs(p - q) == r: h.append(e) break return h def top_k_similar_countries(df, country, t, n, k): h = [] j = get_confirmed_cases(df,country) for i in range(len(j)): if j[i] > t and i+n < len(j): q = abs((j[i+n]-j[i])/n) break r = q for e in get_all_countries(df): if e != country: c = get_confirmed_cases(df,e) for i in range(len(c)): if c[i] > t and i+n < len(c): p = abs((c[i+n]-c[i])/n) r = abs(p - q) h.append([r,e]) break h.sort() f = [] i = 0 while i != k: if i == k-1 and h[i][0] == h[i+1][0]: k += 1 f.append(h[i][1]) i += 1 return f #------------------------------------------------- |
all: cluster #9 (2)
# 6331124821 (2020-09-27 14:42) %diff = 0.0 100.0% # Prog-07: COVID-19 # 6331124821 ภากร สิทธินันท์เจริญ # ... # ขอยืนยันว่าทำด้วยตนเอง def steepest_countries(df, t, n): c = [] a = get_all_countries(df) for e in a: confirmed_cases = get_confirmed_cases(df,e) for i in range(len(confirmed_cases)): if confirmed_cases[i] > t: y1 = confirmed_cases[i] if i+n < len(confirmed_cases): y2 = confirmed_cases[i+n] slope = (y2 - y1)/n c.append([slope,e]) break break c.sort() c = c[::-1] d = [] d.append(c[0][1]) for i in range(1,len(c)): if c[i][0] == c[0][0]: d.append(c[i][1]) else: break return d def most_similar_countries(df, country, t, n): ref = get_confirmed_cases(df,country) for i in range(len(ref)): if ref[i] > t: y1 = ref[i] y2 = ref[i+n] sloperef = (y2-y1)/n break c = [] a = get_all_countries(df) a.remove(country) for e in a: confirmed_cases = get_confirmed_cases(df,e) for i in range(len(confirmed_cases)): if confirmed_cases[i] > t: y1 = confirmed_cases[i] if i+n < len(confirmed_cases): y2 = confirmed_cases[i+n] slope = (y2 - y1)/n ab = abs(slope-sloperef) c.append([ab,e]) break break c.sort() d = [] d.append(c[0][1]) for i in range(1,len(c)): if c[i][0] == c[0][0]: d.append(c[i][1]) else: break return d def top_k_similar_countries(df, country, t, n, k): ref = get_confirmed_cases(df,country) for i in range(len(ref)): if ref[i] > t: y1 = ref[i] y2 = ref[i+n] sloperef = (y2-y1)/n break c = [] a = get_all_countries(df) a.remove(country) for e in a: confirmed_cases = get_confirmed_cases(df,e) for i in range(len(confirmed_cases)): if confirmed_cases[i] > t: y1 = confirmed_cases[i] if i+n < len(confirmed_cases): y2 = confirmed_cases[i+n] slope = (y2 - y1)/n ab = abs(slope-sloperef) c.append([ab,e]) break break c.sort() d = [] for i in range(0,k): d.append(c[i][1]) for i in range(k,len(c)): if c[i][0] == c[k-1][0]: d.append(c[i][1]) else: break return d #------------------------------------------------- | # 6331125421 (2020-09-27 17:05) %diff = 0.0 100.0% # Prog-07: COVID-19 # 6331125421 ยศพัทธ์ ศรีภูมิชัย # ... # ผมทำเองครับ def steepest_countries(df, t, n): c = [] a = get_all_countries(df) for e in a: confirmed_cases = get_confirmed_cases(df,e) for i in range(len(confirmed_cases)): if confirmed_cases[i] > t: y1 = confirmed_cases[i] if i+n < len(confirmed_cases): y2 = confirmed_cases[i+n] slope = (y2 - y1)/n c.append([slope,e]) break break c.sort() c = c[::-1] d = [] d.append(c[0][1]) for i in range(1,len(c)): if c[i][0] == c[0][0]: d.append(c[i][1]) else: break return d def most_similar_countries(df, country, t, n): ref = get_confirmed_cases(df,country) for i in range(len(ref)): if ref[i] > t: y1 = ref[i] y2 = ref[i+n] sloperef = (y2-y1)/n break c = [] a = get_all_countries(df) a.remove(country) for e in a: confirmed_cases = get_confirmed_cases(df,e) for i in range(len(confirmed_cases)): if confirmed_cases[i] > t: y1 = confirmed_cases[i] if i+n < len(confirmed_cases): y2 = confirmed_cases[i+n] slope = (y2 - y1)/n ab = abs(slope-sloperef) c.append([ab,e]) break break c.sort() d = [] d.append(c[0][1]) for i in range(1,len(c)): if c[i][0] == c[0][0]: d.append(c[i][1]) else: break return d def top_k_similar_countries(df, country, t, n, k): ref = get_confirmed_cases(df,country) for i in range(len(ref)): if ref[i] > t: y1 = ref[i] y2 = ref[i+n] sloperef = (y2-y1)/n break c = [] a = get_all_countries(df) a.remove(country) for e in a: confirmed_cases = get_confirmed_cases(df,e) for i in range(len(confirmed_cases)): if confirmed_cases[i] > t: y1 = confirmed_cases[i] if i+n < len(confirmed_cases): y2 = confirmed_cases[i+n] slope = (y2 - y1)/n ab = abs(slope-sloperef) c.append([ab,e]) break break c.sort() d = [] for i in range(0,k): d.append(c[i][1]) for i in range(k,len(c)): if c[i][0] == c[k-1][0]: d.append(c[i][1]) else: break return d #------------------------------------------------- |
all: cluster #10 (2)
# 6330026821 (2020-09-27 21:55) %diff = 0.0 20.0% # Prog-07: COVID-19 # 6330026821 กานต์พิภัข ขูเสน # I write new function called slope for calculating each country's slope. # I write this by myself. def steepest_countries(df, t, n): countries = get_all_countries(df) number_of_countries = len(countries) lst = [] for i in range(number_of_countries): country = countries[i] slope_country = slope(df, t, n, country) lst.append([slope_country, country]) lst.sort() lst = lst[::-1] ans = lst[0][1] return [ans] def most_similar_countries(df, country, t, n): ct1 = slope(df, t, n, country) countries = get_all_countries(df) number_of_countries = len(countries) lst = [] for i in range(number_of_countries): country = countries[i] ct2 = slope(df, t, n, country) lst.append([abs(ct1-ct2), country]) lst.sort() ans = lst[1][1] return [ans] def top_k_similar_countries(df, country, t, n, k): count = 0 ans = [] ct1 = slope(df, t, n, country) countries = get_all_countries(df) number_of_countries = len(countries) lst = [] for i in range(number_of_countries): country = countries[i] ct2 = slope(df, t, n, country) lst.append([abs(ct1-ct2), country]) lst.sort() for i in range (len(lst)-1): if (count == k): break if lst[i+1][0] == lst[i][0]: if count < k: ans.append(lst[i+1][1]) elif lst[i+1][0] > lst[i][0]: count += 1 if count < k: ans.append(lst[i+1][1]) return ans #------------------------------------------------- def slope(df, t, n, country): m = 0 all_cases = get_confirmed_cases(df,country) number_of_cases = len(all_cases) for i in range(number_of_cases): if all_cases[i] >= t and i+n < number_of_cases: m = ((all_cases[i+n] - all_cases[i])/n) break return m | # 6330025121 (2020-09-27 23:16) %diff = 0.0 20.0% # Prog-07: COVID-19 # 6330025121 : กาญจนา อุปชิน # ดิฉันขอยืนยันว่าได้เขียนโปรแกรมนี้ขึ้นด้วยตัวเอง def steepest_countries(df, t, n): countries = get_all_countries(df) number_of_countries = len(countries) lst = [] for i in range(number_of_countries): country = countries[i] slope_country = slope(df, t, n, country) lst.append([slope_country, country]) lst.sort() lst = lst[::-1] ans = lst[0][1] return [ans] def most_similar_countries(df, country, t, n): ct1 = slope(df, t, n, country) countries = get_all_countries(df) number_of_countries = len(countries) lst = [] for i in range(number_of_countries): country = countries[i] ct2 = slope(df, t, n, country) lst.append([abs(ct1-ct2), country]) lst.sort() ans = lst[1][1] return [ans] def top_k_similar_countries(df, country, t, n, k): count = 0 ans = [] ct1 = slope(df, t, n, country) countries = get_all_countries(df) number_of_countries = len(countries) lst = [] for i in range(number_of_countries): country = countries[i] ct2 = slope(df, t, n, country) lst.append([abs(ct1-ct2), country]) lst.sort() for i in range (len(lst)-1): if (count == k): break if lst[i+1][0] == lst[i][0]: if count < k: ans.append(lst[i+1][1]) elif lst[i+1][0] > lst[i][0]: count += 1 if count < k: ans.append(lst[i+1][1]) return ans #------------------------------------------------- def slope(df, t, n, country): m = 0 all_cases = get_confirmed_cases(df,country) number_of_cases = len(all_cases) for i in range(number_of_cases): if all_cases[i] >= t and i+n < number_of_cases: m = ((all_cases[i+n] - all_cases[i])/n) break return m |
all: cluster #11 (2)
# 6330051421 (2020-09-27 21:27) %diff = 0.0 20.0% # Prog-07: COVID-19 # 6330051421 จาริตร์ จาริตรบุตร # ผมขอยืนยันว่าได้พัฒนาโปรแกรมนี้ขึ้นด้วยตนเอง def steepest_countries(df, t, n): countries = get_all_countries(df) steepest_country = '' highest_slope = 0 for c in countries: m = cal_slope(df, t ,n ,c) if highest_slope <= m: highest_slope = m steepest_country = c return steepest_country def most_similar_countries(df, country, t, n): y = cal_slope(df, t, n, country) closest = -1 countries = get_all_countries(df) most_similar_country = '' for c in countries: if c != country and cal_slope(df, t ,n ,c) != 0: diff = abs(cal_slope(df, t ,n ,c) - y) if closest < 0 or closest > diff: closest = diff most_similar_country = c return most_similar_country def top_k_similar_countries(df, country, t, n, k): y = cal_slope(df, t, n, country) countries = get_all_countries(df) countries.remove(country) k_sim = [] for i in range(k): most_similar_country = '' closest = -1 for c in countries: if c not in k_sim and cal_slope(df, t ,n ,c) != 0: diff = abs(cal_slope(df, t, n, c) - y) if closest < 0 or closest > diff: closest = diff most_similar_country = c k_sim.append(most_similar_country) return k_sim # ------------------------------------------------- def cal_slope(df, t, n, c): x = get_confirmed_cases(df, c) a = 0 for i in range(len(x)): if x[i] > t and i + n < len(x): a = (x[i+n] - x[i])/n return a | # 6330141221 (2020-09-27 22:00) %diff = 0.0 20.0% # Prog-07: COVID-19 # 6330141221 ณภัทร นิลพฤกษ์ # ผมขอยืนยันว่าผมเป็นผู้เขียนโปรแกรมนี้ด้วยตนเอง def steepest_countries(df, t, n): countries = get_all_countries(df) steepest_country = '' highest_slope = 0 for c in countries: m = slope(df, t ,n ,c) if highest_slope <= m: highest_slope = m steepest_country = c return steepest_country def most_similar_countries(df, country, t, n): y = slope(df, t, n, country) closest = -1 countries = get_all_countries(df) most_similar_country = '' for c in countries: if c != country and slope(df, t ,n ,c) != 0: diff = abs(slope(df, t ,n ,c) - y) if closest < 0 or closest > diff: closest = diff most_similar_country = c return most_similar_country def top_k_similar_countries(df, country, t, n, k): y = slope(df, t, n, country) countries = get_all_countries(df) countries.remove(country) k_sim = [] for i in range(k): most_similar_country = '' closest = -1 for c in countries: if c not in k_sim and slope(df, t ,n ,c) != 0: diff = abs(slope(df, t, n, c) - y) if closest < 0 or closest > diff: closest = diff most_similar_country = c k_sim.append(most_similar_country) return k_sim # ------------------------------------------------- def slope(df, t, n, c): x = get_confirmed_cases(df, c) a = 0 for i in range(len(x)): if x[i] > t and i + n < len(x): a = (x[i+n] - x[i])/n return a |
all: cluster #12 (3)
# 6331419021 (2020-09-27 22:29) %diff = 0.0 70.0% # Prog-07: COVID-19 # 6331419021 & นายวชิรพันธ์ เมฆฉาย # ... # ยืนยันว่าผมทำเองครับ def steepest_countries(df, t, n): x = get_all_countries(df) mc = [] for i in x : c = get_confirmed_cases(df,i) z = len(c) for k in range(0,z): if k + n <len(c): if c[k] >= t: m = (c[k+n]-c[k])/(n) mc.append([m,i]) break mc.sort() mc_m = mc[-1][0] ansc = [] for i in mc: if i[0] == mc_m: ansc.append(i[1]) return ansc def most_similar_countries(df, country, t, n): mc = [] p = get_confirmed_cases(df,country) x = get_all_countries(df) x.remove(country) j = 0 while j+n < len(p): if p[j] >= t: mco = (p[j+n]-p[j])/(n) break j+=1 for i in x: y = get_confirmed_cases(df,i) z = len(y) for j in range(0,z): if j+n < len(y): if y[j] >= t: slope = (y[j+n]-y[j])/(n) mc.append([abs(mco-slope),i]) break mc.sort() slope_max = mc[0][0] g = [] for i in mc: if i[0] == mc[0][0]: g.append(i[1]) return g return 0 def top_k_similar_countries(df, country, t, n, k): mc = [] p = get_confirmed_cases(df,country) x = get_all_countries(df) x.remove(country) j = 0 while j+n < len(p): if p[j] >= t: mco = (p[j+n]-p[j])/(n) break j+=1 for i in x: y = get_confirmed_cases(df,i) for j in range(len(y)): if j+n < len(y): if y[j] >= t: slope = (y[j+n]-y[j])/(n) mc.append([abs(mco-slope),i]) break mc.sort() slope_max = mc[0][0] O = [] for i in range(k): O.append(mc[i][1]) n = k while mc[k-1][0] == mc[n][0]: O.append(mc[n][1]) n += 1 return O #------------------------------------------------- | # 6331010921 (2020-09-27 23:02) %diff = 0.0 70.0% # Prog-07: COVID-19 # 6331010921 ธนพล ขุนสังวาลย์ def steepest_countries(df, t, n): x = get_all_countries(df) mc = [] for i in x : c = get_confirmed_cases(df,i) z = len(c) for k in range(0,z): if k + n <len(c): if c[k] >= t: m = (c[k+n]-c[k])/(n) mc.append([m,i]) break mc.sort() mc_m = mc[-1][0] ansc = [] for i in mc: if i[0] == mc_m: ansc.append(i[1]) return ansc def most_similar_countries(df, country, t, n): mc = [] p = get_confirmed_cases(df,country) x = get_all_countries(df) x.remove(country) j = 0 while j+n < len(p): if p[j] >= t: mco = (p[j+n]-p[j])/(n) break j+=1 for i in x: y = get_confirmed_cases(df,i) z = len(y) for j in range(0,z): if j+n < len(y): if y[j] >= t: slope = (y[j+n]-y[j])/(n) mc.append([abs(mco-slope),i]) break mc.sort() slope_max = mc[0][0] g = [] for i in mc: if i[0] == mc[0][0]: g.append(i[1]) return g return 0 def top_k_similar_countries(df, country, t, n, k): mc = [] p = get_confirmed_cases(df,country) x = get_all_countries(df) x.remove(country) j = 0 while j+n < len(p): if p[j] >= t: mco = (p[j+n]-p[j])/(n) break j+=1 for i in x: y = get_confirmed_cases(df,i) for j in range(len(y)): if j+n < len(y): if y[j] >= t: slope = (y[j+n]-y[j])/(n) mc.append([abs(mco-slope),i]) break mc.sort() slope_max = mc[0][0] O = [] for i in range(k): O.append(mc[i][1]) n = k while mc[k-1][0] == mc[n][0]: O.append(mc[n][1]) n += 1 return O #------------------------------------------------- | # 6330070321 (2020-09-27 23:53) %diff = 1.61 70.0% # Prog-07: COVID-19 # 6330070321 ชญานนท์ ศรีจรัส # ... # ผมทำเองจริงๆ ครับ def steepest_countries(df, t, n): a = get_all_countries(df) r = [] for i in a : c = get_confirmed_cases(df,i) b = len(c) for k in range(1,b-1): if k + n<len(c): if c[k] >= t: m = (c[k+n]-c[k])/(n) r.append([m,i]) break r.sort() r_m = r[-2][0] l = [] for i in r: if i[0] == r_m: l.append(i[1]) return l def most_similar_countries(df, country, t, n): r = [] p = get_confirmed_cases(df,country) a = get_all_countries(df) a.remove(country) j = 0 while j+n<len(p): if p[j] >= t: mco = (p[j+n]-p[j])/(n) break j=j+1 for i in a: y = get_confirmed_cases(df,i) b = len(y) for j in range(1,b): if j+n < len(y): if y[j] >= t: slope = (y[j+n]-y[j])/n r.append([abs(mco-slope),i]) break r.sort() slope_max = r[0][0] g = [] for i in r: if i[0] == r[0][0]: g.append(i[1]) return g return 0 def top_k_similar_countries(df, country, t, n, k): r = [] p = get_confirmed_cases(df,country) a = get_all_countries(df) a.remove(country) j = 0 while j+n < len(p): if p[j] >= t: mco = (p[j+n]-p[j])/(n) break j = j+1 for i in a: y = get_confirmed_cases(df,i) for j in range(len(y)): if j+n < len(y): if y[j] >= t: slope = (y[j+n]-y[j])/n r.append([abs(mco-slope),i]) break r.sort() slope_max = r[0][0] h = [] for i in range(k): h.append(r[i][1]) n = k while r[k-1][0] == r[n][0]: h.append(r[n][1]) n = n+1 return h #------------------------------------------------- |
all: cluster #13 (5)
# 6330104021 (2020-09-26 15:49) %diff = 0.22 40.0% # Prog-07: COVID-19 # 6330104021 ชาญกิจ สุขสุวรรณวีรี # ... # ทำเองแน่นอนครับ def steepest_countries(df, t, n): coun=get_all_countries(df) Max=0 ans=[] for i in range(len(coun)): case=get_confirmed_cases(df,coun[i]) dX=0 for j in range(len(case)): if case[j]>=t: if j+n<len(case): dX=(case[j+n]-case[j])/n break if dX>Max: Max=dX ans.clear() ans.append(coun[i]) elif dX==Max: ans.append(coun[i]) return ans def most_similar_countries(df, country, t, n): case=get_confirmed_cases(df,country) for i in range(len(case)): if case[i]>=t: dX=(case[i+n]-case[i])/n break Min=99999999999 coun=get_all_countries(df) ans=[] for i in range(len(coun)): case=get_confirmed_cases(df,coun[i]) if coun[i]!=country: for j in range(len(case)): if case[j]>=t: if j+n<len(case): simi=(case[j+n]-case[j])/n break if Min>abs(simi-dX): Min=abs(simi-dX) # print(Min,simi,dX) ans.clear() ans.append(coun[i]) elif Min==abs(simi-dX): ans.append(coun[i]) return ans def top_k_similar_countries(df, country, t, n, k): case=get_confirmed_cases(df,country) for i in range(len(case)): if case[i]>=t: dX=(case[i+n]-case[i])/n break coun=get_all_countries(df) ans=[];real_ans=[] for i in range(len(coun)): case=get_confirmed_cases(df,coun[i]) if coun[i]!=country: for j in range(len(case)): if case[j]>=t: if j+n<len(case): simi=(case[j+n]-case[j])/n else: simi=9999999999 break ans.append(abs(simi-dX)) else: ans.append(999999999999) anss=list(ans) anss.sort() for i in range(k): pin=ans.index(anss[i]) real_ans.append(coun[pin]) while anss[i]==anss[i+1]: pin=ans.index(anss[i+1],pin+1) real_ans.append(coun[pin]) i+=1 return real_ans #------------------------------------------------- | # 6331418321 (2020-09-27 22:49) %diff = 0.87 40.0% # Prog-07: COVID-19 # 6331418321 ภาณุวิชญ์ โลจายะ # ผมขอยืนยันว่าเป็นผู้เขียนโปรแกรมนี้ด้วยตนเอง def steepest_countries(df, t, n): coun=get_all_countries(df) Max=0 answer=[] for i in range(len(coun)): case=get_confirmed_cases(df,coun[i]) dX=0 for j in range(len(case)): if case[j]>=t: if j+n<len(case): dX=(case[j+n]-case[j])/n break if dX>Max: Max=dX answer.clear() answer.append(coun[i]) elif dX==Max: answer.append(coun[i]) return answer def most_similar_countries(df, country, t, n): case=get_confirmed_cases(df,country) for i in range(len(case)): if case[i]>=t: dX=(case[i+n]-case[i])/n break Min=99999999999 coun=get_all_countries(df) answer=[] for i in range(len(coun)): case=get_confirmed_cases(df,coun[i]) if coun[i]!=country: for j in range(len(case)): if case[j]>=t: if j+n<len(case): simi=(case[j+n]-case[j])/n break if Min>abs(simi-dX): Min=abs(simi-dX) # print(Min,simi,dX) answer.clear() answer.append(coun[i]) elif Min==abs(simi-dX): answer.append(coun[i]) return answer def top_k_similar_countries(df, country, t, n, k): case=get_confirmed_cases(df,country) for i in range(len(case)): if case[i]>=t: dX=(case[i+n]-case[i])/n break coun=get_all_countries(df) answer=[];real_answer=[] for i in range(len(coun)): case=get_confirmed_cases(df,coun[i]) if coun[i]!=country: for j in range(len(case)): if case[j]>=t: if j+n<len(case): simi=(case[j+n]-case[j])/n else: simi=9999999999 break answer.append(abs(simi-dX)) else: answer.append(999999999999) answer2=list(answer) answer2.sort() for i in range(k): pin=answer.index(answer2[i]) real_answer.append(coun[pin]) while answer2[i]==answer2[i+1]: pin=answer.index(answer2[i+1],pin+1) real_answer.append(coun[pin]) i+=1 return real_answer #------------------------------------------------- | # 6331130521 (2020-09-27 23:40) %diff = 0.22 40.0% # Prog-07: COVID-19 # 6331130521 สมัชญ์ บุญส่งอำนาจ # ... # โปรแกรมที่ผมเขียนมีพี่รหัสที่อยู่ภาคคอมของเพื่อนช่วยครับ def steepest_countries(df, t, n): c = get_all_countries(df) Max = 0 ans = [] for i in range(len(c)): case = get_confirmed_cases(df,c[i]) dX = 0 for j in range(len(case)): if case[j] >= t: if j+n < len(case): dX = (case[j+n]-case[j])/n break if Max < dX: Max = dX ans.clear() ans.append(c[i]) elif dX == Max: ans.append(c[i]) return ans def most_similar_countries(df, country, t, n): case = get_confirmed_cases(df,country) for i in range(len(case)): if case[i] >= t: dX = (case[i+n]-case[i])/n break Min = 99999999999 c = get_all_countries(df) ans = [] for i in range(len(c)): case = get_confirmed_cases(df,c[i]) if c[i] != country: for j in range(len(case)): if case[j] >= t: if j+n < len(case): sm = (case[j+n]-case[j])/n break if Min > abs(sm-dX): Min = abs(sm-dX) # print(Min,simi,dX) ans.clear() ans.append(c[i]) elif Min == abs(sm-dX): ans.append(c[i]) return ans def top_k_similar_countries(df, country, t, n, k): case = get_confirmed_cases(df,country) for i in range(len(case)): if case[i] >= t: dX = (case[i+n]-case[i])/n break c = get_all_countries(df) ans = [];real_ans = [] for i in range(len(c)): case = get_confirmed_cases(df,c[i]) if c[i] != country: for j in range(len(case)): if case[j] >= t: if j+n < len(case): sm = (case[j+n]-case[j])/n else: sm = 9999999999 break ans.append(abs(sm-dX)) else: ans.append(999999999999) ans2 = list(ans) ans2.sort() for i in range(k): pin = ans.index(ans2[i]) real_ans.append(c[pin]) while ans2[i] == ans2[i+1]: pin = ans.index(ans2[i+1],pin+1) real_ans.append(c[pin]) i += 1 return real_ans #------------------------------------------------- | # 6331120221 (2020-09-27 23:51) %diff = 5.95 40.0% # Prog-07: COVID-19 # 6331120221 ปิยังกูร สุภาษร # ... # ผมทำเองครับ ขอบคุณครับ def steepest_countries(df, t, n): c=get_all_countries(df) ax=0 G=[] for i in range(len(c)): se=get_confirmed_cases(df,c[i]) dX=0 for j in range(len(se)): if t<=se[j]: if len(se)>j+n: dX=(se[j+n]-se[j])/n break if ax<dX: ax=dX G.clear() G.append(c[i]) elif dX==ax: G.append(c[i]) return G def most_similar_countries(df, country, t, n): se=get_confirmed_cases(df,country) for i in range(len(se)): if t<=se[i]: dX=(se[i+n]-se[i])/n break Min=99999999999 c=get_all_countries(df) G=[] for i in range(len(c)): se=get_confirmed_cases(df,c[i]) if c[i]!=country: for j in range(len(se)): if t<=se[j]: if len(se)>j+n: simi=(se[j+n]-se[j])/n break if Min>abs(simi-dX): Min=abs(simi-dX) print(Min,simi,dX) G.clear() G.append(c[i]) elif Min==abs(simi-dX): G.append(c[i]) return G def top_k_similar_countries(df, country, t, n, k): se=get_confirmed_cases(df,country) for i in range(len(se)): if t<=se[i]: dX=(se[i+n]-se[i])/n break c=get_all_countries(df) G=[];real_G=[] for i in range(len(c)): se=get_confirmed_cases(df,c[i]) if c[i]!=country: for j in range(len(se)): if t<=se[j]: if len(se)>j+n: simi=(se[j+n]-se[j])/n else: simi=9999999999 break G.append(abs(simi-dX)) else: G.append(999999999999) anss=list(G) anss.sort() for i in range(k): pin=G.index(anss[i]) real_G.append(c[pin]) while anss[i]==anss[i+1]: pin=G.index(anss[i+1],pin+1) real_G.append(c[pin]) i+=1 return real_G #------------------------------------------------- | # 6331504621 (2020-09-27 23:53) %diff = 6.72 40.0% # Prog-07: COVID-19 # 6331504621 ฉัตร สินธุเชาวน์ # ... # ทำเองแน่นอนครับและเป็นโปรแกรมที่ทำยากอยู่ครับ def steepest_countries(df, t, n): coun=get_all_countries(df) Max=0 ans=[] for co in coun: case=get_confirmed_cases(df,co) dX=0 for j in range(len(case)): if case[j]>=t: if j+n<len(case): dX=(case[j+n]-case[j])/n break if dX>Max: Max=dX ans.clear() ans.append(co) elif dX==Max: ans.append(co) return ans def most_similar_countries(df, country, t, n): case=get_confirmed_cases(df,country) for i in range(len(case)): if case[i]>=t: dX=(case[i+n]-case[i])/n break Min=99999999999 coun=get_all_countries(df) ans=[] for coll in coun: case=get_confirmed_cases(df,coll) if coll !=country: for j in range(len(case)): if case[j]>=t: if j+n<len(case): simi=(case[j+n]-case[j])/n break if Min>abs(simi-dX): Min=abs(simi-dX) # print(Min,simi,dX) ans.clear() ans.append(coll) elif Min==abs(simi-dX): ans.append(coll) return ans def top_k_similar_countries(df, country, t, n, k): case=get_confirmed_cases(df,country) for i in range(len(case)): if case[i]>=t: dX=(case[i+n]-case[i])/n break coun=get_all_countries(df) ans=[];real_ans=[] for i in range(len(coun)): case=get_confirmed_cases(df,coun[i]) if coun[i]!=country: for j in range(len(case)): if case[j]>=t: if j+n<len(case): simi=(case[j+n]-case[j])/n else: simi=9999999999 break ans.append(abs(simi-dX)) else: ans.append(999999999999) anss=list(ans) anss.sort() for i in range(k): pin=ans.index(anss[i]) real_ans.append(coun[pin]) while anss[i]==anss[i+1]: pin=ans.index(anss[i+1],pin+1) real_ans.append(coun[pin]) i+=1 return real_ans #------------------------------------------------- |
all: cluster #14 (6)
# 6330087021 (2020-09-26 22:56) %diff = 0.37 20.0% # Prog-07: COVID-19 # 6330087021 ชยางกูร สอนเสนา # ผมได้วิเคราะห์และเขียนฟังก์ชันทั้งหมดนี้ด้วยตนเอง def steepest_countries(df, t, n): all_countries = get_all_countries(df) m_list = [] m_confirm_list = [] confirm_countries = [] for country in all_countries: confirm = get_confirmed_cases(df,country) m = get_m(confirm, t, n) m_list.append(m) m_confirm_list.append([m, country]) maximum = max(m_list) for n in m_confirm_list: if n[0] == maximum: confirm_countries.append(n[1]) return confirm_countries def most_similar_countries(df, country, t, n): m_confirm_list = get_m_and_country(df, t, n) confirm_countries = [] m_interest = get_m_interest(country, m_confirm_list) m_minimum_list = m_distance_list(country, m_confirm_list, m_interest) minimum = min(m_minimum_list) for n in m_confirm_list: if abs(m_interest - n[0]) == minimum: confirm_countries.append(n[1]) return confirm_countries def top_k_similar_countries(df, country, t, n, k): m_confirm_list = get_m_and_country(df, t, n) m_interest = get_m_interest(country, m_confirm_list) m_minimum_list = m_distance_list(country, m_confirm_list, m_interest) for p in m_confirm_list: if p[1] == country: index = m_confirm_list.index(p) m_confirm_list.pop(index) temp_country = [] for i in range(len(m_confirm_list)): temp_country.append([m_minimum_list[i], m_confirm_list[i][1]]) temp_country.sort() top_k_list = [] temp_m = [] for u in temp_country[0:k]: temp_m.append(u[0]) for k in temp_m: for e in temp_country: if k == e[0]: top_k_list.append(e[1]) return top_k_list def get_m(confirm, t, n): xi = 0 for i in confirm: if float(i) >= float(t): xi = confirm.index(i) break interest = confirm[xi:xi+n+1] m = 0 if len(interest) > 1: m = (interest[-1] - interest[0])/n return m def get_m_and_country(df, t, n): all_countries = get_all_countries(df) m_confirm_list = [] for countryy in all_countries: confirm = get_confirmed_cases(df,countryy) m = get_m(confirm, t, n) m_confirm_list.append([m, countryy]) return m_confirm_list def get_m_interest(country, m_confirm_list): m_interest = 0 for c in m_confirm_list: if c[1] == country: m_interest = c[0] return m_interest #------------------------------------------------- def m_distance_list(country, m_confirm_list, m_interest): m_interest_list = [] for l in m_confirm_list: if l[1] != country: temp = abs(m_interest - l[0]) m_interest_list.append(temp) return m_interest_list | # 6331517821 (2020-09-27 18:44) %diff = 3.21 20.0% # Prog-07: COVID-19 # 6331517821 อนรรฆ เสนารักษ์ # Declare that I do this by myself def steepest_countries(df, t, n): ALLcountry = get_all_countries(df) m_list = [] List_Of_Confirm = [] confirm_countries = [] for country in ALLcountry: confirm = get_confirmed_cases(df,country) m = get_p(confirm, t, n) m_list.append(m) List_Of_Confirm.append([m, country]) Max_Case = max(m_list) for n in List_Of_Confirm: if n[0] == Max_Case : confirm_countries.append(n[1]) return confirm_countries def most_similar_countries(df, country, t, n): List_Of_Confirm = get_p_and_country(df, t, n) confirm_countries = [] m_interest = get_CountryInUse(country, List_Of_Confirm) m_minimum_list = m_distance_list(country, List_Of_Confirm, m_interest) minimum = min(m_minimum_list) for n in List_Of_Confirm: if abs(m_interest - n[0]) == minimum: confirm_countries.append(n[1]) return confirm_countries def top_k_similar_countries(df, country, t, n, k): List_Of_Confirm = get_p_and_country(df, t, n) m_interest = get_CountryInUse(country, List_Of_Confirm) m_minimum_list = m_distance_list(country, List_Of_Confirm, m_interest) for p in List_Of_Confirm: if p[1] == country: index = List_Of_Confirm.index(p) List_Of_Confirm.pop(index) temp_country = [] for i in range(len(List_Of_Confirm)): temp_country.append([m_minimum_list[i], List_Of_Confirm[i][1]]) temp_country.sort() top_k_list = [] temp_m = [] for u in temp_country[0:k]: temp_m.append(u[0]) for k in temp_m: for e in temp_country: if k == e[0]: top_k_list.append(e[1]) return top_k_list def get_p(confirm, t, n): xi = 0 for i in confirm: if float(i) >= float(t): xi = confirm.index(i) break interest = confirm[xi:xi+n+1] m = 0 if len(interest) > 1: m = (interest[-1] - interest[0])/n return m def get_p_and_country(df, t, n): ALLcountry = get_all_countries(df) List_Of_Confirm = [] for countryX in ALLcountry: confirm = get_confirmed_cases(df,countryX) m = get_p(confirm, t, n) List_Of_Confirm.append([m, countryX]) return List_Of_Confirm #------------------------------------------------- def get_CountryInUse(country, List_Of_Confirm): CountryInUse = 0 for Y in List_Of_Confirm: if Y[1] == country: CountryInUse = Y[0] return CountryInUse def m_distance_list(country, List_Of_Confirm, m_interest): m_interest_list = [] for l in List_Of_Confirm: if l[1] != country: temp = abs(m_interest - l[0]) m_interest_list.append(temp) return m_interest_list | # 6331510321 (2020-09-27 18:50) %diff = 0.37 20.0% # Prog-07: COVID-19 # 6331510321 ธนดล จันทรสวาท # ผมทำเองครับ def steepest_countries(df, t, n): all_countries = get_all_countries(df) m_list = [] m_confirm_list = [] confirm_countries = [] for country in all_countries: confirm = get_confirmed_cases(df,country) m = get_m(confirm, t, n) m_list.append(m) m_confirm_list.append([m, country]) maximum = max(m_list) for n in m_confirm_list: if n[0] == maximum: confirm_countries.append(n[1]) return confirm_countries def most_similar_countries(df, country, t, n): m_confirm_list = get_m_and_country(df, t, n) confirm_countries = [] m_interest = get_m_interest(country, m_confirm_list) m_minimum_list = m_distance_list(country, m_confirm_list, m_interest) minimum = min(m_minimum_list) for n in m_confirm_list: if abs(m_interest - n[0]) == minimum: confirm_countries.append(n[1]) return confirm_countries def top_k_similar_countries(df, country, t, n, k): m_confirm_list = get_m_and_country(df, t, n) m_interest = get_m_interest(country, m_confirm_list) m_minimum_list = m_distance_list(country, m_confirm_list, m_interest) for p in m_confirm_list: if p[1] == country: index = m_confirm_list.index(p) m_confirm_list.pop(index) temp_country = [] for i in range(len(m_confirm_list)): temp_country.append([m_minimum_list[i], m_confirm_list[i][1]]) temp_country.sort() temp_m = [] top_k_list = [] for u in temp_country[0:k]: temp_m.append(u[0]) for k in temp_m: for e in temp_country: if k == e[0]: top_k_list.append(e[1]) return top_k_list def get_m(confirm, t, n): xi = 0 for i in confirm: if float(i) >= float(t): xi = confirm.index(i) break interest = confirm[xi:xi+n+1] m = 0 if len(interest) > 1: m = (interest[-1] - interest[0])/n return m def get_m_and_country(df, t, n): all_countries = get_all_countries(df) m_confirm_list = [] for countryy in all_countries: confirm = get_confirmed_cases(df,countryy) m = get_m(confirm, t, n) m_confirm_list.append([m, countryy]) return m_confirm_list def get_m_interest(country, m_confirm_list): m_interest = 0 for v in m_confirm_list: if v[1] == country: m_interest = v[0] return m_interest #------------------------------------------------- def m_distance_list(country, m_confirm_list, m_interest): m_interest_list = [] for c in m_confirm_list: if c[1] != country: temp = abs(m_interest - c[0]) m_interest_list.append(temp) return m_interest_list | # 6331205021 (2020-09-27 19:39) %diff = 3.46 20.0% # Prog-07: COVID-19 # 6331205021 ชมพูนุท ฤทธิวรชาติ # หนูได้เขียนโปรแกรมนี้ด้วยตนเอง def steepest_countries(df, t, n): all_countries = get_all_countries(df) m_list = [] ConfirmList = [] confirm_countries = [] for country in all_countries: confirm = get_confirmed_cases(df,country) m = getO(confirm, t, n) m_list.append(m) ConfirmList.append([m, country]) maximum = max(m_list) for n in ConfirmList: if n[0] == maximum: confirm_countries.append(n[1]) return confirm_countries def most_similar_countries(df, country, t, n): ConfirmList = getO_and_country(df, t, n) confirm_countries = [] InterstO = confirmcontry(country, ConfirmList) m_minimum_list = interestlist(country, ConfirmList, InterstO) minimum = min(m_minimum_list) for n in ConfirmList: if abs(InterstO - n[0]) == minimum: confirm_countries.append(n[1]) return confirm_countries def top_k_similar_countries(df, country, t, n, k): ConfirmList = getO_and_country(df, t, n) InterstO = confirmcontry(country, ConfirmList) m_minimum_list = interestlist(country, ConfirmList, InterstO) for p in ConfirmList: if p[1] == country: index = ConfirmList.index(p) ConfirmList.pop(index) temp_country = [] for i in range(len(ConfirmList)): temp_country.append([m_minimum_list[i], ConfirmList[i][1]]) temp_country.sort() top_k_list = [] temp_m = [] for u in temp_country[0:k]: temp_m.append(u[0]) for k in temp_m: for e in temp_country: if k == e[0]: top_k_list.append(e[1]) return top_k_list def getO(confirm, t, n): xi = 0 for i in confirm: if float(i) >= float(t): xi = confirm.index(i) break interest = confirm[xi:xi+n+1] O = 0 if len(interest) > 1: O = (interest[-1] - interest[0])/n return O def getO_and_country(df, t, n): all_countries = get_all_countries(df) ConfirmList = [] for countryy in all_countries: confirm = get_confirmed_cases(df,countryy) m = getO(confirm, t, n) ConfirmList.append([m, countryy]) return ConfirmList def confirmcontry(country, ConfirmList): InterstO = 0 for P in ConfirmList: if P[1] == country: InterstO = P[0] return InterstO #------------------------------------------------- def interestlist(country, ConfirmList, InterstO): interestlist = [] for B in ConfirmList: if B[1] != country: temp = abs(InterstO - B[0]) interestlist.append(temp) return interestlist | # 6331005821 (2020-09-27 21:39) %diff = 3.43 20.0% # Prog-07: COVID-19 # 6331005821 จิรเมธ สุทธิเมธากร # ทำการบ้านชุดนี้ด้วยตัวเอง def steepest_countries(df, t, n): all_countries = get_all_countries(df) m_list = [] m_confirm = [] confirm_countries = [] for country in all_countries: confirm = get_confirmed_cases(df,country) m = slope_(confirm, t, n) m_list.append(m) m_confirm.append([m, country]) maximum = max(m_list) for n in m_confirm: if n[0] == maximum: confirm_countries.append(n[1]) return confirm_countries def most_similar_countries(df, country, t, n): m_confirm = slope_and_country(df, t, n) confirm_countries = [] m_interest = slope_interest(country, m_confirm) m_minimum_list = m_distance(country, m_confirm, m_interest) minimum = min(m_minimum_list) for i in m_confirm: if abs(m_interest - i[0]) == minimum: confirm_countries.append(i[1]) return confirm_countries def top_k_similar_countries(df, country, t, n, k): m_confirm = slope_and_country(df, t, n) m_interest = slope_interest(country, m_confirm) m_minimum_list = m_distance(country, m_confirm, m_interest) for p in m_confirm: if p[1] == country: index = m_confirm.index(p) m_confirm.pop(index) temp_country = [] for i in range(len(m_confirm)): temp_country.append([m_minimum_list[i], m_confirm[i][1]]) temp_country.sort() top_k_list = [] temp_m = [] for j in temp_country[0:k]: temp_m.append(j[0]) for k in temp_m: for e in temp_country: if k == e[0]: top_k_list.append(e[1]) return top_k_list def slope_(confirm, t, n): xi = 0 for i in confirm: if float(i) >= float(t): xi = confirm.index(i) break interest = confirm[xi:xi+n+1] m = 0 if len(interest) > 1: m = (interest[-1] - interest[0])/n return m def slope_and_country(df, t, n): all_countries = get_all_countries(df) m_confirm = [] for country in all_countries: confirm = get_confirmed_cases(df,country) m = slope_(confirm, t, n) m_confirm.append([m, country]) return m_confirm def slope_interest(country, m_confirm): m_interest = 0 for i in m_confirm: if i[1] == country: m_interest = i[0] return m_interest #------------------------------------------------- def m_distance(country, m_confirm, m_interest): m_interest_list = [] for i in m_confirm: if i[1] != country: temp = abs(m_interest - i[0]) m_interest_list.append(temp) return m_interest_list | # 6330099621 (2020-09-27 22:08) %diff = 3.43 20.0% # Prog-07: COVID-19 #6330099621 ชัชชัย โพธิ์นา #ผมได้ทำการวิเคราะห์เเละสร้างโปรแกรมสุดหล่อเท่นี้ด้วยตนเอง def steepest_countries(df, t, n): all_countries = get_all_countries(df) s_list = [] s_verify_list = [] verify_countries = [] for country in all_countries: verify = get_confirmed_cases(df,country) s = get_s(verify, t, n) s_list.append(s) s_verify_list.append([s, country]) highest = max(s_list) for n in s_verify_list: if n[0] == highest: verify_countries.append(n[1]) return verify_countries def most_similar_countries(df, country, t, n): s_verify_list = get_s_and_country(df, t, n) verify_countries = [] s_attend = get_s_attend(country, s_verify_list) s_lowest_list = s_dis_list(country, s_verify_list, s_attend) lowest = min(s_lowest_list) for n in s_verify_list: if abs(s_attend - n[0]) == lowest: verify_countries.append(n[1]) return verify_countries def top_k_similar_countries(df, country, t, n, k): s_verify_list = get_s_and_country(df, t, n) s_attend = get_s_attend(country,s_verify_list) s_lowest_list = s_dis_list(country, s_verify_list, s_attend) for p in s_verify_list: if p[1] == country: index = s_verify_list.index(p) s_verify_list.pop(index) tem_country = [] for i in range(len(s_verify_list)): tem_country.append([s_lowest_list[i], s_verify_list[i][1]]) tem_country.sort() top_k_list = [] tem_s = [] for u in tem_country[0:k]: tem_s.append(u[0]) for k in tem_s: for e in tem_country: if k == e[0]: top_k_list.append(e[1]) return top_k_list def get_s(verify, t, n): ci = 0 for i in verify: if float(i) >= float(t): ci = verify.index(i) break attend = verify[ci:ci+n+1] s = 0 if len(attend) > 1: s = (attend[-1] - attend[0])/n return s def get_s_and_country(df, t, n): all_countries = get_all_countries(df) s_verify_list = [] for country in all_countries: verify = get_confirmed_cases(df,country) s = get_s(verify, t, n) s_verify_list.append([s, country]) return s_verify_list def get_s_attend(country, s_attend_list): s_attend = 0 for e in s_attend_list: if e[1] == country: s_attend = e[0] return s_attend #------------------------------------------------- def s_dis_list(country, s_verify_list, s_attend): s_attend_list = [] for e in s_verify_list: if e[1] != country: t = abs(s_attend - e[0]) s_attend_list.append(t) return s_attend_list |
all: cluster #15 (2)
# 6330112021 (2020-09-27 03:08) %diff = 0.75 40.0% # Prog-07: COVID-19 # 6330112021 ชุติวัต สุขแสนไกรศร # ผมนายชุติวัต สุขแสนไกรศรทำเองจริงครับ def steepest_countries(df, t, n): country = get_all_countries(df) M = [] countryh = [] i = 0 for e in country : case = get_confirmed_cases(df,e) M.append(m(case,t,n)) H = max(M) for i in range(len(M)): if M[i] == H: countryh.append(country[i]) return countryh def most_similar_countries(df, country, t, n): country1 = get_all_countries(df) M = [] countryh = [] for e in country1 : case = get_confirmed_cases(df,e) M.append([m(case,t,n),e]) for i in range(len(M)): if M[i][1] == country: mw = M[i][0] T = different(mw,M) t = different(mw,M) for e in M: if e[1] == country: a = M.index(e) T.pop(a) t.pop(a) M.pop(a) T.sort() for i in range(len(M)): if t[i] == T[0]: countryh.append(M[i][1]) return countryh def top_k_similar_countries(df, country, t, n, k): country1 = get_all_countries(df) M = [] B = [] Ml = [] countryh = [] for e in country1 : case = get_confirmed_cases(df,e) M.append([m(case,t,n),e]) for i in range(len(M)): if M[i][1] == country: mw = M[i][0] t = different(mw,M) T = different(mw,M) for e in M: if e[1] == country: a = M.index(e) T.pop(a) t.pop(a) M.pop(a) T.sort() B = T[0:k:] for i in range(len(T)): Ml.append([t[i],M[i][1]]) Ml.sort() for e in B: for a in Ml: if e == a[0]: countryh.append(a[1]) return countryh def m(case,t,n): for i in range(len(case)): x = 0 if case[i] >= t : x = i break if x+n <= len(case): m = (case[x+n]-case[x])/n else: m = 0 return m def different(mw,M): x = [] for i in range(len(M)): x.append(abs(mw - M[i][0])) return x #------------------------------------------------- | # 6330138421 (2020-09-27 21:10) %diff = 0.75 40.0% # Prog-07: COVID-19 # 6330138421 ณพวนัตถ์ อมรพรวิวัฒน์ # ผมเขียนโปรแกรมนี้ด้วยตัวเองครับ def steepest_countries(df, t, n): country = get_all_countries(df) A = [] allcountry = [] i = 0 for e in country : event = get_confirmed_cases(df,e) A.append(m(event,t,n)) M = max(A) for i in range(len(A)): if A[i] == M: allcountry.append(country[i]) return allcountry def most_similar_countries(df, country, t, n): country1 = get_all_countries(df) A = [] allcountry = [] for e in country1 : event = get_confirmed_cases(df,e) A.append([m(event,t,n),e]) for i in range(len(A)): if A[i][1] == country: mw = A[i][0] T = different(mw,A) t = different(mw,A) for e in A: if e[1] == country: a = A.index(e) T.pop(a) t.pop(a) A.pop(a) T.sort() for i in range(len(A)): if t[i] == T[0]: allcountry.append(A[i][1]) return allcountry def top_k_similar_countries(df, country, t, n, k): country1 = get_all_countries(df) A = [] B = [] Al = [] allcountry = [] for e in country1 : event = get_confirmed_cases(df,e) A.append([m(event,t,n),e]) for i in range(len(A)): if A[i][1] == country: mw = A[i][0] t = different(mw,A) T = different(mw,A) for e in A: if e[1] == country: a = A.index(e) T.pop(a) t.pop(a) A.pop(a) T.sort() B = T[0:k:] for i in range(len(T)): Al.append([t[i],A[i][1]]) Al.sort() for e in B: for a in Al: if e == a[0]: allcountry.append(a[1]) return allcountry def m(event,t,n): for i in range(len(event)): x = 0 if event[i] >= t : x = i break if x+n <= len(event): m = (event[x+n]-event[x])/n else: m = 0 return m def different(mw,A): x = [] for i in range(len(A)): x.append(abs(mw - A[i][0])) return x #------------------------------------------------- |
all: cluster #16 (2)
# 6330017121 (2020-09-27 16:45) %diff = 1.03 100.0% # Prog-07: COVID-19 # 6330017121 กันต์ เอนกทวีผล # เป็นงานที่ทำด้วยตนเอง def steepest_countries(df, t, n): r = [[0, ""]] countrieslist = get_all_countries(df) for c in countrieslist: data = get_confirmed_cases(df, c) for i in range(len(data)): if data[i] > t: if (i+n) > (len(data)-1): break else: j = i + n m = (data[j] - data[i]) / n for p in range(len(r)): if r[p][0] == m: r[p].append(c) break elif p == len(r) - 1: r.append([m, c]) break break r.sort() return list(r[-1][1:]) def most_similar_countries(df, country, t, n): r = [[99999, ""]] countrieslist = get_all_countries(df) countrieslist.remove(country) data = get_confirmed_cases(df, country) for i in range(len(data)): if data[i] > t: if i + n > (len(data)-1): break else: j = i + n check = (data[j] - data[i]) / n break for c in countrieslist: data = get_confirmed_cases(df, c) for i in range(len(data)): if data[i] > t: if (i+n) > (len(data)-1): break else: j = i + n m = (data[j] - data[i]) / n d = abs(m - check) for p in range(len(r)): if r[p][0] == d: r[p].append(c) break elif p == len(r) - 1: r.append([d, c]) break break r.sort() return list(r[0][1:]) def top_k_similar_countries(df, country, t, n, k): r = [[99999, ""]] countrieslist = get_all_countries(df) countrieslist.remove(country) data = get_confirmed_cases(df, country) for i in range(len(data)): if data[i] > t: j = i + n if j > (len(data)-1): j = len(data)-1 check = (data[j] - data[i]) / n break for c in countrieslist: data = get_confirmed_cases(df, c) for i in range(len(data)): if data[i] > t: if (i+n) > (len(data)-1): break else: j = i + n m = (data[j] - data[i]) / n d = abs(m - check) r.append([d, c]) break r.sort() rr = [] for i in range(k): rr.append(r[i][1]) extra = len(rr) while r[extra-1][0] == r[extra][0]: rr.append(r[extra][1]) extra += 1 return list(rr) #------------------------------------------------- | # 6330119521 (2020-09-27 23:50) %diff = 1.03 100.0% # Prog-07: COVID-19 # 6330119521 # โปรแกรมนี้แสดงผลลัพธ์ด้านการประมวลผลข้อมูลเกี่ยวกับ COVID-19 # ผมขอรับรองว่าเป็นผู้เขียนโปรแกรมนี้ด้วยตัวเอง def steepest_countries(df, t, n): c = [[0, ""]] all_countries = get_all_countries(df) for a in all_countries: info = get_confirmed_cases(df, a) for i in range(len(info)): if info[i] > t: if (i+n) > (len(info)-1): break else: j = i + n x = (info[j] - info[i]) / n for m in range(len(c)): if c[m][0] == x: c[m].append(a) break elif m == len(c) - 1: c.append([x, a]) break break c.sort() return list(c[-1][1:]) def most_similar_countries(df, country, t, n): c = [[10000000, ""]] all_countries = get_all_countries(df) all_countries.remove(country) info = get_confirmed_cases(df, country) for i in range(len(info)): if info[i] > t: if i + n > (len(info)-1): break else: j = i + n checkpoint = (info[j] - info[i]) / n break for a in all_countries: info = get_confirmed_cases(df, a) for i in range(len(info)): if info[i] > t: if (i+n) > (len(info)-1): break else: j = i + n x = (info[j] - info[i]) / n d = abs(x - checkpoint) for m in range(len(c)): if c[m][0] == d: c[m].append(a) break elif m == len(c) - 1: c.append([d, a]) break break c.sort() return list(c[0][1:]) def top_k_similar_countries(df, country, t, n, k): c = [[10000000, ""]] all_countries = get_all_countries(df) all_countries.remove(country) info = get_confirmed_cases(df, country) for i in range(len(info)): if info[i] > t: j = i + n if j > (len(info)-1): j = len(info)-1 checkpoint = (info[j] - info[i]) / n break for a in all_countries: info = get_confirmed_cases(df, a) for i in range(len(info)): if info[i] > t: if (i+n) > (len(info)-1): break else: j = i + n x = (info[j] - info[i]) / n d = abs(x - checkpoint) c.append([d, a]) break c.sort() result = [] for i in range(k): result.append(c[i][1]) special_case = len(result) while c[special_case-1][0] == c[special_case][0]: result.append(c[special_case][1]) special_case += 1 return list(result) #------------------------------------------------- |
all: cluster #17 (3)
# 6331803221 (2020-09-27 19:24) %diff = 1.04 70.0% # Prog-07: COVID-19 #6331803221 กุลกิตติ์ หุ่นกิตติเวชกุล #ยืนยันว่าเขียนเองครับ def steepest_countries(df, t, n): allcoun = get_all_countries(df) Max = -9999999 slopec = [] Maxcoun = [] k=0 for i in allcoun: index=0 cases = get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index+=1 if index+n >245: continue slope = (cases[index+n]-cases[index])/n if slope>Max: put = [slope,i] slopec.append(put) Max = slope for j in slopec: if j[0]==Max: put = j[1] Maxcoun.append(j[1]) return Maxcoun def most_similar_countries(df, country, t, n): allcoun = get_all_countries(df) Min = 9999999 slopec = [] Mindiff = [] k=0 indexM=0 diff = 0 caseMain = get_confirmed_cases(df,country) for g in caseMain: if g>t: break indexM+=1 slopeM = (caseMain[indexM+n]-caseMain[indexM])/n for i in allcoun: if i ==country: continue index=0 cases = get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index+=1 if index+n >245: continue slope = (cases[index+n]-cases[index])/n diff = abs(slope-slopeM) if diff<Min: put = [diff,i] slopec.append(put) Min = diff for j in slopec: if j[0]==Min: put = j[1] Mindiff.append(j[1]) return Mindiff def top_k_similar_countries(df, country, t, n, k): allcoun = get_all_countries(df) slopec = [] Mindiff = [] indexM=0 diff = 0 E = 0 caseMain = get_confirmed_cases(df,country) for g in caseMain: if g>t: break indexM+=1 slopeM = (caseMain[indexM+n]-caseMain[indexM])/n for i in allcoun: if i ==country: continue index=0 cases = get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index+=1 if index+n >len(cases): continue slope = (cases[index+n]-cases[index])/n diff = abs(slope-slopeM) put = [diff,i] slopec.append(put) Min = diff slopec = bubble_sort(slopec) for j in range(k): b = slopec[j] Mindiff.append(b[1]) E = b[0] for l in slopec[k:]: if E == l[0]: Mindiff.append(l[1]) else: break return Mindiff def bubble_sort(nums): swapped = True while swapped: swapped = False for i in range(len(nums) - 1): s = nums[i] k = nums[i+1] if s[0] > k[0]: nums[i], nums[i + 1] = nums[i + 1], nums[i] swapped = True return nums #------------------------------------------------- | # 6330057221 (2020-09-27 20:02) %diff = 1.04 70.0% # Prog-07: COVID-19 # 6330057221 จิราธิป ไชยสิงห์ # ... # Declare that you do this by yourself def steepest_countries(df, t, n): all_c = get_all_countries(df) Max = -9999999 slope_c = [] Max_c = [] k=0 for i in all_c: index=0 cases = get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index+=1 if index+n >245: continue slope = (cases[index+n]-cases[index])/n if slope>Max: x = [slope,i] slope_c.append(x) Max = slope for j in slope_c: if j[0]==Max: x = j[1] Max_c.append(j[1]) return Max_c def most_similar_countries(df, country, t, n): all_c = get_all_countries(df) Min = 9999999 slope_c = [] Min_d = [] k=0 indexM=0 d = 0 Main = get_confirmed_cases(df,country) for g in Main: if g>t: break indexM+=1 slopeM = (Main[indexM+n]-Main[indexM])/n for i in all_c: if i == country: continue index=0 cases = get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index+=1 if index+n >245: continue slope = (cases[index+n]-cases[index])/n d = abs(slope-slopeM) if d<Min: x = [d,i] slope_c.append(x) Min = d for j in slope_c: if j[0]==Min: x = j[1] Min_d.append(j[1]) return Min_d def top_k_similar_countries(df, country, t, n, k): all_c = get_all_countries(df) slope_c = [] Min_d = [] indexM=0 d = 0 E = 0 Main = get_confirmed_cases(df,country) for g in Main: if g>t: break indexM+=1 slopeM = (Main[indexM+n]-Main[indexM])/n for i in all_c: if i == country: continue index=0 cases = get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index+=1 if index+n >len(cases): continue slope = (cases[index+n]-cases[index])/n d = abs(slope-slopeM) x = [d,i] slope_c.append(x) Min = d slope_c = sorting(slope_c) for j in range(k): b = slope_c[j] Min_d.append(b[1]) E = b[0] for l in slope_c[k:]: if E == l[0]: Min_d.append(l[1]) else: break return Min_d def sorting(n): swapped = True while swapped: swapped = False for i in range(len(n) - 1): s = n[i] k = n[i+1] if s[0] > k[0]: n[i], n[i + 1] = n[i + 1], n[i] swapped = True return n #------------------------------------------------- | # 6331805521 (2020-09-27 23:17) %diff = 3.85 70.0% # Prog-07: COVID-19 #6331805521 ชวนินทร์ เลิศวัฒนะกุลศิริ #เขียนด้วยตัวเองครับ def steepest_countries(df, t, n): allcoun=get_all_countries(df) Max=-9999999 slopec=[] Maxcoun=[] k=0 for i in allcoun: index=0 cases=get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index=index+1 if index+n>245: continue slope=(cases[index+n]-cases[index])/n if slope>Max: put=[slope,i] slopec.append(put) Max=slope for j in slopec: if j[0]==Max: put=j[1] Maxcoun.append(j[1]) return Maxcoun def most_similar_countries(df, country, t, n): allcoun=get_all_countries(df) Min=9999999 slopec=[] Mindiff=[] k=0 indexM=0 diff=0 caseMain=get_confirmed_cases(df,country) for g in caseMain: if g>t: break indexM=indexM+1 slopeM=(caseMain[indexM+n]-caseMain[indexM])/n for i in allcoun: if i==country: continue index=0 cases=get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index=index+1 if index+n >245: continue slope=(cases[index+n]-cases[index])/n diff=slope-slopeM if diff<0: diff=abs(diff) if diff<Min: put=[diff,i] slopec.append(put) Min=diff for j in slopec: if j[0]==Min: put=j[1] Mindiff.append(j[1]) return Mindiff def top_k_similar_countries(df, country, t, n, k): allcoun=get_all_countries(df) slopec=[] Mindiff=[] indexM=0 diff=0 E=0 caseMain=get_confirmed_cases(df,country) for g in caseMain: if g>t: break indexM=indexM+1 slopeM=(caseMain[indexM+n]-caseMain[indexM])/n for i in allcoun: if i==country: continue index=0 cases=get_confirmed_cases(df,i) if cases[-1]<=t: continue for g in cases: if g>t: break index=index+1 if index+n>len(cases): continue slope=(cases[index+n]-cases[index])/n diff=slope-slopeM if diff<0: diff=abs(diff) put=[diff,i] slopec.append(put) Min=diff slopec=bubble_sort(slopec) for j in range(k): b=slopec[j] Mindiff.append(b[1]) E=b[0] for l in slopec[k:-1]: if E==l[0]: Mindiff.append(l[1]) else: break return Mindiff def bubble_sort(nums): swapped=True while swapped: swapped=False for i in range(len(nums)-1): s=nums[i] k=nums[i+1] if s[0]>k[0]: nums[i], nums[i+1]=nums[i+1], nums[i] swapped=True return nums #------------------------------------------------- |
all: cluster #18 (2)
# 6331102021 (2020-09-27 19:31) %diff = 1.3 40.0% # Prog-07: COVID-19 # 6331102021 กิตติณัฐ ตั้งวิจิตรเจนการ # ... # ผมขอยืนยันว่าผมเป็นผู้เขียนโปรแกรมนี้ด้วยตนเอง def steepest_countries(df, t, n): m = highest_to_low(df, t, n) m2 = [m[-1][1]] N = len(m)-1 for i in range(1,len(m)): if m[N-i][0] == m[N-i-1][0] : m2.append(m[N-i-1][1]) else : break return m2 def most_similar_countries(df, country, t, n) : m = highest_to_low(df, t, n) c = mcount(df, country, t, n) x = m.index(c) if x != m.index(m[-1]) and x != m.index(m[0]) : y = abs(m[x][0]-m[x+1][0]) z = abs(m[x][0]-m[x-1][0]) if y < z : m2 = [m[x+1]] for i in range(1,len(m)-1): if m[x+i][0] == m[x+1+i][0] : m2.append(m[x+1+i]) else : break elif y > z : m2 = [m[x-1]] for i in range(2,len(m)): k = 0 if m[x-1-k][0] == m[x-2-k][0] : m2.append(m[x-2-k]) k +=1 else : break elif y == z : m2 = [m[x+1],m[x-1]] if m[x+1][0] == m[x+2][0] : for i in range(1,len(m)-2): k = 0 if m[x+1+k][0] == m[x+2+k][0] : m2.append(m[x+2+k]) k += 1 else : break elif m[x-1][0] == m[x-2][0] : for i in range(2,len(m)): k = 0 if m[x-1-k][0] == m[x-2-k][0] : m2.append(m[x-2-k]) k += 1 else : break elif x == m.index(m[-1]) : m2 = [m[x]] for i in range(2,len(m)): k = 0 if m[x-k][0] == m[x-1-k][0] : m2.append(m[x-1-k]) k +=1 else : break elif x == m.index(m[0]) : m2 = [m[x]] for i in range(len(m)-2): if m[x+i][0] == m[x+1+i][0] : m2.append(m[x+1+i]) else : break m3 = [] for i in range(len(m2)) : m3.append(m2[i][1]) return m3 def top_k_similar_countries(df, country, t, n, k) : u = [] ; j = 1 ; s = [] m = mcount(df,country, t, n) c = highest_to_low(df, t, n) x = c.index(m) c.remove(m) for i in range(len(c)) : c[i][0] = abs(m[0]-c[i][0]) c.sort() r = 1 for i in range(len(c)) : if c[i][0] != c[i+1][0] : r+=1 h = c.index(c[i+1]) if r == k : break c.sort() for i in range(h+1) : s.append(c[i][1]) return s #------------------------------------------------- def highest_to_low(df, t, n): #เรียงความชัน allcount = get_all_countries(df) htl = [] for e in allcount : cases = [] cases = get_confirmed_cases(df,e) cases.append(t) cases.sort() x = cases.index(t) if len(cases[x+1::]) > n : a = (cases[x+1+n] - cases[x+1])/n b = [a,e] htl.append(b) htl.sort() return htl def mcount(df,country, t, n): #ความชันประเทศที่ต้องการ case = get_confirmed_cases(df,country) case.append(t) case.sort() x = case.index(t) c = [] if len(case[x+1::]) > n : a = (case[x+1+n] - case[x+1])/n return [a,country] | # 6331103621 (2020-09-27 22:36) %diff = 1.3 40.0% #Prog-07: COVID-19 #6331103621 ชานน แสงโชติชัย #วุ่นวายและปวดหัวมากเลยครับกับเรื่องการสร้าง list และเติมแต่ง list #I do this by myself. def steepest_countries(df, t, n):#listความชันสูงสุด cm = countries_cases(df, t, n) cm2 = [cm[-1][1]] N = len(cm)-1 for i in range(1,len(cm)): if cm[N-i][0] == cm[N-i-1][0] : cm2.append(cm[N-i-1][1]) else : break return cm2 def most_similar_countries(df, country, t, n):#listของชื่อที่มีความใกล้เคียงมากที่สุด cm = countries_cases(df, t, n) c = country_m(df, country, t, n) x = cm.index(c) if x != cm.index(cm[-1]) and x != cm.index(cm[0]) : y = abs(cm[x][0]-cm[x+1][0]) z = abs(cm[x][0]-cm[x-1][0]) if y < z : cm2 = [cm[x+1]] for i in range(1,len(cm)-1): if cm[x+i][0] == cm[x+1+i][0] : cm2.append(cm[x+1+i]) else : break elif y > z : cm2 = [cm[x-1]] for i in range(2,len(cm)): k = 0 if cm[x-1-k][0] == cm[x-2-k][0] : cm2.append(cm[x-2-k]) k +=1 else : break elif y == z : cm2 = [cm[x+1],cm[x-1]] if cm[x+1][0] == cm[x+2][0] : for i in range(1,len(cm)-2): k = 0 if cm[x+1+k][0] == cm[x+2+k][0] : cm2.append(cm[x+2+k]) k += 1 else : break elif cm[x-1][0] == cm[x-2][0] : for i in range(2,len(cm)): k = 0 if cm[x-1-k][0] == cm[x-2-k][0] : cm2.append(cm[x-2-k]) k += 1 else : break elif x == cm.index(cm[-1]) : cm2 = [cm[x]] for i in range(2,len(cm)): k = 0 if cm[x-k][0] == cm[x-1-k][0] : cm2.append(cm[x-1-k]) k +=1 else : break elif x == cm.index(cm[0]) : cm2 = [cm[x]] for i in range(len(cm)-2): if cm[x+i][0] == cm[x+1+i][0] : cm2.append(cm[x+1+i]) else : break cm3 = [] for i in range(len(cm2)) : cm3.append(cm2[i][1]) return cm3 def top_k_similar_countries(df, country, t, n, k) : u = [] ; j = 1 ; s = [] cm = country_m(df,country, t, n) c = countries_cases(df, t, n) x = c.index(cm) c.remove(cm) for i in range(len(c)) : c[i][0] = abs(cm[0]-c[i][0]) c.sort() r = 1 for i in range(len(c)) : if c[i][0] != c[i+1][0] : r+=1 h = c.index(c[i+1]) if r == k : break c.sort() for i in range(h+1) : s.append(c[i][1]) return s #------------------------------------------------- def countries_cases(df, t, n):#ความชันของทุกประเทศที่เรียงจากน้อยไปหามาก all_contries = get_all_countries(df) m_c = [] for e in all_contries : cases = [] cases = get_confirmed_cases(df,e) cases.append(t) ; cases.sort() x = cases.index(t) if len(cases[x+1::]) > n : m = (cases[x+1+n] - cases[x+1])/n c = [m,e] m_c.append(c) m_c.sort() return m_c def country_m(df,country, t, n):#ความชันของประเทศที่ต้องการ case = get_confirmed_cases(df,country) case.append(t) ; case.sort() x = case.index(t) c = [] if len(case[x+1::]) > n : m = (case[x+1+n] - case[x+1])/n return [m,country] |
all: cluster #19 (2)
# 6330018821 (2020-09-27 15:38) %diff = 1.4 30.0% # Prog-07: COVID-19 # 6330018821 กันต์กวินทร์ อังกูรสุทธิพันธ์ # ผมขอยืนยันว่าผมเป็นผู้ปรับแต่งโปรแกรมนี้จากโจทย์ต้นฉบับด้วยตนเอง def steepest_countries(df, t, n): all_countries = get_all_countries(df) slope = [] output = [] for e in all_countries: country = get_confirmed_cases(df, e) i = 0 try: while country[i] < t: i += 1 slope.append([(country[i+n]-country[i])/n,e]) except IndexError: slope.append([0,e]) slope.sort() slope.reverse() output.append(slope[0][1]) x = 0 while slope[0][0] == slope[1+x][0]: output.append(slope[1+x][1]) x += 1 return output def most_similar_countries(df, country, t, n): all_countries = get_all_countries(df) country_inq = get_confirmed_cases(df, country) slope_inq = [] slope_diff = [] output = [] i = 0 try: while country_inq[i] < t: i += 1 slope_inq.append([(country_inq[i+n]-country_inq[i])/n,country]) except IndexError: slope_inq.append([0,country]) for e in all_countries: if e == country: pass else: c = get_confirmed_cases(df, e) j = 0 try: while c[j] < t: j += 1 slope = (c[i+n]-c[i])/n if slope > slope_inq[0][0]: diff = slope - slope_inq[0][0] else: diff = slope_inq[0][0] - slope slope_diff.append([diff,e]) except IndexError: pass slope_diff.sort() output.append(slope_diff[0][1]) x = 0 while slope_diff[0][0] == slope_diff[1+x][0]: output.append(slope_diff[1+x][1]) x += 1 return output def top_k_similar_countries(df, country, t, n, k): all_countries = get_all_countries(df) country_inq = get_confirmed_cases(df, country) slope_inq = [] slope_diff = [] output = [] i = 0 try: while country_inq[i] < t: i += 1 slope_inq.append([(country_inq[i+n]-country_inq[i])/n,country]) except IndexError: slope_inq.append([0,country]) for e in all_countries: if e == country: pass else: c = get_confirmed_cases(df, e) j = 0 try: while c[j] < t: j += 1 slope = (c[i+n]-c[i])/n if slope > slope_inq[0][0]: diff = slope - slope_inq[0][0] else: diff = slope_inq[0][0] - slope slope_diff.append([diff,e]) except IndexError: pass slope_diff.sort() for i in range(k): output.append(slope_diff[i][1]) x = 0 while slope_diff[k-1][0] == slope_diff[k+x][0]: output.append(slope_diff[k+x][1]) x += 1 return output #------------------------------------------------- | # 6331511021 (2020-09-27 23:41) %diff = 1.4 30.0% # Prog-07: COVID-19 # 6331511021 # HW07 # Edited by 6331511021 Thanat Thamrongvisith def steepest_countries(df, t, n): all_countries = get_all_countries(df) slope = [] output = [] for e in all_countries: country = get_confirmed_cases(df, e) i = 0 try: while t > country[i]: i += 1 slope.append([(country[i+n]-country[i])/n,e]) except IndexError: slope.append([0,e]) slope.sort() slope.reverse() output.append(slope[0][1]) x = 0 while slope[0][0] == slope[1+x][0]: output.append(slope[1+x][1]) x += 1 return output def most_similar_countries(df, country, t, n): all_countries = get_all_countries(df) country_inq = get_confirmed_cases(df, country) slope_inq = [] slope_diff = [] output = [] i = 0 try: while t > country_inq[i]: i += 1 slope_inq.append([(country_inq[i+n]-country_inq[i])/n,country]) except IndexError: slope_inq.append([0,country]) for e in all_countries: if e == country: pass else: c = get_confirmed_cases(df, e) j = 0 try: while t > c[j]: j += 1 slope = (c[i+n]-c[i])/n if slope > slope_inq[0][0]: diff = slope - slope_inq[0][0] else: diff = slope_inq[0][0] - slope slope_diff.append([diff,e]) except IndexError: pass slope_diff.sort() output.append(slope_diff[0][1]) x = 0 while slope_diff[0][0] == slope_diff[1+x][0]: output.append(slope_diff[1+x][1]) x += 1 return output def top_k_similar_countries(df, country, t, n, k): all_countries = get_all_countries(df) country_inq = get_confirmed_cases(df, country) slope_inq = [] slope_diff = [] output = [] i = 0 try: while t > country_inq[i]: i += 1 slope_inq.append([(country_inq[i+n]-country_inq[i])/n,country]) except IndexError: slope_inq.append([0,country]) for e in all_countries: if e == country: pass else: c = get_confirmed_cases(df, e) j = 0 try: while t > c[j]: j += 1 slope = (c[i+n]-c[i])/n if slope > slope_inq[0][0]: diff = slope - slope_inq[0][0] else: diff = slope_inq[0][0] - slope slope_diff.append([diff,e]) except IndexError: pass slope_diff.sort() for i in range(k): output.append(slope_diff[i][1]) x = 0 while slope_diff[k-1][0] == slope_diff[k+x][0]: output.append(slope_diff[k+x][1]) x += 1 return output #------------------------------------------------- |
all: cluster #20 (5)
# 6231109321 (2020-09-26 19:02) %diff = 6.9 70.0% # Prog-07: COVID-19 # 6231109321 ณัฐภัทร ศุภรัตน์โสภิณ # v.5 # ขอยืนยันว่าเขียนโปรแกรมนี้ด้วยตัวเอง def steepest_countries(df, t, n): return [pest_countries(df, t, n)[-1][0]] def most_similar_countries(df, country, t, n): return top_k_similar_countries(df, country, t, n) def top_k_similar_countries(df, country, t, n, k=1): key=k ans = [] ans_onlyname = [] sim = similar_country(df, t, n, country) #list all similar sorted if sim != 0: #errror check similar_country_list = sim else: return 'Could no found {} data that reached {} comfirmed case for {} days'.format( country, t, n) i = 0 while k > 0: if similar_country_list[i][1] == similar_country_list[i + 1][1]: #check if gab i , gab i+1 == j = i stack = 1 while similar_country_list[j][1] == similar_country_list[j + 1][1]: #count how many country have the same gab value stack += 1 j += 1 for l in range(stack): #append ans ans.append(similar_country_list[i + l]) i += stack #skip group that already use else: ans.append(similar_country_list[i]) #append value i += 1 k -= 1 if len(ans)>=key: #place of ans more than k break for i in range(len(ans)): ans_onlyname.append(ans[i][0]) #forrmath ans by name return ans_onlyname #------------------------------------------------- def pest_countries(df, t, n, country='all'): #calculate treashole treashole = [] if country == 'all': country_list = get_all_countries(df) for i in country_list: #find each country confirm_case = get_confirmed_cases(df, i) for j in range(len(confirm_case)): if confirm_case[j] >= t: #if confirm reach t looking_case = confirm_case[j:j + n + 1] treashole.append([ str(i), str((looking_case[-1] - looking_case[0]) / n) ]) #save teashole in sub list [country,value] break return Sort(treashole) #return in list [[country,value]....] else: confirm_case = get_confirmed_cases(df, country) for j in range( len(confirm_case)): #calculte treshole in direct country if confirm_case[j] >= t: #if confirm reach t looking_case = confirm_case[j:j + n + 1] treashole = (str( (looking_case[-1] - looking_case[0]) / n)) #save teashol break return treashole #return value def Sort(sub_li): # sort sublist min to max [[str,value]...] l = len(sub_li) for i in range(0, l): for j in range(0, l - i - 1): if (float(sub_li[j][1]) > float(sub_li[j + 1][1])): tempo = sub_li[j] sub_li[j] = sub_li[j + 1] sub_li[j + 1] = tempo return sub_li def similar_country(df, t, n, country): similar = [] #[[name, gab],[...]] treashole_list = pest_countries(df, t, n) #list of all treashole treashole_main = pest_countries(df, t, n, country) #value we looking for if treashole_main: for i in treashole_list: gab = abs(float(i[1]) - float(treashole_main)) similar.append([i[0], gab]) return Sort(similar)[1:] #return similar country except self else: return 0 #incase country,n out of range | # 6231113821 (2020-09-26 21:40) %diff = 1.62 70.0% # Prog-07: COVID-19 # 6231113821 ธนภูมิ ศรีธัญรัตน์ # ทำอย่างใจเย็น def steepest_countries(df, t, n): return [pest_countries(df, t, n)[-1][0]] def most_similar_countries(df, country, t, n): return top_k_similar_countries(df, country, t, n) def top_k_similar_countries(df, country, t, n, k=1): key=k ans = [] ANSname = [] sim = similar_country(df, t, n, country) if sim != 0: similar_country_list = sim else: return 'Could no found {} data that reached {} comfirmed case for {} days'.format( country, t, n) i = 0 while k > 0: if similar_country_list[i][1] == similar_country_list[i + 1][1]: j = i stack = 1 while similar_country_list[j][1] == similar_country_list[j + 1][1]: stack += 1 j += 1 for l in range(stack): ans.append(similar_country_list[i + l]) i += stack else: ans.append(similar_country_list[i]) i += 1 k -= 1 if len(ans)>=key: break for i in range(len(ans)): ANSname.append(ans[i][0]) return ANSname def pest_countries(df, t, n, country='all'): treashole = [] if country == 'all': country_list = get_all_countries(df) for a in country_list: confirm_case = get_confirmed_cases(df, a) for b in range(len(confirm_case)): if confirm_case[b] >= t: looking_case = confirm_case[b:b + n + 1] treashole.append([ str(a), str((looking_case[-1] - looking_case[0]) / n) ]) break return Sort(treashole) else: confirm_case = get_confirmed_cases(df, country) for b in range( len(confirm_case)): if confirm_case[b] >= t: looking_case = confirm_case[b:b + n + 1] treashole = (str( (looking_case[-1] - looking_case[0]) / n)) break return treashole def Sort(lst): l = len(lst) for a in range(0, l): for b in range(0, l - a - 1): if (float(lst[b][1]) > float(lst[b + 1][1])): tempo = lst[b] lst[b] = lst[b + 1] lst[b + 1] = tempo return lst def similar_country(df, t, n, country): similar = [] treashole_list = pest_countries(df, t, n) treashole_main = pest_countries(df, t, n, country) if treashole_main: for i in treashole_list: gab = abs(float(i[1]) - float(treashole_main)) similar.append([i[0], gab]) return Sort(similar)[1:] else: return 0 | # 6231125321 (2020-09-27 23:16) %diff = 1.62 70.0% # Prog-07: COVID-19 # นายวิมุทร์เอก เตชะมรกต 6231125321 # ทำไปร้องไห้ไป def steepest_countries(df, t, n): return [pest_countries(df, t, n)[-1][0]] def most_similar_countries(df, country, t, n): return top_k_similar_countries(df, country, t, n) def top_k_similar_countries(df, country, t, n, k=1): key=k ans = [] AnswerKEY = [] sim = similar_country(df, t, n, country) if sim != 0: similar_country_list = sim else: return 'Could no found {} data that reached {} comfirmed case for {} days'.format( country, t, n) i = 0 while k > 0: if similar_country_list[i][1] == similar_country_list[i + 1][1]: j = i ; stack = 1 while similar_country_list[j][1] == similar_country_list[j + 1][1]: stack += 1 ; j += 1 for l in range(stack): ans.append(similar_country_list[i + l]) i += stack else: ans.append(similar_country_list[i]) i += 1 ; k -= 1 if len(ans)>=key: break for i in range(len(ans)): AnswerKEY.append(ans[i][0]) return AnswerKEY #------------------------------------------------- def pest_countries(df, t, n, country='all'): treashole = [] if country == 'all': country_list = get_all_countries(df) for a in country_list: confirm_case = get_confirmed_cases(df, a) for b in range(len(confirm_case)): if confirm_case[b] >= t: looking_case = confirm_case[b:b + n + 1] treashole.append([ str(a),str((looking_case[-1] - looking_case[0]) / n)]) break return Sort(treashole) else: confirm_case = get_confirmed_cases(df, country) for b in range( len(confirm_case)): if confirm_case[b] >= t: looking_case = confirm_case[b:b + n + 1] treashole = (str( (looking_case[-1] - looking_case[0]) / n)) break return treashole def Sort(abc): l = len(abc) for a in range(0, l): for b in range(0, l - a - 1): if (float(abc[b][1]) > float(abc[b + 1][1])): tempo = abc[b] abc[b] = abc[b + 1] ; abc[b + 1] = tempo return abc def similar_country(df, t, n, country): similar = [] treashole_list = pest_countries(df, t, n) treashole_main = pest_countries(df, t, n, country) if treashole_main: for i in treashole_list: gab = abs(float(i[1]) - float(treashole_main)) ; similar.append([i[0], gab]) return Sort(similar)[1:] else: return 0 | # 6231117321 (2020-09-27 23:18) %diff = 9.52 70.0% # Prog-07: COVID-19 # นายปราโมทย์ มหาศิวะกุล 6231117321 # ทำด้วยความยากลำบากมากๆครับ def steepest_countries(df, t, n): return [pest_countries(df, t, n)[-1][0]] def most_similar_countries(df, country, t, n): return top_k_similar_countries(df, country, t, n) def top_k_similar_countries(df, country, t, n, k=1): Hint=k ; ans = [] ; ANSname = [] sim = similar_country(df, t, n, country) if sim != 0: similar_country_list = sim else: return 'Could no found {} data that reached {} comfirmed case for {} days'.format( country, t, n) p = 0 while k > 0: if similar_country_list[p][1] == similar_country_list[p + 1][1]: j = p stack = 1 while similar_country_list[j][1] == similar_country_list[j + 1][1]: stack += 1 ; j += 1 for l in range(stack): ans.append(similar_country_list[p + l]) p += stack else: ans.append(similar_country_list[p]) p += 1 ; k -= 1 if len(ans)>=Hint: break for c in range(len(ans)): ANSname.append(ans[c][0]) return ANSname #------------------------------------------------- def pest_countries(df, t, n, country='all'): treashole = [] if country == 'all': country_list = get_all_countries(df) for a in country_list: confirm_case = get_confirmed_cases(df, a) for b in range(len(confirm_case)): if confirm_case[b] >= t: looking_case = confirm_case[b:b + n + 1] treashole.append([str(a), str((looking_case[-1] - looking_case[0]) / n) ]) break return Sort(treashole) else: confirm_case = get_confirmed_cases(df, country) for b in range( len(confirm_case)): if confirm_case[b] >= t: looking_case = confirm_case[b:b + n + 1] treashole = (str((looking_case[-1] - looking_case[0]) / n)) break return treashole def Sort(Cov): l = len(Cov) for a in range(0, l): for b in range(0, l - a - 1): if (float(Cov[b][1]) > float(Cov[b + 1][1])): tempo = Cov[b] Cov[b] = Cov[b + 1] Cov[b + 1] = tempo return Cov def similar_country(df, t, n, country): similar = [] treashole_list = pest_countries(df, t, n) treashole_main = pest_countries(df, t, n, country) if treashole_main: for k in treashole_list: gab = abs(float(k[1]) - float(treashole_main)) similar.append([k[0], gab]) return Sort(similar)[1:] else: return 0 | # 6231502221 (2020-09-27 23:19) %diff = 6.94 70.0% # Prog-07: COVID-19 # นายกันตพงศ์ โกมินทร์ 6231502221 # ทำอย่างใจเย็น def steepest_countries(df, t, n): return [pest_countries(df, t, n)[-1][0]] def most_similar_countries(df, country, t, n): return top_k_similar_countries(df, country, t, n) def top_k_similar_countries(df, country, t, n, k=1): key=k ; ans = [] ; top = [] ; sim = similar_country(df, t, n, country) if sim == 0: return 'Could no found {} data that reached {} comfirmed case for {} days'.format(country, t, n) else: similar_country_list = sim i = 0 while k > 0: if similar_country_list[i][1] == similar_country_list[i + 1][1]: j = i ; stack = 1 while similar_country_list[j][1] == similar_country_list[j + 1][1]: stack += 1 ; j += 1 for l in range(stack): ans.append(similar_country_list[i + l]) i += stack else: ans.append(similar_country_list[i]) ; i += 1 k -= 1 if len(ans)>=key: break for i in range(len(ans)): top.append(ans[i][0]) return top #------------------------------------------------- def pest_countries(df, t, n, country='all'): treashole = [] if country == 'all': country_list = get_all_countries(df) for a in country_list: confirm_case = get_confirmed_cases(df, a) for b in range(len(confirm_case)): if confirm_case[b] >= t: looking_case = confirm_case[b:b + n + 1] treashole.append([str(a),str((looking_case[-1] - looking_case[0]) / n)]) break return Sort(treashole) else: confirm_case = get_confirmed_cases(df, country) for b in range( len(confirm_case)): if confirm_case[b] >= t: looking_case = confirm_case[b:b + n + 1] treashole = (str((looking_case[-1] - looking_case[0]) / n)) break return treashole def Sort(source): l = len(source) for i in range(0, l): for b in range(0, l - i - 1): if (float(source[b][1]) > float(source[b + 1][1])): tempo = source[b] source[b] = source[b + 1] source[b + 1] = tempo return source def similar_country(df, t, n, country): similar = [] treashole_list = pest_countries(df, t, n) treashole_main = pest_countries(df, t, n, country) if treashole_main: for i in treashole_list: gab = abs(float(i[1]) - float(treashole_main)) similar.append([i[0], gab]) return Sort(similar)[1:] else: return 0 |
all: cluster #21 (2)
# 6330049221 (2020-09-27 15:57) %diff = 2.33 40.0% # Prog-07: COVID-19 # 6330049221 คุณาสิน อยู่สุข # ... # กราฟนี้ข้าพเจ้าเขียนโดยข้าพเจ้าเองโดยความช่วยเหลือจากอินเตอร์เน็ตในบางส่วน def steepest_countries(df, t, n): countries=get_all_countries(df) z=[] z1=[] xb1=[] for c in countries: #หาตัวที่เข้าเกณฑ์ e = get_confirmed_cases(df, c) d = [int(f) for f in e] #ทำให้ใน list เป็น int h=[] for i in d: if i>=t: h.append(i) if len(h)>=n: z.append(c) for c in z: #หาความชันเเต่ละตัว e = get_confirmed_cases(df, c) d = [int(f) for f in e] #ทำให้ใน list เป็น int h=[] h1=[] for i in d: if i>=t: h.append(i) p=(h[n]-h[0])/n z1.append(p) q=z1.index(max(z1)) #หาความชันมากสุด v=-1 for i in z1: #ถ้ามีหลายตัว v=v+1 if i==max(z1): xb1.append(z[v]) return (xb1) def most_similar_countries(df, country, t, n): countries=get_all_countries(df) z=[] z1=[] h=[] h2=[] xb1=[] e1 = get_confirmed_cases(df, country) d1 = [int(f) for f in e1] #ทำให้ใน list เป็น int for i in d1: #หาความชันตัวนำเข้า if i>=t: h.append(i) p1=(h[n]-h[0])/n j=countries.index(country) countries.pop(j) #เอาตัวนำเข้าออกจากลิสต์ for c in countries: #หาตัวที่เข้าเกณฑ์ e = get_confirmed_cases(df, c) d = [int(f) for f in e] #ทำให้ใน list เป็น int h=[] for i in d: if i>=t: h.append(i) if len(h)>=n: z.append(c) for c in z: #หาความชันตัวที่เข้าเกณฑ์ e = get_confirmed_cases(df, c) d = [int(f) for f in e] #ทำให้ใน list เป็น int h=[] h1=[] for i in d: if i>=t: h.append(i) p=(h[n]-h[0])/n z1.append(p) lol=min(z1, key=lambda x:abs(x-p1)) #หาตัวที่ใกล้ที่สุด(ได้มาจากการหาเพิ่มเติมจาก stockflow) ans=[] v=-1 for i in z1: #หากมีหลายตัว v=v+1 if i==lol: ans.append(z[v]) return (ans) def top_k_similar_countries(df, country, t, n, k): countries=get_all_countries(df) z=[] z1=[] h=[] h2=[] l5=[] ps5=[] e1 = get_confirmed_cases(df, country) d1 = [int(f) for f in e1] for i in d1: #หาความชันตัวนำเข้า if i>=t: h.append(i) p1=(h[n]-h[0])/n j=countries.index(country) countries.pop(j) #เอาตัวนำเข้าออก for c in countries: #หาตัวที่เข้าเกณฑ์ e = get_confirmed_cases(df, c) d = [int(f) for f in e] #ทำให้ใน list เป็น int h=[] for i in d: if i>=t: h.append(i) if len(h)>=n: z.append(c) for c in z: #หาความชันตัวที่เข้าเกณฑ์ e = get_confirmed_cases(df, c) d = [int(f) for f in e] h=[] h1=[] for i in d: if i>=t: h.append(i) p=(h[n]-h[0])/n z1.append(p) for i in range(k):#หาตัวที่ใกล้ lol=min(z1, key=lambda x:abs(x-p1)) #หาตัวที่ใกล้ที่สุด(ได้มาจากการหาเพิ่มเติมจาก stockflow) v=-1 for i in z1: #หากมีหลายตัว v=v+1 if i==lol: ps5.append(z[v]) z.pop(v) #เอาชื่อประเทศที่มีเเล้วออก z1.pop(v) #เอาจำนวนตนตืดเชื้อที่มีเเล้วออก return (ps5) #------------------------------------------------- | # 6331229021 (2020-09-27 23:18) %diff = 2.33 30.0% # Prog-07: COVID-19 # 6331229021 สาธิดา ปัญหา # ข้าพเจ้าขอยืนยันว่าได้เขียนโปรแกรมนี้ด้วยตนเอง # Declare that you do this by yourself def steepest_countries(df, t, n): countries=get_all_countries(df) a=[] a1=[] xb1=[] for b in countries: c = get_confirmed_cases(df, b) d = [int(f) for f in c] h=[] for i in d: if i>=t: h.append(i) if len(h)>=n: a.append(b) for c in a: c = get_confirmed_cases(df, b) d = [int(f) for f in c] h=[] h1=[] for i in d: if i>=t: h.append(i) p=(d[n]-d[0])/n a1.append(p) q=a1.index(max(a1)) v=-1 for i in a1: v=v+1 if i==max(a1): xb1.append(a[v]) return ([xb1[1]]) def most_similar_countries(df, country, t, n): countries=get_all_countries(df) a=[] a1=[] h=[] h2=[] xb1=[] ans = [] c1 = get_confirmed_cases(df, country) d1 = [int(f) for f in c1] for i in d1: if i>=t: h.append(i) p1=(h[n]-h[0])/n j=countries.index(country) countries.pop(j) for b in countries: c = get_confirmed_cases(df, b) d = [int(f) for f in c] h=[] for i in d: if i>=t: h.append(i) if len(h)>=n: a.append(b) for b in a: c = get_confirmed_cases(df, b) d = [int(f) for f in c] h=[] h1=[] for i in d: if i>=t: h.append(i) p=(h[n]-h[0])/n a1.append(p) lol=min(a1, key=lambda x:abs(x-p1)) v=-1 for i in a1: v=v+1 if i==lol: ans.append(a[v]) return (ans) def top_k_similar_countries(df, country, t, n, k): countries=get_all_countries(df) a=[] a1=[] h=[] h2=[] l5=[] ps5=[] c1 = get_confirmed_cases(df, country) d1 = [int(f) for f in c1] for i in d1: if i>=t: h.append(i) p1=(h[n]-h[0])/n j=countries.index(country) countries.pop(j) for b in countries: c = get_confirmed_cases(df, b) d = [int(f) for f in c] h=[] for i in d: if i>=t: h.append(i) if len(h)>=n: a.append(b) for b in a: c = get_confirmed_cases(df, b) d = [int(f) for f in c] h=[] h1=[] for i in d: if i>=t: h.append(i) p=(h[n]-h[0])/n a1.append(p) for i in range(k): lol=min(a1, key=lambda x:abs(x-p1)) v=-1 for i in a1: v=v+1 if i==lol: ps5.append(a[v]) a.pop(v) a1.pop(v) return (ps5) #------------------------------------------------- |
all: cluster #22 (2)
# 6330113721 (2020-09-27 00:46) %diff = 2.34 70.0% # Prog-07: COVID-19 # 6330113721 # โชคชัย ชูพาณิชสกุล # งานที่ผมได้ทำด้วยตัวผมเอง def steepest_countries(df, t, n): b = 0 min_slp = 0 max_slp = [] c = get_all_countries(df) for i in range(len(c)): c_slp = slope(df,c[i],t,n) if c_slp == []: pass else: if c_slp[0][0] > b: max_slp = [] max_slp.append(c[i]) b = c_slp[0][0] elif c_slp[0][0] == b: max_slp.append(c[i]) else: pass return max_slp def most_similar_countries(df, country, t, n): c = get_all_countries(df) all_slp = [] for e in c: all_slp += (slope(df,e,t,n)) all_slp.sort() for i in range(len(all_slp)): if all_slp[i][1] == country: slp_c = all_slp[i][1] slp1 = all_slp[i][0] break a = all_slp.index([slp1,slp_c]) z=[] if a != 0 and a != -1: x = abs(slp1-all_slp[a-1][0]) y = abs(slp1-all_slp[a+1][0]) if x <y: z+=[all_slp[a-1][1]] while True: a+=1 if (all_slp[a-1][0] != all_slp[a-2][0]) : break z+=[all_slp[a-1][1]] elif y < x: z+=[all_slp[a+1][1]] while True: a+=1 if (all_slp[a+1][0] != all_slp[a][0]) : break z+=[all_slp[a+1][1]] else: z+=[all_slp[a-1][1],all_slp[a+1][1]] return z def top_k_similar_countries(df, country, t, n, k): c = get_all_countries(df) all_slp = [] for e in c: all_slp += (slope(df,e,t,n)) all_slp.sort() for i in range(len(all_slp)): if all_slp[i][1] == country: slp_c = all_slp[i][1] slp1 = all_slp[i][0] break a = all_slp.index([slp1,slp_c]) x = [] for i in range(len(all_slp)): if i != a: x.append([abs(slp1-all_slp[i][0]),all_slp[i][1]]) x.sort() p = [] for i in range(k): p.append(x[i][1]) for i in range(k,len(x)): if x[k-1][0] == x[i][0]: p.append(x[i][1]) return p #------------------------------------------------- def slope(df,country,t,n): c = get_all_countries(df) c_slp = [] s = get_confirmed_cases(df,country) for k in range(1,len(s)+1): if s[k-1] >= t and k < len(s)-n : c_slp.append([(s[(k-1)+n]-s[k-1])/n,country]) break c_slp.sort() return c_slp | # 6330169921 (2020-09-27 12:30) %diff = 2.34 70.0% # Prog-07: COVID-19 # 6330169921 ณัฐภัทร ดังดี # ... # Declare that you do this by yourself def steepest_countries(df, t, n): a = 0 minslop = 0 maxslop = [] c = get_all_countries(df) for i in range(len(c)): cslop = slope(df,c[i],t,n) if cslop == []: pass else: if cslop[0][0] > a: maxslop = [] maxslop.append(c[i]) a = cslop[0][0] elif cslop[0][0] == a: maxslop.append(c[i]) else: pass return maxslop def most_similar_countries(df, country, t, n): c = get_all_countries(df) allslop = [] for e in c: allslop += (slope(df,e,t,n)) allslop.sort() for i in range(len(allslop)): if allslop[i][1] == country: slp_c = allslop[i][1] slp1 = allslop[i][0] break p = allslop.index([slp1,slp_c]) j=[] if p != 0 and p != -1: x = abs(slp1-allslop[p-1][0]) y = abs(slp1-allslop[p+1][0]) if x <y: j+=[allslop[p-1][1]] while True: p+=1 if (allslop[p-1][0] != allslop[p-2][0]) : break j+=[allslop[p-1][1]] elif y < x: j+=[allslop[p+1][1]] while True: p+=1 if (allslop[p+1][0] != allslop[p][0]) : break j+=[allslop[p+1][1]] else: j+=[allslop[p-1][1],allslop[p+1][1]] return j def top_k_similar_countries(df, country, t, n, k): c = get_all_countries(df) allslop = [] for e in c: allslop += (slope(df,e,t,n)) allslop.sort() for i in range(len(allslop)): if allslop[i][1] == country: cslop = allslop[i][1] slp = allslop[i][0] break a = allslop.index([slp,cslop]) x = [] for i in range(len(allslop)): if i != a: x.append([abs(slp-allslop[i][0]),allslop[i][1]]) x.sort() h = [] for i in range(k): h.append(x[i][1]) for i in range(k,len(x)): if x[k-1][0] == x[i][0]: h.append(x[i][1]) return h #------------------------------------------------- def slope(df,country,t,n): c = get_all_countries(df) cslop = [] s = get_confirmed_cases(df,country) for k in range(1,len(s)+1): if s[k-1] >= t and k < len(s)-n : cslop.append([(s[(k-1)+n]-s[k-1])/n,country]) break cslop.sort() return cslop |
all: cluster #23 (2)
# 6330020021 (2020-09-27 22:42) %diff = 3.22 100.0% # Prog-07: COVID-19 # 6330020021 กันตชัย ควรเสนาะ # ข้าพเจ้าเป็นคนออกแบบ function และการทำงานของ function ด้วยตนเอง def steepest_countries(df, t, n): y = get_all_countries(df) slopelist=[] cc=[] cmax=0 for i in range(len(y)): if slope_of_country(df,y[i], t ,n) > cmax: cmax = slope_of_country(df,y[i], t ,n) slopelist.append(slope_of_country(df,y[i], t ,n)) for i in range(len(slopelist)): if slopelist[i] == cmax : cc.append(y[i]) return cc def most_similar_countries(df, country, t, n): y = get_all_countries(df) a=slope_of_country(df,country, t, n) b=[] bslope=[] vv=[] for i in range(len(y)): b.append(y[i]) bslope.append([abs(float(slope_of_country(df,y[i], t, n))-float(a)),y[i]]) bslope.remove([0.0,country]) bslope.sort() bb=bslope[0][0] for i in bslope : if i[0] == bb: vv.append(i[1]) else: break # print(bslope) # v=min(bslope) return vv def top_k_similar_countries(df, country, t, n, k): y = get_all_countries(df) a=slope_of_country(df,country, t, n) slopelist=[] cc=[] cmax=0 for i in range(len(y)): if slope_of_country(df,y[i], t ,n) > cmax: cmax = slope_of_country(df,y[i], t ,n) slopelist.append(slope_of_country(df,y[i], t ,n)) for i in range(len(slopelist)): cc.append([abs(a-slopelist[i]),y[i]]) cc.sort() cc.remove([0.0,country]) l=0 for i in range(k,len(cc)): if cc[i][0] == cc[i-1][0] : l+=1 else: break return [e[1]for e in cc[:k+l]] # ------------------------------------------------- def slope_of_country(df,country, t, n): #My function #For finding the slope of each country num = get_confirmed_cases(df,country) slope =0 for i in range(len(num)): if num[i] > t and i+n < len(num) : slope = (num[i+n]-num[i])/n break return slope | # 6331002921 (2020-09-27 23:06) %diff = 3.22 100.0% # Prog-07: COVID-19 # กันต์ธร ลิบวาณิชย์ 6331002921 # ... # ผมตั้งใจทำสุดๆแล้วครับ def steepest_countries(df, t, n): z = get_all_countries(df) m_slope = [] p = [] p_mak = 0 for i in range(len(z)): if slope_prated(df,z[i],t,n) > p_mak : p_mak = slope_prated(df,z[i],t,n) m_slope.append(slope_prated(df,z[i], t ,n)) for i in range(len(m_slope)): if m_slope[i] == p_mak : p.append(z[i]) return p def most_similar_countries(df, country, t, n): z = get_all_countries(df) gap=slope_prated(df,country, t, n) tee=[] teeslope=[] pai=[] for i in range(len(z)): tee.append(z[i]) teeslope.append([abs(float(slope_prated(df,z[i], t, n))-float(gap)),z[i]]) teeslope.remove([0.0,country]) teeslope.sort() nes=teeslope[0][0] for u in teeslope : if u[0] == nes: pai.append(u[1]) else: break return pai def top_k_similar_countries(df, country, t, n, k): z = get_all_countries(df) gap=slope_prated(df,country, t, n) m_slope=[] p=[] p_mak = 0 for i in range(len(z)): if slope_prated(df,z[i], t ,n) > p_mak: p_mak = slope_prated(df,z[i], t ,n) m_slope.append(slope_prated(df,z[i], t ,n)) for i in range(len(m_slope)): p.append([abs(gap-m_slope[i]),z[i]]) p.sort() p.remove([0.0,country]) c = 0 for q in range(k,len(p)): if p[q][0] == p[q-1][0] : c+=1 else: break return [j[1]for j in p[:k+c]] #------------------------------------------------- def slope_prated (df,country,t,n): time = get_confirmed_cases(df,country) slope = 0 for i in range (len(time)): if time[i] > t and i+n < len(time) : slope = (time[i+n] - time[i]) / n break return slope |
all: cluster #24 (2)
# 6330089321 (2020-09-27 23:51) %diff = 3.74 30.0% # Prog-07: COVID-19 # 6330089321 ชยุต ฤทัยธนารัตน์ # ผมตั้งใจทำงานนี้ด้วยตนเอง def steepest_countries(df, t, n): slope = [] countrys = get_all_countries(df) for i in countrys: country_case = get_confirmed_cases(df,i) for j in range(len(country_case)): if len(country_case) - j < n: slope.append(0) break elif float(country_case[j]) > t: slope.append((country_case[j+n] - country_case[j])/n) break a = slope.index(max(slope)) country_max_slope = countrys[a] d = [] d.append(country_max_slope) return d def most_similar_countries(df, country, t, n): country_main = get_confirmed_cases(df,country) for i in range(len(country_main)): if float(country_main[i]) > t: slope_main = (country_main[i+n] - country_main[i])/n break slope = [] countrys = get_all_countries(df) countrys.remove(country) for i in countrys: country_case = get_confirmed_cases(df,i) for j in range(len(country_case)): if len(country_case) - j < n: slope.append(0) break elif float(country_case[j]) > t: slope.append((country_case[j+n] - country_case[j])/n) break dt = [] for i in range(len(slope)): dt.append(abs(slope[i]-slope_main)) a = dt.index(min(dt)) country_near = countrys[a] d = [] d.append(country_near) return d def top_k_similar_countries(df, country, t, n, k): country_main = get_confirmed_cases(df,country) for i in range(len(country_main)): if float(country_main[i]) > t: slope_main = (country_main[i+n] - country_main[i])/n break slope = [] countrys = get_all_countries(df) countrys.remove(country) for i in countrys: country_case = get_confirmed_cases(df,i) for j in range(len(country_case)): if len(country_case) - j < n: slope.append(0) break elif float(country_case[j]) > t: slope.append((country_case[j+n] - country_case[j])/n) break dt = [] for i in range(len(slope)): dt.append(abs(slope[i]-slope_main)) Dt = [] for i in range(len(dt)): Dt.append(dt[i]) Dt.sort() c = [] a = Dt[k-1] b = 0 for i in range(k): if Dt[i] != a: c.append(countrys[dt.index(Dt[i],b+1)]) b = dt.index(Dt[i],b+1) b = 0 for i in range(len(Dt)): if Dt[i] == a: c.append(countrys[dt.index(Dt[i],b+1)]) b = dt.index(Dt[i],b+1) return c #------------------------------------------------- | # 6331107121 (2286-11-21 00:46) %diff = 3.74 20.0% # Prog-07: COVID-19 # 6331107121 Nattawat Tapanasomboon # This program introduces the COVID-19 situation. # Confirm that I did this myself. def steepest_countries(df, t, n): slope = [] countrys = get_all_countries(df) for e in countrys: country_case = get_confirmed_cases(df,e) for f in range(len(country_case)): if len(country_case) - f < n: slope.append(0) break elif float(country_case[f]) > t: slope.append((country_case[f+n] - country_case[f])/n) break a = slope.index(max(slope)) country_max_slope = countrys[a] d = [] d.append(country_max_slope) return d def most_similar_countries(df, country, t, n): country_main = get_confirmed_cases(df,country) for e in range(len(country_main)): if float(country_main[e]) > t: slope_main = (country_main[i+n] - country_main[e])/n break slope = [] countrys = get_all_countries(df) countrys.remove(country) for e in countrys: country_case = get_confirmed_cases(df,e) for f in range(len(country_case)): if len(country_case) - f < n: slope.append(0) break elif float(country_case[f]) > t: slope.append((country_case[f+n] - country_case[f])/n) break dt = [] for i in range(len(slope)): dt.append(abs(slope[i]-slope_main)) a = dt.index(min(dt)) country_near = countrys[a] d = [] d.append(country_near) return d def top_k_similar_countries(df, country, t, n, k): country_main = get_confirmed_cases(df,country) for i in range(len(country_main)): if float(country_main[i]) > t: slope_main = (country_main[i+n] - country_main[i])/n break slope = [] countrys = get_all_countries(df) countrys.remove(country) for i in countrys: country_case = get_confirmed_cases(df,i) for j in range(len(country_case)): if len(country_case) - j < n: slope.append(0) break elif float(country_case[j]) > t: slope.append((country_case[j+n] - country_case[j])/n) break dt = [] for i in range(len(slope)): dt.append(abs(slope[i]-slope_main)) Dt = [] for i in range(len(dt)): Dt.append(dt[i]) Dt.sort() c = [] a = Dt[k-1] b = 0 for i in range(k): if Dt[i] != a: c.append(countrys[dt.index(Dt[i],b+1)]) b = dt.index(Dt[i],b+1) b = 0 for i in range(len(Dt)): if Dt[i] == a: c.append(countrys[dt.index(Dt[i],b+1)]) b = dt.index(Dt[i],b+1) return c #------------------------------------------------- |
all: cluster #25 (2)
# 6330037721 (2020-09-26 09:48) %diff = 5.18 40.0% # Prog-07: COVID-19 # 6330037721 กึกก้อง แก้วกรกฎ # ... # เป็น code ที่เขียนด้วยตัวเองอย่างภาคภูมิใจ def steepest_countries(df, t, n): all = get_all_countries(df) c = [] M = 0 for i in range(len(all)): m = slope(df,all[i],t,n) # หาค่าslope if m > M: M = m c.append([M, all[i]]) c.reverse() #print(c) final = [c[0][1]] for i in range(len(c)): if i == 0: continue else: if c[i][0] == c[i-1][0]: final.append(c[i][1]) return final def most_similar_countries(df, country, t, n): slope_country = slope(df,country,t,n) all = get_all_countries(df) c = [] for i in range(len(all)): m = slope(df,all[i],t,n) # หาค่าslope a = abs(slope_country - m) c.append([a,all[i]]) c.sort() C = [c[1][1]] for i in range(2,len(c)): if c[i][0] == c[i-1][0]: C.append(c[i][1]) else: break return C def top_k_similar_countries(df, country, t, n, k): slope_country = slope(df,country,t,n) all = get_all_countries(df) c = [] for i in range(len(all)): m = slope(df,all[i],t,n) # หาค่าslope c.append([abs(m-slope_country),all[i]]) c.sort() top = [] x = 0 # นับจำนวนประเทศ i = 1 while i < len(c): if x >= k: break top.append(c[i][1]) x += 1 while i < len(c)-1 and c[i+1][0] == c[i][0]: top.append(c[i+1][1]) i += 1 i += 1 return top #------------------------------------------------- def slope(df,country, t, n): # ใช้หาค่า slope a = get_confirmed_cases(df,country) q = 0 s = 0 while q < len(a) - n: if a[q] < t: q +=1 else: s = (a[q+n] - a[q]) / n break return s | # 6330027421 (2020-09-27 17:20) %diff = 5.18 0.0% # Prog-07: COVID-19 # 6330027421 การัณยภาส ชาสวัสดิ์ # I add function for take the slope to compare. # I write this code by myself. def steepest_countries(df, t, n): all = get_all_countries(df) c = [] x = 0 for i in range(len(all)): y = slope(all[i],t,n) if y > x: x = y c.append([x, all[i]]) c.reverse() final = [c[0][1]] for i in range(len(c)): if i == 0: continue else: if c[i][0] == c[i-1][0]: final.append(c[i][1]) return final def most_similar_countries(df, country, t, n): slope_country = slope(country,t,n) all = get_all_countries(df) x = 0 c = [] for i in range(len(all)): y = slope(all[i],t,n) a = abs(slope_country - y) c.append([a,all[i]]) c.sort() C = [c[1][1]] for i in range(2,len(c)): if c[i][0] == c[i-1][0]: C.append(c[i][1]) else: break return C def top_k_similar_countries(df, country, t, n, k): slope_country = slope(country,t,n) all = get_all_countries(df) c = [] for i in range(len(all)): y = slope(all[i],t,n) c.append([abs(y-slope_country),all[i]]) c.sort() top = [] x = 0 i = 1 while i < len(c): if x >= k: break top.append(c[i][1]) x += 1 while i < len(c)-1 and c[i+1][0] == c[i][0]: top.append(c[i+1][1]) i += 1 i += 1 return top #------------------------------------------------- def slope(country, t, n): df = get_data() a = get_confirmed_cases(df,country) q = 0 s = 0 while q < len(a) - n: if a[q] < t: q +=1 else: s = (a[q+n] - a[q]) / n break return s |
all: cluster #26 (2)
# 6330067521 (2020-09-27 17:09) %diff = 5.42 100.0% # Prog-07: COVID-19 # 6330067521 ฉัตรดนัย เจียระนัย # I hereby declare that I coded the COVID-19 by myself. def steepest_countries(df, t, n): list_ans = [] list_final = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() list_ans = list_ans[::-1] if len(list_ans) == 0: return [''] else: list_final.append((list_ans[0])[1]) for i in range(1,len(list_ans)): if (list_ans[i])[0] == (list_ans[i-1])[0]: list_final.append((list_ans[i])[1]) else: break return list_final def most_similar_countries(df, country, t, n): list_ans = [] list_pre = [] list_final = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() if len(list_ans) == 0: return [''] else: for i in range(len(list_ans)): if (list_ans[i])[1] == country : break for j in range(len(list_ans)): list_pre.append([abs((list_ans[j])[0] - (list_ans[i])[0]), (list_ans[j])[1]]) list_pre.sort() list_pre.pop(0) list_final.append((list_pre[0])[1]) for i in range(1,len(list_pre)): if (list_pre[i])[0] == (list_pre[i-1])[0]: list_final.append((list_pre[i])[1]) else: break return list_final def top_k_similar_countries(df, country, t, n, k): list_ans = [] list_pre = [] list_final = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n list_ans.append([m,(get_all_countries(df))[i]]) break list_ans.sort() a = get_confirmed_cases(df, country) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n break ind = list_ans.index([m, country]) list_ans.pop(ind) for i in range(len(list_ans)): list_pre.append([abs(m-(list_ans[i])[0]) , (list_ans[i])[1]]) list_pre.sort() for i in range(len(list_pre)): if i < k: list_final.append((list_pre[i])[1]) elif (list_pre[i])[0] != (list_pre[i-1])[0]: break elif (list_pre[i])[0] == (list_pre[i-1])[0]: list_final.append((list_pre[i])[1]) return list_final #------------------------------------------------- | # 6330036021 (2020-09-27 22:36) %diff = 5.42 90.0% # -*- coding: utf-8 -*- def steepest_countries(df, t, n): lstanswer = [] lstfinal = [] for i in range(0,len(get_all_countries(df))): each_country = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(0,len(each_country)): if each_country[j] > t and len(each_country[j::]) > n : diff_y = each_country[j+n] - each_country[j] slope = diff_y / n lstanswer.append([slope,(get_all_countries(df))[i]]) break lstanswer.sort() lstanswer.reverse() if len(lstanswer) == 0: return [''] else: lstfinal.append(lstanswer[0][1]) for i in range(0,len(lstanswer)): if (lstanswer[i])[0] == (lstanswer[i+1])[0]: lstfinal.append(lstanswer[i][1]) else: break return lstfinal def most_similar_countries(df, country, t, n): lstanswer = [] lstpre = [] lstfinal = [] for i in range(0,len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n lstanswer.append([m,(get_all_countries(df))[i]]) break lstanswer.sort() if len(lstanswer) == 0: return [''] else: for i in range(len(lstanswer)): if (lstanswer[i])[1] == country : break for j in range(len(lstanswer)): lstpre.append([abs((lstanswer[j])[0] - (lstanswer[i])[0]), (lstanswer[j])[1]]) lstpre.sort() lstpre.pop(0) lstfinal.append((lstpre[0])[1]) for i in range(1,len(lstpre)): if (lstpre[i])[0] == (lstpre[i-1])[0]: lstfinal.append((lstpre[i])[1]) else: break return lstfinal def top_k_similar_countries(df, country, t, n, k): lstanswer = [] lstpre = [] lstfinal = [] for i in range(len(get_all_countries(df))): a = get_confirmed_cases(df, (get_all_countries(df))[i]) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n lstanswer.append([m,(get_all_countries(df))[i]]) break lstanswer.sort() a = get_confirmed_cases(df, country) for j in range(len(a)): if a[-1] > t and len(a[j::]) > n and a[j] > t: m = (a[j+n]-a[j])/n break ind = lstanswer.index([m, country]) lstanswer.pop(ind) for i in range(len(lstanswer)): lstpre.append([abs(m-(lstanswer[i])[0]) , (lstanswer[i])[1]]) lstpre.sort() for i in range(len(lstpre)): if i < k: lstfinal.append((lstpre[i])[1]) elif (lstpre[i])[0] != (lstpre[i-1])[0]: break elif (lstpre[i])[0] == (lstpre[i-1])[0]: lstfinal.append((lstpre[i])[1]) return lstfinal #------------------------------------------------- |
all: cluster #27 (2)
# 6331118021 (2020-09-27 22:17) %diff = 5.5 0.0% # Prog-07: COVID-19 # 6331118021 บราลี เกาะสมุทร # ขอยืนยันว่าได้เขียนโค้ดด้วยตัวเอง def steepest_countries(df, t, n): all = get_all_countries(df) c = [] M = 0 for i in range(len(all)): m = slope(all[i],t,n) # หาค่าslope if m > M: M = m c.append([M, all[i]]) c.reverse() #print(c) final = [c[0][1]] for i in range(len(c)): if i == 0: continue else: if c[i][0] == c[i-1][0]: final.append(c[i][1]) return final def most_similar_countries(df, country, t, n): slope_country = slope(country,t,n) all = get_all_countries(df) M = 0 # เริ่มประเทศแรก c = [] for i in range(len(all)): m = slope(all[i],t,n) # หาค่าslope if abs(M-slope_country) > abs(m-slope_country): M = m c.append([all[i]]) return c[-2] def top_k_similar_countries(df, country, t, n, k): slope_country = slope(country,t,n) all = get_all_countries(df) c = [] for i in range(len(all)): m = slope(all[i],t,n) # หาค่าslope c.append([abs(m-slope_country),all[i]]) c.sort() top = [] x = 0 # นับจำนวนประเทศ i = 1 while i < len(c): if x >= k: break top.append(c[i][1]) x += 1 while i < len(c)-1 and c[i+1][0] == c[i][0]: top.append(c[i+1][1]) i += 1 i += 1 return top #------------------------------------------------- def slope(country, t, n): # ใช้หาค่า slope df = get_data() a = get_confirmed_cases(df,country) q = 0 s = 0 while q < len(a) - n: if a[q] < t: q +=1 else: s = (a[q+n] - a[q]) / n break return s | # 6331112221 (2020-09-27 23:55) %diff = 5.5 0.0% # Prog-07: COVID-19 # 6331112221 ธนพัฒน์ สุวรรณวัฒนะ # ... # ผมตั้งใจทำด้วยตัวเองอย่างภูมิใจยิ่ง def steepest_countries(df, t, n): all = get_all_countries(df) s = [] z = 0 for i in range(len(all)): m = slope(all[i],t,n) # หาค่าslope if m > z: z = m s.append([z, all[i]]) s.reverse() #print(s) final = [s[0][1]] for i in range(len(s)): if i == 0: continue else: if s[i][0] == s[i-1][0]: final.append(s[i][1]) return final def most_similar_countries(df, country, t, n): slope_country = slope(country,t,n) all = get_all_countries(df) w = 0 # เริ่มประเทศแรก c = [] for i in range(len(all)): m = slope(all[i],t,n) # หาค่าslope if abs(w-slope_country) > abs(m-slope_country): w = m c.append([all[i]]) return c[-2] def top_k_similar_countries(df, country, t, n, k): slope_country = slope(country,t,n) all = get_all_countries(df) y = [] for i in range(len(all)): m = slope(all[i],t,n) # หาค่าslope y.append([abs(m-slope_country),all[i]]) y.sort() top = [] x = 0 # นับจำนวนประเทศ i = 1 while i < len(y): if x >= k: break top.append(y[i][1]) x += 1 while i < len(y)-1 and y[i+1][0] == y[i][0]: top.append(y[i+1][1]) i += 1 i += 1 return top #------------------------------------------------- def slope(country, t, n): # ใช้หาค่า slope df = get_data() a = get_confirmed_cases(df,country) q = 0 s = 0 while q < len(a) - n: if a[q] < t: q +=1 else: s = (a[q+n] - a[q]) / n break return s |
all: cluster #28 (2)
# 6331121921 (2020-09-27 22:26) %diff = 5.54 0.0% # Prog-07: COVID-19 # Fill in your ID & Name # 6331121921 พรลภัส สุนทรเรืองศิริ # Declare that you do this by yourself def steepest_countries(df, t, n): x = get_all_countries(df) y = [] M1 = 0 for i in range(len(x)): m = slope(x[i],t,n) if m > M1: M1 = m y.append([M1, x[i]]) y.reverse() f = [y[0][1]] for i in range(len(y)): if i == 0: continue else: if y[i][0] == y[i-1][0]: f.append(y[i][1]) return f def most_similar_countries(df, country, t, n): slope_country = slope(country,t,n) a = get_all_countries(df) y = [] M1 = 0 for i in range(len(a)): m = slope(a[i],t,n) if abs(M1-slope_country) > abs(m-slope_country): M1 = m y.append([a[i]]) return y[-2] def top_k_similar_countries(df, country, t, n, k): slope_country = slope(country,t,n) a = get_all_countries(df) y = [] for i in range(len(a)): m = slope(a[i],t,n) y.append([abs(m-slope_country),a[i]]) y.sort() t = [] x = 0 i = 1 while i < len(y): if x >= k: break t.append(y[i][1]) x += 1 while i < len(y)-1 and y[i+1][0] == y[i][0]: t.append(y[i+1][1]) i += 1 i += 1 return t #------------------------------------------------- def slope(country, t, n): # หาความชัน df = get_data() a = get_confirmed_cases(df,country) b = 0 c = 0 while b < len(a) - n: if a[b] < t: b +=1 else: c = (a[b+n] - a[b]) / n break return c | # 6331131121 (2020-09-27 23:17) %diff = 5.54 0.0% # Prog-07: COVID-19 # 6331131121 # สุธิมนต์ เลาหธีรวัฒน์ # ผมสู้สุดชีวิตแล้วครับ ขอบคุณครับ def steepest_countries(df, t, n): n_countries = get_all_countries(df) c = [] M = 0 for i in range(len(n_countries)): m = slope(n_countries[i],t,n) if m > M: M = m c.append([M, n_countries[i]]) c.sort() final = [c[0][1]] for i in range(len(c)): if i == 0: continue else: if c[i][0] == c[i-1][0]: final.append(c[i][1]) return final def most_similar_countries(df, country, t, n): each_slope = slope(country,t,n) n_countries = get_all_countries(df) M = 0 c = [] for i in range(len(n_countries)): m = slope(n_countries[i],t,n) if abs(M-each_slope) > abs(m-each_slope): M = m c.append([n_countries[i]]) return c[-2] def top_k_similar_countries(df, country, t, n, k): each_slope = slope(country,t,n) n_countries = get_all_countries(df) c = [] for i in range(len(n_countries)): m = slope(n_countries[i],t,n) c.append([abs(m-each_slope),n_countries[i]]) c.sort() top_k = [] x = 0 i = 1 while i < len(c): if x >= k: break top_k.append(c[i][1]) x += 1 while i < len(c)-1 and c[i+1][0] == c[i][0]: top_k.append(c[i+1][1]) i += 1 i += 1 return top_k #------------------------------------------------- def slope(country, t, n): df = get_data() cf = get_confirmed_cases(df,country) count = 0 slope = 0 while n < len(cf) - count: if cf[count] < t: count +=1 else: slope = (cf[count+n] - cf[count]) / n break return slope |
all: cluster #29 (2)
# 6331408021 (2020-09-26 04:58) %diff = 6.63 80.0% # Prog-07: COVID-19 # 6331408021 ณัฏฐชัย สุขม่วง # โปรแกรมนี้ข้าพเจ้าเป็นคนทำขึ้นมาเอง def steepest_countries(df, t, n): a = [] b = get_all_countries(df) for i in b : c = get_confirmed_cases(df,i) for j in range(len(c)) : if c[j] > t and j + n < len(c) : h = c[j+n] m = (h - c[j]) / n a.append([m,i]) break a.sort() g = [] amax = a[-1][0] for i in a : if i[0] == amax : g.append(i[1]) return g def most_similar_countries(df, country, t, n): x = get_confirmed_cases(df,country) for i in range(len(x)) : if x[i] > t and i + n < len(x) : h = x[i+n] m1 = (h - x[i]) / n break a = [] b = get_all_countries(df) for i in b : c = get_confirmed_cases(df,i) for j in range(len(c)) : if c[j] > t and j + n < len(c) : h = c[j+n] m2 = (h - c[j]) / n a.append([m2,i]) break a.sort() k = [] for i in range(len(a)) : f = abs(a[i][0] - m1) k.append([f,a[i][1]]) k.sort() ans = k[1][0] g = [] for i in k : if i[0] == ans : g.append(i[1]) return g def top_k_similar_countries(df, country, t, n, k): x = get_confirmed_cases(df,country) for i in range(len(x)) : if x[i] > t and i + n < len(x) : h = x[i+n] m1 = (h - x[i]) / n break a = [] b = get_all_countries(df) for i in b : c = get_confirmed_cases(df,i) for j in range(len(c)) : if c[j] > t and j + n < len(c) : h = c[j+n] m2 = (h - c[j]) / n a.append([m2,i]) break a.sort() ans = [] l = [] for i in range(len(a)) : f = abs(a[i][0] - m1) l.append([f,a[i][1]]) l.sort() i = 0 while l[k][0] == l[k+i][0] : i += 1 k += i-1 for j in range(k) : ans.append(l[j+1][1]) return ans #------------------------------------------------- | # 6331405121 (2020-09-27 23:55) %diff = 6.63 80.0% # Prog-07: COVID-19 # 6331405121 เกียรติ์การันต์ บุญเลี้ยง # ... # ผมได้เขียนโปรแกรมในส่วนที่ต้องเขียนด้วยตนเอง def steepest_countries(df, t, n): a = [] country = get_all_countries(df) for z in country : case = get_confirmed_cases(df,z) for j in range(len(case)) : if case[j] > t and j + n < len(case) : f = case[j+n] m = (f - case[j]) / n a.append([m,z]) break a.sort() g = [] amax = a[-1][0] for i in a : if i[0] == amax : g.append(i[1]) return g def most_similar_countries(df, country, t, n): x = get_confirmed_cases(df,country) for i in range(len(x)) : if x[i] > t and i + n < len(x) : f = x[i+n] m1 = (f - x[i]) / n break a = [] country = get_all_countries(df) for z in country : case = get_confirmed_cases(df,z) for j in range(len(case)) : if case[j] > t and j + n < len(case) : f = case[j+n] m2 = (f - case[j]) / n a.append([m2,z]) break a.sort() k = [] for i in range(len(a)) : f = abs(a[i][0] - m1) k.append([f,a[i][1]]) k.sort() ans = k[1][0] g = [] for i in k : if i[0] == ans : g.append(i[1]) return g def top_k_similar_countries(df, country, t, n, k): x = get_confirmed_cases(df,country) for i in range(len(x)) : if x[i] > t and i + n < len(x) : f = x[i+n] m1 = (f - x[i]) / n break a = [] country = get_all_countries(df) for z in country : case = get_confirmed_cases(df,z) for j in range(len(case)) : if case[j] > t and j + n < len(case) : f = case[j+n] m2 = (f - case[j]) / n a.append([m2,z]) break a.sort() ans = [] l = [] for i in range(len(a)) : f = abs(a[i][0] - m1) l.append([f,a[i][1]]) l.sort() i = 0 while l[k][0] == l[k+i][0] : i += 1 k += i-1 for j in range(k) : ans.append(l[j+1][1]) return ans #------------------------------------------------- |
all: cluster #30 (2)
# 6331017321 (2020-09-26 12:54) %diff = 7.69 100.0% # Prog-07: COVID-19 # 6331017321 พีรวิชญ์ ฐาปนวงศ์เวช # ... # ข้าพเจ้าเขียนโปรเเกรมนี้ด้วยตนเองโดยใช้ความรู้ในเรื่องfuncion def steepest_countries(df, t, n): all_countries = get_all_countries(df) vic_cntry = [] slope1 = [] for i in range(len(all_countries)) : get = get_confirmed_cases(df,all_countries[i]) for j in range(len(get)-n) : if get[j] > t: slope1.append((get[j+n]-get[j])/n) vic_cntry.append(all_countries[i]) break m = max(slope1) most_slope = [] for k in range(len(slope1)) : if slope1[k] == m : most_slope.append(vic_cntry[k]) return most_slope def most_similar_countries(df, country, t, n): all_countries = get_all_countries(df) all_countries.remove(country) vic_cntry = [] slope = [] gett = get_confirmed_cases(df,country) for i in range(len(gett)-n) : if gett[i] >t: d1 = (gett[i+n]-gett[i])/n break for j in range(len(all_countries)): get = get_confirmed_cases(df,all_countries[j]) for k in range(len(get)-n) : if get[k] > t: d2 = (get[k+n]-get[k])/n slope.append(abs(d1-d2)) vic_cntry.append(all_countries[j]) break m = min(slope) most_simil_slope = [] for l in range(len(slope)) : if slope[l] == m : most_simil_slope.append(vic_cntry[l]) return most_simil_slope def top_k_similar_countries(df, country, t, n, k): all_countries = get_all_countries(df) all_countries.remove(country) vic_cntry = [] slope = [] gett = get_confirmed_cases(df,country) for i in range(len(gett)-n) : if gett[i] >t: d1=(gett[i+n]-gett[i])/n break for j in range(len(all_countries)): get = get_confirmed_cases(df,all_countries[j]) for l in range(len(get)-n) : if get[l] > t: d2 = (get[l+n]-get[l])/n slope.append([abs(d1-d2),all_countries[j]]) break top_simil_slope = [] slope.sort() for a in range(k) : top_simil_slope.append(slope[a][1]) for e in range(k,len(slope)) : if slope[e][0] == slope[k-1][0] : top_simil_slope.append(slope[e][1]) return top_simil_slope #------------------------------------------------- | # 6331014421 (2020-09-27 19:58) %diff = 7.69 100.0% # Prog-07: COVID-19 # 6331014421 พชรพล จันทร์โต # ผมขอยืนยันว่าได้ออกแบบและปรับปรุงโปรแกรมนี้ด้วยความยากลำบากของตนเอง def steepest_countries(df, t, n): all_countries = get_all_countries(df) all_con=[] dis=[] for i in range(len(all_countries)): gcc = get_confirmed_cases(df,all_countries[i]) for k in range(len(gcc)-n): if gcc[k] > t: dis.append((gcc[k+n]-gcc[k])/n) all_con.append(all_countries[i]) break b = max(dis) ans=[] for i in range(len(dis)): if dis[i] == b: ans.append(all_con[i]) return ans def most_similar_countries(df, country, t, n): all_countries = get_all_countries(df) all_countries.remove(country) all_con=[] dis=[] gcc1 = get_confirmed_cases(df,country) for k in range(len(gcc1)-n): if gcc1[k] > t: d1 = (gcc1[k+n]-gcc1[k])/n break for i in range(len(all_countries)): gcc2 = get_confirmed_cases(df,all_countries[i]) for k in range(len(gcc2)-n): if gcc2[k] > t: d2 = (gcc2[k+n]-gcc2[k])/n dis.append(abs(d1-d2)) all_con.append(all_countries[i]) break b = min(dis) ans=[] for i in range(len(dis)): if dis[i] == b: ans.append(all_con[i]) return ans def top_k_similar_countries(df, country, t, n, k): all_countries = get_all_countries(df) all_countries.remove(country) dis=[] gcc1 = get_confirmed_cases(df,country) for kk in range(len(gcc1)-n): if gcc1[kk] > t: d1 = (gcc1[kk+n]-gcc1[kk])/n break for i in range(len(all_countries)): gcc2 = get_confirmed_cases(df,all_countries[i]) for l in range(len(gcc2)-n): if gcc2[l] > t: d2 = (gcc2[l+n]-gcc2[l])/n dis.append([abs(d1-d2),all_countries[i]]) break ans=[] dis.sort() for i in range(k): ans.append(dis[i][1]) for e in range(k,len(dis)): if dis[e][0] == dis[k-1][0]: ans.append(dis[e][1]) return ans #------------------------------------------------- |
all: cluster #31 (2)
# 6331423421 (2020-09-26 15:35) %diff = 9.91 70.0% # Prog-07: COVID-19 # 6331423421 : สิริกาญจน์ ทองระอา # เป็นงานที่ผ่านการใช้ความพยายามอย่างมากและได้รับการช่วยเหลือจาก TA # I hereby declare that I coded the SA part by myself. def steepest_countries(df, t, n): mc=[] x = get_all_countries(df) for i in x : y = get_confirmed_cases(df,i) j = 0 while j+n < len(y): if y[j]>= t: slope = (y[j+n]-y[j])/(n) mc.append([slope,i]) break j+=1 mc.sort() slope_max = mc[-1][0] g = [] for i in mc: if i[0] == slope_max : g.append(i[1]) return g def most_similar_countries(df, country, t, n): mc = [] x = get_all_countries(df) x.remove(country) p = get_confirmed_cases(df,country) j = 0 while j+n < len(p): if p[j]>= t: mco = (p[j+n]-p[j])/(n) break j+=1 for i in x : y = get_confirmed_cases(df,i) for j in range(len(y)): if j +n < len(y): if y[j]>= t: slope = (y[j+n]-y[j])/(n) mc.append([abs(mco-slope),i]) break mc.sort() slope_max = mc[0][0] g = [] for i in mc: if i[0] == slope_max : g.append(i[1]) return g def top_k_similar_countries(df, country, t, n, k): mc = [] x = get_all_countries(df) x.remove(country) p = get_confirmed_cases(df,country) j = 0 while j+n < len(p): if p[j]>= t: mco = (p[j+n]-p[j])/(n) break j+=1 for i in x: y = get_confirmed_cases(df,i) for j in range(len(y)): if j +n < len(y): if y[j]>= t: slope = (y[j+n]-y[j])/(n) mc.append([abs(mco-slope),i]) break mc.sort() slope_max = mc[0][0] g = [] for i in range(k): g.append(mc[i][1]) n = k while mc[k-1][0] == mc[n][0]: g.append(mc[n][1]) n += 1 return g #------------------------------------------------- | # 6331420521 (2020-09-27 11:53) %diff = 9.91 70.0% # Prog-07: COVID-19 # 6331420521 วริษา ทองโกมล # เป็นงานที่สร้างสรรค์แล้วทันเหตุการณ์ # ข้าพจ้าขอยืนยันว่าเป็นผู้เขียนโปรแกรมด้วยตัวเองโดยได้ความช่วยเหลือมาจากพี่TA ใน discord def steepest_countries(df, t, n): mc=[] a = get_all_countries(df)#a=รายชื่อประเทศทั้งหมด for i in a:#i ชื่อประเทศ b = get_confirmed_cases(df,i)#b=ตัวเลขผู้ป่วยแต่ละวัน for j in range(len(b)):#j อยู่ในตย b if j +n < len(b):#มีโอกาสที่จะเกิน if b[j]>= t: m = (b[j+n]-b[j])/(n)#j+n-j mc.append([m,i])#mcเป็นลิสความชันและประเทศ ขึั้นเป้นความชันประเทศ ความชันประเทศ break#ข้ามloop for j mc.sort() #mc[-1][0] #mcเป็นลิสของลิส mc[-1]เป็นลิส ละตัวสุดท้ายมันมี2 ตัวละเอาตัวแรก mcm = mc[-1][0]#ค่าความชัน ans = [] for i in mc: if i[0] == mcm: ans.append(i[1]) return ans def most_similar_countries(df, country, t, n): mc = [] a = get_all_countries(df)#a=รายชื่อประเทศทั้งหมดไม่นับประเทศcountry a.remove(country) p = get_confirmed_cases(df,country) for j in range(len(p)):#j อยู่ในตย b if j +n < len(p):#มีโอกาสที่จะเกิน if p[j]>= t: mco = (p[j+n]-p[j])/(n)#j+n-j break#ข้ามloop for j for i in a:#i ชื่อประเทศ b = get_confirmed_cases(df,i)#b=ตัวเลขผู้ป่วยแต่ละวัน for j in range(len(b)):#j อยู่ในตย b if j +n < len(b):#มีโอกาสที่จะเกิน if b[j]>= t: m = (b[j+n]-b[j])/(n)#j+n-j mc.append([abs(mco-m),i])#mcค่าหน้าเก็บผลต่าง ข้างหลังเก็บชื่อประเทศ break#ข้ามloop for j mc.sort() mcm = mc[0][0]#ค่าความชัน ans = [] for i in mc: if i[0] == mcm: ans.append(i[1]) return ans def top_k_similar_countries(df, country, t, n, k): mc = [] a = get_all_countries(df)#a=รายชื่อประเทศทั้งหมดไม่นับประเทศcountry a.remove(country) p = get_confirmed_cases(df,country) for j in range(len(p)):#j อยู่ในตย b if j +n < len(p):#มีโอกาสที่จะเกิน if p[j]>= t: mco = (p[j+n]-p[j])/(n)#j+n-j break#ข้ามloop for j for i in a:#i ชื่อประเทศ b = get_confirmed_cases(df,i)#b=ตัวเลขผู้ป่วยแต่ละวัน for j in range(len(b)):#j อยู่ในตย b if j +n < len(b):#มีโอกาสที่จะเกิน if b[j]>= t: m = (b[j+n]-b[j])/(n)#j+n-j mc.append([abs(mco-m),i])#mcค่าหน้าเก็บผลต่าง ข้างหลังเก็บชื่อประเทศ break#ข้ามloop for j mc.sort() mcm = mc[0][0]#ค่าความชัน ans = [] for i in range(k): ans.append(mc[i][1]) biw = k while mc[k-1][0] == mc[biw][0]: ans.append(mc[biw][1]) biw+=1 return ans #------------------------------------------------- |