blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
a0361f8dcf052c07cc19ebb342338b16359a6153
daniel-reich/ubiquitous-fiesta
/BuwHwPvt92yw574zB_22.py
109
3.78125
4
def list_of_multiples (num, length): m = [] for n in range(1,length+1): m.append(num*n) return m
25c2a52dc82f3627136508c0b0e837494f02a40b
daniel-reich/ubiquitous-fiesta
/wwN7EwvqXKCSxzyCE_12.py
187
3.765625
4
def reorder_digits(lst, direction): return [f(x, direction) for x in lst] ​ def f(x, d): s = ''.join(sorted(str(x))) if d == 'desc': s = s[::-1] return int(s)
5e3efa710ef91443d0a89dd658a02ca931006e01
daniel-reich/ubiquitous-fiesta
/stXWy2iufNhBo9sTW_9.py
180
3.53125
4
def valid_rondo(s): A = s[::2] ; sec = s[1::2] ; lets = "BCDEFGHIJKLMNOPQRSTUVWXYZ" if s[-1]!= 'A' or len(A)==1: return False return all(i=="A" for i in A) and sec in lets
4178ffc4a8e1d87d81b08a897a45dbda46a12660
daniel-reich/ubiquitous-fiesta
/646cCaFig6AP89YRo_9.py
341
3.671875
4
def fizz_buzz(maximum): lst = [] for i in range(1,maximum+1): lst.append(i) final = [] for i in lst: if i%3 == 0 and i%5 != 0: final.append("Fizz") elif i%5 == 0 and i%3 != 0: final.append("Buzz") elif i%5 == 0 and i%3 == 0: final.append("FizzBuzz") else: final.append(i) return final
7376e72466ebeb989eeecb0a6fc9bfd28923bbcd
daniel-reich/ubiquitous-fiesta
/mrrKngM2fqDEDMXtS_9.py
800
3.890625
4
def can_patch(bridge, planks): # Find holes holes = [] hole_length = 0 for i in range(len(bridge)-1): if bridge[i] == 1: hole_length = 0 pass elif bridge[i+1] == 1: hole_length += 1 holes.append(hole_length) elif i+1 == len(bridge)-1: hole_length += 2 holes.append(hole_length) else: hole_length += 1 ​ # Use Planks to fill holes for j in range(len(holes)): if holes == [] or planks == []: pass elif max(holes) <= max(planks)+1: holes.remove(max(holes)) planks.remove(max(planks)) else: pass # check remaining holes if holes ==[]: return True elif max(holes)>1: return False else: return True
c27fec624d927e3174c401cf3d2501a435004188
daniel-reich/ubiquitous-fiesta
/cGaTqHsPfR5H6YBuj_18.py
212
3.734375
4
def make_sandwich(i, f): new_list = [] for n in i: if n == f: new_list.append("bread") new_list.append(n) new_list.append("bread") else: new_list.append(n) return new_list
850e7580abf8f4ea2b76f6e5b49d46d3335bdaeb
daniel-reich/ubiquitous-fiesta
/bo4REhn9paGcFoMBs_18.py
232
3.875
4
def age_difference(ages): ages = sorted(ages) difference = ages[-1]-ages[-2] if difference == 0 : return "No age difference between spouses." elif difference == 1 : return "1 year" else: return "{} years".format(difference)
079171f09b0b5185e70cb046b25156368c9b7cd7
daniel-reich/ubiquitous-fiesta
/sEChDwmcHvWcMSmRM_21.py
206
3.71875
4
def find_the_falsehoods(lst): lst1 = [] for i in lst: if i == False or i == '' or i == [] or i == None or i == 0 or i == {} or i == (): lst1.append(i) else: continue return lst1
bb85ff936c4e6658ae784f8535016de8bb33e2ad
daniel-reich/ubiquitous-fiesta
/kEww9Hjds5Zkgjyfj_20.py
123
3.59375
4
def replace_next_largest(l): a = sorted(l) return [-1 if l[i]==a[-1] else a[a.index(l[i])+1] for i in range(len(l))]
48b564fa222622d9038dc4d2df0f3485c9176c96
daniel-reich/ubiquitous-fiesta
/sKXWQym3xg6uBLrpY_23.py
372
3.53125
4
def iqr(lst): slst = sorted(lst) med = median(lst) if(len(lst)%2 == 1): slst.remove(med) q3l = slst[int(len(lst)/2):] q1l = slst[:int(len(lst)/2)] return(median(q3l) - median(q1l)) def median(lst): slst = sorted(lst) mid = int(len(lst)/2) if(len(lst) % 2 == 0): return(slst[mid]/2 + slst[mid - 1]/2) else: return(slst[int(mid+0.5)])
c2483ff9d8f0df4f191dfddd6a242c2a53dc4077
daniel-reich/ubiquitous-fiesta
/L4HM6uMHDCnepz5HK_21.py
210
3.890625
4
def halloween(dt): ld = [i for i in dt.split('/')] for i in range(len(ld)): if ld[-1] == '31' and ld[-2] == '10': return 'Bonfire toffee' else: return 'toffee'
f1890ce8dd67325870d8a6693a7696e27bffc887
daniel-reich/ubiquitous-fiesta
/BeCSQjqycsY8JadFT_17.py
358
3.515625
4
def recur_index(txt): if txt == None: return {} return recur_index_tmp(txt, {}, 0) def recur_index_tmp(txt, dict, n): if len(txt) == n: return {} t = txt[n] if t in dict: dict[t].append(n) return {t: dict[txt[n]]} else: dict.setdefault(t, [n]) return recur_index_tmp(txt, dict, n+1)
c60f5e96cf1d288a6266f9dd20bec0712fe2ac40
daniel-reich/ubiquitous-fiesta
/GPibesdkGf433vHBX_9.py
422
3.8125
4
def is_prime(num): if num == 1: return False for i in range(2, num): if num % i == 0: return False return True def goldbach_conjecture(n): if n % 2 != 0 or n <= 2: return [] primes = [i for i in range(2, n) if is_prime(i)] reverse = primes[::-1] for num1 in primes: for num2 in reverse: if num1 + num2 == n: return [num1, num2] elif num1 + num2 < n: break
a3885537d9ea1d307a4bb35a74d8b67a03ceebe9
daniel-reich/ubiquitous-fiesta
/KT8ApJ2EJcLz4K3t2_17.py
85
3.5625
4
def two_digit_sum(n): sum=0 while(n>0): sum+=n%10 n=n//10 return sum
38d29e3e62f4fa0dc6e319af9cb3f64453fe7861
daniel-reich/ubiquitous-fiesta
/o7u9hqTW5AY3SoZgT_22.py
277
3.53125
4
import string def switcheroo(txt): l = txt.split() for i in range(len(l)): w = l[i].strip(string.punctuation) if "nts" in w[-3:]: l[i] = l[i].replace("nts", "nce") elif "nce" in w[-3:]: l[i] = l[i].replace("nce", "nts") return " ".join(l)
a95d875b10c76f58cee4e4bb82e217ce67319abb
daniel-reich/ubiquitous-fiesta
/MKpSfBCXargD35J8p_23.py
133
3.75
4
def journey_distance(n): km=0 if n>=3: n-=3 km+=1 while n!=0: n-=2 km+=1 return km
4ffa612b099371b22877a8a73f897ab9144ff9ba
daniel-reich/ubiquitous-fiesta
/xXenZR2hWFE7Jb9vR_20.py
259
3.8125
4
def is_isomorphic(s, t): return morph(s) == morph(t) ​ def morph(text): result = [] chars = {} cur_val = 0 for char in text: if char not in chars: chars[char] = cur_val cur_val += 1 result.append(chars[char]) return result
aa0c70e86c7db7a3bafd72c59a7a4591c892f417
daniel-reich/ubiquitous-fiesta
/Kh7Bm9X7Q4rYB8uT7_14.py
222
4.0625
4
def is_vowel_sandwich(s): vowels = ['a','e','i','o','u'] if len(s) == 3: if s[0] not in vowels and s[1] in vowels and s[2] not in vowels : return True else: return False else: return False
950ab87ddb8b343c4e16833da29c7e940052db71
daniel-reich/ubiquitous-fiesta
/YcqAY72nZNPtvofuJ_12.py
206
3.546875
4
def quad_sequence(lst): length = len(lst) n = (lst[2]-lst[1])-(lst[1]-lst[0]) while len(lst)<length*2: diff = lst[-1]-lst[-2] diff+=n lst.append(lst[-1]+diff) return lst[len(lst)//2:]
e640458d3bbd89460e441898d596d9d2321a8994
daniel-reich/ubiquitous-fiesta
/pimnBHXJNtQffq4Cf_11.py
155
3.765625
4
def mapping(letters): print(type(letters), letters) new_dict = {} for item in letters: new_dict[item] = item.upper() return new_dict
9a68baa4df2c97cc83f35f6a8888e624a690c214
daniel-reich/ubiquitous-fiesta
/FF6kYPHdAcJnoosr5_15.py
68
3.703125
4
def factorial(num): return num*factorial(num-1) if num>0 else 1
d015ce25af621d334f2a1f1c0915ecd8c4aa30ca
daniel-reich/ubiquitous-fiesta
/cXfcK7iXpuZ67taSh_14.py
128
3.578125
4
def mystery_func(txt): s = "" for i in range(0, len(txt)-1, 2): s += txt[i] * int(txt[int(i+1)]) return s
47c078f5bddca525061147b45ac56eca801614c4
daniel-reich/ubiquitous-fiesta
/jjPGM3a22AgzcBFCx_15.py
242
3.703125
4
def decrypt(lst): for num in range(len(lst)): lst[num] += 63 # return lst lst.sort() # print(lst) for char in range(len(lst)): if lst[char] + 1 != lst[char + 1]: return chr(lst[char + 1])
b0824077c917fe8a428d19029634776906747baf
daniel-reich/ubiquitous-fiesta
/zJSF5EfPe69e9sJAc_3.py
157
3.5625
4
def censor_string(txt, lst, char): words = txt.split(" ") newtxt = [w if w not in lst else len(w)*char for w in words] return ' '.join(newtxt)
17a7d63af0b062c408845784cd8d71991c705513
daniel-reich/ubiquitous-fiesta
/5q3FdCvrXtwQRoGmP_14.py
181
3.5
4
def count_towers(towers): lst1 = [] for i in range(len(towers)): for j in range(len(towers[i])): lst1.append(towers[i][j].split(" ").count("##")) return max(lst1)
cab798b05f073f9c641309064558979320935c6f
daniel-reich/ubiquitous-fiesta
/2hvruws6kgiKj98Rv_2.py
111
3.703125
4
def to_scottish_screaming(txt): return ''.join([c if c not in 'aeiouAEIOU' else 'E' for c in txt]).upper()
f00bf3ec375aea0183852963ab1a399b8cf69128
daniel-reich/ubiquitous-fiesta
/sLq6GDa4NzDWRD9hY_19.py
137
3.671875
4
def count(n): digits, number = 0, abs(n) while number > 0: number //= 10 digits += 1 return 1 if abs(n) < 10 else digits
591696f5abe896a8a67ac583787c8ee84414d693
daniel-reich/ubiquitous-fiesta
/Gmt2QbusvNdzfiFWu_2.py
302
3.59375
4
is_prime = lambda n: n > 1 and (n == 2 or (n%2 != 0 and all(n%ii for ii in range(3, int(n**0.5 + 1), 2)))); ​ def sum_prime(lst): res = [(p, sum(v for v in lst if v % p == 0)) for p in range(2, max(lst) + 1) if is_prime(p)] return ''.join(str(v) for v in res if v[1] > 0).replace(',', '')
fd114063f8cc573ff2672154c2d4484c8c5eee0c
daniel-reich/ubiquitous-fiesta
/Hs7YDjZALCEPRPD6Z_14.py
164
3.640625
4
def count_uppercase(lst): b=[] count=0 for i in lst: for x in i: if x.isupper(): count=count+1 return (count)
e5cff3f1e24b6e6bbdd326f1816cfba383d5ede7
daniel-reich/ubiquitous-fiesta
/Box2A6Rb94ao8wAye_11.py
305
3.53125
4
def leader(lst): highest_number = max(lst) leader = lst.index(highest_number) lst2 = lst[leader:] result = [] for i,v in enumerate(lst2): if i == 0 or i == (len(lst2) -1): result.append(v) elif i < (len(lst2) -1): if v > lst2[i+1]: result.append(v) return result
8d9c800483cbc4365d8ffc5965d1357414779fb1
daniel-reich/ubiquitous-fiesta
/smLmHK89zNoeaDSZp_22.py
535
3.90625
4
class Country: ​ def __init__(self, name, population, area): self.name = name self.population = population self.area = area self.is_big = False # implement self.is_big if (population > 250000000) or (area > 3000000): self.is_big = True def compare_pd(self, other): # code if self.population/self.area > other.population/other.area: return self.name + " has a larger population density than " + other.name return self.name + " has a smaller population density than " + other.name
15f12c2a558eaf21c73d7d06890d256c94d5a48b
daniel-reich/ubiquitous-fiesta
/sLq6GDa4NzDWRD9hY_20.py
182
3.546875
4
import math def count(n): if n>0: digits = int(math.log10(n))+1 elif n == 0: digits = 1 else: digits = int(math.log10(-n))+1 return digits
0514f08ff94349553ddfa3cc2c4556693f1daddb
daniel-reich/ubiquitous-fiesta
/4QLMtW9tzMcvG7Cxa_18.py
203
3.609375
4
def resistance_calculator(resistors): s = sum(resistors) if s == 0: return [0, 0] return [0, s] if 0 in resistors else [round(1. / sum([1. / r for r in resistors]),2), round(s, 2)]
9607e758b82fa3f6e8f86a591f08a3078cc57e8e
daniel-reich/ubiquitous-fiesta
/uHcc8Gg4jwSax5qd4_19.py
1,081
3.53125
4
class Minecart: ​ def __init__(self, v=0): self.v = v ​ if self.v <= 0: self.im = False else: self.im = True def add_speed(self, speed): if self.im == False: self.im = True ​ if self.v + speed <= 8 and self.v + speed > 0: self.v += speed elif self.v + speed <= 0: self.v = 0 self.im = False else: self.v = 8 ​ def mine_run(tracks): speed = 0 count = 0 for i in tracks: ​ if i == "-->" : if speed <= 8 : speed += 2.67 count += 1 elif i == "<--" : if speed > 0: speed -= 2.67 count += 1 elif i == "<-->" : count += 1 elif i == "---" : if speed > 0: speed -= 1 count += 1 if speed == 0: if count == len (tracks): return True break else : return count-1 break
e7006fa1f3be91de540bba8dbf8e0f6789c6b095
daniel-reich/ubiquitous-fiesta
/XZQw3zto7keDWPa5v_23.py
329
3.5
4
def day_amount(month, year): if month == 2: if year % 4 == 0: if year % 100 == 0 and year % 400 != 0: return 28 elif year % 400 == 0: return 29 elif year % 100 != 0: return 29 else: return 28 elif month in [1, 3, 5, 7, 8, 10, 12]: return 31 else: return 30
42e256c473cea0f98172de2bcb30a04e9016afe1
daniel-reich/ubiquitous-fiesta
/mJB9CYyGsADLQPjnx_17.py
149
3.578125
4
def first_non_repeated_character(txt): return False if not len(txt) or len(set(txt)) == len(txt)/2 else [i for i in txt if txt.count(i) == 1][0]
df17bd75bf0a04a9603825c266803d8d3fc3626f
daniel-reich/ubiquitous-fiesta
/88RHBqSA84yT3fdLM_13.py
175
3.59375
4
def inatorInator(word): if word.lower()[-1] not in 'aieou': return '{}inator {}000'.format(word,len(word)) else: return '{}-inator {}000'.format(word,len(word))
8ee8394d34a37ec05dc4ce5c52224614d286f5d9
daniel-reich/ubiquitous-fiesta
/jzCGNwLpmrHQKmtyJ_12.py
100
3.625
4
def parity_analysis(num): nu = sum([int(i) for i in str(num)]) return int(num%2) == int(nu%2)
f22e10a957f686379dfed4a0d30d7d43b42a1fe5
daniel-reich/ubiquitous-fiesta
/kozqCJFi4de2JnR26_9.py
329
3.640625
4
def fib_str(n, txt): Sequence = [] Sequence.append(txt[-2]) Sequence.append(txt[-1]) String = txt[0] + ", " + txt[1] Steps = 2 while (Steps < n): New = Sequence[-1] + Sequence[-2] Sequence.append(New) String = String + ", " + New Sequence = Sequence[1:] Steps += 1 return String
61c6876db6b9529a8364e926cc8652d16ec5a5bc
daniel-reich/ubiquitous-fiesta
/ET2voBkuSPLb3mFSD_20.py
99
3.640625
4
def sum_every_nth(numbers, n): return sum(numbers[x] for x in range(n - 1, len(numbers), n))
83f20166ddc64152033275056e10cbea37df77dc
daniel-reich/ubiquitous-fiesta
/WixXhsdqcNHe3vTn3_14.py
277
3.5
4
def how_bad(n): result = [] pop = bin(n).count('1') if pop % 2: result.append('Odious') else: result.append('Evil') if pop == 1: return result for i in range(2,pop): if pop % i == 0: break else: result.append('Pernicious') return result
ea99f2bf73c46d40e8a123001ac6269a3b424c2d
daniel-reich/ubiquitous-fiesta
/kdhgEC2ECXAfoXWQP_2.py
203
3.609375
4
def transpose_matrix(mtx): output='' i=0 while i < len(mtx[0]): for k in range(0,len(mtx)): output+=mtx[k][i] if i != len(mtx[0])-1 or k != len(mtx)-1: output+=' ' i+=1 return output
22ef354e85facdbbab2fdd4950614f87ecd340d4
daniel-reich/ubiquitous-fiesta
/k9usvZ8wfty4HwqX2_19.py
425
3.75
4
def is_prime(n): if n < 4 or n%2 == 0: return n == 2 or n == 3 for i in range(3, 1+int(n**0.5), 2): if n%i == 0: return False return True ​ def cuban_prime(num): if is_prime(num): y, p = 1, 0 while p < num: p = (y+1)**3 - y**3 if p == num: return str(num) + " is cuban prime" y += 1 return str(num) + " is not cuban prime"
7d1aa73f11f9a57e4d2bdac9e2ab50b14a9a310f
daniel-reich/ubiquitous-fiesta
/JsisSTswerLQqJ73X_16.py
118
3.546875
4
def priority_sort(l, s): a=sorted([i for i in l if i in s]) b=sorted([i for i in l if i not in s]) return a+b
03ada7019f796384ce454d24ca9ab1aba1051205
daniel-reich/ubiquitous-fiesta
/TCQkKzgi8FFYYG4kR_0.py
110
3.578125
4
def camel_to_snake(s): return ''.join('_'+ i.lower() if i == i.upper() and i.isalpha() else i for i in s)
0dd822c15825f86cd582b29eccad5babbac871d6
daniel-reich/ubiquitous-fiesta
/LtwvpqeRY2gQcMQyy_24.py
1,359
3.609375
4
def sig_figs(num): if float(num) == 0: return 0 if len(str(num)) == 1: return 1 cnt = 0 if str(num)[0] == "-": str_num = str(num[1:]) else: str_num = str(num) if "." not in str_num: if str_num[0] != "0": cnt += 1 if str_num[-1] != "0": cnt += 1 for i in range(1, len(str_num)-1): if str_num[i] != "0": cnt += 1 elif str_num[i] == "0" and any(str_num[j] != "0" for j in range(0, i)) and any(str_num[j] != "0" for j in range(i + 1, len(str_num)-1)): cnt += 1 print(str_num[i]) elif "." in str_num: if str_num[0] != "0" and str_num[0] != ".": cnt += 1 for i in range(1, len(str_num)-1): if str_num[i] != "0" and str_num[i] != ".": cnt += 1 elif str_num[i] == "0" and not all(str_num[j] == "." or str_num[j] == "0" for j in range(0, i)) and \ any(str_num[j].isdigit() and str_num[j] != "0" for j in range(i+1, len(str_num)-1)): cnt += 1 elif str_num[i] == "0" and all(str_num[j] == "0" for j in range(i+1, len(str_num)) if str_num[j] != "."): print(str_num[i]) cnt += 1 if str_num[-1] != ".": cnt += 1 return cnt
8415c238a5fadf3bf70af4a092dd78de84df50cc
daniel-reich/ubiquitous-fiesta
/Rn3g3hokznLu8ZtDP_1.py
387
3.5
4
def increment_string(txt): numlst = [] end = 0 for i in range(len(txt) - 1, 0, -1): try: val = int(txt[i]) numlst.append(str(val)) except ValueError: end = i + 1 break txt = txt[:end] numlst.reverse() numlen = len(numlst) num = str(1 if numlen == 0 else int("".join(numlst)) + 1) num = "0" * (numlen - len(num)) + num return txt + num
f5588837d397714b51c0d2950b93d2a9f28457ef
daniel-reich/ubiquitous-fiesta
/4afgmFpLP6CpwtRMY_17.py
552
3.75
4
def sudoku_validator(x): ​ def checker(lst): return len(set(lst))==len(lst) #check the rows rowChk = [] rowChk = [checker(n) for n in x] #check the columns colChk = [] for c in range(9): col = [row[c] for row in x] colChk.append(checker(col)) #check the 3X3 boxes boxChk = [] for j in range(0,9,3): for i in range(0,9,3): box = [x[r][c] for c in range(0+j,3+j) for r in range(0+i,3+i)] boxChk.append(checker(box)) return all(rowChk)==True and all(colChk)==True and all(boxChk)==True
09956f1eacc582b2f9334ce5fa4f198679b72801
daniel-reich/ubiquitous-fiesta
/wuQWimjDwkpnd4xJL_15.py
193
3.53125
4
def balanced(lst): a = int(len(lst) / 2) aa = lst[ : a] bb = lst[a : ] if sum(aa) == sum(bb): return lst elif sum(bb) > sum(aa) : return bb + bb else: return aa + aa
790193297b15cc522393ce0ea4a00c10492076ed
daniel-reich/ubiquitous-fiesta
/ojNRprg7fKpWJpj47_18.py
312
3.578125
4
def shift_sentence(txt): first_letter = [a[0] for a in txt.split(' ')] first_letter_new_index = list(first_letter[-1]) + first_letter[0:len(first_letter)-1] other_letters = [a[1:] for a in txt.split(' ')] return ' '.join([''.join(a) for a in list(zip(first_letter_new_index, other_letters))])
22d96729f2138578b5448bba250a66a675670ba7
daniel-reich/ubiquitous-fiesta
/sZkMrkgnRN3z4CxxB_11.py
310
3.859375
4
class Rectangle: def __init__(self,x,y,width,height): self.x = x self.y = y self.width = width self.height = height ​ def intersecting(rect1, rect2): if (rect1.x + rect1.width) >= rect2.x and (rect1.y + rect1.height) >= rect2.y: return True return False
cdee0494bb14d9b25e6ddcab297862f61efa93c2
daniel-reich/ubiquitous-fiesta
/RvCEzuqacuBA94ZfP_3.py
162
3.609375
4
def generate_hashtag(txt): lst = ''.join([i.capitalize() for i in txt.split(' ') if i != '']) return "#{}".format(lst) if lst and len(lst) < 140 else False
07c0fa053732d37dff84e605e74d22c8f1e98fee
daniel-reich/ubiquitous-fiesta
/bd2fLqAxHfGTx86Qx_20.py
190
3.59375
4
def can_complete(initial, word): i = 0 for c in word: if c == initial[i]: i += 1 if i == len(initial): return True return False
fe35c0f5ca606fd39188d6fa2a1bef7803aadff4
daniel-reich/ubiquitous-fiesta
/bYDPYX9ajWC6PNGCp_11.py
263
3.671875
4
def track_robot(*steps): x = 0 y = 0 steps = list(steps) for i in range(0,len(steps)): if i % 4 == 0: y += steps[i] elif i % 4 == 1: x += steps[i] elif i % 4 == 2: y -= steps[i] else: x -= steps[i] return [x,y]
91fd586cc0cbce0a7877a078cedf4a34bdc4f169
daniel-reich/ubiquitous-fiesta
/FeNrBCG9rSdNeJTuX_12.py
298
3.515625
4
def max_possible(n1, n2): digs = [int(i) for i in str(n1)] digs2 = [int(i) for i in str(n2)] for n in range(len(digs)): if len(digs2)>0: m = max(digs2) if m > digs[n]: digs[n] = m digs2.remove(m) s = '' for dig in digs: s += str(dig) return int(s)
4765a42b254fc493a0ecf2dbe54dc0339a419f58
daniel-reich/ubiquitous-fiesta
/EFwDXErjDywXp56WG_5.py
80
3.53125
4
def is_in_order(txt): return True if txt == "".join(sorted(txt)) else False
3c20ad495d8307fcae29e011e28cf57e6f768762
daniel-reich/ubiquitous-fiesta
/dKLJ4uvssAJwRDtCo_6.py
659
3.84375
4
def vending_machine(products, money, product_number): if 1 > product_number < 9: return "Enter a valid product number" elif products[product_number - 1]["price"] > money: return "Not enough money for this product" product = products[product_number - 1]["name"] price = products[product_number - 1]["price"] changes = [500, 200, 100, 50, 20, 10] change = [] while sum(change) < (money - price): for i in range(len(changes)): if changes[i] + sum(change) > (money - price): changes.pop(i) break else: change.append(changes[i]) break return {"product": product, "change": change}
12b31dc55568efb606ca7fa185318fb9333a061c
daniel-reich/ubiquitous-fiesta
/GWBvmSJdciGAksuwS_2.py
122
3.75
4
def find_letters(word): a=[] for num in word: if num not in a and word.count(num)==1: a+=[num] return a
e99d9d3e492fe8dd10e335f5b8c03a66ee804e56
daniel-reich/ubiquitous-fiesta
/dZhxErwMfyWymXbPN_14.py
124
3.5625
4
def hangman(phrase, lst): return ''.join(x if x.lower() in ''.join(lst)+' ,.!' or x.isdigit() else '-' for x in phrase)
ff046964d826f50b8f5d32622f06ff24556d8dae
daniel-reich/ubiquitous-fiesta
/hQRuQguN4bKyM2gik_23.py
315
3.515625
4
def simple_check(a, b): count = 0 if max(a,b) % min(a,b) == 0: count += 1 else: count += 0 while a and b: a = a-1 b = b-1 if min(a,b) == 0: break else: if max(a,b) % min(a,b) == 0: count += 1 return count
213f4f5a3f6d133c4eb4fcfe161ee3b3daa003b3
daniel-reich/ubiquitous-fiesta
/mPpcATtDMYiegZ3Jw_10.py
156
3.5625
4
def right_triangle(*args): if any( n<=0 for n in args ): return False else: args = sorted(args); return args[0]**2 + args[1]**2 == args[2]**2
282ab3720a31056f283a43f113b6e9f39d7207a5
daniel-reich/ubiquitous-fiesta
/vfuZia9ufckGzhGZh_22.py
268
3.546875
4
def seq_level(lst): difference = lambda x: [x[foo + 1] - x[foo] for foo in range(len(x) - 1)] return_lst = ["Linear", "Quadratic", "Cubic"] for bar in range(3): lst = difference(lst) if len(set(lst)) == 1: return return_lst[bar] return None
550328bf522431e5320a6eab98e6574aaa00755f
daniel-reich/ubiquitous-fiesta
/MiCMj8HvevYzGSb8J_21.py
154
3.578125
4
def fibo_word(n): out = ['b', 'a'] for _ in range(n-2): out.append(out[-1] + out[-2]) return ', '.join(out) if n > 1 else 'invalid'
59a155c20e8d1835d0b378a03ec01e4c12d3fdbb
daniel-reich/ubiquitous-fiesta
/yXZhG7zq6dWhWhirt_21.py
186
3.75
4
def filter_primes(num): return [x for x in num if is_prime(x)] def is_prime(n): if n < 2: return False for x in range(2,n//2+1): if n % x == 0: return False return True
35425c028b8689b4ef034b87b5e6cc821d40d545
daniel-reich/ubiquitous-fiesta
/nqvuJue4TevAERzCs_15.py
159
3.78125
4
import re def has_digit(txt): tester = re.findall("[0-9]", txt) tester = ''.join(tester) if tester.isalnum(): return True else: return False
ba9ee2c177cb34510aa900a41605306f354e4ac1
daniel-reich/ubiquitous-fiesta
/gPJTSqmJ4qQPxRg5a_5.py
127
3.78125
4
def func(num): string=str(num) count=0 for char in string: count+=int(char) return count-len(string)*len(string)
40be5d70d680ab5a490776b7ad743305169f8d38
daniel-reich/ubiquitous-fiesta
/dFz2PDjQkXZ9FhEaz_16.py
334
3.90625
4
def letter_check(lst): for i in range (len(lst)): if i==1: STRING2 = lst[1] STRING1 = lst[0] for elem in STRING2: if elem not in STRING1 and elem not in STRING1.lower(): print('NO') return False print("YES") return True
66399d188336947333042261bec2fe32c369891a
daniel-reich/ubiquitous-fiesta
/YDgtdP69Mn9pC73xN_19.py
824
3.53125
4
def num_grid(lst): copy = [] copy = lst counter = 0 for x in range(len(lst)): for y in range(len(lst[0])): print("x = %i, y = %i" % (x,y)) if lst[x][y] == "-": for addx in range(-1, 2, 1): if x + addx not in range(0, len(lst)): continue for addy in range(-1, 2, 1): if addx == 0 and addy == 0: continue if y + addy not in range(0, len(lst[0])): continue print(x+addx, y+addy) if lst[x + addx][y + addy] == "#": counter += 1 copy[x][y] = str(counter) counter = 0 return copy
426855db285d8d9a40097d939a8254afef0b175c
daniel-reich/ubiquitous-fiesta
/egHeSWSjHTgzMysBX_19.py
166
3.640625
4
from fractions import Fraction def half_a_fraction(fract): x = Fraction(fract) y = x * Fraction(1,2) z = '{}/{}'.format(y.numerator,y.denominator) return z
ebbde0130567ec5429be57fc30c93a471725d939
daniel-reich/ubiquitous-fiesta
/BfSj2nBc33aCQrbSg_21.py
637
3.765625
4
def isprime(a): if a == 1: return False for i in range(2, int((a**0.5) + 1)): if a % i == 0: return False return True ​ ​ def truncatable(n): s = str(n) if "0" in s: return False l, r = True, True x, y = s, s for i in range(len(s)): if not isprime(int(x)): l = False x = x[1:] if not isprime(int(y)): r = False y = y[:-1] if r == True and l == True or len(s) == 1: return "both" elif r == True: return "right" elif l == True: return "left" else: return False
52cf2164fb7988fef7e2f4b9a5fcc438054cefe7
daniel-reich/ubiquitous-fiesta
/hv572GaPtbqwhJpTb_15.py
328
3.640625
4
def elasticize(word): fin = '' if len(word) % 2 == 1: mults = [a+1 for a in list(range(len(word)//2))+list(range(len(word)//2,-1,-1))] else: mults = [a+1 for a in list(range(len(word)//2))] + sorted([a+1 for a in list(range(len(word)//2))],reverse=True) for a,b in zip(word,mults): fin += a*b return fin
d6b34b1a7c8dcf5b30a7e750962f06991e263836
daniel-reich/ubiquitous-fiesta
/rPnq2ugsM7zsWr3Pf_0.py
255
3.96875
4
def find_all_digits(nums): digits = list('0123456789') for n in nums: for d in str(n): if d in digits: digits.remove(d) if not digits: return n return 'Missing digits!'
d2664eae7086f5f6d6d1b30ac0a90997a17a3414
daniel-reich/ubiquitous-fiesta
/BokhFunYBvsvHEjfx_8.py
92
3.5625
4
def seven_boom(lst): return "Boom!" if "7" in str(lst) else "there is no 7 in the list"
7465ed1d0e7fa0b3f3518ad92a861c45842e9f4e
daniel-reich/ubiquitous-fiesta
/XgJ3L3GF7o2dEaPAW_2.py
138
3.515625
4
def shared_letters(a, b): lst =[] for i in a.lower(): if i in b.lower(): lst.append(i) return ''.join(sorted(set(lst)))
24c50a37b11a032612523ee7903eb810446ce52e
daniel-reich/ubiquitous-fiesta
/ksZrMdraPqHjvbaE6_12.py
186
3.859375
4
def largest_even(l): def find(l): if len(l)==1:return l[0] r=find(l[1:]) return r if not r%2 or (r>l[0] and not r%2) else l[0] r=find(l) return r if not r%2 else -1
99dd29c266e09714a3180540a59e419c088713a3
daniel-reich/ubiquitous-fiesta
/Es985FEDzEQ2tkM75_14.py
207
3.875
4
def caesar_cipher(string, key): alphabet = "abcdefghijklmnopqrstuvwxyz" return "".join([alphabet[(alphabet.index(letter) + key)%len(alphabet)] if letter.isalpha() else letter for letter in string ]);
d57661f62ba5b2328d353c3df3d204cebb7739bc
daniel-reich/ubiquitous-fiesta
/7AQgJookgCdbom2Zd_11.py
209
3.953125
4
def pig_latin(txt): vowels = ['a','e','i','o','u'] return ' '.join((word[1:] + word[:1] + 'ay') if word[0].lower() not in vowels else (word + 'way') for word in txt[:-1].split()).capitalize() + txt[-1:]
c86fe0daf9f5b1bd3e6e1fc7a6247b313a0a1462
daniel-reich/ubiquitous-fiesta
/dy3WWJr34gSGRPLee_14.py
295
3.640625
4
def makeBox(n): if n == 1: return ["#"] topbot, middle, box = "", "", [] for i in range(n): topbot += "#" middle += "#" for j in range(n-2): middle += " " middle += "#" box = [topbot] for k in range(n-2): box += [middle] box += [topbot] return box
553d946a82c160f80ad9469c36cd3ed0d1367144
daniel-reich/ubiquitous-fiesta
/q3JMk2yqXfNyHWE9c_7.py
100
3.703125
4
def double_letters(word): return (len([a for a in range(len(word)-1) if word[a]==word[a+1]])>0)
1281b55c57c2f6f6a2a4c40bbcd64de0e1836de2
daniel-reich/ubiquitous-fiesta
/oCe79PHB7yoqkbNYb_16.py
207
3.703125
4
def break_point(num): num = [int(i) for i in str(num)] if len(num) == 2: return True if num[0] == num[1] else False else: return any([sum(num[:i]) == sum(num[i:]) for i in range(len(num))])
0cb9ca98fbc0ee72d509a6b7009bd786d4a0866c
daniel-reich/ubiquitous-fiesta
/5pYkwf948KBQ3pNwz_9.py
790
3.578125
4
import collections import unicodedata import itertools ​ ​ def _segment_into_words(text): return [ ''.join(elements).lower() for category, elements in itertools.groupby( text, key=lambda character: unicodedata.category(character)[0] ) if category == 'L' ] ​ def most_common_words(text, n): words = _segment_into_words(text) counts = collections.Counter(words) ​ try: count_threshold = sorted(counts.values(), reverse=True)[n] except IndexError: count_threshold = 0 ​ word_preference = sorted( counts.keys(), key=lambda word: (-counts[word], words.index(word)), ) ​ return { word: counts[word] for word in word_preference[:n] }
08d6fc6c3e7752379a0091b7a419c57ccd6e9205
daniel-reich/ubiquitous-fiesta
/QNvtMEBzxz5DvyXTe_3.py
821
3.59375
4
def strong_password(passwd): numbers = "0123456789" lower_case = "abcdefghijklmnopqrstuvwxyz" upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" special_characters = "!@#$%^&*()-+" length = len(passwd) digit_flag = 0 lower_flag = 0 upper_flag = 0 special_flag = 0 for e in passwd: if e in numbers: digit_flag = 1 elif e in lower_case: lower_flag = 1 elif e in upper_case: upper_flag = 1 elif e in special_characters: special_flag = 1 total_flags = digit_flag+lower_flag+upper_flag+special_flag more_flags = 4 -total_flags if more_flags + length >=6: num_char_needed = more_flags else: num_char_needed = more_flags + (6 - (more_flags + length)) return num_char_needed
474d60e62571395224cd80dd969d236fc924dd51
daniel-reich/ubiquitous-fiesta
/NybeH5L7wFPYeynCn_24.py
111
3.6875
4
def three_letter_collection(s): return sorted([s[i:i+3] for i in range(len(s)-2)]) if len(s) > 2 else []
bfb9586d176f69ae88835c8e737de081cd7af032
daniel-reich/ubiquitous-fiesta
/veCWQHJNgeZQCNbdY_12.py
95
3.671875
4
def root_digit(n): return n if len(str(n))==1 else root_digit(sum(int(i) for i in str(n)))
a812336ec44b1bb9bdc545bf22a2689307eceb34
daniel-reich/ubiquitous-fiesta
/XPCqS7GYYouXg5ut9_22.py
177
3.765625
4
import math def simplify_sqrt(n): square_factors = [r for r in range(1, int(math.sqrt(n)) + 1) if n % r**2 == 0] return square_factors[-1], n // square_factors[-1]**2
7c7798f71e791fd3a2891d1eb087d59dcd457540
daniel-reich/ubiquitous-fiesta
/mJB9CYyGsADLQPjnx_0.py
113
3.53125
4
def first_non_repeated_character(txt): for c in txt: if txt.count(c) == 1: return c return False
0bae7cd5acb5616c06b0e333a301d9a2772f3c73
daniel-reich/ubiquitous-fiesta
/wEDHiAcALvS2KuRBJ_23.py
1,036
3.625
4
class StackCalc: ​ def __init__(self): self.stack = [] self.inp_parsed = [] self.invalid = False def run(self, instructions): inp_parsed = instructions.split(" ") for el in inp_parsed: if el.isnumeric(): self.stack.append(int(el)) elif el in ["+", "-", "*", "/"]: num1 = self.stack.pop() num2 = self.stack.pop() if el == "+": self.stack.append(num1 + num2) elif el == "-": self.stack.append(num1 - num2) elif el == "*": self.stack.append(num1 * num2) else: self.stack.append(num1 / num2) elif el == "DUP": self.stack.append(self.stack[-1]) elif el == "POP": if self.stack: self.stack.pop() elif el.isalpha(): self.stack = [el] self.invalid = True break def getValue(self): if self.stack: if self.invalid: return "Invalid instruction: {}".format(self.stack[0]) return self.stack.pop() return 0
122af8672dedd8ddf65e4dda299917ea56c49522
daniel-reich/ubiquitous-fiesta
/uPAmqwiHmvwpwoBom_21.py
836
3.765625
4
def convert_to_roman(num): retval = '' while num >= 1000: retval = retval + 'M' num -= 1000 while num >= 900: retval = retval + 'CM' num -= 900 while num >= 500: retval = retval + 'D' num -= 500 while num >= 400: retval = retval + 'CD' num -= 400 while num >= 100: retval = retval + 'C' num -= 100 while num >= 90: retval = retval + 'XC' num -= 90 while num >= 50: retval = retval + 'L' num -= 50 while num >= 40: retval = retval + 'XL' num -= 40 while num >= 10: retval = retval + 'X' num -= 10 while num >= 9: retval = retval + 'IX' num -= 9 while num >= 5: retval = retval + 'V' num -= 5 while num >= 4: retval = retval + 'IV' num -= 4 while num >= 1: retval = retval + 'I' num -= 1 return retval
2ba1d83da5b4d47f6d6e478c0d5bcbd45cee215d
daniel-reich/ubiquitous-fiesta
/JsisSTswerLQqJ73X_23.py
146
3.6875
4
def priority_sort(lst, s): flst = sorted([i for i in lst if i not in s]) fst = sorted([i for i in lst if i in s]) return fst + flst
6dac780af9f9f9e9374227e3804cf0a673dd5671
daniel-reich/ubiquitous-fiesta
/QuxCNBLcGJReCawjz_11.py
573
3.8125
4
def palindrome_type(n): lst = [int(i) for i in list(str(n))] decimal = True while len(lst) > 1: if lst[0] != lst[-1]: decimal = False break lst.pop(0) lst.pop(-1) lst = list(bin(n)) lst.pop(0) lst.pop(0) lst = [int(i) for i in lst] binary = True while len(lst) > 1: if lst[0] != lst[-1]: binary = False lst.pop(0) lst.pop(-1) if decimal and binary: return 'Decimal and binary.' elif decimal: return 'Decimal only.' elif binary: return 'Binary only.' else: return 'Neither!'
95482dc11b44987806a4a8244c6b42daffedff0f
daniel-reich/ubiquitous-fiesta
/fTXXkQ7bfuQDjgNyH_12.py
361
3.59375
4
import re def day_of_year(date): nums = re.findall(r'\d+',date) m,d,y = int(nums[0]),int(nums[1]),int(nums[2]) days = [31,28,31,30,31,30,31,31,30,31,30,31] if m == 1: return d if m == 2: return 31 + d if y % 4 == 0: if y % 100 == 0: if y % 400 == 0: days[1] = 29 else: days[1] = 29 return sum(days[:m-1]) + d
29df65562761a36da75c1d08b79140a019162e5f
daniel-reich/ubiquitous-fiesta
/pEozhEet5c8aFJdso_2.py
466
3.59375
4
def all_about_strings(txt): middle = '' if len(txt) % 2 == 0: middle += txt[int((len(txt) / 2) - 1)] middle += txt[int((len(txt) / 2))] else: middle = txt[round(int((len(txt) / 2)))] search = txt[1] for i in range(2,len(txt)): if txt[i] == search: search = i if type(search) == str or type(search) == chr: search = "not found" else: search = "@ index " + str(search) return [len(txt), txt[0], txt[-1], middle, search]
54b8347568ea1cce278ec1a59c5c330a9fdb44a2
daniel-reich/ubiquitous-fiesta
/g3BokS6KZgyYT8Hjm_10.py
76
3.609375
4
def shift_to_left(x, y): return shift_to_left(2 * x, y - 1) if y else x
adb315567ae447412ae29b9e129fbf6cd23e6103
daniel-reich/ubiquitous-fiesta
/dHGpjWHJ265BCthiM_24.py
288
3.578125
4
import datetime def dayNum(date): return datetime.datetime.strptime(date, "%Y-%m-%d").date().toordinal() def current_streak(today, lst): dates = set([dayNum(d["date"]) for d in lst]) day = dayNum(today) count = 0 while day in dates: count += 1 day -= 1 return count
e11fb35dea961730ee1b2aac612eecacf46b7cb3
daniel-reich/ubiquitous-fiesta
/PLdJr4S9LoKHHjDJC_20.py
265
3.53125
4
def identify(*cube): n = len(cube) max1 = 1 for i in range(n): max1 = max(max1, len(cube[i])) total = 0 for i in range(n): total += max1 - len(cube[i]) return 'Missing {}'.format(total) if total else 'Non-Full' if max1 > len(cube) else 'Full'
c67f9641fcc88395b4bc252b7ae14c3cd8487d34
daniel-reich/ubiquitous-fiesta
/oFwoAA62gRvX5agEN_20.py
819
3.609375
4
def knapsack(capacity, items): import pandas as pd i=0 df=pd.DataFrame(columns=['name','weight','value']) for item in items: df.loc[i,'name']=item['name'] df.loc[i,'weight']=item['weight'] df.loc[i,'value']=item['value'] i+=1 if(len(items)>4): df=df.sort(['value'],ascending=False).reset_index() else: df=df.sort(['weight']).reset_index() items_, items1,weight, value =[],[],0,0 for i in range (df.shape[0]): if (weight+df.loc[i,'weight']<=capacity): items_.append({'name':df.loc[i,'name'],'weight':df.loc[i,'weight'],'value':df.loc[i,'value']}) weight +=df.loc[i,'weight'] value +=df.loc[i,'value'] for item in items: if (item in items_): items1.append(item) return {'capacity': capacity, 'items': items1, 'weight': weight, 'value': value}
1173dea9c1f79ebdcd90161d650a9aec615ba8fd
daniel-reich/ubiquitous-fiesta
/Ff84aGq6e7gjKYh8H_0.py
107
3.640625
4
def minutes_to_seconds(time): m, s = map(int, time.split(':')) return False if s >= 60 else m*60 + s
c3a80247a17e90332feec615ed89b67fa9d612bf
daniel-reich/ubiquitous-fiesta
/jQGT8CNFcMXr55jeb_7.py
121
3.828125
4
def numbers_sum(lst): sum = 0 for num in lst: if type(num) == int: sum += num return sum
3f1d30035adc5f88c5f50dd3392393b8fd3e0936
daniel-reich/ubiquitous-fiesta
/2jcxK7gpn6Z474kjz_6.py
205
3.78125
4
def security(txt): for i in range(len(txt)): if txt[i]=='T': for j in range(len(txt)): if txt[j]=='$' and 'G' not in txt[i:j] and 'G' not in txt[j:i]: return 'ALARM!' return 'Safe'
1037d618f32396635caf89d1422432e3686afe05
daniel-reich/ubiquitous-fiesta
/kBXHbwQZPiLmwjrMy_21.py
530
3.828125
4
import re ​ def replacer(match_obj): output = match_obj.group(3) if match_obj.group(2) != "": if match_obj.group(2)[0].isupper(): output = output.capitalize() output += match_obj.group(2).lower() else: output += "y" return match_obj.group(1) + output + "ay" + match_obj.group(4) ​ def translate_word(word): return re.sub("^([^a-zA-Z]*)([^AaEeIiOoUu]*)([a-zA-Z]+)(.*)$", replacer, word) ​ def translate_sentence(sentence): return " ".join(translate_word(word) for word in sentence.split(" "))