blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
b86297ff8d7627e0c301d6c2f16298a737a260e1 | daniel-reich/ubiquitous-fiesta | /bo4REhn9paGcFoMBs_0.py | 193 | 3.796875 | 4 |
def age_difference(ages):
[a, b, *_] = sorted(ages, reverse=True)
return 'No age difference between spouses.' if a == b else \
"{} {}".format(a - b, 'years' if a - b > 1 else 'year')
|
38b57c7ad637d1bb7dc29918aec62f6a1f4723f5 | daniel-reich/ubiquitous-fiesta | /HyLkfdagDGc99ZhbF_23.py | 84 | 3.546875 | 4 |
def f(n):
if n%2==0:
return 8
else:
return 2
print(f(12))
|
d045ce6c66bfe3b75a21c197e2e19914cfd4fea0 | daniel-reich/ubiquitous-fiesta | /xmyWLvzP5df6okDTG_24.py | 101 | 3.71875 | 4 |
def binary_to_decimal(binary):
a = ''
for item in binary:
a += str(item)
return int(a,2)
|
ddec4209734d64fccac1d063acff82f323a40638 | daniel-reich/ubiquitous-fiesta | /n5Ar5F2CJMpGRXz3o_22.py | 240 | 3.734375 | 4 |
def mineral_formation(cave):
for i in cave:
if any(cave[0]) and any(cave[-1]):
return "both"
elif any(cave[0]):
return "stalactites"
elif any(cave[-1]):
return "stalagmites"
|
9286688297bdf10c2c62c4c18a51d3c47fa4b8bc | daniel-reich/ubiquitous-fiesta | /WQjynmyMXcR83Dd8K_12.py | 1,209 | 3.78125 | 4 |
def swapPositions(list, pos1, pos2):
list[pos1],list[pos2] = list[pos2],list[pos1]
return list
def number_of_swaps(listOfNumbers):
currentNumber = 0
nextNumber = 0
count = 1
organizedListOfNumbers = []
numberOfSwaps = 0
for i in listOfNumbers:
organizedListOfNumbers.append(i... |
b5032df233baa0ff6c915a3b45940d520c5c1475 | daniel-reich/ubiquitous-fiesta | /dFz2PDjQkXZ9FhEaz_10.py | 181 | 3.78125 | 4 |
def letter_check(lst):
boolean = True
for i in lst:
for j in lst[1]:
if j.lower() not in i.lower():
boolean = False
return boolean
|
196e37b2632d6e4e1f6fd597958ce1c68eb07a49 | daniel-reich/ubiquitous-fiesta | /dMcvdFzSvvqdLJBEC_18.py | 190 | 3.828125 | 4 |
def num_of_days(cost, savings, start):
days = 0
while True:
for i in range(start, start+7):
if savings < cost: days += 1; savings += i
else: return days
start += 1
|
5810aa9c54a5b510ee065e2df051f5113f72e153 | daniel-reich/ubiquitous-fiesta | /zE37mNeG4cn6HesaP_2.py | 230 | 3.53125 | 4 |
def max_ham(s1, s2):
count = 0
if sorted(s1) != sorted(s2):
return False
else:
for i in range(len(s1)):
if s1[i]!=s2[i]:
count+=1
if count==len(s1):
return True
else:
return count
|
9543d3c7bf965f319793ee115d615b4440225f02 | daniel-reich/ubiquitous-fiesta | /ojBNREQrg7EW9ZzYx_9.py | 402 | 3.71875 | 4 |
import re
def count_eatable_chocolates(txt, price):
rx = re.compile(r'(?<!-)\b\d+(?=\s*(?:[$]|dollars))')
m, p = rx.findall(txt), rx.findall(price)
if not m or not p or p[0] == '0': return "Invalid Input"
count = wrappers = int(m[0]) // int(p[0])
while wrappers >= 3:
chocs, wrappers = divmo... |
0aaec62c8458478087713098da3bc03621779ff3 | daniel-reich/ubiquitous-fiesta | /vZJJjYWtzYCBEnnGY_7.py | 468 | 3.671875 | 4 |
def score(list_of_cards):
running_score = 0
score_dictionary = {'A':11,'3':10,'K':4,'Q':3,'J':2}
for card in list_of_cards:
card_rank = card[0]
running_score += score_dictionary.get(card_rank, 0)
return running_score
def briscola_score(my_deck1, my_deck2):
score_to_beat = 120 - score(my_deck1)
i... |
57afe40d65a28699e04dd51262ecb0b360cfe081 | daniel-reich/ubiquitous-fiesta | /Jx4mjwEoFdfYuF9ky_8.py | 136 | 3.84375 | 4 |
def hello_world(num):
return "Hello World" if num%3==0 and num%5==0 else "Hello" if num%3==0 else "World" if num%5==0 else ""
|
caefb8ca35c34e83790a49627e2c30aed6b39a35 | daniel-reich/ubiquitous-fiesta | /aqA6KSHRCwfE44Q9m_10.py | 130 | 3.609375 | 4 |
def normalize(txt):
return '{}{}!'.format(txt[0],txt[1:].lower()) if txt.isupper() else '{}{}'.format(txt[0],txt[1:].lower())
|
f3b8dbca0c42bb86aad7074812968b36e0a434e2 | daniel-reich/ubiquitous-fiesta | /dy3WWJr34gSGRPLee_16.py | 214 | 3.515625 | 4 |
def make_box(n):
c1 = ''.join(['#' for i in range(n)])
c2 = ''.join(['#' if (i == 0 or i == n-1) else ' ' for i in range(n)])
c3 = [c1 if (i == 0 or i == n-1) else c2 for i in range(n)]
return c3
|
8aee4d61234c4ef8dbad55682dd56b3bc9b7023b | daniel-reich/ubiquitous-fiesta | /4kwft4k6zebmM2BDX_17.py | 677 | 3.53125 | 4 |
def chi_squared_test(data):
matriz = [data["E"], data["T"]]
for i in range(2):
matriz[i].append(matriz[i][0] + matriz[i][1])
matriz.append([matriz[0][0] + matriz[1][0], matriz[0][1] + matriz[1][1], matriz[0][2] + matriz[1][2]])
M = [[0, 0]for i in range(2)]
chi = 0
for i in range(2):
for j in ... |
23a26b9f369d8a3722c0fb3b13a0173598dbe219 | daniel-reich/ubiquitous-fiesta | /jJuMKJcS4TwoKA6Ju_15.py | 736 | 3.578125 | 4 |
def dial(txt):
List_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" ]
List_B = [ "2", "2", "2", "3", "3", "3", "4", "4", "4", "5",
"5", "5", "6", "6", "6", "7", "7", "7", "7",... |
990101b63cc1e2b59dc0068e3645269a2310adbd | daniel-reich/ubiquitous-fiesta | /fTXXkQ7bfuQDjgNyH_8.py | 396 | 3.84375 | 4 |
def days_in_month(month, year):
if month in [4, 6, 9, 11]:
return 30
if month == 2:
return 29 if (year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)) else 28
return 31
def day_of_year(date):
month, day, year = [int(_) for _ in date.split('/')]
if month == 1:
return day... |
f97008716666d23a1f13e632721e656f3c3649b8 | daniel-reich/ubiquitous-fiesta | /NbZ2cMeEfH3KpQRku_15.py | 263 | 3.625 | 4 |
def percentage_happy(nums):
unhappy = nums[:2] == [0,1] or nums[:2] == [1,0]
unhappy += nums[-2:] == [0,1] or nums[-2:] == [1,0]
for i in range(len(nums)-2):
unhappy += nums[i:i+3] == [0,1,0] or nums[i:i+3] == [1,0,1]
return 1 - unhappy / len(nums)
|
95891bd04edfbf64afadaac37a9bee5a92a1608e | daniel-reich/ubiquitous-fiesta | /Aj377wZtxWya7gjK9_3.py | 112 | 3.515625 | 4 |
def sum_missing_numbers(lst):
s = set(lst)
return sum(i for i in range(min(s), max(s)) if i not in s)
|
c6285511394283a4e031d60926f620c700599631 | daniel-reich/ubiquitous-fiesta | /dBBhtQqKZb2eDERHg_7.py | 411 | 3.65625 | 4 |
def numberSequence(n, s = 1, r = None, t = None):
if not t:
if n < 3 : return "1" + " 1"*(n == 2) if n > 0 else "-1"
n, r = int(-1 * (n / 2) // 1 * -1), (n - 1) % 2; t = n
if s:
return " "*(t!=n)+str(n)+numberSequence(n - 1, s, r, t) if n > 1 else " 1"*(1+r) + numberSequence(n + 1, 0, r... |
47416823899b1f1caedf5e6b275bca84af09f655 | daniel-reich/ubiquitous-fiesta | /7QvH8PJgQ5x4qNGLh_4.py | 127 | 3.734375 | 4 |
def countdown(n, txt):
text = ""
for i in range(n, 0, -1):
text = text + str(i) + ". "
return text+txt.upper()+"!"
|
ff22dfc8626e184d97845359ce75bafe624ed729 | daniel-reich/ubiquitous-fiesta | /K6oxe3bvPqaQWxkFw_6.py | 164 | 3.5 | 4 |
def join_digits(n):
new_lst = []
for i in list(range(1, n + 1)):
for k in str(i):
new_lst.append(k)
return '-'.join(i for i in new_lst)
|
bdd4002986e24d790886cedbae30332cedda1ea8 | daniel-reich/ubiquitous-fiesta | /TApvBKg2WiAXPnwLS_14.py | 131 | 3.609375 | 4 |
def nth_smallest(lst, n):
lst.sort()
l = len(lst)
if n <= l:
return lst[n - 1]
else:
return None
|
f99eb16adf80328d37dc7957c39c4684a3187668 | daniel-reich/ubiquitous-fiesta | /W8rasxGkqr6JHEdiv_2.py | 1,066 | 3.5625 | 4 |
def countdown(operands, target):
import itertools
len_opands = len(operands)
len_optors = len(operands) - 1
optors = ['+', '-', '*', '//']
lst_opands = list(itertools.permutations(operands, len_opands))
lst_optors = list(itertools.product(optors, repeat = len_optors))
for x... |
0a7ba303225757043ba8498065a5ce2f26652880 | daniel-reich/ubiquitous-fiesta | /Nr33pizZC2XdHXAm6_5.py | 1,040 | 3.890625 | 4 |
import datetime
MONTHS = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']
def months_interval(dateStart, dateEnd):
year1 = dateStart.year
month1 = dateStart.month - 1
year2 = dateEnd.year
month2 = dateEnd.month - 1
... |
663e89bbd83422fac3c2f9f5d5968d42baf6a9fa | daniel-reich/ubiquitous-fiesta | /jhghtvT2s58FnDr5T_23.py | 105 | 3.53125 | 4 |
def jazzify(lst):
l = [element + "7" if element[-1]!="7" else element for element in lst]
return l
|
954685589cd12d5ae9e1022e4915b28c7d78219e | daniel-reich/ubiquitous-fiesta | /L9Zh7dWsENnE9P6qc_7.py | 316 | 3.578125 | 4 |
def josephus(people):
prisoners = []
for x in range(people):
prisoners.append(str(x+1))
count = 1
while len(prisoners)>1:
if count>=len(prisoners):
count -= len(prisoners)
continue
prisoners.pop(count)
count += 1
return int(prisoners[0])
|
073d08f76376dc6f3910de4f98a2a6d5d1294e43 | daniel-reich/ubiquitous-fiesta | /r9y4yrSAGRaqTT7nM_20.py | 301 | 3.78125 | 4 |
def find_missing(lst):
len_lst = []
if lst == None or len(lst) == 0:
return False
else:
for i in lst:
if i == None or len(i) == 0:
return False
else:
len_lst.append(len(i))
i = min(len_lst)
while i in len_lst:
i += 1
return i
|
b8118250819748c20ef9bcc15401fd4c1704d548 | daniel-reich/ubiquitous-fiesta | /2zKetgAJp4WRFXiDT_5.py | 110 | 3.546875 | 4 |
def number_length(n):
out = 0
while n >= 1:
n /= 10
out += 1
if n == 0: out += 1
return out
|
4fd2efd3cc6d4f2b28d3254a3fd28b53acd6b3a9 | daniel-reich/ubiquitous-fiesta | /wuQWimjDwkpnd4xJL_20.py | 174 | 3.53125 | 4 |
def balanced(lst):
a = len(lst) // 2
if sum(lst[:a]) > sum(lst[a:]):
return lst[:a]*2
if sum(lst[:a]) < sum(lst[a:]):
return lst[a:]*2
else:
return lst
|
4765be1bcd95fcf21339d73876b0dfaa43b4429c | daniel-reich/ubiquitous-fiesta | /3f2qF2CgM32zvQTwa_9.py | 312 | 3.75 | 4 |
def format_math(expr):
lst = expr.split(' ')
if lst[1] == '+':
res = eval(lst[0]+'+'+lst[-1])
elif lst[1] == '-':
res = eval(lst[0]+'-'+lst[-1])
elif lst[1] == 'x':
res = eval(lst[0]+'*'+lst[-1])
elif lst[1] == '/':
res = int(eval(lst[0]+'/'+lst[-1]))
return expr + ' = ' + str(res)
|
e6345e417c930da56c97ce0dc1561b55e75088e9 | daniel-reich/ubiquitous-fiesta | /kBXHbwQZPiLmwjrMy_13.py | 693 | 3.625 | 4 |
def translate_word(s):
vows = 'aoueiAOUEI'
if not s:
return s
if s[0] in vows:
return s + "yay"
for i in range(1, len(s)):
if s[i] in vows:
if s[0].isupper():
return s[i].upper() + s[i+1:] + s[0].lower() + s[1:i] + 'ay'
else:
... |
e22dfc62741de93e960d55d88f518cb6624e5888 | daniel-reich/ubiquitous-fiesta | /2Tr4gAzWimWvGpJW7_19.py | 226 | 3.703125 | 4 |
def is_there_consecutive(lst, n, times):
if times==0 and n not in lst:
return True
x = 0
for num in lst:
if num == n:
x += 1
if x == times:
return True
else:
x = 0
return False
|
78a1a6e36d35979a6c8f73791e606bb365af4471 | daniel-reich/ubiquitous-fiesta | /HvsBiHLGcsv2ex3gv_7.py | 171 | 3.671875 | 4 |
import math
def shortestDistance(txt):
lst = txt.split(',')
return round(math.sqrt(math.pow(int(lst[0]) - int(lst[2]),2) + math.pow(int(lst[1]) - int(lst[3]),2)),2)
|
1708ed3baf409213f4cf47c29643dd1baa3b3289 | daniel-reich/ubiquitous-fiesta | /GaJkMnuHLuPmXZK7h_11.py | 221 | 3.5625 | 4 |
def letters(word1, word2):
shared = sorted(set(word1) & set(word2))
uniq1 = sorted(set(word1) - set(word2))
uniq2 = sorted(set(word2) - set(word1))
return [''.join(shared), ''.join(uniq1), ''.join(uniq2)]
|
a78769ee9c79da636a61afb0487717c4c8d9c3d3 | daniel-reich/ubiquitous-fiesta | /fDfh3WJPPiiJwgTrW_24.py | 178 | 3.609375 | 4 |
def num_of_sublists(lst):
x = 0
for i in lst:
if type(i) == list:
x += 1
return x
num_of_sublists([[1],[1,4,5],[1,7,'a',3], 7, 5, 3 , [54, 2]])
|
5d3917571de62b00f8b5139a910b5643946ecf81 | daniel-reich/ubiquitous-fiesta | /662nTYb83Lg3oNN79_5.py | 416 | 3.78125 | 4 |
from math import atan2
def is_parallelogram(lst):
x, y = zip(*lst)
x_mid = sum(x) / len(lst)
y_mid = sum(y) / len(lst)
lst.sort(key=lambda p: atan2(p[1] - y_mid, p[0] - x_mid))
x, y = zip(*lst)
sides = [((x[i] - x[(i + 1) % len(x)]) ** 2
+ (y[i] - y[(i + 1) % len(x)]) ** 2) ** 0.5... |
feb583458c5af1f44f0b52233e83544ff402d292 | daniel-reich/ubiquitous-fiesta | /4bX7qAqELq9XJeB26_8.py | 213 | 4.03125 | 4 |
def to_camel_case(txt):
camel = ''
i = 0
while i < len(txt):
if txt[i] == '-' or txt[i] == '_':
camel += txt[i+1].upper()
i += 2
else:
camel += txt[i]
i += 1
return camel
|
6f6110a298ee53eb2f93ad0972014a0fb339c444 | daniel-reich/ubiquitous-fiesta | /7kZhB4FpJfYHnQYBq_23.py | 255 | 3.734375 | 4 |
def lcm_three(num):
lista = []
a, b, c = num[0], num[1], num[2]
mini = min(a, b,c)
maxi = a * b * c
for n in range(mini, maxi + 1):
if n % a == 0 and n % b == 0 and n % c == 0:
lista.append(n)
return lista[0]
|
7eec6c6536a21f9c9455d5f44ff8865d7b519c38 | daniel-reich/ubiquitous-fiesta | /bupEio82q8NMnovZx_14.py | 614 | 3.703125 | 4 |
def track_robot(instructions):
if len(instructions) == 0:
return [0,0]
direction = [0]*len(instructions)
for i in range(len(instructions)):
if instructions[i].split()[0] == 'right':
direction[i] = [int(instructions[i].split()[1]), 0]
elif instructions[i].split()[0] == 'left':
direction[i]... |
2e6d987bc632e5bba734121ca60ba045d480b6ce | daniel-reich/ubiquitous-fiesta | /gJSkZgCahFmCmQj3C_16.py | 142 | 3.671875 | 4 |
def de_nest(lst):
while type(lst) ==list:
lst = lst[0]
if type(lst)==int:
break
return lst
|
0f98af2c541f737223f5687c1249584a70c4ba1a | daniel-reich/ubiquitous-fiesta | /9Kuah39g997SvZmex_24.py | 176 | 3.5625 | 4 |
def common_last_vowel(txt):
last_v = [[x for x in word[::-1] if x in 'aeiou'][0:1] for word in txt.lower().split()]
return max(last_v, key= lambda x: last_v.count(x))[0]
|
c616e1f24c3f811c0c729150325af33328e6c930 | daniel-reich/ubiquitous-fiesta | /r9y4yrSAGRaqTT7nM_8.py | 194 | 3.75 | 4 |
def find_missing(lst):
if not lst: return False
lst = sorted(len(i) for i in lst)
if min(lst)==0: return False
for i in range(min(lst),max(lst)+1):
if i not in lst:
return i
|
e1ae48a1c161bfe52e9e044c3c9db6a48cc2a151 | daniel-reich/ubiquitous-fiesta | /kDKNRcmZfRFKxSkjz_12.py | 306 | 3.6875 | 4 |
def unmix(txt):
new_txt=''
if len(txt)%2==0:
for i in range(len(txt)):
if i%2==0:
new_txt+=txt[i+1]
new_txt+=txt[i]
elif len(txt)%2>0:
for i in range(len(txt)-1):
if i%2==0:
new_txt+=txt[i+1]
new_txt+=txt[i]
new_txt+=txt[-1]
return new_txt
|
9f172d1506eb1afe83221891af7a78565f4e9f81 | daniel-reich/ubiquitous-fiesta | /9yk63KrKDHzNFWKBJ_17.py | 576 | 3.5625 | 4 |
def is_it_inside(folders: dict, subfolder: int, targetfolder: int):
if subfolder == targetfolder:
return True
if targetfolder not in folders:
return False
if subfolder in folders[targetfolder]: # list
return True
else:
l = []
for f in folders[targetfolder]:
... |
de35322ce619709e2236c408340871ecb622c015 | daniel-reich/ubiquitous-fiesta | /JD9vSKZGrxQhLbA9r_7.py | 97 | 3.5 | 4 |
def pile_of_cubes(m):
n = 1
while m>0:
m-=n**3
n+=1
return n-1 if m==0 else None
|
f815bb221580c1576ae32f110b7174cbebd735da | daniel-reich/ubiquitous-fiesta | /gHrMmA7emP6CFAMnb_9.py | 186 | 3.890625 | 4 |
def is_apocalyptic(number):
m = str(2**number).count(str(666))
if m == 3:
return "Triple"
elif m == 2:
return "Double"
else:
return "Single" if m == 1 else "Safe"
|
74034aabfb47f2cc31bfd28b102e00f19ee6370c | daniel-reich/ubiquitous-fiesta | /fRjfrCYXWJAaQqFXF_19.py | 478 | 3.671875 | 4 |
def primorial(n):
mul = []
mul1 = 1
i = 0
while True:
if not is_prime(i):
i += 1
elif is_prime(i):
if len(mul) == n:
break
mul.append(i)
i += 1
for i in mul:
mul1 *= i
return mul1
def is... |
52681a174306879dce56ee81ffb25df022013330 | daniel-reich/ubiquitous-fiesta | /d54ESyh48HKacmTwb_12.py | 191 | 3.5 | 4 |
def gcd(lst):
lst = sorted(lst)
g = func(lst[0],lst[1])
for i in range(2,len(lst)):
g = func(g,lst[i])
return g
def func(a,b):
if b%a==0:
return a
return func(b,a%b)
|
f9e43538325792622243e44a4a73e73edc91facd | daniel-reich/ubiquitous-fiesta | /eJLwXpuaffjFnzENN_14.py | 140 | 3.875 | 4 |
def find_even_nums(num):
#vals = [expression for value in collection if condition]
return [n for n in range(1,num+1) if n%2 == 0]
|
6b5adbd63b9b1e3f9dad1320696926d8d04ba87f | daniel-reich/ubiquitous-fiesta | /vSo5XWNqKiBuN5zGr_14.py | 1,015 | 3.65625 | 4 |
def divide(*args):
Parameters = []
for arg in args:
Parameters.append(arg)
if (len(Parameters) == 2):
Parameters.append(0)
Parameters.append(abs(Parameters[0]))
Parameters.append(abs(Parameters[1]))
Value_A = Parameters[0]
Value_B = Parameters[1]
Answer = Parameters[2]
Remaini... |
bf573707595c8ef58963638107919878064168d2 | daniel-reich/ubiquitous-fiesta | /6M4gYkxWTsE6Rxhge_17.py | 231 | 3.71875 | 4 |
def is_prime(number):
if number==1: return False
for i in range(2,number):
if number%i==0: return False
return True
def all_prime(lst):
ls = [True if is_prime(element) else False for element in lst]
return all(ls)
|
27e96478a2736776680e357d30b9c9632727f40c | daniel-reich/ubiquitous-fiesta | /ZwsHZLRqx3TLFk3CR_15.py | 182 | 3.734375 | 4 |
def eval_factorial(lst):
def fact(f):
if f == 0:
return 1
else :
return f*fact(f-1)
lst1 = [int(x.strip("!")) for x in lst]
return sum([fact(x) for x in lst1])
|
b5137e39415ab80cc5f02c212470c08c9e9fa6c5 | daniel-reich/ubiquitous-fiesta | /PCtTk9RRPPKXCxnAx_18.py | 548 | 3.78125 | 4 |
def modulo(x, y):
c = 0
if x < 0:
c += 1
if y < 0:
c += 1
if c == 1:
if x < 0:
if x > -y:
return x
else:
return modulo(x+y,y)
else:
if x < abs(y):
return x
else:
... |
7d8df857827755130520c36855426321fa572e81 | daniel-reich/ubiquitous-fiesta | /G2QnBrxvpq9FacFuo_16.py | 96 | 3.578125 | 4 |
def possible_path(lst):
return all(a == 'H' or b == 'H' for a, b in zip(lst[:-1], lst[1:]))
|
1633af8e836191a121006f7246d46665b1028d84 | daniel-reich/ubiquitous-fiesta | /JgD9KHBYrDnKrGJ7a_8.py | 98 | 3.578125 | 4 |
def swap_dict(dic):
return {j: [x for x, y in dic.items() if y == j] for i, j in dic.items()}
|
eb7257da825888f8278b7d07d80226738815f47f | daniel-reich/ubiquitous-fiesta | /MiCMj8HvevYzGSb8J_1.py | 218 | 3.96875 | 4 |
def fibo_word(n): # Fibonacci word
""" Fibonacci sequence but with words """
arr = ["b", "a"]
while len(arr) < n: arr.append(arr[-1] + arr[-2])
return ", ".join(arr) if n>1 else "invalid"
|
8eda7457a95e9c9d5a9b1c3d3d9435e4b76c9149 | daniel-reich/ubiquitous-fiesta | /hfivDc24QmqWWc5Ws_12.py | 358 | 3.671875 | 4 |
def eratosthenes(n):
if n == 0 or n == 1:
return []
prime = [True for i in range(n + 1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * 2, n + 1, p):
prime[i] = False
p += 1
prime[0]= False
prime[1]= False
return [... |
7f2dfb6339a59fc0a5bc7d8329a4f231e30882b9 | daniel-reich/ubiquitous-fiesta | /r8jXYt5dQ3puspQfJ_17.py | 310 | 3.765625 | 4 |
def is_vowel(b):
vowels = "aeiou"
if str(b) in vowels:
return True
else:
return False
def split(txt):
vow = ""
cons = ""
ans = ""
for i in txt:
if is_vowel(i) == True:
vow += i
else:
cons += i
sorted(vow)
sorted(cons)
ans += vow
ans += cons
return ans
|
3898a885389d9ffc7e440ae6b9854b185c5a7e29 | daniel-reich/ubiquitous-fiesta | /LDQvCxTPv4iiY8B2A_11.py | 221 | 4.09375 | 4 |
def same_upsidedown(txt):
new = ""
for i in txt:
if i == "6":
new += "9"
if i == "9":
new += "6"
if i == "0":
new += "0"
if txt == new[::-1]:
return True
else:
return False
|
675bf4fc5a4f0e1aa89fb5a6cea0e30a517c9eb6 | daniel-reich/ubiquitous-fiesta | /dcFp6EuCm8J2HNKFG_9.py | 309 | 3.671875 | 4 |
def func(lst):
output = []
count = []
def flatten(lst):
for i in lst:
if type(i) == list:
count.append(1)
flatten(i)
else:
output.append(i)
return output
flatten(lst)
return len(count) + len(output)
|
569fdd7855543e0fa0bdc30e11a31f4aa10330a3 | daniel-reich/ubiquitous-fiesta | /nb836onw9bek4FPDt_15.py | 262 | 3.546875 | 4 |
import re
def count_same_ends(txt):
remove_punct = re.sub(r"[^ A-Za-z]", "", txt)
count = 0
for word in remove_punct.lower().split():
if len(word) > 1:
if word[0] == word[-1]:
count += 1
return count
|
31ef2f4c250d1e7ae122743deabff4549be863ff | daniel-reich/ubiquitous-fiesta | /TrP8spqHxMiLWfsg8_19.py | 810 | 3.921875 | 4 |
class Node:
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def insert(self, data):
if self.data < data:
if self.right == None:
self.right = Node(data)
else:
self.right.insert(data)
e... |
a4ee41573fa9f53082e25f94053b9c539094edf9 | daniel-reich/ubiquitous-fiesta | /vgbrdMw85i4C5sgS8_1.py | 144 | 3.578125 | 4 |
def skip_the_sugar(drinks):
lst = []
for i in drinks:
if i not in ["cola", "fanta"]:
lst.append(i)
return lst
|
b5692e20cc7376d1f10b846f6052e9da806dcfd4 | daniel-reich/ubiquitous-fiesta | /vhzXonKmxnFd5ib7s_21.py | 907 | 3.546875 | 4 |
class Matrix:
def __init__(self, matrix):
self.mtx = matrix
self.cols = []
for c in range(len(self.mtx[0])):
col = [self.mtx[r][c] for r in range(len(self.mtx))]
self.cols.append(col)
def multiply(self, other):
if len(self.cols) != len(other.mtx):
return 'inva... |
855eac061cd75fb61c9b4bf9c28087a457e8cfb1 | daniel-reich/ubiquitous-fiesta | /CMDy4pvnTZkFwJmmx_21.py | 2,654 | 3.796875 | 4 |
class Sudoku:
def __init__(self, raw_board):
board = []
row = []
current_n = 0
n = 0
while current_n < len(raw_board):
if n == 9:
board.append(row)
row = []
n = 0
row.append(int(raw_board[current_n]))
current_n += 1
n += 1
... |
c21f693e1349c55b2e5cf251bb38e7b2591c0f6b | daniel-reich/ubiquitous-fiesta | /xzisrRDwWT8prHtiQ_21.py | 237 | 3.734375 | 4 |
def difference_two(lst):
result = []
lst.sort()
for num1 in lst:
for num2 in lst:
if abs(num1-num2)==2 and sorted([num1,num2]) not in result:
result.append([num1,num2])
return result
|
cc0339d7662040d8a3d1593c444c2162540a5f79 | daniel-reich/ubiquitous-fiesta | /sHJmjMcZPiCsEujk6_2.py | 1,032 | 3.59375 | 4 |
def pilish_string(txt):
result = ""
done = False
nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9]
counter = 0
prevCounter = 0
index = 0
while not done:
counter = counter + nums[index]
if (txt[prevCounter:counter] == ""):
done = True
break
... |
85a9e36a82f43090df64d3032bbb868fab4232bd | daniel-reich/ubiquitous-fiesta | /8rXfBzRZbgZP7mzyR_11.py | 67 | 3.796875 | 4 |
def is_last_character_n(word):
return word[len(word)-1] == 'n'
|
aa87e86775e1bfdfe64bafbcdc0ad0c83b1b29dd | daniel-reich/ubiquitous-fiesta | /nC7iHBbN8FEPy2EJ2_6.py | 218 | 3.671875 | 4 |
from math import pi
class Circle:
def __init__(self, radius=0):
self.radius = radius
def getArea(self):
return pi * self.radius**2
def getPerimeter(self):
return 2 * pi * self.radius
|
c7785fc54a8c2c90e9d682a512d84c44f9bf1aa3 | daniel-reich/ubiquitous-fiesta | /4xZFisQX8NnYB3nv4_5.py | 262 | 3.65625 | 4 |
def maximum_seating(lst):
lst = [0,0] + lst + [0,0]
total = 0
for i in range(2,len(lst)-2):
if lst[i] == 0:
if all([lst[i + j] == 0 for j in [1,2,-1,-2]]):
total += 1
lst[i] = 1
return total
|
d213de457a5883138abf238be58c8f79e5120602 | daniel-reich/ubiquitous-fiesta | /od6i73gJxc6xGFzsz_6.py | 351 | 3.53125 | 4 |
def is_slidey(n):
Text = str(n)
Previous = 0
Current = 1
Length = len(Text)
while (Current < Length):
Value_A = int(Text[Previous])
Value_B = int(Text[Current])
Difference = int(abs(Value_A - Value_B))
if (Difference == 1):
Previous += 1
Current += 1
else:
... |
39e8969a5272b10de00c51e653a8490cc451e979 | daniel-reich/ubiquitous-fiesta | /6BXmvwJ5SGjby3x9Z_22.py | 314 | 3.671875 | 4 |
def hours_passed(time1, time2):
x = int(time1.split(':')[0]) + 12 if time1[-2] == 'P' else 0 if int(time1.split(':')[0]) == 12 else int(time1.split(':')[0])
y = int(time2.split(':')[0]) + 12 if time2[-2] == 'P' else int(time2.split(':')[0])
return str(y - x) + " hours" if y - x != 0 else "no time passed"
|
4d5c7ea384ec98342583fff41811ef95dc2a43dd | daniel-reich/ubiquitous-fiesta | /3tCPFQxdC5NTm5PsG_7.py | 395 | 3.515625 | 4 |
from itertools import combinations
def find_triangles(lst):
side = lambda p1, p2: (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2
count = 0
for perm in combinations(lst, 3):
A, B, C = perm
if (B[1] - A[1]) * (C[0] - A[0]) != (C[1] - A[1]) * (B[0] - A[0]):
s1, s2, s3 = side(A, B), side(B, C), side(C, A)
... |
f508b4e72f1dfc32feb8c6524afa6fccc416e626 | daniel-reich/ubiquitous-fiesta | /RJySHrDkBjSAj5gzq_1.py | 158 | 3.515625 | 4 |
import math
def nespers(lst):
ans = math.factorial(len(lst))
for i in lst:
if type(i) is list:
ans *= nespers(i)
return ans
|
63dbc292af2cff1a746d90c0a23ab99884ef77d6 | daniel-reich/ubiquitous-fiesta | /JPdKrztrcL7DpooDr_11.py | 274 | 3.65625 | 4 |
def collatz(n):
print(n)
count = 0
high = 0
if n == 1:
count = 0
high = 1
while n != 1:
count = count + 1
if high < n:
high = n
if n % 2 == 0:
n = n / 2
else:
n = (n * 3) + 1
print(count, high)
return([count, high])
|
537d8f4aaa8da4e8d11f2718eb565414b4cb172c | daniel-reich/ubiquitous-fiesta | /neMnxprBg6cM5Z4gr_2.py | 134 | 3.59375 | 4 |
def arithmetic_progression(start, diff, n):
st=''
for i in range(0,n):
st=st+str(start)+', '
start=start+diff
return st[:-2]
|
6ecc4bf660178904131c1ccd742c91d49728f73f | daniel-reich/ubiquitous-fiesta | /cMyMt377ReBsoTHnz_23.py | 117 | 3.75 | 4 |
def dict_to_list(d):
return sorted([x for x in d.items()])
print(dict_to_list({"D": 1,"B": 2,"C": 3}))
|
3098e7d2b15390511e61e3b667283f1097335514 | daniel-reich/ubiquitous-fiesta | /s45bQoPtMoZcj7rnR_14.py | 227 | 3.703125 | 4 |
def closest_palindrome(num):
a = 0
b = 0
c = 1
while str(num)!=str(num)[::-1]:
a = str(num-c)
if a==a[::-1]:
return int(a)
b = str(num+c)
if b==b[::-1]:
return int(b)
c+=1
return num
|
6e2684cffbf34fda627f54044f3808c30191c5b8 | daniel-reich/ubiquitous-fiesta | /xCFHFha5sBmzsNARH_6.py | 97 | 3.828125 | 4 |
def reverse(txt):
if len(txt)==0:
return ''
else:
return txt[-1]+reverse(txt[:-1])
|
f6639df8a677d38c3d3dd89dbf986b2a4f1bbccc | daniel-reich/ubiquitous-fiesta | /aFLqW5hqqRmM4QXZq_4.py | 788 | 3.53125 | 4 |
def bar_chart(sales):
sales_reverse = {sales[i]:i for i in sales}
sales_value_list = []
for e in sales:
if len(sales_value_list) == 0:
sales_value_list.append(e)
else:
insert = False
for i in range(len(sales_value_list)):
if sales[e] > sales[sales_value_list[i]] or (sales[e] ... |
8ed05e6a8fa14d0c35582b0c1c5c22c5e40a15ad | daniel-reich/ubiquitous-fiesta | /x3pW72MfFLi2GYh6g_12.py | 745 | 3.703125 | 4 |
def is_scalable(lst):
Length = len(lst)
if (Length < 2):
return True
Value_1A = lst[0]
Value_1B = lst[1]
Scale_01 = abs(Value_1B - Value_1A)
if (Scale_01 > 5):
return False
Value_2A = lst[-1]
Value_2B = lst[-2]
Scale_02 = abs(Value_2B - Value_2A)
if (Scale_02 > 5):
ret... |
61021749a30624c5dd95650421b5c63013870a8d | daniel-reich/ubiquitous-fiesta | /XoBSfW4j6PNKerpBa_19.py | 680 | 3.875 | 4 |
def is_prime(n):
if n < 2:
return False
if n < 4:
return True
if not n % 2:
return False
for k in range(3, int(n ** 0.5) + 1, 2):
if n % k == 0:
return False
return True
def complete_factorization(num):
if is_prime(num) or num == 1:
return... |
8759fe87064af970ab739a4dd087d0c21d55f5d0 | daniel-reich/ubiquitous-fiesta | /eHwd6medMrY3QXM8k_9.py | 397 | 3.5625 | 4 |
def is_consecutive(s):
return any([all([num - decoupe(s,p)[i+1] == 1 for i, num in enumerate(decoupe(s,p)[:-1])]) or
all([num - decoupe(s,p)[i+1] == -1 for i, num in enumerate(decoupe(s,p)[:-1])])
for p in range(1,len(s)//2+1)])
def decoupe(string,p):
if len(string)%p == 0:
return [int(stri... |
00b6a57d31f1c2e75c13f4bfdcd17ba54afbc80f | daniel-reich/ubiquitous-fiesta | /6CGomPbu3dK536PH2_8.py | 152 | 3.6875 | 4 |
def accumulating_list(lst):
a = []
for i in range(0, len(lst)):
b = 0
for j in range(0,i+1):
b += lst[j]
a.append(b)
return a
|
c4b7e51e4d564338d3815608917cc45f3d384326 | daniel-reich/ubiquitous-fiesta | /9YmYQTdPSdr8K8Bnz_14.py | 122 | 3.640625 | 4 |
def unique_lst(lst):
lst2=[]
for num in lst:
if num>0 and num not in lst2:
lst2.append(num)
return lst2
|
19d0dae0b38d0c093c4eac902c22ff2552fb938b | daniel-reich/ubiquitous-fiesta | /pSrCZFim6Y8HcS9Yc_2.py | 367 | 4 | 4 |
def convert(deg):
split_deg = deg.split('*')
if len(split_deg) == 1:
return 'Error'
else:
degree = int(split_deg[0])
unit = split_deg[1]
converted_unit = 'F'
if unit == 'C':
degree = degree * 9 / 5 + 32;
else:
converted_unit = 'C'
degree = (degree - 32) * 5 / 9
ret... |
96c7076354ddf885ed00493d2ce9969d2e14c706 | daniel-reich/ubiquitous-fiesta | /TApvBKg2WiAXPnwLS_12.py | 106 | 3.515625 | 4 |
def nth_smallest(lst, n):
lst.sort()
if n > len(lst):
return None
else:
return lst[n - 1]
|
a81c46dd502f0db6e64830ed1583b83339a2744f | daniel-reich/ubiquitous-fiesta | /W73q9yML66xXbFfGY_24.py | 224 | 3.71875 | 4 |
def coloured_triangle(row):
while len(row)>1:
trow=""
for x,y in zip(row,row[1:]):
d=list(set("RGB")-set([x,y]))
if len(d)==2:
trow+=x
else:
trow+=d[0]
row=trow
return row
|
42d3211af569d6a983a0b12941c699d1afd43d17 | daniel-reich/ubiquitous-fiesta | /kfXz49avvohsYSxoe_14.py | 265 | 3.828125 | 4 |
def binary_search(lst, left, right, elem):
if left > right:
return False
mid = (left + right) // 2
if lst[mid] < elem:
left = mid + 1
elif lst[mid] > elem:
right = mid - 1
else:
return True
return binary_search(lst, left, right, elem)
|
4210a12f7aa132f7353a10f302dcec3097095adb | daniel-reich/ubiquitous-fiesta | /2nx4JCytABfczdYGt_6.py | 644 | 3.6875 | 4 |
pronouns = {1: "Io", 2: "Tu", 3: "Egli", 4: "Noi", 5: "Voi", 6: "Essi"}
suffixes = {1: "o", 2: "i", 3: "a", 4: "iamo", 5: "ate", 6: "ano"}
def conjugate(verb, pronoun):
assert verb[-3:] == "are"
root = verb[:-3]
if pronoun in [1, 3, 5, 6]:
ans = pronouns[pronoun] + ' ' + root + suffixes[pronoun]
... |
4a3487bd61b0cb0c5a2ef41e2259f59fcae3a769 | daniel-reich/ubiquitous-fiesta | /bPHcgMpkf9WvbwbAo_18.py | 151 | 3.5625 | 4 |
def format_phone_number(lst):
lst = [str(i) for i in lst]
return "("+"".join(lst[:3])+")" + " " + "".join(lst[3:6]) + "-" + "".join(lst[6:])
|
47c659ccacdaa9f83a70b7d3153df86cbaeaecd7 | daniel-reich/ubiquitous-fiesta | /2iQhC3t4SDZ6LGMWw_15.py | 408 | 3.5 | 4 |
def on_rectangle_bounds(points):
x,y=[points[i][0] for i in range(len(points))],[points[i][1] for i in range(len(points))]
return sum([1 for i in range(len(points)) \
if (((points[i][0]== max(x) or points[i][0]==min(x)) and (points[i][1]<=max(y) and points[i][1]>=min(y))) \
or ((points[i][1]== max(y) or points... |
09463dc6f3a200600697e1c6b9a01235e48f9fa2 | daniel-reich/ubiquitous-fiesta | /srEFhCNueikMKs3oT_19.py | 251 | 3.5625 | 4 |
def consecutive_sum(n):
n2 = 2 * n
for diff in range(1, n + 1):
if not n2 % (diff + 1):
start2 = n2 // (diff + 1) - diff
if not start2 % 2 and 0 < start2 // 2 < n:
return True
return False
|
7c68937b7f56b1b9ea377e53f3c19cdbf6f36d55 | daniel-reich/ubiquitous-fiesta | /6pFZZ9CdSFDGhvNBc_15.py | 123 | 3.53125 | 4 |
def factor_group(num):
if num == 1 or num == 36 or num == 100 or num == 16:
return "odd"
else:
return "even"
|
91581ae307a8cd6e921481ce669022ee3aeb845f | daniel-reich/ubiquitous-fiesta | /cH3WN6TsqEC3qDg8f_6.py | 116 | 3.59375 | 4 |
import math
def rectangle_in_circle(w, h, radius):
return True if 2*radius>=math.sqrt(w**2+h**2) else False
|
de8d75b8f1d16ff76773d11913e6910dffee28f3 | daniel-reich/ubiquitous-fiesta | /egWRSXEE8dbKujvHw_18.py | 169 | 3.78125 | 4 |
import math
def is_circle_collision(c1, c2):
r=c1[0]+c2[0]
d=math.sqrt((c1[1]-c2[1])**2+(c1[2]-c2[2])**2)
if d>=r:
return False
elif d<r :
return True
|
4ad9a2a781043a80c6ca1abfb97ed5a0d304f5ed | daniel-reich/ubiquitous-fiesta | /X8fNb5EouWxrMMjZL_5.py | 245 | 3.921875 | 4 |
def collatz(num):
count = 1
if (num / 2) != 1:
while (num / 2) != 1:
if (num % 2) != 0:
num = num * 3 + 1
count += 1
else:
num = num / 2
count += 1
return count
else:
return count
|
2e63bddd64c05529896a82773497616ad64588b9 | daniel-reich/ubiquitous-fiesta | /9TcXrWEGH3DaCgPBs_10.py | 78 | 3.6875 | 4 |
def find_odd(lst):
for i in lst:
if lst.count(i)%2!=0:
return i
|
7f89372627187ac37c299c3d2ce3ed701c19f8fe | daniel-reich/ubiquitous-fiesta | /C6pHyc4iN6BNzmhsM_18.py | 1,778 | 3.609375 | 4 |
def get_rank(card):
rank = card[:-1]
if rank == 'J':
return 11
elif rank == 'Q':
return 12
elif rank == 'K':
return 13
elif rank == 'A':
return 14
else:
return int(rank)
def get_ranks(deck):
ranks = []
for card in deck:
rank = get_rank(card)
if rank not in rank... |
785b4da1e4669f61b049540471a6d0cfe320535b | daniel-reich/ubiquitous-fiesta | /g6yjSfTpDkX2STnSX_17.py | 95 | 3.671875 | 4 |
def convert_to_hex(txt):
return ''.join([hex(ord(char))[2:] + ' ' for char in txt])[:-1]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.