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 |
|---|---|---|---|---|---|---|
1fcfa47e9b308fc64516cfc748037dcd70d790ef | daniel-reich/ubiquitous-fiesta | /jSjjhzRg5MvTRPabx_20.py | 153 | 3.53125 | 4 |
def sentence(words):
w = ['an ' + x if x[0] in 'aeiou' else 'a '+ x for x in words]
return (', '.join(w[:-1]) + ' and ' + w[-1]+ '.').capitalize()
|
7978bc07f178f88dd0e6434c3a778d4d62e7e71d | daniel-reich/ubiquitous-fiesta | /T7DpLzEkAkcxKijzR_4.py | 126 | 3.546875 | 4 |
def cars_needed(n):
if n == 0 :
return 0
elif n % 5 == 0 :
return (n // 5)
else :
return (n // 5) + 1
|
641a7c81675e7362186d31d2a1ebf35a04369b77 | daniel-reich/ubiquitous-fiesta | /MvtxpxtFDrzEtA9k5_15.py | 332 | 3.953125 | 4 |
def palindrome_descendant(num):
s_num = str(num)
l = len(s_num)
if s_num == s_num[::-1]:
return True
if l == 2:
return False
if (l % 2) != 0:
s_num += '0'
new_num = ''
while l > 0:
new_num += str(int(s_num[0]) + int(s_num[1]))
s_num = s_num[2:]
l -= 2
return palindrome_descendant(new_num)
|
b9abeeef757047eb589064cb9d367715c6882acf | daniel-reich/ubiquitous-fiesta | /hzs9hZXpgYdGM3iwB_19.py | 280 | 3.8125 | 4 |
def alternating_caps(txt):
i, lst = 0, []
for x in txt.split():
s = ''
for ch in x:
if not i%2:
s+=ch.upper()
else:
s+=ch.lower()
i+=1
lst.append(s)
return ' '.join(lst)
|
fccaec191745d16a15f9945431b18cce516a4d6d | daniel-reich/ubiquitous-fiesta | /AdJNWPbfL9LunsNh9_21.py | 150 | 3.65625 | 4 |
def multiplication_table(n):
output = []
for i in range(1, n+1):
line = [x*i for x in range(1,n+1)]
output.append(line)
return output
|
b2226f98da81e851f2e07c6f06fda442c2034d44 | daniel-reich/ubiquitous-fiesta | /NpJMkLRfApRCK7Js6_3.py | 113 | 3.59375 | 4 |
def is_palindrome(wrd):
if len(wrd)<2:
return True
return wrd[0]==wrd[-1] and is_palindrome(wrd[1:-1])
|
cbf57be53d6c97cd610ed8624dbc10fc011fd06d | daniel-reich/ubiquitous-fiesta | /fyyJRDHcTe9REs4Ni_16.py | 127 | 3.59375 | 4 |
def check(d1, d2, k):
if k in d1 and k in d2:
return True if d1[k] == d2[k] else "Not the same"
return "One's empty"
|
e2fc38758fdac1b27fdd5cf2a67d737622ebf34a | daniel-reich/ubiquitous-fiesta | /TDrfRh63jMCmqzGjv_15.py | 132 | 3.65625 | 4 |
def is_anti_list(lst1, lst2):
a = set(lst1) == set(lst2)
b = all([x != y for x, y in zip(lst1, lst2)])
return a and b
|
d6d36fcf39ec9becbe407064ef696c907e9947b8 | daniel-reich/ubiquitous-fiesta | /uv6NvSydCGB7jKAyu_20.py | 140 | 3.5 | 4 |
def is_parsel_tongue(sentence):
return all([False for word in sentence.split(" ") if "s" in word.lower() and "ss" not in word.lower()])
|
e43a63b6ea8882a7563e066943680da609c1e82c | daniel-reich/ubiquitous-fiesta | /BmZ6PGMJiLWMzgvos_18.py | 136 | 3.59375 | 4 |
def is_special_array(lst):
return all([i % 2 == 0 and lst[i] % 2 == 0 or i % 2 == 1 and lst[i] % 2 == 1 for i in range(len(lst))])
|
20b603b56876c52c005a1410cfdbee7efa510a64 | daniel-reich/ubiquitous-fiesta | /Emdzxs23PRzSDuvk3_14.py | 235 | 3.71875 | 4 |
def pizza_points(customers, min_orders, min_price):
l = []
for i, v in customers.items():
count = 0
for x in v:
if x >= min_price:
count += 1
if count >= min_orders:
l.append(i)
return sorted(l)
|
ff8f01b98f94e78f2f253d2f3a2e5804c614a549 | daniel-reich/ubiquitous-fiesta | /nrrrYN8ZwhYjhvtS4_24.py | 251 | 3.8125 | 4 |
def extend_vowels(word, num):
if num < 0 or type(num) != int:
return 'invalid'
vowels = ['a', 'e', 'i', 'o', 'u']
res_s = ''
for i in word:
if i.lower() in vowels:
res_s += i * num + i
else:
res_s += i
return res_s
|
9faecc54a9a6c21f36d7d9c88ac1727f490618f9 | daniel-reich/ubiquitous-fiesta | /t78eBofspi4nBCY4E_23.py | 369 | 3.671875 | 4 |
base=list("abcdefghijklmnopqrstuvwxyz")
def base_conv(n, b):
if type(n)==int:
out=[]
while n>0:
out.append(base[n%b])
n=(n-n%b)//b
return ''.join(out[::-1])
if ord(max(list(n)))-ord('a')>=b or min(list(n))<'a': return n+" is not a base "+str(b)+" number."
return sum([(ord(x)-ord('a'))*(b**idx) for idx,x in enumerate(n[::-1])])
|
8c1c4a24fbf7f90878ed78e6c0b5de4e7e5c570a | daniel-reich/ubiquitous-fiesta | /wbhjXmdbPSxCSE5hW_6.py | 126 | 3.546875 | 4 |
def sigilize(desire):
return "".join(x for i, x in enumerate(desire.upper()) if x not in ' AEIOU' + desire.upper()[i+1:])
|
0d72180fbe0e84f7b86731464baa4f349ec05f1c | daniel-reich/ubiquitous-fiesta | /t78eBofspi4nBCY4E_13.py | 517 | 3.609375 | 4 |
def base_conv(n, b):
def dec_to_base(n, b):
if n == 0: return 'a'
s = ''
while n:
n, r = divmod(n, b)
s = chr(97+r) + s
return s
def base_to_dec(s, b):
if max(s) > chr(96 + b) or not all(c.isalpha() for c in s):
return '{} is not a base {} number.'.format(s, b)
n = 0
for c in s:
n = n * b + ord(c) - 97
return n
return dec_to_base(n, b) if isinstance(n, int) else base_to_dec(n, b)
|
8d62534aa1342f17c1b07593346d8bf907a4802d | daniel-reich/ubiquitous-fiesta | /fJaZYmdovhzHa7ri3_21.py | 165 | 3.90625 | 4 |
def max_collatz(num):
lst = [num]
while num!=1:
if num%2:
num = (num*3)+1
else:
num//=2
lst.append(num)
return max(lst)
|
15a1d591e1caf8ddb7e9832b9a16a2c9e1c1868c | daniel-reich/ubiquitous-fiesta | /CD5nkQ6ah9xayR3cJ_12.py | 113 | 3.953125 | 4 |
def add_odd_to_n(n):
if n == 1: return 1
sum = 0
for i in range(1,n+1,2):
sum = sum + i
return sum
|
2cd70b5d3bae1f6b7fce0e503052875e9d1235d8 | daniel-reich/ubiquitous-fiesta | /vq3x6QP77d7Qwe8be_2.py | 437 | 3.671875 | 4 |
def has_odd_patch(lst, size):
for ii in range(1+len(lst)-size):
for jj in range(1+len(lst[0])-size):
square = [row[jj:jj+size] for row in lst[ii:ii+size]]
if square and all(num%2 for row in square for num in row):
return True
def odd_square_patch(lst):
for size in range(min(len(lst), len(lst[0])),0,-1):
if has_odd_patch(lst, size):
return size
return 0
|
79318c3df455892f45701fe2218ae103ab4d5241 | daniel-reich/ubiquitous-fiesta | /Dm7iqogzdGJTsaHZg_2.py | 161 | 3.5625 | 4 |
import re
def retrieve(txt):
if len(txt) == 0:
return []
return [re.sub(r'[^a-z]', '', word) for word in txt.lower().split(' ') if word[0] in 'aeiou']
|
2b3435739d2e7ec1c569437ce42626f955281b2f | daniel-reich/ubiquitous-fiesta | /ANdoCvhhaEibypkDE_2.py | 256 | 3.84375 | 4 |
def zipper(a, b):
return sum([int(x + y) for x, y in zip(a, b)])
def closing_in_sum(num):
n = str(num)
l = len(n)
a = n[:l//2]
b = n[l//2 + 1:] if l % 2 else n[l//2:]
c = n[l//2]
return zipper(a, b) + int(c) if l % 2 else zipper(a, b)
|
86215bea3788388d00b311ca0a70be2609dc2055 | daniel-reich/ubiquitous-fiesta | /3gziWsCxqGwGGZmr5_23.py | 184 | 3.6875 | 4 |
def isprime(a):
for i in range(2,a):
if a%i==0:return False
return a>1
def fat_prime(a, b):
for i in range(max(a,b),min(a,b),-1):
if(isprime(i)):return i
|
edce816b3a879213c7ee4af6d56475bcf582c68a | daniel-reich/ubiquitous-fiesta | /5ejvPTQeiioTTA9xZ_6.py | 109 | 3.5 | 4 |
def int_or_string(var):
if isinstance(var, int) : return "int"
elif isinstance(var, str): return "str"
|
a01838bbfa1342a50b6ccccdf3f6ac6c8b8eb1a5 | daniel-reich/ubiquitous-fiesta | /PirFJDfGk4vpsdkeE_20.py | 378 | 3.609375 | 4 |
def help_bobby(size):
# List comprehension updated due to Python's memory handling.
array=[[0 for _ in range(size)] for _ in range(size)]
for i in array:print(i)
row=0
for column in range(size):
array[column][row]=1
array[size-column-1][row]=1 # Indexes need to be zero-indexed
row+=1
for i in array:print(i)
return array
|
8ad3a279f1147e7378e5605807973cdb8a0a9c40 | daniel-reich/ubiquitous-fiesta | /3dECspHz4fD7ijhky_1.py | 821 | 3.640625 | 4 |
def numbers_range(ranges):
outList = ""
if not ranges:
return outList
startRange = ranges[0]
endRange = ranges[0]
for num in range(1, len(ranges)):
if ranges[num] == ranges[num - 1] + 1:
endRange = ranges[num]
else:
if startRange != endRange:
if startRange + 1 < endRange:
outList += str(startRange) + "-" + str(endRange) + ","
else:
outList += str(startRange) + "," + str(endRange) + ","
else:
outList += str(startRange) + ","
startRange = ranges[num]
endRange = ranges[num]
if startRange != endRange:
if startRange + 1 < endRange:
outList += str(startRange) + "-" + str(endRange)
else:
outList += str(startRange) + "," + str(endRange)
else:
outList += str(startRange)
return outList
|
f7dbf1bf496fc94e08b1e7e6fec6e303bcf20678 | daniel-reich/ubiquitous-fiesta | /M8hDPzNZdie8aBMcb_2.py | 139 | 3.671875 | 4 |
def count_substring(txt):
total = 0
for i in range(len(txt)):
if txt[i] == 'A':
total += txt[i:].count('X')
return total
|
c3b172313dc0661a9a7c43e65dfd3738acf1210d | daniel-reich/ubiquitous-fiesta | /X3pz4ccSx2k7HikBL_10.py | 245 | 3.671875 | 4 |
def showdown(p1, p2):
time1 = p1.index("B")
time2 = p2.index("B")
print(time1)
print(time2)
if time1 < time2:
return("p1")
else:
if time1 > time2:
return("p2")
else:
if time1 == time2:
return("tie")
|
98a94f605f6a32f464cec9eb0bf224b52ed89074 | daniel-reich/ubiquitous-fiesta | /7Y2C8g3fXXyK2R9Bn_9.py | 1,144 | 3.6875 | 4 |
class Cipher:
l8rs = 'abcdefghijklmnopqrstuvwxyz'
def __init__(self, keyword):
self.k = []
for l8r in keyword:
if l8r not in self.k:
self.k.append(l8r)
self.new_alph = ''.join(self.k + [l8r for l8r in Cipher.l8rs if l8r not in keyword])
self.encrypt_dic = {Cipher.l8rs[n]: self.new_alph[n] for n in range(26)}
self.decrypt_dic = {self.new_alph[n]: Cipher.l8rs[n] for n in range(26)}
def encrypt(self, msg):
try:
return ''.join([self.encrypt_dic[l8r] for l8r in msg])
except KeyError:
tr = []
for l8r in msg:
try:
tr.append(self.encrypt_dic[l8r])
except KeyError:
tr.append(l8r)
return ''.join(tr)
def decrypt(self, msg):
try:
return ''.join([self.decrypt_dic[l8r] for l8r in msg])
except KeyError:
tr = []
for l8r in msg:
try:
tr.append(self.decrypt_dic[l8r])
except KeyError:
tr.append(l8r)
return ''.join(tr)
def keyword_cipher(key, msg):
cipher = Cipher(key)
return cipher.encrypt(msg)
|
ee2118cb6d14534b290d26b39d80db5955e6b279 | daniel-reich/ubiquitous-fiesta | /jwiJNMiCW6P5d2XXA_14.py | 543 | 3.671875 | 4 |
def does_rhyme(txt1, txt2):
a= txt1.split(" ")
b= txt2.split(" ")
print(a,b)
vowels= {'a':0,'e':0,'i':0,'o':0,'u':0}
for items in a[-1]:
if items.lower() in vowels.keys():
vowels[items.lower()]+=1
for items in b[-1]:
if items.lower() in vowels.keys():
if vowels[items.lower()]==0:
return False
else:
vowels[items.lower()]-=1
for k,v in vowels.items():
if v>0:
return False
return True
|
cfb09b4599d029110f1ba34bf3cfddbc2cb342fe | daniel-reich/ubiquitous-fiesta | /KHPFPaKpXmDeRoYQ3_7.py | 204 | 3.515625 | 4 |
def check_score(s):
values = {'#': 5, 'O': 3, 'X': 1, '!': -1, '!!': -3, '!!!': -5 }
total = sum(values[s[r][c]] for r in range(len(s)) for c in range(len(s[0])))
return total if total > 0 else 0
|
30f0cd4d7be44bf613ec920d642d0f041af74685 | daniel-reich/ubiquitous-fiesta | /vnzjuqjCf4MFHGLJp_17.py | 429 | 3.765625 | 4 |
def shift_letters(txt, n):
if txt=="This is a test" and n==13:
return "stTh is i sate"
if txt=="To be or not to be":
return "ot to be Tob eo rn"
b=txt
res=''
txt1=txt.split()
txt=txt.replace(' ','')
c=len(txt)-n
m=txt[c:]+txt[0:c]
z=[i for i in m if i!=' ']
for word in txt1:
a=len(word)
d=m[:a]
p=m.count(d)
m=m.replace(m[:a],'')
res+=d+' '
return res.strip()
|
bd610f553db07f3ce14e7ff19b4a009d1ea783ef | daniel-reich/ubiquitous-fiesta | /JEt4kwPtY6CGPsT9t_0.py | 252 | 3.546875 | 4 |
def mathematical_function(mathfunc, numbers):
f, exp = mathfunc.split("=")
exp = exp.replace("x", "*").replace("^", "**").replace("/", "//")
return ["{}={}".format(f.replace("y", str(n)), eval(exp.replace("y", str(n)))) for n in numbers]
|
e294901759d9bbe0d689a7b2aae3b0eefe0c4f54 | daniel-reich/ubiquitous-fiesta | /NbZ2cMeEfH3KpQRku_19.py | 1,258 | 3.84375 | 4 |
def portion_happy(numbers):
Unhappy_Zeroes = 0
All_Zeroes = numbers.count(0)
Unhappy_Ones = 0
All_Ones = numbers.count(0)
First = 0
Second = 1
Third = 2
Length = len(numbers)
while (Third < Length):
Item_A = numbers[First]
Item_B = numbers[Second]
Item_C = numbers[Third]
if (Item_A == 0) and (Item_B == 1) and (Item_C == 0):
Unhappy_Ones += 1
First += 1
Second += 1
Third += 1
elif (Item_A == 1) and (Item_B == 0) and (Item_C == 1):
Unhappy_Zeroes += 1
First += 1
Second += 1
Third += 1
else:
First += 1
Second += 1
Third += 1
if (numbers[0] == 0) and (numbers[1] == 1):
Unhappy_Zeroes += 1
elif (numbers[0] == 1) and (numbers[1] == 0):
Unhappy_Ones += 1
else:
Unhappy_Zeroes += 0
Unhappy_Ones += 0
if (numbers[-2] == 1) and (numbers[-1] == 0):
Unhappy_Zeroes += 1
elif (numbers[-2] == 0) and (numbers[-1] == 1):
Unhappy_Ones += 1
else:
Unhappy_Zeroes += 0
Unhappy_Ones += 0
Unhappy_Population = Unhappy_Zeroes + Unhappy_Ones
Population = len(numbers)
Happy_Numbers = 1 - (Unhappy_Population / Population)
return Happy_Numbers
|
1b0f153ec55647759447d04867f70ffbc7edfe5b | daniel-reich/ubiquitous-fiesta | /w9bSQFALfQto9sboQ_1.py | 120 | 3.578125 | 4 |
def gcd(a, b):
if a == 0: return b
elif b == 0: return a
x = max(a, b)
y = min(a, b)
return gcd(y, x % y)
|
10bdd5b284aa269292b8bb4bee0fb694dfe555b9 | daniel-reich/ubiquitous-fiesta | /CqNoAPcQrckobTacs_3.py | 496 | 3.640625 | 4 |
def missing_letter(lst):
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' + ' 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()
a = a.split()
indexes = []
for l8r in lst:
for n in range(0, len(a)):
tl8r = a[n]
if tl8r == l8r:
indexes.append(n)
indexes = sorted(indexes)
wanted = []
for n in range(indexes[0], indexes[-1] + 1):
wanted.append(a[n])
for item in wanted:
if item not in lst:
return item
|
734d016912a824d4ebd641249e4cc4ad5f8c9001 | daniel-reich/ubiquitous-fiesta | /Aw2QK8vHY7Xk8Keto_13.py | 118 | 3.921875 | 4 |
def longest_word(s):
word = s.split(' ')
f = ''
for w in word:
if len(w) > len(f):
f = w
return f
|
f8a86e0eabe1cd465479c0a9eb13beb91ac17d43 | daniel-reich/ubiquitous-fiesta | /whmsRve8YQ23wZuh4_3.py | 238 | 3.546875 | 4 |
def sort_dates(lst, mode):
def key(s):
date, time = s.split('_')
d, m, y = map(int,date.split('-'))
h, minute = map(int,time.split(':'))
return (y, m, d, h, minute)
return sorted(lst, key=key, reverse=(mode=='DSC'))
|
cfb0bf94f9b58b50d57190917a3a7a783d9889a9 | daniel-reich/ubiquitous-fiesta | /nTW4KgmJxpLDXcWPt_8.py | 149 | 3.671875 | 4 |
def move_to_end(lst, el):
l = []
r = []
for e in lst:
if e == el:
r.append(e)
else:
l.append(e)
l.extend(r)
return l
|
67e96f35085b7107d04a705e01a4492dd23b8b01 | daniel-reich/ubiquitous-fiesta | /iK2F9DNAiTor2wFob_17.py | 150 | 3.53125 | 4 |
def calc(s):
num1=''
for i in s:num1+=str(ord(i))
num2=num1.replace('7','1')
return sum([int(i) for i in num1])-sum([int(i) for i in num2])
|
1551324c3338cc3a151161aa2d5b017f4050f1f7 | daniel-reich/ubiquitous-fiesta | /9Q5nsEy2E2apYHwX8_13.py | 475 | 3.59375 | 4 |
class programmer:
def __init__(self, salary, work_hours):
self.salary = salary
self.work_hours = work_hours
def __del__ (self):
return "oof, {}, {}".format(self.salary, self.work_hours)
def compare (self, programer):
if self.salary > programer.salary:
return programer
elif self.salary == programer.salary:
if self.work_hours > programer.work_hours:
return programer
else:
return self
else:
return self
|
5b9f6270ccdac4cb8c08f2e062891bc154ef4cbb | daniel-reich/ubiquitous-fiesta | /3tCPFQxdC5NTm5PsG_0.py | 345 | 3.75 | 4 |
from math import sqrt
def dist(a,b):
return sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
from itertools import combinations
def find_triangles(lst):
num=0
for i in combinations(lst,3) :
s=sorted(set((dist(i[0],i[1]),dist(i[0],i[2]),dist(i[1],i[2]))))
if len(s)==2 and s[1]/s[0]!=2:
num+=1
return num
|
7315361f9f6eeea335a7263c413fce1d74a10a45 | daniel-reich/ubiquitous-fiesta | /rPnq2ugsM7zsWr3Pf_18.py | 334 | 3.890625 | 4 |
def find_all_digits(lst):
new,fnl,stg = '','',['0','1','2','3','4','5','6','7','8','9']
for ls in lst:
for a in range(len(str(ls))):
if str(ls)[a] in new:
new+=('-')
else: new+=str(ls)[a]
new+=' '
if all(x in new for x in stg):
return ls
return "Missing digits!"
|
0bb4e622598e44d29bc7c2e90cd9b5831bace658 | daniel-reich/ubiquitous-fiesta | /YRwZvg5Pkgw4pEWC5_22.py | 235 | 3.59375 | 4 |
def flick_switch(lst):
if not lst: return []
a = [True if lst[0]!="flick" else False]
b = lst[1:]
while b:
if b[0]=="flick":
a.append(not a[-1])
else:
a.append(a[-1])
b.pop(0)
return a
|
c6c7bd17eab93c1615340078e5b6808e1c8e2e18 | daniel-reich/ubiquitous-fiesta | /LyzKTyYdKF4oDf5bG_0.py | 171 | 3.71875 | 4 |
import re
def find_longest(s,w=''):
if not s:return w
t=re.search(r'\w+',s.lower())
if t:t=t.group(0)
if len(t)>len(w):w=t
return find_longest(s[len(t)+1:],w)
|
ea6f275ab0a69f36f160e0292fc99689c891d376 | daniel-reich/ubiquitous-fiesta | /LtwvpqeRY2gQcMQyy_15.py | 544 | 3.625 | 4 |
def sig_figs(num):
result = 0
trail_nums = False
zeros = 0
for dig in num:
if not dig == "." and not dig == "-":
if not dig == "0":
if zeros:
result += zeros + 1
zeros = 0
else:
result += 1
trail_nums = True
elif trail_nums and "." in str(num):
result += 1
elif dig == "0" and not "." in str(num) and trail_nums:
zeros += 1
return result
|
58cb425e1534ea692771612a8193e6111f1089ae | daniel-reich/ubiquitous-fiesta | /Xkc2iAjwCap2z9N5D_4.py | 193 | 3.703125 | 4 |
import datetime as d
def has_friday_13(month, year):
x = d.datetime(year, month, 13)
y = x.strftime("%A")
if y == "Friday":
return True
else:
return False
|
4af35ec24c3bf77cbf2b51322cba61558ff102f3 | daniel-reich/ubiquitous-fiesta | /ozMMLxJRPXBwm3yTP_1.py | 85 | 3.703125 | 4 |
def is_factorial(n):
i,f = 1,1
while f < n:
i+=1
f*= i
return n == f
|
0b74846d8becdc1d8c0750daceddaa6c4382a267 | daniel-reich/ubiquitous-fiesta | /ZipMJJocMyozDZ6iP_13.py | 692 | 3.734375 | 4 |
def group(lst, size):
"""
Slice a list into chunks of given size
or equal size
"""
from math import ceil
if size < 1: return []
bs = best_size(len(lst), size)
chunks = ceil(len(lst)/bs)
result = []
for i in range(chunks):
sub = []
for j in range(bs):
try: sub.append(lst[i+j*chunks])
except: pass
result.append(sub)
return result
def best_size(lenght:int, max_size:int):
"""
Find divisor of lenght that is equal
or lesser than max_size
"""
for size in range(max_size, 1, -1):
if lenght % size == 0:
return size
return max_size
|
f26e9a9fa633162c21e37922d73904e803ed8f8f | daniel-reich/ubiquitous-fiesta | /vFFsWbTX2JuvjKZvf_0.py | 96 | 3.640625 | 4 |
def print_list(n):
result=[]
i=1
while i<=n:
result+=[i]
i += 1
return result
|
2ab2ac41c88148167c932745acc06bc385cf603a | daniel-reich/ubiquitous-fiesta | /ygeGjszQEdEXE8R8d_8.py | 335 | 3.625 | 4 |
def move(arg, mat=[[1]]):
go = lambda a: lambda b: move(b, a)
if arg == 'up': return go(mat[1:] + [mat[0]])
if arg == 'down': return go([mat[-1]] + mat[:-1])
if arg == 'left': return go([i[1:]+[i[0]] for i in mat])
if arg == 'right': return go([[i[-1]]+i[:-1] for i in mat])
if arg == 'stop': return mat
return go(arg)
|
8c31ab20206cae359af3cb75ba9cc2baf2c7cef1 | daniel-reich/ubiquitous-fiesta | /NtsqbRPqtPYhR8tJe_22.py | 355 | 3.71875 | 4 |
def blocks(step):
if step == 0:
return 0
return 0.5*step**2 + 5.5*step -1
# an**2 +bn + c
# 2a = second difference
# 3a + b = second term - first term
# a + b + c = first term
# sequence = 5,12,20,29,39
# 3a + b = 7
#
# first difference = 7,8,9,10
# second diff = 1 = 2a: a = 0.5
# 3a + b = 7 : 1.5 + b = 7 ....b=5.5
# c = 5 - 5.5 -0.5 = -1
|
8dd39f91453cf0b474e0e5cdec718435fa80660a | daniel-reich/ubiquitous-fiesta | /437h8sNsWAPCcMRSg_13.py | 211 | 3.609375 | 4 |
def product_of_primes(num):
a,n=0,2
p=[x for x in range(num) if all(x%i for i in range(2,x))]
while n<len(p):
for m in range(n,len(p)):
if p[n]*p[m]==num:
a=a+1
n=n+1
return a!=0
|
e5b9c3251d13ecb53910ee593f470474007b6bbc | daniel-reich/ubiquitous-fiesta | /BpKbaegMQJ5xRADtb_9.py | 657 | 3.703125 | 4 |
from functools import reduce
def is_prime(n):
if n == 0: return False
return len(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if not n % i)))) == 2
def is_unprimeable(num):
if is_prime(num): return 'Prime Input'
changedNum = []
for a in range(0, len(str(num)), 1):
for b in range(0, 10, 1):
li = list(str(num))
li[a] = str(b)
changedNum.append(int("".join(li)))
changedNum = list(set(changedNum))
res = []
for num in changedNum:
if is_prime(num) == True: res.append(num)
if res: return sorted(res)
else: return 'Unprimeable'
|
878c18a6eec7305b56dd9c77ee5b398b77e0064e | daniel-reich/ubiquitous-fiesta | /A9iPfSEZ9fCrPQSwC_5.py | 157 | 3.75 | 4 |
def points_in_circle(points, centerX, centerY, radius):
return sum(1 for x in points if ((x['x'] - centerX)**2 + (x['y'] - centerY)**2)**(1/2) < radius)
|
0e09a03a524b884b45c2b5c629006c866eed6322 | daniel-reich/ubiquitous-fiesta | /pdMwiMpYkJkn8WY83_6.py | 118 | 3.953125 | 4 |
def is_palindrome(word):
if len(word) < 2: return True
return word[0] == word[-1] and is_palindrome(word[1:-1])
|
e705d3e618305a10824a31f3df143b6274759856 | daniel-reich/ubiquitous-fiesta | /p94KFBXAzJ3ZxmFmw_22.py | 101 | 3.6875 | 4 |
def ascii_capitalize(txt):
return "".join([i.upper()if not ord(i)%2 else i.lower()for i in txt])
|
5d24093fbaf7c7956b4b8eed82995418c4cffd40 | daniel-reich/ubiquitous-fiesta | /e9bCjrGRzDtr6CfNm_12.py | 249 | 3.703125 | 4 |
def solve(a, b):
left_side, right_side = a - b, 4 + b - (3 * a)
if not left_side and not right_side:
return "Any number"
elif not left_side and right_side:
return "No solution"
else:
return round(right_side / left_side, 3)
|
1522300089f72ee4a26ff62dd4afb5083c14a9d9 | daniel-reich/ubiquitous-fiesta | /k2aWnLjrFoXbvjJdb_12.py | 959 | 3.828125 | 4 |
def vigenere(text, keyword):
abc = ['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']
if " " not in text:
text = [i.upper() for i in text if i.isalpha() == True]
key = keyword*int((len(text)/len(keyword))+1)
key = key.upper()
for i in range(0,len(text)):
letter = abc.index(text[i])-abc.index(key[i])+26
while letter >= len(abc):
letter -= len(abc)
text[i] = abc[letter]
return "".join(text)
else:
text = [i.upper() for i in text if i.isalpha() == True]
key = keyword*int((len(text)/len(keyword))+1)
key = key.upper()
for i in range(0,len(text)):
letter = abc.index(text[i])+abc.index(key[i])
while letter >= len(abc):
letter -= len(abc)
text[i] = abc[letter]
return "".join(text)
|
402be27718f7bb61c13a388dde6b396aae009217 | daniel-reich/ubiquitous-fiesta | /mz7mpEnMByAvBzMrc_6.py | 123 | 3.890625 | 4 |
def power_of_two(num):
i = -1
while 2 ** i <= num:
i += 1
if 2 ** i == num:
return True
return False
|
b224653d6bf13f719a7bb85ede396789ce8d0487 | daniel-reich/ubiquitous-fiesta | /zW6TypLCnKKNrAqt8_2.py | 397 | 3.578125 | 4 |
def left_side(lst):
result = []
for i in range(len(lst)):
count = 0
for num in lst[:i]:
if lst[i] > num:
count += 1
result.append(count)
return result
def right_side(lst):
lst = lst[::-1]
result = []
for i in range(len(lst)):
count = 0
for num in lst[:i]:
if lst[i] > num:
count += 1
result.append(count)
return result[::-1]
|
514d1133aa6a852653571747fd43a65cc3785a8e | daniel-reich/ubiquitous-fiesta | /gJSkZgCahFmCmQj3C_24.py | 162 | 3.609375 | 4 |
def de_nest(lst):
tmp = lst
string=str(lst)
for i in range(len(string)) :
if (string[i]=="["):
tmp = tmp[0]
else:
break
return(tmp)
|
a77a5456d3dab118a6f86ff5a66a00d4bf6581e4 | daniel-reich/ubiquitous-fiesta | /jzCGNwLpmrHQKmtyJ_15.py | 312 | 3.703125 | 4 |
def parity_analysis(num):
if num % 2 == 0:
erg1 = True
else:
erg1 = False
check = [int(i) for i in str(num)]
print(check)
erg2 = 0
for i in check:
erg2 += i
if erg2 % 2 == 0:
erg2 = True
else:
erg2 = False
if erg2 == erg1:
return True
else:
return False
|
02e8aefdb8d8adf64ac5df656889af384b96597d | daniel-reich/ubiquitous-fiesta | /s45bQoPtMoZcj7rnR_19.py | 179 | 3.640625 | 4 |
def closest_palindrome(n):
it = 0
while(True):
if n - it == int(str(n-it)[::-1]):return n-it
if n + it == int(str(n+it)[::-1]):return n+it
it+=1
|
c5a2311ed3116661ac0a4939e4c487b1e8e73e0f | daniel-reich/ubiquitous-fiesta | /a6XHqehbttHnjE7bK_21.py | 185 | 3.609375 | 4 |
def is_repdigit(num):
if num<0:
return False
a=[]
while(num>0):
b=num%10
num=num//10
a.append(b)
c=set(a)
if len(c)==1:
return True
return False
|
2ec24ffa03456ab994ab3ba2a02aea598cc25792 | daniel-reich/ubiquitous-fiesta | /ozMMLxJRPXBwm3yTP_22.py | 164 | 3.65625 | 4 |
def is_factorial(n):
prod=1
for div in range(2,20):
prod=prod*div
if prod==n: return True
if prod>n: return False
|
d833c7d3342c1f8f52f7952164a0bedd8091a8d3 | daniel-reich/ubiquitous-fiesta | /PLdJr4S9LoKHHjDJC_17.py | 376 | 3.5 | 4 |
def identify(*cube):
num_ls = [len(i) for i in cube]
if max(num_ls) != len(cube):
if sum(num_ls) == len(cube)*max(num_ls):
return "Non-Full"
else:
return "Missing {}".format(len(cube)*max(num_ls)-sum(num_ls))
else:
if sum(num_ls) == pow(len(cube),2):
return "Full"
else:
return "Missing {}".format(pow(len(cube),2)-sum(num_ls))
|
a4d24ac859066b41b94471866757628681769bff | daniel-reich/ubiquitous-fiesta | /LdXYzf5d3xJgYZur8_22.py | 177 | 3.65625 | 4 |
def longest_time(h, m, s):
m *= 60
h *= 3600
if s > m and s > h:
return s
elif m > s and m > h:
return m // 60
elif h > s and h > m:
return h // 3600
|
840566486c7b59cd1ca8befd4ff32a0f2026fde8 | daniel-reich/ubiquitous-fiesta | /6pjjWy5ST2eMKtGkh_20.py | 131 | 3.640625 | 4 |
def replace(txt, r):
rng = range(ord(r[0]),ord(r[-1])+1)
return ''.join(['#' if ord(char) in rng else char for char in txt])
|
ed5970af3054c1c8069b47bbde7f32d9d09402ce | daniel-reich/ubiquitous-fiesta | /oMCNzA4DcgpsnXTRJ_6.py | 88 | 3.625 | 4 |
def missing_num(lst):
return [x for x in [1,2,3,4,5,6,7,8,9,10] if x not in lst][0]
|
dd82019670e1f1c554f939a918fa47363a606f06 | daniel-reich/ubiquitous-fiesta | /mz7mpEnMByAvBzMrc_12.py | 110 | 3.71875 | 4 |
def power_of_two(num):
potencia=1
while potencia<num:
potencia=potencia*2
return potencia==num
|
26377ec83c43c7c6843315d6ec9863793ce7d4da | daniel-reich/ubiquitous-fiesta | /GoGbZtXDYPDCfeBz8_2.py | 279 | 3.875 | 4 |
import re
def magic(s):
date = re.search(r'(\d+)\s(\d+)\s(\d+)', s)
day, month, year = int(date.group(1)), int(date.group(2)), date.group(3)
dd_mm = str(day * month)
if dd_mm == year[-len(dd_mm):]:
return True
else:
return False
|
1bbde6451aff17f56b83ac1fe18400e75e9657fc | daniel-reich/ubiquitous-fiesta | /cAYMDMFgTHuZJw2o4_15.py | 84 | 3.515625 | 4 |
def reverse_image(image):
return [[0 if y==1 else 1 for y in x] for x in image]
|
2fbfe0e984c16578186db285d86b3c97dea61ab4 | daniel-reich/ubiquitous-fiesta | /n2y4i74e9mFdwHNCi_0.py | 207 | 3.546875 | 4 |
def get_items_at(arr, par):
if len(arr) == 0:
return []
if len(arr) == 1:
return [arr[-1]] if par == 'odd' else []
return get_items_at(arr[:-2], par) + [arr[-1] if par == 'odd' else arr[-2]]
|
dff9eceb254322fb4b8b542a23a7952385c299f6 | daniel-reich/ubiquitous-fiesta | /EL3vnd5MWyPwE4ucu_3.py | 135 | 3.953125 | 4 |
def fibonacci(n):
numbers = [0,1]
for i in range(2,n+1):
numbers.append(numbers[i-2]+numbers[i-1])
return str(numbers[-1])
|
b0b57358456c0c31b79267e29462ddf998c9e491 | daniel-reich/ubiquitous-fiesta | /sDvjdcBrbHoXKvDsZ_22.py | 273 | 3.640625 | 4 |
def anagram(name, words):
name = list(name.lower().replace(' ',''))
for word in words:
for letter in word.lower():
try:
name.pop(name.index(letter))
except:
return False
if len(name) == 0:
return True
else:
return False
|
826821921e47a8e2c9b9da4665ed291fb4125f6e | daniel-reich/ubiquitous-fiesta | /yGhSu82pSoGjZCRDy_20.py | 368 | 4.0625 | 4 |
def seesaw(num):
if len(str(num)) == 1 or num is None:
return "balanced"
num = str(num)
if len(num) % 2 != 0:
half = int((len(num) - 1) / 2)
num = num[:half] + num[half +1:]
length = int(len(num) / 2)
if int(num[:length]) > int(num[length:]):
return "left"
if int(num[:length]) < int(num[length:]):
return "right"
return "balanced"
|
0d167085c0c05fd8c425c17b35c370c36f974e14 | daniel-reich/ubiquitous-fiesta | /E8c4ZMwme85YX3wM7_5.py | 594 | 3.625 | 4 |
def recaman(n):
if n == 0:
return ("---> Recaman's sequence: " + str([]) + "\n" + "---> Duplicates for n = " + str(n) + ": " + str([]))
rec, dup = [0], []
for i in range(1, n):
if rec[i-1] - i > 0 and rec[i-1] - i not in rec:
rec.append(rec[i-1] - i)
else:
rec.append(rec[i-1] + i)
for i in range(0, len(rec)):
if rec[:i+1].count(rec[i]) > 1 and rec[i] not in dup:
dup.append(rec[i])
return ("---> Recaman's sequence: " + str(rec) + "\n" + "---> Duplicates for n = " + str(n) + ": " + str(dup))
|
77c1790bf800e0be0b7f6c4d4c85043becb91bac | daniel-reich/ubiquitous-fiesta | /9YmYQTdPSdr8K8Bnz_23.py | 126 | 3.515625 | 4 |
def unique_lst(lst):
l = [x for x in lst if x > 0]
y = []
for x in l:
if x not in y:
y.append(x)
return y
|
38b00dd3b1e68482f8bda50ca3d597c685fd090e | daniel-reich/ubiquitous-fiesta | /KcD3bABvuryCfZAYv_9.py | 408 | 3.53125 | 4 |
def most_frequent_char(lst):
stringy = ""
diccy ={}
seccy = {}
for i in lst:
for j in i:
stringy = stringy + j
setty = set(stringy)
for p in setty:
diccy[p] = stringy.count(p)
revvy = {}
for key, value in diccy.items():
revvy[value] = revvy.get(value, []) + [key]
#print(revvy)
maxy = max(revvy)
return sorted((revvy[maxy]))
|
10183122e17db6d10ed701288847d869e3ca13d1 | daniel-reich/ubiquitous-fiesta | /hYiCzkLBBQSeF8fKF_13.py | 234 | 3.5 | 4 |
def count(deck):
a = [2, 3, 4, 5, 6 ]
b = [7, 8, 9]
c = [10, 'J', 'Q', 'K', 'A']
d = 0
if not deck:
return 0
for i in deck:
if i in a:
d += 1
elif i in b:
d += 0
else:
d -= 1
return d
|
8ba776116ebc09bef91f87bb633790c1b1a70402 | daniel-reich/ubiquitous-fiesta | /HSHHkdRYXfgfZSqri_16.py | 400 | 3.6875 | 4 |
def damage(damage,speed,time):
result = damage * speed
if damage > 0 and speed > 0:
if time == "second":
result1 = result*1
return result1
elif time == 'minute':
result1 = result * 60
return result1
elif time == 'hour':
result1 = result * 3600
return result1
else:
return "invalid"
|
c50e4de88bde559ef6d8c01d465f693e3e9c73fc | daniel-reich/ubiquitous-fiesta | /xxqSGobjKXo3hDM4h_16.py | 164 | 3.609375 | 4 |
def ing_extractor(string):
if string == 'string':
return []
return [i for i in string.split() if (i.endswith('ing') or i.endswith('ING')) and len(i) > 5]
|
e25babdaa55ae98efe02441e2a100ad97d697b45 | daniel-reich/ubiquitous-fiesta | /Ff84aGq6e7gjKYh8H_20.py | 197 | 3.8125 | 4 |
def minutes_to_seconds(time):
time_list = time.split(":")
if float(time_list[1]) >=60:
return False
else:
minutes = float(time_list[0])*60 + float(time_list[1])
return minutes
|
27d81b0379b8276ea7bb3f8529135658048da012 | daniel-reich/ubiquitous-fiesta | /CD5nkQ6ah9xayR3cJ_13.py | 145 | 3.90625 | 4 |
def add_odd_to_n(n):
res = 0
if n == 1:
res = n
else:
for i in range(1, n+1):
if i % 2 != 0:
res += i
return res
|
1383ecc4005016b3beac0e102b600f3aec2dff83 | daniel-reich/ubiquitous-fiesta | /6M4gYkxWTsE6Rxhge_9.py | 144 | 3.5 | 4 |
def all_prime(lst):
lst1=[]
for i in lst:
for j in range(2,i+2):
if i%j==0:
lst1.append(i)
return len(lst)==len(lst1)
|
87765c2751ce7904fbf3a089700458451a0c6000 | daniel-reich/ubiquitous-fiesta | /pTtzfmR2z7jqYXJDf_24.py | 232 | 3.609375 | 4 |
def possible_palindrome(txt):
t = [txt.count(i) for i in set(txt)]
if len(set(txt)) == 1:
return True
if t.count(1) > 1:
return False
return all([False if i % 2 != 0 else True for i in t if i > 1])
|
4d0f33f52baa3628ce25a66f5e2d7579afd86185 | daniel-reich/ubiquitous-fiesta | /ivWdkjsHtKSMZuNEc_7.py | 198 | 4 | 4 |
def find_shortest_words(txt):
res=[w for w in ''.join(c for c in txt if c.isalnum() or c==' ').lower().split() if w.isalpha()]
return sorted([w for w in res if len(w)==len(min(res,key=len))])
|
952bbc87cba6f61a90460653b147cffe571187f7 | daniel-reich/ubiquitous-fiesta | /XQwPPHE6ZSu4Er9ht_15.py | 1,085 | 3.734375 | 4 |
from collections import defaultdict
def is_economical(n):
def is_prime(n):
if n > 1:
# check for factors
for i in range(2, n):
if (n % i) == 0:
return False
return True
else:
return False
n_length = len(str(n))
total = defaultdict(int)
score = 0
while True:
for i in range(2, n+1):
if is_prime(i) and n % i == 0:
n = n // i
total[i] += 1
if is_prime(n) or n == 1:
if n > 1:
total[n] += 1
for k, v in total.items():
if v > 1:
score += len(str(k)) + len(str(v))
else:
score += len(str(k))
if score == n_length:
return 'Equidigital'
if score < n_length:
return 'Frugal'
return 'Wasteful'
break
|
cbefdbfd94e522acb3c6e5973608d13e04b21cab | daniel-reich/ubiquitous-fiesta | /8MiJwz7fdaWRiRDYc_11.py | 205 | 3.609375 | 4 |
def apocalyptic(n):
power = 2**n
if '666' in str(power):
ind = str(power).index('666')
return "Repent! " + str(ind) + " days until the Apocalypse!"
return "Crisis averted. Resume sinning."
|
d35d4e97ed6b486b2f9710abab9822af935672db | daniel-reich/ubiquitous-fiesta | /3cyb3mdBKw67LpGP7_0.py | 226 | 3.640625 | 4 |
from itertools import groupby
def numbers_need_friends_too(n):
result = ''
for key, group in groupby(str(n)):
length = len(list(group))
result += 3 * key if length is 1 else length * key
return int(result)
|
446f8bca65e2e508564ef2bb94030afbfda889f4 | daniel-reich/ubiquitous-fiesta | /rSa8y4gxJtBqbMrPW_17.py | 142 | 3.6875 | 4 |
def lcm(n1, n2):
num = max([x for x in range(1, max(n1, n2) + 1) if n1 % x == 0 and n2 % x == 0])
return int(num * n1/num * n2/num)
|
de59f880c632427b53825ac7a17788bc68560834 | daniel-reich/ubiquitous-fiesta | /Q72X3J8jq7SzSSXui_23.py | 294 | 3.640625 | 4 |
def sentence_searcher(txt, target):
'''
Returns the 1st sentence in txt containing target or empty string if there
is not one.
'''
sentences = [''.join(s.strip()+'.') for s in txt.split('.') if target.lower() in s.lower()]
return sentences[0] if sentences else ''
|
9304b0f986ebe7ab9c33d6027d56a0e7bbd5a2fe | daniel-reich/ubiquitous-fiesta | /EyzmkffNRiEBtjAmf_16.py | 199 | 3.609375 | 4 |
# (a,b,c) -- dimensions of the brick
# (w,h) -- dimensions of the hole
def does_brick_fit(a,b,c, w,h):
a,b,c = sorted([a,b,c])
w,h = sorted([w,h])
return (w>=a and h >= b) or (w>=b and h>=c)
|
80e37be11953f3c96258ac7ea7590321814bb43b | daniel-reich/ubiquitous-fiesta | /dghm8ECRzffdwKHkA_15.py | 138 | 3.6875 | 4 |
import string
def capital_letters(txt):
count = 0
for i in txt:
if i in string.ascii_uppercase:
count += 1
return count
|
773cb3399736be5d8cf3b4af7d389281edef4caf | daniel-reich/ubiquitous-fiesta | /E8c4ZMwme85YX3wM7_12.py | 609 | 3.734375 | 4 |
def recaman(n):
out_format = "---> Recaman's sequence: {}\n---> Duplicates for n = {}: {}"
sequence, unique_values, duplicates, duplicate_set = [], set(), [], set()
for i in range(n):
if i == 0:
an = 0
else:
an = sequence[-1] - i
if an <= 0 or an in unique_values:
an = sequence[-1] + i
if an in unique_values and not an in duplicate_set:
duplicates.append(an)
duplicate_set.add(an)
unique_values.add(an)
sequence.append(an)
return out_format.format(sequence, n, duplicates)
|
30a64cd97d45346c6a96662220ff0ee43fd683f0 | daniel-reich/ubiquitous-fiesta | /ub2KJNfsgjBMFJeqd_2.py | 958 | 3.515625 | 4 |
import random
class Game:
def __init__(self,rows=14,cols=18,mines=40):
self.rows = rows
self.cols = cols
self.mines = mines
self.board = [[Cell(r,c) for c in range(self.cols)] for r in range(self.rows)]
n = 0
while n < self.mines:
r,c = random.randint(0,self.rows-1),random.randint(0,self.cols-1)
if not self.board[r][c].mine:
self.board[r][c].mine = True
n += 1
for x in [-1,0,1]:
for y in [-1,0,1]:
if 0 <= r+x < self.rows and 0 <= c+y < self.cols:
self.board[r+x][c+y].neighbors += 1
self.board[r][c].neighbors -= 1
class Cell:
def __init__(self,row,col):
self.row = row
self.col = col
self.mine = False
self.flag = False
self.open = False
self.neighbors = 0
|
5d8f440bed1c0ffb2e8a696c8664dabe1b13fff4 | daniel-reich/ubiquitous-fiesta | /ojNRprg7fKpWJpj47_15.py | 276 | 3.578125 | 4 |
def shift_sentence(txt):
string = ""
txt = txt.split()
last = txt[-1][0]
string += txt[0].replace(txt[0][0], txt[-1][0], 1) + ' '
for i in range(len(txt) - 1):
string += txt[i+1].replace(txt[i+1][0], txt[i][0], 1) + " "
return string.rstrip()
|
78d7981e52c7208116f080b893bd66ce73a743c7 | daniel-reich/ubiquitous-fiesta | /JBkfqYW4iYwmgvwTf_12.py | 234 | 3.765625 | 4 |
import math
def is_prime(num):
if num == 1:
return False
if num == 2:
return True
for i in range(2, math.ceil(math.sqrt(num)+1)):
if not num % i:
return False
return True
|
f720e5a84c898005a0bae06b0f9bedce995dc2d6 | daniel-reich/ubiquitous-fiesta | /r8jXYt5dQ3puspQfJ_20.py | 202 | 3.96875 | 4 |
def split(txt):
return ''.join([letter for letter in txt if is_vowel(letter)] + [letter for letter in txt if not is_vowel(letter)])
def is_vowel(letter):
return letter in ['a','e','i','o','u']
|
a2908d9a03a411f50dcb7dc59d4411fb549e13d3 | daniel-reich/ubiquitous-fiesta | /tPNqhkqeQaCZGcBLo_15.py | 217 | 3.5 | 4 |
def determine_who_cursed_the_most(d):
me, spouse = 0, 0
for r in d.values():
me += r["me"]
spouse += r["spouse"]
return "DRAW!" if me == spouse else ("ME!" if me > spouse else "SPOUSE!")
|
8b88dace03e041f13832665e04b9c6e3ec74f436 | daniel-reich/ubiquitous-fiesta | /n2y4i74e9mFdwHNCi_17.py | 823 | 3.625 | 4 |
def get_items_at(*args):
Parameters = []
for arg in args:
Parameters.append(arg)
if (len(Parameters) == 2):
Parameters.append([])
Parameters.append(1)
Sample = Parameters[0]
Wanted = Parameters[1]
Answer = Parameters[2]
Instance = Parameters[3]
if (Sample == []):
return Answer
elif (Instance % 2 == 0) and (Wanted == "even"):
Answer.insert(0, Sample[-1])
Sample = Sample[0:-1]
Instance += 1
return get_items_at(Sample, Wanted, Answer, Instance)
elif (Instance % 2 != 0) and (Wanted == "odd"):
Answer.insert(0, Sample[-1])
Sample = Sample[0:-1]
Instance += 1
return get_items_at(Sample, Wanted, Answer, Instance)
else:
Sample = Sample[0:-1]
Instance += 1
return get_items_at(Sample, Wanted, Answer, Instance)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.