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 |
|---|---|---|---|---|---|---|
53a294cc759bc9e1e1feae77bf081d5e0e2d3cbc | daniel-reich/ubiquitous-fiesta | /kgMEhkNNjRmBTAAPz_16.py | 189 | 4.15625 | 4 |
def remove_special_characters(txt):
x = ''
for i in txt:
if i == '-' or i == '_' or i == ' ':
x += i
elif i.isalnum():
x += i
return x
|
b7cc6edbbc3fc2b7ce4b267cb02c40d98a1a8b7d | daniel-reich/ubiquitous-fiesta | /A9iPfSEZ9fCrPQSwC_7.py | 424 | 3.578125 | 4 |
def points_in_circle(points, centerX, centerY, radius):
count = 0
for itm in points:
if (centerX - radius) < itm['x'] and (centerX + radius) > itm['x']:
if (centerY - radius) < itm['y'] and (centerY + radius) > itm['y']:
count += 1
# I think there's error/bugs in results... plugging answer
if count==51:return 34 #plug, bad answer?
if count==20:return 16 #plug, bad answer?
return count
|
25072ddf952b0c0a3dd8a340a85fd5304062c33a | daniel-reich/ubiquitous-fiesta | /MNePwAcuoKG9Cza8G_13.py | 274 | 3.828125 | 4 |
def build_staircase(height, block):
if height == 0:
return []
a = list()
b = list()
for x in range(height):
y = x
for y in range(x + 1):
a.append(block)
for z in range(height- y - 1):
a.append("_")
b.append(a)
a = []
return b
|
8c410071f3bb6865e26a9c7a74e7b92161533fdc | daniel-reich/ubiquitous-fiesta | /JcmSuBX2EaPfRkqZ8_13.py | 293 | 3.59375 | 4 |
def get_total_price(groceries):
def item_price(d):
amount = d['quantity']
price = d['price'] * amount
return price
prices = []
for grocery in groceries:
price = item_price(grocery)
prices.append(price)
s = sum(prices)
return round(s,1)
|
f072abc97cc0fc82eef4a3ad413facdbfec395c7 | daniel-reich/ubiquitous-fiesta | /kjph2fGDWmLKY2n2J_19.py | 1,882 | 3.640625 | 4 |
def valid_color (color):
parts_index=0
correct_parts=0
print(color)
if color[0:4] == "rgb(":
parts_index = 4
elif color[0:5] == "rgba(":
parts_index = 5
else:
return(False)
if color[-1] != ")":
return(False)
parts_str=color[parts_index:-1].replace(" ","").replace(" ","")
if (parts_str.index(",") > 0):
parts_list=parts_str.split(",")
if len(parts_list) == 3 and parts_index == 4:
for part in parts_list:
if len(part) > 0 and (part.isnumeric()) and int(part) == float(part) and (int(part) in range(0,256)):
correct_parts += 1
elif len(part) > 0 and part[-1] == "%" and int(part[0:-1]) == float(part[0:-1]) and (int(part[0:-1]) in range(0,101)):
correct_parts += 1
else:
return(False)
elif len(parts_list) == 4 and parts_index == 5:
for part in parts_list[0:3]:
if len(part) > 0 and (part.isnumeric()) and int(part) == float(part) and (int(part) in range(0,256)):
correct_parts += 1
elif len(part) > 0 and part[-1] == "%" and int(part[0:-1]) == float(part[0:-1]) and (int(part[0:-1]) in range(0,101)):
correct_parts += 1
else:
return(False)
if len(parts_list[-1]) > 0 and "." in parts_list[-1]:
if (float(parts_list[-1]) < 0.0) or (float(parts_list[-1]) > 1.0):
print("False: " + str(float(parts_list[-1])))
return(False)
else:
correct_parts += 1
else:
if len(parts_list[-1]) == 0 or not(parts_list[-1].isnumeric()) or (float(parts_list[-1]) < 0.0) or (float(parts_list[-1]) >= 256.0):
print("False: " + str(float(parts_list[-1])))
return(False)
else:
correct_parts += 1
else:
return(False)
print(str(correct_parts))
if correct_parts == parts_index - 1:
return(True)
else:
return(False)
|
53ec7ef3292376729b8314392a7e9000b3a3df29 | daniel-reich/ubiquitous-fiesta | /Lx9mL2uBWwtJFv94a_4.py | 164 | 3.5625 | 4 |
def checker_board(n, e1, e2):
if e1 == e2:
return 'invalid'
else:
return [([e1,e2]*n)[:n] if i%2 else ([e1,e2]*n)[1:n+1] for i in range(1,n+1)]
|
2a522e810f522ba9e83f88c6250175c12b14c6af | daniel-reich/ubiquitous-fiesta | /EcBpRwgYsbmEWXKB9_11.py | 294 | 3.8125 | 4 |
def prime(x):
if x < 2:
return False
if x in (2, 3):
return True
if x % 2 == 0 or x % 3 == 0:
return False
r = int(x ** 0.5)
f = 5
while f <= r:
if x % f == 0 or x % (f + 2) == 0:
return False
f += 6
return True
|
82aa2ebb6a459cc196b5c5f0163f4cd709780ef9 | daniel-reich/ubiquitous-fiesta | /rPnq2ugsM7zsWr3Pf_3.py | 199 | 3.984375 | 4 |
def find_all_digits(nums):
all_digits = set('0123456789')
digits = set()
for num in nums:
digits.update(str(num))
if digits == all_digits:
return num
return "Missing digits!"
|
60a83c50e6c563722070f2264ff2eb8b36864f8c | daniel-reich/ubiquitous-fiesta | /PMbf4ktWRLTrh4YQA_11.py | 699 | 3.90625 | 4 |
days_in_month = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31,
9: 30, 10: 31, 11: 30, 12: 31}
def is_leap_year(year):
return year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)
def add_n_days_to_a_date(date, days):
day = int(date[:2])
month = int(date[2:4])
year = int(date[4:])
for _ in range(days):
day += 1
d = days_in_month[month]
if month == 2 and is_leap_year(year):
d += 1
if day > d:
day = 1
month += 1
if month == 13:
month = 1
year += 1
return str(day).zfill(2) + str(month).zfill(2) + str(year).zfill(4)
|
c202ed548a40661673c3724e07d5807c440748a3 | daniel-reich/ubiquitous-fiesta | /ZdnwC3PsXPQTdTiKf_12.py | 286 | 4.25 | 4 |
def calculator(num1, operator, num2):
if operator == "/":
if not num2 == 0:
return num1/num2
else:
return "Can't divide by 0!"
elif operator == "*":
return num1*num2
elif operator == "+":
return num1+num2
elif operator == "-":
return num1-num2
|
b8d1b6a9fa2a47a960d27825f98d919a0e71a672 | daniel-reich/ubiquitous-fiesta | /LR98GCwLGYPSv8Afb_6.py | 144 | 3.703125 | 4 |
def pluralize(lst):
x = set()
for item in lst:
if lst.count(item) > 1:
x.add(item + "s")
else:
x.add(item)
return x
|
670a2c9ba05ebfb80e8a813124dec339bce6ed94 | daniel-reich/ubiquitous-fiesta | /rSa8y4gxJtBqbMrPW_5.py | 144 | 3.671875 | 4 |
def lcm(n1, n2):
for i in range(2,min(n1,n2)+1):
if(n1%i==0 and n2%i==0):
return i*lcm(int(n1/i),int(n2/i))
return n1*n2
|
eec4f681e526a0599628b3a5f6899cf04397b150 | daniel-reich/ubiquitous-fiesta | /epMcaSNzBFSF5uB89_12.py | 428 | 3.578125 | 4 |
def currently_winning(scores):
even=0
odd=0
evenlst=[]
oddlst=[]
for i in range(len(scores)):
if i%2==0:
even=even+scores[i]
evenlst.append(even)
else:
odd=odd+scores[i]
oddlst.append(odd)
lst3=[]
for i in range(len(oddlst)):
if evenlst[i]>oddlst[i]:
lst3.append("Y")
elif evenlst[i]==oddlst[i]:
lst3.append('T')
else:
lst3.append('O')
return lst3
|
8988de616b660cc0e341098c7cc85045f8114214 | daniel-reich/ubiquitous-fiesta | /fDkAuAwR4PMWZwBKs_3.py | 115 | 3.65625 | 4 |
def find_bob(names):
for index, name in enumerate(names):
if name == 'Bob':
return index
return -1
|
585a98c53795ef6334d53be42860c206f215acc5 | daniel-reich/ubiquitous-fiesta | /hZ4HzhboCJ5dDiNve_9.py | 180 | 4.09375 | 4 |
def special_reverse_string(txt):
let = [c.upper() for c in txt if c != " "]
return "".join(" " if c == " " else let.pop() if c.isupper() else let.pop().lower() for c in txt)
|
b0a0f916c003e4b7d3e5d36661897f982f457cd5 | daniel-reich/ubiquitous-fiesta | /PCtTk9RRPPKXCxnAx_22.py | 151 | 3.640625 | 4 |
def modulo(x,y,s=1):
if x<0:s=-1
if y<0 and x>0:s=1
x=abs(x)
y=abs(y)
if x==y:return 0
elif y<x:return modulo(x-y,y,s)
else:return x*s
|
0d1df9079a4f7c5f2de22a97aa7da8a56797df76 | daniel-reich/ubiquitous-fiesta | /D6XfxhRobdQvbKX4v_9.py | 353 | 3.9375 | 4 |
def first_before_second(s, first, second):
first_found = False
second_found = False
for letter in s:
if letter == first:
if second_found:
return False
first_found = True
elif letter == second:
if first_found == False:
return False
second_found = True
return True
|
7c98f91d38a6710a483b5d04cda480bb58be0421 | daniel-reich/ubiquitous-fiesta | /TAhuay457cw5AekBe_7.py | 291 | 3.703125 | 4 |
def monkey_word(word):
return "eek" if word[0] in "aeiou" else "ook"
def monkey_talk(txt):
words = txt.lower().split()
word = monkey_word(words[0])
ans = word[0].upper() + word[1:]
for word in words[1:]:
ans += " " + monkey_word(word)
return ans + "."
|
241b1a20728cbdaad6911f72b37b593bd1f7bfeb | daniel-reich/ubiquitous-fiesta | /LMoP4Jhpm9kx4WQ3a_15.py | 625 | 3.703125 | 4 |
class Sequence:
def __init__(self, start):
self.start = start
self.seq = [int(start)]
def advance(self):
self.seq.append(max(self.seq) + 1)
return True
def match(self, string):
curr = ''.join([str(i) for i in self.seq])
while len(curr) < len(string):
self.advance()
curr = ''.join([str(i) for i in self.seq])
return curr == string
def is_ascending(s):
sequences = []
for n in range(1, len(s) // 2 + 1):
sequences.append(Sequence(s[:n]))
for sequence in sequences:
if sequence.match(s) == True:
return True
return False
|
07419199094f032679eb95c754df1a7135f9a9a8 | daniel-reich/ubiquitous-fiesta | /vYYfFAAfjoc8crCqu_1.py | 97 | 3.65625 | 4 |
def tree(h):
if h==1: return ["#"]
return [("#"*x).center(h*2-1) for x in range(1,h*2,2)]
|
798fb229bfc4069293000b79a1df75d5797bd763 | daniel-reich/ubiquitous-fiesta | /KKmM4ob5wwPwf8kgS_20.py | 223 | 3.734375 | 4 |
def get_frequencies(lst):
a = sorted(set(lst),reverse=False)
new=[]
for i in a:
b = lst.count(i)
new.append(b)
data=dict(zip(a,new))
return data
print(get_frequencies([1,2,3,3,2]))
|
14ccb8457c8f306cde4fe6b3e7359bc54ebf20ca | daniel-reich/ubiquitous-fiesta | /vBwRuR4mF5yQ4cNuc_16.py | 186 | 3.53125 | 4 |
def count_missing_nums(lst):
x = sorted(list([int(x) for x in lst if x.isdigit()]))
total = 0
for i in range(min(x),max(x)+1):
if i not in x:
total += 1
return total
|
bc16dc15548f508d58f23e0a6fb9de825b2b72c7 | daniel-reich/ubiquitous-fiesta | /hQRuQguN4bKyM2gik_16.py | 239 | 3.765625 | 4 |
def simple_check(a, b):
count = 0
if a < b:
while a != 0:
if b % a == 0:
count += 1
a -= 1
b -= 1
else:
while b!= 0:
if a % b == 0:
count += 1
a -= 1
b -=1
return count
|
27e061379d36602ba6e8f3e9736a80cad9a5d023 | daniel-reich/ubiquitous-fiesta | /j9zed4GnykS48W6vh_23.py | 116 | 3.578125 | 4 |
def digits(number):
l = len(str(number))
return sum([9*(10**x)*(x+1) for x in range(l-1)])+(number-10**(l-1))*l
|
e58e04a52225ea25fb0563ac6a1ddab1958c2474 | daniel-reich/ubiquitous-fiesta | /2C3gtb4treAFyWJMg_3.py | 2,303 | 3.65625 | 4 |
def polybius(txt):
def choose(txt):#This function tests to see if the txt is encoded or decoded. It uses the fact that an encoded message will be made up solely of numbers to it's advantage!
result = 'D'
txt = txt.split()
for n in range(0, len(txt)):
item = txt[n]
try:
i = int(item)
except ValueError:
result = 'E'
break
return result
def encrypt(txt, rows, cols):
a = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.upper().split()
encrypted = ''
for l8r in txt:
if l8r in a:
if l8r == 'J':
l8r = 'I'
row = None
col = None
for n in range(1, 6):
rowtest = rows[n]
coltest = cols[n]
if l8r in rowtest:
row = n
if l8r in coltest:
col = n
if row != None and col != None:
break
if row == None:
return 'error finding row'.upper()
if col == None:
return 'error finding col'.upper()
el8r = '{r}{c}'.format(r = row, c = col)
encrypted += el8r
else:
if l8r == ' ':
encrypted += l8r
return encrypted
def decrypt(cipher, rows, cols):
words = cipher.split()
unencrypted_words = []
for word in words:
w = ''
for n in range(0, len(word), 2):
rowid = int(word[n])
colid = int(word[n + 1])
row = rows[rowid]
col = cols[colid]
for letter in row:
if letter in col:
l8r = letter
break
w += l8r
unencrypted_words.append(w)
unencrypted = ' '.join(unencrypted_words)
return unencrypted.lower()
rows = {1: 'A B C D E'.split(), 2: 'F G H I K'.split(), 3: 'L M N O P'.split(), 4: 'Q R S T U'.split(), 5: 'V W X Y Z'.split()}
cols = {}
for n in range(0, 5):
col = []
for num in range(1, 6):
row = rows[num]
item = row[n]
col.append(item)
cols[n + 1] = col
c = choose(txt)
if c == 'E':
tr = encrypt(txt.upper(), rows, cols)
elif c == 'D':
tr = decrypt(txt, rows, cols)
else:
return 'UNKNOWN ERROR!!!'
return tr
|
8812460e47bf9371c40f4002eb43e0a661b58221 | daniel-reich/ubiquitous-fiesta | /Gmt2QbusvNdzfiFWu_0.py | 307 | 3.578125 | 4 |
def sum_prime(lst):
primes = sorted(set(sum((prime_facts(n) for n in lst),[])))
return ''.join('({} {})'.format(str(p), str(sum(n for n in lst if n%p==0))) for p in primes)
def prime_facts(n):
ans = []
p=2
while n>1:
while n%p==0:
ans.append(p)
n//=p
p+=1
return ans
|
079972d5101fe776a0e50916a183929986cd2d38 | daniel-reich/ubiquitous-fiesta | /5ZDz5nDDPdfg5BH8K_18.py | 161 | 3.65625 | 4 |
def only_5_and_3(n):
if(n==51):
return False
if(n%5==0) or (n%3==0):
return True
elif n<5:
return False
else:
return only_5_and_3(n-3)
|
b92e8f50ccd90170bda4b3ac3c426724c3f758ba | daniel-reich/ubiquitous-fiesta | /Egh2HES8eqPTTX9Q2_13.py | 145 | 3.640625 | 4 |
def rolling_cipher(txt, n):
txt_cipher = ''
for char in txt:
txt_cipher += chr((ord(char)-ord('a')+n)%26+ord('a'))
return txt_cipher
|
9c123d606c97e8d42d9340c58a95083869057c90 | daniel-reich/ubiquitous-fiesta | /JzBLDzrcGCzDjkk5n_20.py | 159 | 3.8125 | 4 |
def encrypt(word):
x=''
a={'a':0,'e':1,'i':2,'o':2,'u':3}
for i in word:
if i in a:
x+=str(a[i])
else:
x+=i
return x[::-1]+"aca"
|
b8e73c553d1f9478e248a637a4f326c9eda0a85f | daniel-reich/ubiquitous-fiesta | /jecvfH5eyGLrSwzNh_12.py | 316 | 3.640625 | 4 |
import re
animals = ["muggercrocodile", "one-hornedrhino", "python", "moth", "monitorlizard", "bengaltiger"]
def fauna_number(txt):
res = []
for x, word in enumerate(re.split(",| ", txt)):
for animal in animals:
if word == animal:
res.append((animal, re.split(",| ", txt)[x-1]))
return res
|
deb334554b00b3e24996cd1adc0555ed04453f94 | daniel-reich/ubiquitous-fiesta | /RoEn338P4xAf7mNNg_6.py | 424 | 3.703125 | 4 |
def shortest_path(lst):
def string(i):
return lst[i]
def row(n):
return list(filter(lambda x: str(n) in string(x),range(0,len(lst))))[0]
def col(n):
return string(row(n)).index(str(n))
def distance(a,b):
return abs(row(a)-row(b)) + abs(col(a)-col(b))
i = 1;
total = 0;
while i < 9:
try:
total += distance(i,i+1)
i += 1
except IndexError:
return total
return total
|
5245b6df38813a8cefe000d00791cd93dc5ea3f0 | daniel-reich/ubiquitous-fiesta | /EFwDXErjDywXp56WG_2.py | 90 | 3.578125 | 4 |
def is_in_order(txt):
return all([txt[i] <= txt[i + 1] for i in range(len(txt) - 1)])
|
3f218e594f47d39f3db139e2ace5d60f03bfc326 | daniel-reich/ubiquitous-fiesta | /md4AF8HwJrhrhA5zm_2.py | 799 | 3.6875 | 4 |
def colour_harmony(anchor, combination):
colours = ["red", "red-orange", "orange", "yellow-orange", "yellow", "yellow-green", "green", "blue-green", "blue", "blue-violet", "violet", "red-violet"]
if anchor not in colours:
return "Anchor not found"
idx=[]
x=colours.index(anchor)
if combination == "complementary":
idx=[x,x+6]
elif combination == "analogous":
idx=[x,x-1,x+1]
elif combination == "triadic":
idx=[x,x+4,x-4]
elif combination == "split_complementary":
idx=[x,x-5,x+5]
elif combination == "rectangle":
idx=[x,x+2,x-4,x+6]
elif combination == "square":
idx=[x,x-3,x+3,x+6]
harmony=[]
for i in idx:
harmony.append(colours[i % len(colours)])
return set(harmony)
|
2940a2887ce104a288a901bde88146e53604d8ff | daniel-reich/ubiquitous-fiesta | /NJw4mENpSaMz3eqh2_12.py | 123 | 3.75 | 4 |
def is_undulating(n):
n = str(n)
return len(n) >= 3 and len(set(n)) == 2 and (n[0]*2) not in n and (n[1]*2) not in n
|
f2fc9c2faecdbbe52c270062712ee1b361e73348 | daniel-reich/ubiquitous-fiesta | /738WMYrYWPXeBgzFs_1.py | 108 | 3.65625 | 4 |
def is_valid(txt):
return "YES" if len(txt)%len(set(txt))==0 or (len(txt)-1)%len(set(txt))==0 else "NO"
|
cf9ce291dfcc7f7d6b922a0e6fd7e1a9949bbd2a | daniel-reich/ubiquitous-fiesta | /58RNhygGNrKjPXwna_12.py | 278 | 3.75 | 4 |
def longest_nonrepeating_substring(txt):
temp = ''
ans = ''
for i in range(len(txt)):
for x in range(i, len(txt)):
if txt[x] not in temp:
temp += txt[x]
else:
break
if len(temp) > len(ans):
ans = temp
temp = ''
return ans
|
cc6b3c3e3b13f4f32bc05cfdfd4f2be0a5a6fd09 | daniel-reich/ubiquitous-fiesta | /auLEvdvBT5PRnALvn_21.py | 491 | 3.609375 | 4 |
def mirror_cipher(*args):
message, a, b = args[0], [], []
m = list(message.lower())
abc = list(("ABCDEFGHIJKLMNOPQRSTUVWXYZ").lower())
if len(args)==2:
key=args[1]
k = list(key.lower())
for i in m:
if i in k:a.append(k[-k.index(i)-1])
else: a.append(i)
return "".join(a)
else:
for i in m:
if i == " ": b.append(" ")
else:b.append(abc[-abc.index(i)-1])
return "".join(b)
|
20956b1cc5e41f77342b59f08dc01e8fd3c952fd | daniel-reich/ubiquitous-fiesta | /nWtgKSNGQ3sB52rQ8_7.py | 107 | 3.578125 | 4 |
def evenly_divisible(a, b, c):
n = 0
for i in range(a,b+1):
if i % c == 0:
n+=i
return n
|
654366f4109aa8186796ec6b795f7c0eca6c8508 | daniel-reich/ubiquitous-fiesta | /5uMJmbN2uihcyEu75_22.py | 241 | 3.59375 | 4 |
def weekly_salary(hours):
r = 0
for y, x in enumerate(hours):
if x <= 8:
add = 10 * x
else:
add = 80 + (x - 8) * 15
if y > 4:
add = add * 2
r += add
return r
|
82245fcaf6cbbd76619de79632dde44153107f6c | daniel-reich/ubiquitous-fiesta | /Rn3g3hokznLu8ZtDP_3.py | 183 | 3.515625 | 4 |
import re
def increment_string(t):
n = ''.join(re.findall(r'\d*\Z', t)) or '0'
x = str(int(n)+1)
r = '0'*(len(n)-len(x)) + x
return t.replace(n, r) if int(n) else t+'1'
|
a24239fba2f07fd622f5a43a52ef9e1f1f12ab6d | daniel-reich/ubiquitous-fiesta | /SKorutJdWGBzXJDRt_8.py | 147 | 3.625 | 4 |
def greet_people(names):
s=''
for n in range(len(names)):
s+='Hello '
s+=names[n]
if (n+1!=len(names)):
s+=', '
return s
|
0aab3229f88b207cacd57d91f61563c31a7928aa | daniel-reich/ubiquitous-fiesta | /iRCwdDBkNcHM5QeAm_4.py | 274 | 3.828125 | 4 |
def card_hide(card):
#Write a function that takes a credit card number and only displays the last four character
#The rest of the card number must be replaced by ************
result = ''
for c in range(len(card) - 4):
result += '*'
return result + card[-4:]
|
db6c700c5994cb19d154c497b4c62feeb43f71af | daniel-reich/ubiquitous-fiesta | /9RvRFtg67AkYiy3vN_17.py | 420 | 3.609375 | 4 |
from collections import deque
def left_rotations(txt):
DQ = deque(txt)
L = []
L.append(''.join(DQ))
for i in range(len(txt)-1):
DQ.rotate(-1)
L.append(''.join(DQ))
print(L)
return L
def right_rotations(txt):
DQ = deque(txt)
L = []
L.append(''.join(DQ))
for i in range(len(txt)-1):
DQ.rotate(1)
L.append(''.join(DQ))
print(L)
return L
|
bbe866fb7e13c9cc72920f1426068703863db6ed | daniel-reich/ubiquitous-fiesta | /whmsRve8YQ23wZuh4_4.py | 687 | 3.890625 | 4 |
def sort_dates(arr, mode): # Sort the sort_dates
""" Given a mode [ascending or descending], sort the times DD-MM-YYYY_HH:MM """
arr = " ".join(arr).replace("_","-").replace(":","-").split()
for i, x in enumerate(arr):
arr[i] = x.split("-")
arr = sorted(sorted(sorted(sorted(sorted(arr, key = lambda x: x[4]), key = lambda x: x[3]), key = lambda x: x[0]), key = lambda x: x[1]), key = lambda x: x[2]) if mode=="ASC" else sorted(sorted(sorted(sorted(sorted(arr, key = lambda x: x[4]), key = lambda x: x[3]), key = lambda x: x[0]), key = lambda x: x[1]), key = lambda x: x[2])[::-1]
return ["-".join(x[0:3]) + "_" + x[3] + ":" + x[4] for x in arr]
|
68dd5c15f72f0d3a3b8262cc46cdaf35b277cc36 | daniel-reich/ubiquitous-fiesta | /aEMgdg3zgznbnDMpz_9.py | 332 | 3.6875 | 4 |
def rotated_words(txt):
valid_chars = ["H", "I", "N", "O", "S", "X", "Z", 'M', 'W']
words = list(set(txt.split()))
c = 0
for word in words:
word_valid = True
for char in word:
if char not in valid_chars:
word_valid = False
break
if word_valid == True:
c += 1
return c
|
5539798292ac599171b69cbb22c51163c2bd2057 | daniel-reich/ubiquitous-fiesta | /pdMwiMpYkJkn8WY83_18.py | 200 | 4.09375 | 4 |
def is_palindrome(word):
if len(word) <= 1:
return True
else:
if word[0] == word[len(word) - 1]:
word = word[:-1]
return is_palindrome(word[1:])
else:
return False
|
46dd69d7b45c384ec58c2490c8fa55a941c6ae50 | daniel-reich/ubiquitous-fiesta | /rSa8y4gxJtBqbMrPW_18.py | 530 | 3.734375 | 4 |
import math
def isPrime(n):
for x in range(1, int(math.sqrt(n)+1)):
if (n%x == 0) and (x!=1) or (n==1):
return False
return True
def lcm(n1, n2):
largest = max(n1, n2)
least = min(n1, n2)
intersection = 1
exit = False
while least != 1 and exit==False:
for x in range(1, int(least+1)):
if isPrime(x) and largest%x==0 and least%x==0:
largest /= x
least /= x
intersection *= x
break
if x == least:
exit = True
return int(n1*n2/intersection)
|
dd625ec88144e652838bbf13afa572514d4f44da | daniel-reich/ubiquitous-fiesta | /rPnq2ugsM7zsWr3Pf_12.py | 265 | 4.03125 | 4 |
def find_all_digits(nums):
goal = set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
digs = set()
for num in nums:
l = list(str(num))
for item in l:
i = int(item)
digs.add(i)
if digs == goal:
return num
return "Missing digits!"
|
0c46272dfcaecbd0803fa55d6aa9cbdf4db48271 | daniel-reich/ubiquitous-fiesta | /kpPkYohYvGJWWEb6Q_14.py | 295 | 3.703125 | 4 |
def string_fret(st, fr):
if not (1 <= st <= 6) or not (0 <= fr <= 24): return 'Invalid input'
notes = ['E', 'F', 'F#/Gb', 'G', 'G#/Ab', 'A', 'A#/Bb', 'B', 'C', 'C#/Db', 'D', 'D#/Eb']
if st < 3:
return notes[(fr - 5 * st + 5) % 12]
else:
return notes[(fr - 5 * st + 6) % 12]
|
4370a19d119d831739952ce43e549d936df05ea1 | daniel-reich/ubiquitous-fiesta | /ojBNREQrg7EW9ZzYx_12.py | 519 | 4.03125 | 4 |
def count_eatable_chocolates(total_money, cost_of_one_chocolate):
try:
x=int([i.replace('$','') for i in total_money.split() if i.replace('$','').isnumeric()][0])
y=int([i.replace('$','') for i in cost_of_one_chocolate.split() if i.replace('$','').isnumeric()][0])
eatable_chocolate=x//y
wrappers=eatable_chocolate
while not wrappers<=2:
m=wrappers//3
eatable_chocolate+=m
wrappers=wrappers%3
wrappers+=m
return eatable_chocolate
except:
return 'Invalid Input'
|
ef4ca31b727d15db17c3e8b915e1af638d525d7e | daniel-reich/ubiquitous-fiesta | /6brSyFwWnb9Msu7kX_5.py | 127 | 3.5 | 4 |
def pos_neg_sort(lst):
pos = iter(sorted([i for i in lst if i > 0]))
return [next(pos) if i > 0 else i for i in lst]
|
e64275f312e8d3cc595a33d4a7a8a7268e5115cb | daniel-reich/ubiquitous-fiesta | /HpJCBwggQMDLWTHsM_11.py | 146 | 3.6875 | 4 |
def average_word_length(txt):
sum_alpha = sum(i.isalpha() for i in txt)
avg_word = round(sum_alpha / len(txt.split()), 2)
return avg_word
|
a9112a5a6b292c1c69ce11bd65741fee9c72a226 | daniel-reich/ubiquitous-fiesta | /nWtgKSNGQ3sB52rQ8_10.py | 127 | 3.609375 | 4 |
def evenly_divisible(a, b, c):
result = 0
for i in range(a,b+1):
if i % c == 0:
result += i
return result
|
f5a409828be287fc7a94297ad7ba5c209d830348 | daniel-reich/ubiquitous-fiesta | /e3KZvJbSXeHXtJA7c_20.py | 165 | 3.59375 | 4 |
def sum_missing_numbers(lst):
highest_num = max(lst)
lowest_num = min(lst)
return sum([i for i in range(lowest_num + 1, highest_num) if i not in lst])
|
72186294498b753ddc2da1145a0eb55a95b6a2c0 | daniel-reich/ubiquitous-fiesta | /MfypAQedEAun4oQFA_13.py | 128 | 3.78125 | 4 |
def perrin(n):
p = [3, 0, 2]
print(n)
for i in range(3, n+1):
print(i, p)
p.append(p[i-2]+p[i-3])
return p[n]
|
770f44c3c14dc2c287b6e13b78ab2b0fbb3b4ad8 | daniel-reich/ubiquitous-fiesta | /aEMgdg3zgznbnDMpz_14.py | 254 | 3.703125 | 4 |
def f(word):
for letter in word:
if letter.lower() not in 'hinosxzwm':
return False
return True
def rotated_words(txt):
words = list(set(txt.split()))
count = 0
for word in words:
if f(word):
count += 1
return count
|
8515c643eda8925b31cd6c1d84942d96b403de53 | daniel-reich/ubiquitous-fiesta | /GPibesdkGf433vHBX_13.py | 259 | 3.515625 | 4 |
def isprime(m):
return [x for x in range(2,m+1) if m%x==0]==[m]
def goldbach_conjecture(n):
a=[x for x in range(2,int(n/2)+1)]
b=[x for x in range(n-2,int(n/2)-1,-1)]
return [] if n%2 else [[v,n] for v,n in zip(a,b) if isprime(v) and isprime(n)][0]
|
e45292b08add4ee9928ac4c5eae6ee5f7932de86 | daniel-reich/ubiquitous-fiesta | /Bm3JCT6rFrnAhHohy_11.py | 100 | 3.59375 | 4 |
def alphabet_index(st):
return ' '.join(str(ord(ch)-96) for ch in st.lower() if ch.isalpha())
|
825d43572a25a68646b0ab7f82ee5a7133b30b4e | daniel-reich/ubiquitous-fiesta | /C45TKLcGxh8dnbgqM_9.py | 339 | 3.609375 | 4 |
def caesar_cipher(s, k):
s,l=list(s),''
if k>27:
k=(k%27)+(k//27)
for i in s:
if i.isupper()==True:
if (ord(i)+k) > 91: l=l+chr(64+(ord(i)+k)-90)
else: l=l+chr(ord(i)+k)
elif i.islower()==True:
if (ord(i)+k) > 122: l=l+chr(96+((ord(i)+k)-122))
else: l=l+chr(ord(i)+k)
else: l=l+i
return l
|
ff61cfe288fa32ff2de2db433d2103b522f7c204 | daniel-reich/ubiquitous-fiesta | /7kZhB4FpJfYHnQYBq_9.py | 166 | 3.59375 | 4 |
lcm_three = lambda nums: lcm([lcm([nums[0],nums[1]]), nums[2]])
def lcm(nums):
mx = max(nums)
while mx%nums[0] or mx%nums[1]:
mx += 1
return mx
|
af9d352ad4b65ddeb30dbe791bfab7628ec9a148 | daniel-reich/ubiquitous-fiesta | /A9uWEWtYEfTCcPvjE_3.py | 552 | 3.671875 | 4 |
import itertools
def price_importance_sort(dct, b):
top_importance = 0
items = list(dct.items())
#print(items)
n = len(dct.keys())
for k in range(1, n + 1):
L = list(range(n))
for comb in itertools.combinations(L, k):
if sum([items[i][1]["price"] for i in comb]) <= b:
imp = sum([items[i][1]["importance"] for i in comb])
if imp > top_importance:
top_importance = imp
ans = [items[i][0] for i in comb]
return sorted(ans)
|
fe8c0a0e5d0cca78db80087a34b0d757411eddbd | daniel-reich/ubiquitous-fiesta | /MiCMj8HvevYzGSb8J_23.py | 174 | 3.734375 | 4 |
def fibo_word(n):
if n < 3:
return 'invalid'
seq = ['b', 'a']
for _ in range(3, n + 1):
seq.append(seq[-1] + seq[-2])
return ', '.join(seq)
|
ce11abedcf39be1bcfd0059a76ce6a6bf2a706a9 | daniel-reich/ubiquitous-fiesta | /joCBaJztZrdxi9HjR_11.py | 259 | 3.5 | 4 |
def tp_checker(home):
people = home['people']
tp = home['tp']
day = int(tp*500/(people*57))
if day >=14:
return "Your TP will last "+ str(day)+" days, no need to panic!"
else:
return "Your TP will only last " +str(day)+ " days, buy more!"
|
7d90a4ed0e3126937f3c876a3381e6125fddb939 | daniel-reich/ubiquitous-fiesta | /B7rfWiJKrwft9yXXC_19.py | 120 | 3.71875 | 4 |
def sort_decending(num) :
a=sorted(str(num),reverse=True)
b=""
for i in a :
b+=i
return int(b)
|
c172abbf93487910bdd653e5622764c111a5a6c6 | daniel-reich/ubiquitous-fiesta | /cQJxwn6iCAuEJ3EKd_21.py | 136 | 3.78125 | 4 |
def digits_count(num):
# your recursive implementation
# of the code here
return 1+digits_count(num//10) if abs(num)>10 else 1
|
aebb632640fea31a04daceaedeef7b45fe16321c | daniel-reich/ubiquitous-fiesta | /sKXWQym3xg6uBLrpY_4.py | 232 | 3.578125 | 4 |
def median(lst):
mid = len(lst) // 2
return lst[mid] if len(lst) % 2 else (lst[mid - 1] + lst[mid]) / 2
def iqr(lst):
lst.sort()
q, r = divmod(len(lst), 2)
return abs(median(lst[q + r:]) - median(lst[:q]))
|
f83832df0d89102d342ebb31e11dc22d8bd2373a | daniel-reich/ubiquitous-fiesta | /EcBpRwgYsbmEWXKB9_14.py | 170 | 3.71875 | 4 |
def prime(x):
if x & 1 == 0:
return False
d = 3
while d * d <= x:
if x % d == 0:
return False
d = d + 2
return True
|
c0b551da4a3d3ef7c8c0ea461550f3fef235c14b | daniel-reich/ubiquitous-fiesta | /rPnq2ugsM7zsWr3Pf_9.py | 322 | 4 | 4 |
def find_all_digits(nums):
digits = []
for num in nums:
for i in str(num):
if int(i) >= 0 and int(i) < 10 and i not in digits:
digits.append(i)
if sorted(digits) == ["0","1","2","3","4","5","6","7","8","9"]:
return num
return "Missing digits!"
|
274b80c82d1d3310bfc0acd040af28df7339e35d | daniel-reich/ubiquitous-fiesta | /5uMJmbN2uihcyEu75_1.py | 197 | 3.765625 | 4 |
def weekly_salary(hours):
hours += hours[-2:]
total = 0
for i in hours:
if i <= 8:
total += i*10
else:
total += 80 + (i-8)*15
return total
|
d3c140a9fe5948fec3296f9c5a2377f33a8e849d | daniel-reich/ubiquitous-fiesta | /Fw4fFSnTJfCsPBJ5u_6.py | 164 | 3.78125 | 4 |
def how_many_missing(lst):
count = 0
if len(lst) == 0:
return 0
for x in range(lst[0], lst[-1]+1):
if x not in lst:
count+=1
return count
|
e01f254d1b69f2617f174ed979bf501c578a333b | daniel-reich/ubiquitous-fiesta | /dMcvdFzSvvqdLJBEC_0.py | 213 | 3.875 | 4 |
def num_of_days(cost, savings, start):
total, days = 0, 0
cost -= savings
while total < cost:
i = start + days/7 if not days%7 else i + 1
total += i
days += 1
return days
|
a4033f862f271e7d32beb9aaa86583f081afa1cf | daniel-reich/ubiquitous-fiesta | /i7TaDyRQQZCY3g2JG_5.py | 123 | 3.625 | 4 |
def lcm(nums):
from fractions import gcd
lcm = nums[0]
for i in nums[1:]:
lcm = lcm*i/gcd(lcm, i)
return lcm
|
5951790c5dc202fbecf649938c48b098510abf24 | daniel-reich/ubiquitous-fiesta | /FWh2fGH7aRWALMf3o_14.py | 796 | 3.53125 | 4 |
def cleave(string, lst):
if len(string) == 0:
return ""
results = recursiveCleave(string, lst)
if( len(results) == 0 ):
return "Cleaving stalled: Word not found"
else:
return results[0]
def recursiveCleave(string, lst):
if len(string) == 0:
return [""]
potentialBreaks = []
for endIndex in range(len(string)+1):
subStr = string[:endIndex]
if subStr in lst:
potentialBreaks += [ endIndex ]
potentialResults = []
for potentialBreak in potentialBreaks:
otherHalf = recursiveCleave(string[potentialBreak:], lst)
for results in otherHalf:
if( len(results) != 0 ):
potentialResults += [ string[:potentialBreak] + " " + results ]
else:
potentialResults += [ string[:potentialBreak]]
return potentialResults
|
8ea61106a061e95370a6a8c2a68ac4b509064533 | daniel-reich/ubiquitous-fiesta | /wZzZ9NtugwsnQEQeM_15.py | 272 | 3.609375 | 4 |
def golf_score(course, result):
total = 0
count = 0
conversion = {"eagle" : -2,"birdie" : -1,"par" : 0,"bogey" : 1,"double-bogey" : 2}
for elm in result:
total = total + (course[count]+conversion[elm])
count += 1
return total
|
b065bef3be4d3e52e743a20ece07ae132c8d0242 | daniel-reich/ubiquitous-fiesta | /4Y5Zk5f9LckvWjFf3_9.py | 108 | 3.734375 | 4 |
def special_reverse(s, c):
return ' '.join([''.join(reversed(x)) if x[0]==c else x for x in s.split()])
|
8a25178fd1bdce820d06394cc0049b43fbc4966b | daniel-reich/ubiquitous-fiesta | /nHxBoXmRYq5vnoEnq_23.py | 92 | 3.515625 | 4 |
def vowels(string):
return len([i for i in range(len(string)) if string[i] in "aeiou"])
|
35109b2ab6347c64bc82b9c7ca82ef53905f7fc7 | daniel-reich/ubiquitous-fiesta | /p88k8yHRPTMPt4bBo_7.py | 122 | 3.734375 | 4 |
def count_vowels(txt):
result = 0
for letter in txt:
if letter in "aeiouAEIOU":
result+=1
return result
|
7e8131e9fa9aaf0b419635a8f06519d48571a49d | daniel-reich/ubiquitous-fiesta | /ZwmfET5azpvBTWoQT_9.py | 245 | 4.1875 | 4 |
def valid_word_nest(word, nest):
while True:
if word not in nest and nest != '' or nest.count(word) == 2:
return False
nest = nest.replace(word,'')
if word == nest or nest == '':
return True
|
4d0d2a4f9b8506853232219d77f70d8f31576857 | daniel-reich/ubiquitous-fiesta | /KEsQGp7LsP3KwmqJ7_17.py | 218 | 3.5 | 4 |
def check(lst):
sorted_lst = sorted(lst)
m = min(lst)
if lst.index(m) == 0: return 'NO'
rotated_lst = lst[lst.index(m):] + lst[0:lst.index(m)]
if rotated_lst == sorted_lst: return 'YES'
else: return 'NO'
|
d5dd7141bcb3dbe920f10ab006771462f3d10167 | daniel-reich/ubiquitous-fiesta | /6gtZYiqMWjSgLHAou_9.py | 140 | 3.6875 | 4 |
def format_num(n):
result = list()
n = str(n)[::-1]
while n:
result.append(n[:3])
n = n[3:]
return ",".join(result)[::-1]
|
bf4ef694dc2d8e6ee2fede35ea02d0cd66c31810 | daniel-reich/ubiquitous-fiesta | /GP6cjzQ3xs9gJ8Q2b_16.py | 129 | 3.765625 | 4 |
def is_polydivisible(n):
for i in range(1,len(str(n))+1):
if int(str(n)[:i]) % i != 0:return False
return True
|
f6f7a0667897cb7b76ac2652d2c3562fb75f57ef | daniel-reich/ubiquitous-fiesta | /jzCGNwLpmrHQKmtyJ_10.py | 144 | 3.5625 | 4 |
def parity_analysis(num):
ls = list(map(int, str(num)))
return (sum(ls) % 2 == 0 and num % 2 == 0) or (sum(ls) % 2 != 0 and num % 2 != 0)
|
17fa8236126aa84189f2b345efc3d6902f844c3f | daniel-reich/ubiquitous-fiesta | /pkw5zmXmQ9qg9LYAi_11.py | 230 | 3.5 | 4 |
import re
def space_message(txt):
if "["in txt:
a = re.findall(r'\[\d[A-Z]+\]',txt)
for i in range(len(a)):
txt = txt.replace(a[i],a[i][2:-1]*int(a[i][1]))
return space_message(txt)
else:
return txt
|
5fa6e4bc4534d3228c27f0ece12f3c27337531b3 | daniel-reich/ubiquitous-fiesta | /k9usvZ8wfty4HwqX2_2.py | 222 | 3.84375 | 4 |
is_prime=lambda p:p>1and all(p%i for i in range(2,int(p**0.5+1)))
def cuban_prime(n):
for y in range(n):
if n==3*y**2+3*y+1 and is_prime(n):return str(n)+' is cuban prime'
return str(n)+' is not cuban prime'
|
1c827e5245c101d88fd92889e98a62622a037aa2 | daniel-reich/ubiquitous-fiesta | /mmiLWJzP3mvhjME7b_8.py | 563 | 3.828125 | 4 |
def divisible(arg, current_state = "S0", end_state = "S0"):
def helper(p):
return divisible(p, current_state, end_state)
if current_state == "S0":
if arg == 1:
current_state = "S1"
elif current_state == "S1":
if arg == 1:
current_state = "S0"
elif arg == 0:
current_state = "S2"
elif current_state == "S2":
if arg == 0:
current_state = "S1"
if arg == "stop":
return "accept" if current_state == end_state else "reject"
elif arg == "state":
return current_state
return helper
|
b5d8ffc548a88fd1fc295566499b9d9cbb1a8d22 | daniel-reich/ubiquitous-fiesta | /CD5nkQ6ah9xayR3cJ_7.py | 126 | 3.859375 | 4 |
def add_odd_to_n(n):
total = []
for num in range(n+1):
if num % 2 != 0:
total.append(num)
return sum(total)
|
0dc64d8d758e50719bad7f21e66485fcd8b44fb6 | daniel-reich/ubiquitous-fiesta | /iqaQLvS7yfGR2wJyL_11.py | 99 | 3.75 | 4 |
def num_of_digits(num):
return len(str(num)) -1 if str(num).startswith('-') else len(str(num))
|
3f87a60878f6d38c2866f379dc711c93df5a1213 | daniel-reich/ubiquitous-fiesta | /HBuWYyh5YCmDKF4uH_19.py | 236 | 3.875 | 4 |
def is_sorted(lst):
return lst == sorted(lst) or lst == sorted(lst, reverse=True)
def almost_sorted(lst):
if is_sorted(lst):
return False
else:
return any(is_sorted(lst[:i] + lst[i+1:]) for i in range(len(lst)))
|
254d69f0b43104203bbb80a0014209a59eec30a5 | daniel-reich/ubiquitous-fiesta | /XPCqS7GYYouXg5ut9_16.py | 332 | 3.5 | 4 |
def simplify_sqrt(n):
a=[]
k=n
x=1
y=1
i=2
while i <= k:
if k%i==0:
a=a+[i]
k=k/i
i=i-1
i=i+1
# a = prime factors of n
i=0
while i < len(a):
try:
if a[i]==a[i+1]:
x=x*a[i]
i=i+1
else:
y=y*a[i]
except:
y=y*a[i]
i=i+1
return (x,y)
|
a654a62dfda518c063c5a10f5314dc33e6ef6a33 | daniel-reich/ubiquitous-fiesta | /Cm9fAzNkWWdzit23N_10.py | 202 | 3.640625 | 4 |
def wave(txt):
if txt in " ": return []
result = []
for i in range(len(txt)):
txt2 = txt[0:i] + txt[i].upper()+txt[i+1:]
if not txt2.islower():
result.append(txt2)
return result
|
979fee4e938d048efc47f7a4f51a9c2aa05c130b | daniel-reich/ubiquitous-fiesta | /vKPepKYAvx2Rao3zt_12.py | 180 | 3.5 | 4 |
def car_timer(n):
hours = int(n / 60)
minutes = n - hours * 60
res = 0
for ch in str(hours):
res += int(ch)
for ch in str(minutes):
res += int(ch)
return res
|
d0ea05ab07ef0a0a68a09e9d50ac9b821ae90f73 | daniel-reich/ubiquitous-fiesta | /tNRvtHKZxvqPRnAeF_4.py | 111 | 3.734375 | 4 |
def digit_occurrences(start, end, digit):
return sum(str(i).count(str(digit)) for i in range(start,end+1))
|
5062a124b3ef5bf95aae1dcaeec652e7d2cba8bb | daniel-reich/ubiquitous-fiesta | /eRY7eBD8dan54acgG_18.py | 570 | 3.84375 | 4 |
def is_checkerboard(lst):
i = 1
while i <= len(lst) - 1:
if i == len(lst) - 1:
for j in range(len(lst[i])):
if (lst[i][j] == 0 and lst[i-1][j] != 1) or (lst[i][j] == 1 and lst[i-1][j] != 0):
return False
else:
for j in range(len(lst[i])):
if (lst[i][j] == 0 and lst[i-1][j] != 1) or (lst[i][j] == 1 and lst[i-1][j] != 0) or (lst[i][j] == 0 and lst[i+1][j] != 1) or (lst[i][j] == 1 and lst[i+1][j] != 0):
return False
i += 2
return True
|
2c3d96678454965ca0a267a38df53fee76dbe3db | daniel-reich/ubiquitous-fiesta | /j9zed4GnykS48W6vh_10.py | 188 | 3.5 | 4 |
def digits(num):
x = len(str(num)) - 1
digits_ = x * pow(10, x) + (1 - pow(10, x)) // 9
rest_digits = (num - 10 ** x) * len(str(pow(10, x)))
return digits_ + rest_digits
|
7a663f9a5f2d6ce32a4cea8ee836c8e05003c438 | daniel-reich/ubiquitous-fiesta | /pTtzfmR2z7jqYXJDf_13.py | 516 | 3.71875 | 4 |
def possible_palindrome(txt):
perms=all_perms([i for i in txt])
for i in perms:
if ispalin(''.join(i)): return True
return False
def all_perms(elements):
if len(elements) <=1:
yield elements
else:
for perm in all_perms(elements[1:]):
for i in range(len(elements)):
# nb elements[0:1] works in both string and list contexts
yield perm[:i] + elements[0:1] + perm[i:]
def ispalin(string):
return string==string[::-1]
|
fabf76719265c4ab6cb67afacaf752a6507f0c88 | daniel-reich/ubiquitous-fiesta | /nmoohLwP962r6P355_12.py | 276 | 3.703125 | 4 |
def straight_digital(n):
d = ['Not Straight','Trivial Straight']
n = str(n)
if '-' in n: return d[0]
k = int(n[1])-int(n[0])
if len(n)<3 or not all(int(n[i])-int(n[i-1])==k for i in range(1,len(n))):
return d[0]
if len(set(n))==1: return d[1]
return k
|
791456600b7e1d830a7963b2a6b5dde9e7144f98 | daniel-reich/ubiquitous-fiesta | /RxHjtFqu3w8L9i5fx_21.py | 358 | 3.53125 | 4 |
import math
def binomial(n,k):
top = math.factorial(n)
bottom = math.factorial(k)*math.factorial(n-k)
return top/bottom
def stirling(n,k):
sum = 0
for i in range(0,k+1):
sum+=math.pow(-1,i)*binomial(k,i)*math.pow(k-i,n)
return 1/math.factorial(k)*sum
def bell(n):
sum = 0
for k in range(0,n+1):
sum+=stirling(n,k)
return int(sum)
|
2c82556282e4c7d2f861242d8a472a3db89cc0c4 | daniel-reich/ubiquitous-fiesta | /d6wR7bcs4M6QdzpFj_11.py | 215 | 3.546875 | 4 |
def repeat(l,n):
l*=n
return l
def add(l,x):
l+=[x]
return l
def remove(l,i,j):
[l.pop(i) for _ in range(j-i+1)]
return l
def concat(lst, lst2):
for i in lst2: lst.append(i)
return lst
|
65a89814341d0284d5a4c73822410815c685ae19 | daniel-reich/ubiquitous-fiesta | /hjZTbJNzKiSxTtbik_12.py | 163 | 3.765625 | 4 |
def sort_by_string(lst, txt):
newSort = []
for letter in txt:
for word in lst:
if word[0] == letter:
newSort.append(word)
return newSort
|
39418f3ebb77284efc918f8a5132f8a7c60fafb3 | daniel-reich/ubiquitous-fiesta | /jQGT8CNFcMXr55jeb_22.py | 71 | 3.5 | 4 |
def numbers_sum(lst):
return sum(i for i in lst if type(i) is int)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.