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 |
|---|---|---|---|---|---|---|
f1ab0d1f1c640a20c6368643e94178599c3ea066 | daniel-reich/ubiquitous-fiesta | /qgtKJx6tEMwP4JSAQ_13.py | 215 | 3.515625 | 4 |
def twins(age, distance, velocity):
t = (2*distance)/velocity
E = (1-velocity*velocity)**0.5
a = round((t+age),1)
b = round((age+E*t),1)
return "Jack's age is {}, Jill's age is {}".format(b,a)
|
13a32aa41ccbe48578fd44d4762e66bbc888133d | daniel-reich/ubiquitous-fiesta | /rSa8y4gxJtBqbMrPW_20.py | 123 | 3.5625 | 4 |
def gcd(a, b):
if a == 0:
return b
return gcd(b%a, a)
def lcm(n1, n2):
return (n1*n2) // gcd(n1, n2)
|
2b55bbdd0f421328f3663e2976ac37a9e6cfc273 | daniel-reich/ubiquitous-fiesta | /8Fwv2f8My4kcNjMZh_7.py | 263 | 3.609375 | 4 |
class ones_threes_nines:
def __init__(self, n):
self.nines = n // 9
n -= self.nines * 9
self.threes = n // 3
n -= self.threes * 3
self.ones = n
self.answer = "nines:{0}, threes:{1}, ones:{2}".format(self.nines, self.threes, self.ones)
|
1c8842a9e4c32a992747aa980117090e67000a2f | daniel-reich/ubiquitous-fiesta | /kfXz49avvohsYSxoe_21.py | 299 | 3.828125 | 4 |
def binary_search(lst, left, right, elem):
if left > right:
return False
mid = (left+right)//2
if lst[mid] < elem:
return binary_search(lst, mid + 1, right, elem)
elif lst[mid] > elem:
return binary_search(lst, left, mid - 1, elem)
elif lst[mid] == elem:
return True
|
05d2b8b13ba2b7391795670f348307c7c48db72b | daniel-reich/ubiquitous-fiesta | /aHDrvGQS6TtJeMEWn_2.py | 389 | 3.625 | 4 |
def max_sum_pair(lst):
len_lst = len(lst)
max_sums = min(lst)
for b1 in range(len_lst):
for e1 in range(b1, len_lst + 1):
for b2 in range(e1, len_lst):
for e2 in range(b2, len_lst + 1):
s = sum(lst[b1: e1]) + sum(lst[b2:e2])
if s > max_sums:
max_sums = s
return max_sums
|
941b890d4e40fb9138fe10b987f70f9c3f8726f5 | daniel-reich/ubiquitous-fiesta | /suhHcPgaKdb9YCrve_7.py | 220 | 4.0625 | 4 |
def even_or_odd(s):
od = sum(int(i) if i in "13579" else -int(i) for i in s)
if not od:
return 'Even and Odd are the same'
if od > 0:
return "Odd is greater than Even"
return "Even is greater than Odd"
|
214746803a6e9f00c6df0c2dcd21e439ed281477 | daniel-reich/ubiquitous-fiesta | /nHxBoXmRYq5vnoEnq_9.py | 299 | 3.8125 | 4 |
def vowels(string):
vowel = 0
letters = list(string)
for i in letters:
if i == 'a':
vowel = vowel + 1
if i == 'e':
vowel = vowel + 1
if i == 'i':
vowel = vowel + 1
if i == 'o':
vowel = vowel + 1
if i == 'u':
vowel = vowel + 1
return vowel
|
9f306b63d2f42afbc987bf60b3c56a13554f6c33 | daniel-reich/ubiquitous-fiesta | /sDvjdcBrbHoXKvDsZ_12.py | 226 | 3.671875 | 4 |
def anagram(name, words):
first = "".join(sorted(name.lower().replace(" ","")))
second = "".join(sorted("".join(words)))
if len(first) == len(second):
if first in second:
return True
else:
return False
|
b8fa0fe25a337ba6a173d14435b73c1f4a345d81 | daniel-reich/ubiquitous-fiesta | /c6FoPFprcNW6u5oAn_7.py | 324 | 3.671875 | 4 |
from fractions import Fraction
from itertools import combinations as com
def farey(n):
fractions = list(com([x for x in range(1,n+1)],2))
Frac = []
for n,d in fractions:
if Fraction(n,d) not in Frac:
Frac.append((Fraction(n,d)))
Frac.sort()
Frac.append("1/1")
return ["0/1"] + [str(x) for x in Frac]
|
92269f5716f703c72d318893af59541573ce03ef | daniel-reich/ubiquitous-fiesta | /QEL3QAY9ZhSkZcEih_14.py | 149 | 3.75 | 4 |
import re
def is_odd(n):
return "Yes" if n^1==n-1 else "No"
def is_even(n):
return "Yes" if re.search("[13579]$", n) is None else "No"
|
6ba95adcb4f3a74a57d74a6b83912970ec6346b4 | daniel-reich/ubiquitous-fiesta | /fJaZYmdovhzHa7ri3_17.py | 267 | 3.953125 | 4 |
def max_collatz(num):
greatest = num
current = num
while True:
if current == 1:
return greatest
else:
if current % 2 == 0:
current = current // 2
else:
current = current * 3 + 1
greatest = max(greatest,current)
|
8f8e502754d61a26fa97b745cd61b0d0c148e658 | daniel-reich/ubiquitous-fiesta | /JsLu5qWsJtuJuBZT4_4.py | 188 | 3.828125 | 4 |
def flip(string, spec):
if spec == "word":
x = [word[::-1] for word in string.split()]
x = " ".join(x)
return x
else:
y = " ".join(string.split()[::-1])
return y
|
8cc6d4506bb49ab55b59b16a84fad3fde31e73fd | daniel-reich/ubiquitous-fiesta | /XQwPPHE6ZSu4Er9ht_24.py | 527 | 3.890625 | 4 |
def factorization(n):
factors = []
i = 2
while i * i <= n:
if n % i:
i += 1
else:
n //= i
factors.append(i)
if n > 1:
factors.append(n)
return factors
def is_economical(n):
from collections import Counter
fact = ''.join([str(x)+str(y) if y>1 else str(x) for x,y in Counter(factorization(n)).items()])
if len(fact) == len(str(n)): return "Equidigital"
elif len(fact) < len(str(n)): return "Frugal"
else: return "Wasteful"
|
ec9e6f8bbe59216555d9fdf38c2fed9a8a9befc3 | daniel-reich/ubiquitous-fiesta | /bPHcgMpkf9WvbwbAo_14.py | 262 | 3.703125 | 4 |
def format_phone_number(lst):
pho_num = ''
for i in range(10):
if i == 0:
pho_num = pho_num + '('
elif i == 3:
pho_num = pho_num + ') '
elif i == 6:
pho_num = pho_num + '-'
pho_num = pho_num + str(lst[i])
return pho_num
|
3f0e21f01fe50ce8a4a12eccee306a3dbe445c71 | daniel-reich/ubiquitous-fiesta | /6LwzPRc6LrauEgr7H_7.py | 277 | 3.609375 | 4 |
def worm_length(worm):
length = 0
for l in worm:
if l != "-":
return "invalid"
else:
length = length + 1
if length == 0:
return "invalid"
else:
length = length * 10
string = str(length) + " " + "mm."
return string
|
4986c9b387de79a9cf47a4745f616beec9de3517 | daniel-reich/ubiquitous-fiesta | /YA5sLYuTzQpWLF8xP_7.py | 154 | 3.59375 | 4 |
def clean_up_list(lst):
even, odd = [], []
for i in lst:
odd.append(int(i)) if int(i)%2 else even.append(int(i))
return [even, odd]
|
701687d9659a7c7e4373ed7159096bf1b1f18a85 | daniel-reich/ubiquitous-fiesta | /QuxCNBLcGJReCawjz_7.py | 696 | 4.28125 | 4 |
def palindrome_type(n):
decimal = list(str(n)) == list(str(n))[::-1] # assess whether the number is the same read forward and backward
binary = list(str(bin(n)))[2:] == list(str(bin(n)))[2:][::-1] # assess whether the binary form of the number is the same read forward and backward
if((decimal) and (binary)): # if both decimal and binary forms of the number are palindromes
return "Decimal and binary."
if(decimal): # if only the decimal form of the number is a palindrome
return "Decimal only."
if(binary): # if only the binary form of the number is a palindrome
return "Binary only."
return "Neither!" # if neither forms of the number are palindromes
|
0283b0674435c2435d129d247b01e507a67b732d | daniel-reich/ubiquitous-fiesta | /7nfSdzzpvTta8hhNe_15.py | 137 | 3.71875 | 4 |
def organize(txt):
if not txt:
return {}
n, a, o = txt.split(', ')
return {'name':n, 'age':int(a), 'occupation':o}
|
615adde3e9f3aeab5494fec5afc56bd7a8a2c093 | daniel-reich/ubiquitous-fiesta | /WrpwKSu9XiiCEEDGC_6.py | 124 | 3.734375 | 4 |
def can_alternate(s):
return s.count("0")==s.count("1") or s.count("0")+1==s.count("1") or s.count("0")==s.count("1")+1
|
074d84cd552cfc92de64d20cc691b783ab9f1571 | daniel-reich/ubiquitous-fiesta | /8Fwv2f8My4kcNjMZh_20.py | 476 | 3.75 | 4 |
class ones_threes_nines:
def __init__(self, num):
self.num = num
self.answer = None
if self.num <= 26:
if self.num / 9 > 0:
by_9 = int(self.num/9)
if (self.num - 9*by_9)/3 > 0:
by_3 = int((self.num - 9*by_9)/3)
by_1 = (self.num - 3*by_3 - 9*by_9)
self.answer = "nines:" + \
str(by_9) + ", threes:" + str(by_3) + ", ones:" + str(by_1)
|
e95b4f0a4c0805de3dd87eda3ab4724bfb5bbdb0 | daniel-reich/ubiquitous-fiesta | /fRB5QRYn5WC8jMGTe_22.py | 589 | 3.578125 | 4 |
from datetime import datetime, timedelta
time_zones = {'Los Angeles':(-8, 0), 'New York':(-5, 0), 'Caracas':(-4, -30),
'Buenos Aires':(-3, 0), 'London':(0, 0), 'Rome':(1, 0), 'Moscow':(3, 0),
'Tehran':(3, 30), 'New Delhi':(5, 30), 'Beijing':(8, 0), 'Canberra':(10, 0)}
def time_difference(city_a, timestamp, city_b):
time = datetime.strptime(timestamp, "%B %d, %Y %H:%M")
da = timedelta(hours=time_zones[city_a][0], minutes=time_zones[city_a][1])
db = timedelta(hours=time_zones[city_b][0], minutes=time_zones[city_b][1])
return (time - da + db).strftime("%Y-%-m-%-d %H:%M")
|
b67d7f7f18a23c9e53705310fc63e4628f914bab | daniel-reich/ubiquitous-fiesta | /sZkMrkgnRN3z4CxxB_9.py | 784 | 3.609375 | 4 |
class Rectangle:
def __init__(self, x, y, w, h):
self.x = x
self.y = y
self.w = w
self.h = h
def getedges(self):
# create a dictionary of all edge coordinates
top = { (a, self.y) : True for a in range(self.x, self.x+self.w) }
bot = { (a, self.y+self.h) : True for a in range(self.x, self.x+self.w) }
lf = { (self.x , a) : True for a in range(self.y, self.y + self.h) }
rt = { (self.x+self.w , a) : True for a in range(self.y, self.y + self.h) }
rect = {}
rect.update(top)
rect.update(bot)
rect.update(lf)
rect.update(rt)
print(rect)
return rect.keys()
def intersecting(a, b):
b_coords = b.getedges()
a_coords = a.getedges()
for i in b_coords:
if i in a_coords:
return True
return False
|
b56e3a9c62d300705b40b5171cca95944d08e379 | daniel-reich/ubiquitous-fiesta | /uojwbCn2yyqqk9Wpf_20.py | 615 | 3.703125 | 4 |
import math
def aliquot_sum(n, max_n):
sum = 1
for i in range(2, n):
if sum > max_n:
return 0
if n % i == 0:
if i*i == n:
return sum + i
elif i*i > n:
return sum
else:
sum += i + n // i
return 1
def is_untouchable(number):
if number < 2:
return "Invalid Input"
nums = []
for i in range(2, number * number + 1):
if i % 2 == 1 and number % 2 == 0 and math.sqrt(i) != int(math.sqrt(i)):
continue
asum = aliquot_sum(i, number)
if asum == number:
nums.append(i)
if len(nums) == 0:
return True
return nums
|
5a8d5bc955057131a5956282549e8e2563bd8a8b | daniel-reich/ubiquitous-fiesta | /CMqa7tAtffudQ7hs4_1.py | 172 | 3.640625 | 4 |
def sorting_steps(l):
s=[]
for i in range(len(l)-1):
for j in range(i,len(l)):
if l[i]>l[j]:
s.append((i,j))
l[i],l[j]=l[j],l[i]
return s
|
69d427c4bf610ddd529cd26225289186bec76c5f | daniel-reich/ubiquitous-fiesta | /dMcvdFzSvvqdLJBEC_24.py | 346 | 3.78125 | 4 |
def num_of_days(cost, savings, start):
target = cost - savings
total = 0
monday = start
n_days = 0
while total < target:
for d in range(7):
add_on = monday + d
total += add_on
n_days += 1
if total >= target:
break
monday += 1
return n_days
|
d8646aa9c06efd693fcd7f38e748fd7515f562ce | daniel-reich/ubiquitous-fiesta | /ecwE3tQK9Na8GJ9pN_20.py | 249 | 3.5625 | 4 |
def little_big(n):
x = 100
if n == 2:
return x
elif n % 2 == 0:
n = n//2
for i in range(0,n-1):
x = x*2
return x
elif n % 2 != 0 :
y = (n-1)/2 +5
return y
little_big(10)
|
1eefe9271e83a66a34d167bffa319101ae376a95 | daniel-reich/ubiquitous-fiesta | /fRB5QRYn5WC8jMGTe_9.py | 438 | 3.515625 | 4 |
from datetime import datetime,timedelta
def time_difference(city_a, timestamp, city_b):
timestamp = datetime.strptime(timestamp,"%B %d, %Y %H:%M")
cities = {'Los Angeles':-8,'New York':-5,'Caracas':-4.5,'Buenos Aires':-3,'London':0,'Rome':1,'Moscow':3,'Tehran':3.5,'New Delhi':5.5,'Beijing':8,'Canberra':10}
diff = cities[city_b]-cities[city_a]
timestamp += timedelta(hours=diff)
return timestamp.strftime("%Y-%-m-%-d %H:%M")
|
056d0988fdd3ca90039af3b3986890156734592c | daniel-reich/ubiquitous-fiesta | /hfBoDAN8YMz7cxGqB_23.py | 343 | 3.703125 | 4 |
def we_have_house(hh, hw, hd, rh):
if hh+rh>20:
return "No permission."
elif hw<=14 or hd<=10:
return "House too small."
elif hw>=45 or hd>=45:
return "House too big."
else:
gray = 2*(2*hw+2*hd)-6
yellow = (hh-2)*(2*hw+2*hd)+rh*hw-3*5-4*2*12
resp = "Yellow: "+str(yellow)+", Gray: "+str(gray)
return resp
|
966c991f719ba7cb2b018a7a48df3899a607630b | daniel-reich/ubiquitous-fiesta | /jjPGM3a22AgzcBFCx_22.py | 113 | 3.671875 | 4 |
def decrypt(lst):
c = list(range(1, 26))
for x in c:
if x not in lst:
d = x
return chr(d + 64)
|
9c9f8311e411da2a2913255e5af29ba5709bc5b7 | daniel-reich/ubiquitous-fiesta | /mYGipMffRTYxYmv5i_9.py | 235 | 3.84375 | 4 |
def simple_equation(a, b, c):
if a+b==c: return '{}+{}={}'.format(a,b,c)
elif a-b==c: return '{}-{}={}'.format(a,b,c)
elif a*b==c: return '{}*{}={}'.format(a,b,c)
elif a/b==c: return '{}/{}={}'.format(a,b,c)
else:return ""
|
caf063bbad2d6aa3cb04f720be0a713e2962c50e | daniel-reich/ubiquitous-fiesta | /vudQZFD64nDWkKz8a_6.py | 254 | 3.625 | 4 |
def grant_the_hint(txt):
txt_array = txt.split(" ")
max_length = len(max(txt.split(" "), key=len))
H = list()
for n in range(max_length+1):
hint = [word[:n] + '_'*(len(word)-n) for word in txt_array]
H.append(' '.join(hint))
return H
|
4f84a41b1f580a097d3293aa674c7d639a1f910e | daniel-reich/ubiquitous-fiesta | /2nciiXZN4HCuNEmAi_20.py | 159 | 3.671875 | 4 |
def flatten(r):
out = []
for i in r:
if type(i) is list:
for j in flatten(i):
out.append(j)
else:
out.append(i)
return out
|
3e4d1cd76f7deba293bb6bbfd3b1e2c70539a8f2 | daniel-reich/ubiquitous-fiesta | /YK9fWNBbRJ9PEc4wR_6.py | 127 | 3.6875 | 4 |
def tuck_in(lst1, lst2):
for n in lst2:
lst1.append(n)
lst1.append(lst1[1])
lst1.pop(1)
return(lst1)
|
59c630493d2e65ea962bb272a10a816252da5c5d | daniel-reich/ubiquitous-fiesta | /egHeSWSjHTgzMysBX_7.py | 182 | 3.796875 | 4 |
def half_a_fraction(fract):
fr = list(map(int,fract.split("/")))
if int(fr[0]) % 2 == 0:
return str(fr[0]//2)+"/"+str(fr[1])
else:
return str(fr[0])+"/"+str(fr[1]*2)
|
d4d1cefc58130c4b3c8cc1c8b835d555a02898b9 | daniel-reich/ubiquitous-fiesta | /hah7DaHKswkT8Tjtq_1.py | 559 | 3.578125 | 4 |
def separate_numbers(s):
len_num = 1
len_s = len(s)
while len_num <= len_s // 2:
s_tmp = s[:]
start_num = s_tmp[:len_num]
s_tmp = s_tmp[len_num:]
next_num = int(start_num) + 1
while s_tmp:
str_next = str(next_num)
if s_tmp.startswith(str_next):
s_tmp = s_tmp[len(str_next):]
next_num = int(str_next) + 1
else:
break
if not s_tmp:
return "YES {}".format(start_num)
len_num += 1
return "NO"
|
91134301825e987e8b81bedf2987e1659efda64e | daniel-reich/ubiquitous-fiesta | /H9gjahbSRbbGEpYta_8.py | 231 | 3.65625 | 4 |
def multiply(n1, n2):
pos = n1 > 0 and n2 > 0 or n1 < 0 and n2 < 0
n1, n2 = abs(n1), abs(n2)
count = 1
answer = n1
while count < n2:
answer += n1
count += 1
if pos == False:
return -answer
return answer
|
c084d2eb7d9b17cfac6ff034032f9c694be466b7 | daniel-reich/ubiquitous-fiesta | /hZ4HzhboCJ5dDiNve_2.py | 538 | 3.9375 | 4 |
def special_reverse_string(txt):
new_txt = []
special_reversed = []
for char in reversed(txt):
if char != " ":
new_txt.append(char.lower())
j = 0
for i in range(0, len(txt)):
if txt[i] != " " and txt[i].isupper():
special_reversed.append(new_txt[j].upper())
j += 1
elif txt[i] == " ":
special_reversed.append(" ")
else:
special_reversed.append(new_txt[j])
j += 1
return "".join(special_reversed)
|
1c217cd8a9d5a0fb13613df5e48c1be0e32c9918 | daniel-reich/ubiquitous-fiesta | /CB3pKsWR3b7tvvxmN_6.py | 136 | 3.8125 | 4 |
import re
def is_palindrome(txt):
txt = re.sub(r'[^\w\s]','',txt)
txt = txt.replace(' ','').lower()
return txt==txt[::-1]
|
9bc1f515d332bf5994f5bb3285dea8a1bab1dc6c | daniel-reich/ubiquitous-fiesta | /wqBnr3CDYByA5GLxo_23.py | 421 | 3.5 | 4 |
import re
import itertools
def generate(x):
if len(x) >= 1 and x[0] == '[':
elms = x[1:-1].split('|')
for e in elms:
yield e
else:
yield x
def unravel(txt):
chunks = re.split(r'(\[.*?\])', txt)
gens = []
for c in chunks:
gens.append([e for e in generate(c)])
results = []
for t in itertools.product(*gens):
results.append(''.join(t))
return sorted(results)
|
a1222061fd1928cf80c3751270ea9dfe33ce01a5 | daniel-reich/ubiquitous-fiesta | /4WNkqa5Pb6Lh6ZXvs_11.py | 788 | 3.6875 | 4 |
import re
def evaluate_polynomial(poly, num):
if not poly:
return "invalid"
elif "//" in poly:
return "invalid"
else:
try:
def coefficient(match):
a,b = match.group(1,2)
return a + "*" + b
def variable(match):
a,b,c = match.group(1,2,3)
return a + num + b
def parents(match):
a,b,c = match.group(1,2,3)
return a + eval(b) + c
poly = re.sub(r'\^2',"* x", poly)
poly = re.sub(r'(\d+)(x)',coefficient,poly)
poly = poly.replace("x",str(num))
poly = re.sub(r'({})(x\+\d|x-\d)({})'.format("(",")"),parents,poly)
poly = poly.replace("(","*")
poly = poly.replace(")","")
return int(poly) if poly.isdigit() else eval(poly)
except TypeError:
return "invalid"
|
b6c99f69b0ae43fb2b2ec9bcb47c52507a3f110a | daniel-reich/ubiquitous-fiesta | /srEFhCNueikMKs3oT_7.py | 153 | 3.53125 | 4 |
def consecutive_sum(n):
A=[]
for i in range(1, n//2+1):
s=0
while s<n:
s+=i
i+=1
if s==n:
return True
return False
|
7014b8903883c726780efd1962299b4349cbb30f | daniel-reich/ubiquitous-fiesta | /LyzKTyYdKF4oDf5bG_16.py | 410 | 3.546875 | 4 |
def find_longest(s, wi = 0, max_size = 0, largest = None):
if isinstance(s, str) == True:
s = s.replace('.', '').replace('\"', '')
s = s.split()
if wi == len(s):
return largest.lower()
else:
if len(s[wi]) > max_size:
if '\'' in s[wi]:
s[wi] = s[wi].split('\'')[0]
max_size = len(s[wi])
largest = s[wi]
return find_longest(s, wi+1, max_size, largest)
|
23b3dbf8b085835062fe1b76a98444caaf206ef2 | daniel-reich/ubiquitous-fiesta | /Mm8SK7DCvzissCF2s_5.py | 140 | 3.734375 | 4 |
def is_alpha(word):
return True if sum(ord(letter.lower()) + 1 - ord("a") for letter in word if letter.isalpha()) % 2 == 0 else False
|
6e06d0506989f0cf45d3d4918d93f8d1d6a22f7a | daniel-reich/ubiquitous-fiesta | /u3kiw2gTY3S3ngJqo_23.py | 123 | 3.6875 | 4 |
def superheroes(lst):
l = [i for i in lst if i.lower()[-3:] == "man" and i.lower()[-5:] != "woman"]
return sorted(l)
|
2a9e7687f61c38b909861f682ed86e1fb58c525f | daniel-reich/ubiquitous-fiesta | /vQgmyjcjMoMu9YGGW_15.py | 775 | 3.71875 | 4 |
def simplify(txt):
new1 = ""
new2 = ""
switch = 0
for i in range(len(txt)):
if txt[i] == "/":
switch +=1
elif switch ==1 :
new2 = new2+txt[i]
else:
new1 = new1+txt[i]
new1 = int(new1)
new2 = int(new2)
if new2 > new1:
c = new2
for i in range(new2):
if c == 1:
return txt
if new1%c == 0 and new2%c == 0:
return "{}/{}".format(int(new1/c),int(new2/c))
else:
c-=1
elif new2 == new1:
return str(int(new2/new1))
else:
if new1%new2 == 0:
return str(int(new1/new2))
else:
c = new1
for i in range(new1):
if c == 1:
return txt
if new1%c == 0 and new2%c == 0:
return "{}/{}".format(int(new1/c),int(new2/c))
c-=1
|
644be931e9cba5b4ff8052cf9402741dafb5145e | daniel-reich/ubiquitous-fiesta | /LDQvCxTPv4iiY8B2A_21.py | 171 | 3.5625 | 4 |
def same_upsidedown(ntxt):
res = ntxt.replace('6', '%temp%').replace('9', '6').replace('%temp%', '9')
if res[::-1] == ntxt:
return True
else:
return False
|
25c42ad72ae8ca03e21158476fbf892855efba05 | daniel-reich/ubiquitous-fiesta | /2nx4JCytABfczdYGt_10.py | 378 | 3.640625 | 4 |
def conjugate(verb, pronoun):
pr = ['Io', 'Tu', 'Egli', 'Noi', 'Voi', 'Essi']
suf = ['o', 'i', 'a', 'iamo', 'ate', 'ano']
root = verb[:-3]
suffix = suf[pronoun-1]
if root.endswith('c') or root.endswith('g'):
suffix = 'h' + suffix
elif root.endswith('i'):
if suffix.startswith('i'):
suffix = suffix[1:]
return pr[pronoun-1] + ' ' + root + suffix
|
2e19e08c1824288b9fb38f0bea1a89e3b81f3db3 | daniel-reich/ubiquitous-fiesta | /xFKwv7pAzEdNehwrt_3.py | 425 | 3.578125 | 4 |
def bracket_logic(xp):
new = ""
for c in xp:
if c in "{[(<>)}]":
new += c
if (len(new) % 2) == 0:
i = 0
while i <= len(new):
new = new.replace("()", "")
new = new.replace("<>", "")
new = new.replace("{}", "")
new = new.replace("[]", "")
i += 1
if len(new) == 0:
return True
return False
|
3347d3e0173fa4041cc1b5d126b19681e4646ebf | daniel-reich/ubiquitous-fiesta | /Ns4Sjh7KK58ofAph8_18.py | 97 | 3.65625 | 4 |
def is_triplet(n1, n2, n3):
l=[n1,n2,n3]
l1=sorted(l)
return l1[0]**2+l1[1]**2==l1[2]**2
|
72ecba797eb383ab2041e175719f3e917a8864f6 | daniel-reich/ubiquitous-fiesta | /Qjn6B93kXLj2Kq5jB_7.py | 150 | 3.765625 | 4 |
from fractions import Fraction
def simplify_frac(f):
f = Fraction(f)
num = str(f.numerator)
den = str(f.denominator)
return num + '/' + den
|
49b69f9d1791fc7239d8a556b6e66e809e74cba4 | daniel-reich/ubiquitous-fiesta | /DjyqoxE3WYPe7qYCy_4.py | 100 | 3.671875 | 4 |
def reverse_odd(txt):
return ' '.join(i[::-1] if len(i) % 2 != 0 else i for i in txt.split())
|
aba893701b835cc9db7600c2be08312d772520dc | daniel-reich/ubiquitous-fiesta | /Ns4Sjh7KK58ofAph8_12.py | 106 | 3.578125 | 4 |
def is_triplet(n1, n2, n3):
return True if 2 * max(n1, n2, n3)**2 == n1**2 + n2**2 + n3**2 else False
|
720c43e59f973d13b0fd7dd5e9bc3236167cecf9 | daniel-reich/ubiquitous-fiesta | /ojBNREQrg7EW9ZzYx_3.py | 170 | 3.703125 | 4 |
import re
def count_eatable_chocolates(t,c):
a,b=map(int,re.findall('-?\d+',t+c))
if b<1:return'Invalid Input'
k=s=a//b
while k>2:n=k//3;s+=n;k-=2*n
return s
|
67bb7d672f53580f16d7938f25cdee5f4b20dc82 | daniel-reich/ubiquitous-fiesta | /egWRSXEE8dbKujvHw_23.py | 259 | 3.734375 | 4 |
def is_circle_collision(c1, c2):
distance=((c2[1]-c1[1])**2+(c2[2]-c1[2])**2)**0.5
if distance<max(c1[0], c2[0]) and distance+min(c1[0],c2[0]) < max(c1[0], c2[0]):
return True
elif distance >= c1[0]+c2[0]:
return False
else:
return True
|
631696f61f5265736553edc86aca6addfdf47845 | daniel-reich/ubiquitous-fiesta | /nrrrYN8ZwhYjhvtS4_16.py | 165 | 3.765625 | 4 |
def extend_vowels(word, num):
if num == int(abs(num)):
return ''.join([i*(num+1) if i.lower() in 'ioeau' else i for i in word])
else:
return "invalid"
|
60f5efeee9bbf867fa30081832965b7b2a7a4820 | daniel-reich/ubiquitous-fiesta | /Ns4Sjh7KK58ofAph8_22.py | 128 | 3.828125 | 4 |
def is_triplet(n1, n2, n3):
p = sorted([n1,n2,n3])
return (p[0])**2 + (p[1])**2 == (p[2])**2
print(is_triplet(1,9,5))
|
4bdd23df689de90bb567985e0ca01604eb5c2c39 | daniel-reich/ubiquitous-fiesta | /qwDPeZeufrHo2ejAY_12.py | 523 | 3.640625 | 4 |
def eval_algebra(eq):
lst = eq.split()
if lst.index("x") == 4:
if lst[1] == "+":
return int(lst[0]) + int(lst[2])
else:
return int(lst[0]) - int(lst[2])
if lst.index("x") == 2:
if lst[1] == "+":
return int(lst[4]) - int(lst[0])
else:
return int(lst[0]) - int(lst[4])
if lst.index('x') == 0:
if lst[1] == '+':
return int(lst[4]) - int(lst[2])
else:
return int(lst[4]) + int(lst[2])
|
aec9be4bb89a8f3872453447a7a3a4af7aca13a5 | daniel-reich/ubiquitous-fiesta | /TDrfRh63jMCmqzGjv_14.py | 172 | 3.921875 | 4 |
def is_anti_list(lst1, lst2):
print(lst1,lst2)
for i in range(len(lst1)):
if set(lst1) == set(lst2):
return lst1[i] != lst2[i]
else:
return False
|
c420be02788b95fcd38693ae6ce86bec7b7a1a18 | daniel-reich/ubiquitous-fiesta | /dRjHygERcDJpiDzze_14.py | 188 | 3.609375 | 4 |
def lengthen(s1, s2):
n1 = len(s1)
n2 = len(s2)
res = ""
if n1 < n2:
res = ( (int(n2 / n1) + 1) * s1)[ : n2]
else:
res = ( (int(n1 / n2) + 1) * s2)[ : n1]
return res
|
ea1f8f5348f3c9373e97f65183be8a4b7b53263b | daniel-reich/ubiquitous-fiesta | /dghm8ECRzffdwKHkA_23.py | 104 | 3.515625 | 4 |
def capital_letters(txt):
temp=0
for i in (txt):
if(i.isupper()):
temp+=1
return temp
|
97eb4b798c1f5e787eb0bbed56009bfbc926e88f | daniel-reich/ubiquitous-fiesta | /bo4REhn9paGcFoMBs_17.py | 190 | 3.78125 | 4 |
def age_difference(ages):
ages=sorted(ages)
diff=ages[-1]-ages[-2]
if diff==0:
return "No age difference between spouses."
else:
return '{} year'.format(diff)+'s'*(diff>1)
|
8f73c96e5fe1c5912a435073debba03215d8e2ed | daniel-reich/ubiquitous-fiesta | /Nda8BQHhZSajpnt5z_13.py | 116 | 3.5625 | 4 |
from functools import reduce
gcd = lambda a, b: gcd(b, a % b) if b else a
def GCD(lst):
return reduce(gcd, lst)
|
cb47e5a507aa88ecfbbc93b92f535f983c9e7ba2 | daniel-reich/ubiquitous-fiesta | /FT5Zd4mayPa5ghpPt_1.py | 529 | 3.640625 | 4 |
import re
def color_conversion(h):
if isinstance(h,dict):
if any(list(map(lambda x: x > 255 or x < 0, h.values()))):
return "Invalid input!"
string = ''.join('{:02X}'.format(a) for a in [h['r'],h['g'],h['b']])
return "#" + string.lower()
elif bool(re.search(r'[^f]+ff|ff[^f]',h)) == True:
return "Invalid input!"
else:
dictionary = {}
h = h.lstrip("#")
for char,letter in zip([h[x:x+2] for x in range(0,6,2)],['r','g','b']):
dictionary[letter] = int(char,16)
return dictionary
|
e1f27cc39e04e9f79c931ff70dd4e472ab65e63b | daniel-reich/ubiquitous-fiesta | /iLLqX4nC2HT2xxg3F_18.py | 112 | 3.5625 | 4 |
def deepest(lst):
mx = 0
for x in lst:
if type(x) is list:
mx=max(mx, deepest(x))
return mx+1
|
a487645daf6d1b4e16fd730f7e4ea1d4e7c5759e | daniel-reich/ubiquitous-fiesta | /CMDy4pvnTZkFwJmmx_12.py | 1,803 | 3.640625 | 4 |
class Sudoku:
def __init__(self, board):
blst = []
for i in board:
blst.append(int(i))
self.boardlst = blst
self.board = [self.boardlst[0:9],self.boardlst[9:18], self.boardlst[18:27],self.boardlst[27:36],
self.boardlst[36:45], self.boardlst[45:54], self.boardlst[54:63], self.boardlst[63:72], self.boardlst[72:81]]
self.squares = {0:self.board[0][0:3]+self.board[1][0:3]+self.board[2][0:3]}
self.squares[1] = self.board[0][3:6]+self.board[1][3:6]+self.board[2][3:6]
self.squares[2] = self.board[0][6:9]+self.board[1][6:9]+self.board[2][6:9]
self.squares[3] = self.board[3][0:3]+self.board[4][0:3]+self.board[5][0:3]
self.squares[4] = self.board[3][3:6]+self.board[4][3:6]+self.board[5][3:6]
self.squares[5] = self.board[3][6:9]+self.board[4][6:9]+self.board[5][6:9]
self.squares[6] = self.board[6][0:3]+self.board[7][0:3]+self.board[8][0:3]
self.squares[7] = self.board[6][3:6]+self.board[7][3:6]+self.board[8][3:6]
self.squares[8] = self.board[6][6:9]+self.board[7][6:9]+self.board[8][6:9]
def get_row(self, row):
return self.board[row]
def get_col(self, col):
c = []
for i in range(0, len(self.board)):
c.append(self.board[i][col])
return c
def get_sqr(self, *n):
try:
if n[1] < 3:
if n[0] <3: return self.squares.get(0)
elif n[0] < 6: return self.squares.get(3)
else: return self.squares.get(6)
elif n[1] < 6:
if n[0] <3: return self.squares.get(1)
elif n[0] < 6: return self.squares.get(4)
else: return self.squares.get(7)
else:
if n[0] < 3: return self.squares.get(2)
elif n[0] < 6: return self.squares.get(5)
else: return self.squares.get(8)
except:
return self.squares.get(n[0])
|
e682522f604b81d70a81058e99807f18d5d893bd | daniel-reich/ubiquitous-fiesta | /PCtTk9RRPPKXCxnAx_5.py | 270 | 3.78125 | 4 |
def modulo(x, y):
if abs(x) < abs(y):
return x
else:
if (x<0 and y>0):
return -(modulo (abs(x)-y, y))
elif (x>0 and y<0):
return (modulo (x-abs(y), y))
else:
return modulo (x-y, y)
|
d855dd79c2ca5ee476e370c139a27e2276cf320b | daniel-reich/ubiquitous-fiesta | /dcdy9QMBbryyWENcm_14.py | 103 | 3.546875 | 4 |
def total_cups(n):
if n < 6:
return n
elif n >= 6:
total = n + (n // 6)
return total
|
b96d61a09c07830f53171d358f010140c2e99aeb | daniel-reich/ubiquitous-fiesta | /EXNAxFGgDDtE3SbQf_2.py | 343 | 3.625 | 4 |
def shuffle_count(num, count=0, deck=None):
if not count:
deck = list(range(num))
half = num // 2
left, right = deck[:half], deck[half:]
deck_s = [right[i // 2] if i % 2 else left[i // 2] for i in range(num)]
return (shuffle_count(num, count + 1, deck_s) if deck_s != list(range(num))
else count + 1)
|
ce3d5075e296f53ebf528110db072d0128b12485 | daniel-reich/ubiquitous-fiesta | /88RHBqSA84yT3fdLM_14.py | 232 | 3.5625 | 4 |
def inator_inator(inv):
if inv[-1].lower() == "a" or inv[-1].lower() == "e" or inv[-1] == "i" or inv[-1]=="o" or inv[-1]=="u":
return inv+"-inator "+str(len(inv))+"000"
else:
return inv+"inator " + str(len(inv))+"000"
|
104b8d8473abe611537434eac8634524102fb425 | daniel-reich/ubiquitous-fiesta | /EjjBGn7hkmhgxqJej_17.py | 115 | 3.6875 | 4 |
def word_nest(word, nest):
x = 0
while len(nest)>0:
nest = nest.replace(word,'')
x += 1
return x-1
|
0a39e24516adcc40556affb13435877d92e3084b | daniel-reich/ubiquitous-fiesta | /7AA54JmzruLMwG6do_10.py | 145 | 3.546875 | 4 |
def is_icecream_sandwich(txt):
return sum(txt[i] != txt[i - 1] for i in range(1, len(txt))) == 2 and len(set(txt)) == 2 and txt == txt[::-1]
|
28dad6ef05adf06ede32d85271deba3d2a6eb29e | daniel-reich/ubiquitous-fiesta | /Qjn6B93kXLj2Kq5jB_9.py | 150 | 3.703125 | 4 |
def simplify_frac(f):
a = [int(x) for x in f.split('/')]
b,c = a[0], a[1]
while c:
b,c = c,b%c
return str(a[0]//b) + '/' + str(a[1]//b)
|
87f1405f04b9c2f095b5203579102eebb903a4d2 | daniel-reich/ubiquitous-fiesta | /2JHYavYqynX8ZCmMG_3.py | 361 | 3.984375 | 4 |
def ascii_sort(arr):
wrd1total = 0
wrd2total = 0
word1 = list(arr[0])
word2 = list(arr[1])
for ltr in word1:
wrd1total += ord(ltr)
for ltr in word2:
wrd2total += ord(ltr)
if wrd1total < wrd2total:
return arr[0]
else:
return arr[1]
|
dad66e1ac9314280d39cf6812e767536784644de | daniel-reich/ubiquitous-fiesta | /iHdZmimb82rAvEDkG_9.py | 342 | 3.921875 | 4 |
def bitwise_index(lst):
mx=0
for i in lst:
if i%2==0 and i>mx:
mx=i
else:
mx=mx
if mx not in lst:
return "No even integer found!"
elif lst.index(mx)%2==0:
return {"@even index "+str(lst.index(mx)) : mx}
else:
return {"@odd index "+str(lst.index(mx)) : mx}
|
9792bd6a0add49e5fb54a713be9f7336de55ddf6 | daniel-reich/ubiquitous-fiesta | /NWR5BK4BYqDkumNiB_0.py | 340 | 3.53125 | 4 |
import numpy as np
def digital_division(n):
digits = [int(i) for i in str(n)]
test1 = all(n%d == 0 for d in digits if d != 0)
test2 = n%sum(digits) == 0
test3 = False if 0 in digits else n%np.prod(digits) == 0
passed = sum((test1, test2, test3))
return {3: 'Perfect', 0: 'Indivisible'}.get(passed, passed)
|
0be482a18e262bf24dc7d93b8dfab6ba17386715 | daniel-reich/ubiquitous-fiesta | /pSrCZFim6Y8HcS9Yc_17.py | 223 | 3.78125 | 4 |
def convert(deg):
try:
d, t = deg.split('*')
except ValueError:
return 'Error'
if t == 'C':
return '{:.0f}*F'.format(int(d) * 1.8 + 32)
elif t =='F':
return '{:.0f}*C'.format((int(d) -32) / 1.8 )
|
85344b651cef3ea0aa163aadd0cfc6aae41bbf6c | daniel-reich/ubiquitous-fiesta | /nr35Bm5BRQYHZrt5n_22.py | 187 | 3.640625 | 4 |
def upward_trend(lst):
x=[0]
for i in lst:
if i==str(i):
return "Strings not permitted!"
elif i>x[-1]:
x.append(i)
return x[1:]==lst
|
eebc449ee2de6e43afcd6f6cd60548d8177a4ccf | daniel-reich/ubiquitous-fiesta | /3wLZvWf4sFerNQmo7_21.py | 115 | 3.5625 | 4 |
def neutralise(s1, s2):
return ''.join('+' if a==b=='+' else '-' if a==b=='-' else '0' for a, b in zip(s1,s2))
|
c7dfd71dbd28178ddbd5f63d92ae45ef962f9774 | daniel-reich/ubiquitous-fiesta | /RB6iWFrCd6rXWH3vi_10.py | 673 | 3.75 | 4 |
def longest_substring(digits):
digits = digits
longestSubstring = digits[0]
substringArray = []
parityBit = True if int(digits[0]) % 2 == 0 else False
for x in digits[1:]:
if int(x) % 2 == 0 and not parityBit:
parityBit = True
longestSubstring += x
elif (int(x) % 2) == 1 and parityBit:
parityBit = False
longestSubstring += x
else:
substringArray.insert(len(substringArray), longestSubstring)
longestSubstring = x
parityBit = True if int(x) % 2 == 0 else False
if longestSubstring:
substringArray.insert(len(substringArray), longestSubstring)
return (max(substringArray, key=len))
|
33cf2a9e2e4b2831e193f47b6068c0474b748047 | daniel-reich/ubiquitous-fiesta | /dy3WWJr34gSGRPLee_22.py | 156 | 3.546875 | 4 |
def make_box(s):
n = [("#"*s) for i in range(s)]
n = [k if i == 0 or i == s-1 else "{}".format("#"+" "*(s-2)+"#") for i,k in enumerate(n)]
return n
|
524bc0cebb899f488316dc329aeaa5340e574728 | daniel-reich/ubiquitous-fiesta | /XKEDTh2NMtTLSyCc2_12.py | 453 | 3.75 | 4 |
def valid_credit_card(number):
number = str(number)
Sum = 0
if len(number)%2 == 0: double = True
else: double = False
for i in range(0,len(number)):
if double:
addend = int(number[i])*2
while len(str(addend))>1:
addend = int(str(addend)[0]) +int(str(addend)[1])
Sum+=addend
else:
Sum+=int(number[i])
double= not double
return(Sum%10 == 0)
|
29181064fb88d7743e945f6c0532e508eb1744e2 | daniel-reich/ubiquitous-fiesta | /abdsaD6gwjgAgevsG_23.py | 179 | 3.546875 | 4 |
def power_ranger(power, minimum, maximum):
i = 1
d = 0
while i ** power <= maximum:
if i ** power >= minimum:
d += 1
i += 1
return d
|
036d7bba4eb8b4e864daec7a0d3ccae0ed801098 | daniel-reich/ubiquitous-fiesta | /di7ZjxgvLgz72PvCS_19.py | 608 | 3.578125 | 4 |
def validate_swaps(lst, txt):
res = []
for word in lst:
if len(word) > len(txt) or sorted(word) != sorted(txt):
res.append(False)
continue
letters, s = list(word), list(txt)
indexes = [word.index(c) for c in txt if txt.index(c) != word.index(c)]
if len(indexes) > 2 or len(indexes) < 2:
res.append(False)
continue
letters[indexes[0]], letters[indexes[1]] = letters[indexes[1]],letters[indexes[0]]
if letters == s:
res.append(True)
else:
res.append(False)
return res
|
aaee19b1302e201e378a9e6bae218bde666a5c58 | daniel-reich/ubiquitous-fiesta | /rbeuWab36FAiLj65m_15.py | 270 | 3.609375 | 4 |
def grouping(w):
group = {}
for word in w:
n = sum(c.isupper() for c in word)
if n not in group:
group[n] = []
group[n].append(word)
return {k:sorted(v, key = lexi) for k,v in group.items()}
def lexi(w):
return [ord(c) for c in w.lower()]
|
36418c86e016b5e8ba5c701e68d6ac9bc4ba2ecf | daniel-reich/ubiquitous-fiesta | /JsisSTswerLQqJ73X_13.py | 134 | 3.5625 | 4 |
def priority_sort(lst, s):
return sum([[i]*lst.count(i) for i in s if i in lst] + sorted([[i] for i in lst if i not in s]), [])
|
77de8540a3a9af22a59b4c564e2540fea0821540 | daniel-reich/ubiquitous-fiesta | /tbz5ji3ocwzAeLQNa_4.py | 555 | 3.6875 | 4 |
def exit_maze(maze, directions):
for i in range(len(maze)):
if maze[i].count(2)==1:
pos1=i
pos2=maze[i].index(2)
for dir in directions:
if(dir=="N"):
if pos1==0: return "Dead"
pos1=pos1-1
if(dir=="S"):
if pos1==len(maze)-1: return "Dead"
pos1=pos1+1
if(dir=="E"):
if pos2==len(maze[0])-1: return "Dead"
pos2=pos2+1
if(dir=="W"):
if pos2==0: return "Dead"
pos2=pos2-1
if(maze[pos1][pos2]==1):return "Dead"
if(maze[pos1][pos2]==3):return "Finish"
return "Lost"
|
f3c27e20b9e28a0ddf407d2d6ffda15de355a9f7 | daniel-reich/ubiquitous-fiesta | /6YN2ww3B4cQZ6rTmN_17.py | 98 | 3.59375 | 4 |
def leapYear(year):
return True if year % 100 == 0 or year % 400 and year % 4 == 0 else False
|
bb9b508acbd3d6e332bec4fc5408830266af6e0b | daniel-reich/ubiquitous-fiesta | /XPCqS7GYYouXg5ut9_12.py | 200 | 3.859375 | 4 |
def simplify_sqrt(n):
k = 2
while k ** 2 < n and n % (k**2) != 0:
k += 1
if n % (k**2) == 0:
sq = simplify_sqrt(n / (k ** 2) )
return (k * sq[0], sq[1])
else:
return (1, n)
|
af567069d6ba3c42ac7363b7faf33f1de336b91a | daniel-reich/ubiquitous-fiesta | /FT5Zd4mayPa5ghpPt_20.py | 461 | 3.625 | 4 |
def color_conversion(h):
if type(h) == str:
h = h.replace('#','')
if len(h) != 6:
return "Invalid input!"
r,g,b = h[:2],h[2:4],h[4:]
try:
return {'r':int(r,16),'g':int(g,16),'b':int(b,16)}
except:
return "Invalid input!"
else:
r,g,b = h['r'],h['g'],h['b']
if any(x>255 or x < 0 for x in (r,g,b)):
return "Invalid input!"
return '#{}{}{}'.format(hex(r)[-2:],hex(g)[-2:],hex(b)[-2:]).replace('x','0')
|
251ba44606fe45dc72c8888fbf52b9dd26f60942 | daniel-reich/ubiquitous-fiesta | /8vBvgJMc2uQJpD6d7_19.py | 221 | 3.78125 | 4 |
def prime_factors(num):
factors = []
target_num = num
i = 2
while(i <= target_num):
if(target_num % i == 0):
factors.append(i)
target_num /= i
i = 2
else:
i += 1
return factors
|
80a143f5ca4fbed3735097f76f5e1ae62e33c957 | daniel-reich/ubiquitous-fiesta | /ojBNREQrg7EW9ZzYx_21.py | 441 | 4 | 4 |
import re
def count_eatable_chocolates(total_money, cost_of_one_chocolate):
pattern = re.compile(r"(-?\d+) *(\$|dollars)")
money = int(pattern.findall(total_money)[0][0])
cost = int(pattern.findall(cost_of_one_chocolate)[0][0])
if money < 0 or cost <= 0:
return "Invalid Input"
total = money//cost
wrappers = total
while wrappers >= 3:
wrappers -= 2
total += 1
return total
|
d0146d61770b7b990e574961b7f663c331b268ec | daniel-reich/ubiquitous-fiesta | /T4q8P8cxvBtaLPW4q_3.py | 241 | 3.546875 | 4 |
def extract_primes(n):
return sum(([k] * str(n).count(str(k)) for k in crible(n+1)), [])
def crible(n):
s = [None] * n
for i in range(2, n):
if s[i] is None:
yield i
for k in range(2*i, n, i):
s[k] = False
|
eb63ddf0082ea99fc2b9ac788b04ed34054649e3 | daniel-reich/ubiquitous-fiesta | /ia95ckhN5ztgfJHe4_5.py | 489 | 3.59375 | 4 |
def comments_correct(txt):
if len(txt) % 2 != 0:
return False
lst = []
c = ''
for l in txt:
c += l
if len(c) == 2:
lst.append(c)
c = ''
if lst[0] == '*/':
return False
print(lst)
for i in range(len(lst)):
if lst[i] == '*/':
continue
elif lst[i] == '/*':
if lst[i+1] == '*/':
continue
else:
return False
return True
|
7e97c9314df59dd12520baf6ca80853f916dbe4d | daniel-reich/ubiquitous-fiesta | /o7LPd9dAE5x9k7zFj_23.py | 118 | 3.578125 | 4 |
def logarithm(base, num):
from math import log
if base<2 or num<=0:
return "Invalid"
return log(num,base)
|
5450e74144e826a164b14bc9232df26e5e7b9075 | daniel-reich/ubiquitous-fiesta | /WS6hR6b9EZzuDTD26_4.py | 214 | 3.53125 | 4 |
def no_duplicate_letters(phrase):
lst = phrase.lower().split()
for i in range(len(lst)):
lst[i] = list(lst[i])
for i in lst:
if len(set(i)) != len(i):
return False
return True
|
e3cbb4b33dd1b1d80bc89214a0f0f152001d6bf9 | daniel-reich/ubiquitous-fiesta | /ESAWnF3ySrFusHhYF_18.py | 378 | 3.84375 | 4 |
def edit_words(lst):
return [hyphenate(x).upper()[::-1] for x in lst]
def hyphenate(word):
if len(word) == 0:
return '-'
middle = len(word) // 2
word = list(word)
newlist = []
for i in range(len(word)):
if i == middle:
newlist.append('-')
newlist.append(word[i])
else:
newlist.append(word[i])
return ''.join(newlist)
|
2ada60f2823a5b0cffb652001b1c93e8a8af877c | daniel-reich/ubiquitous-fiesta | /C45TKLcGxh8dnbgqM_3.py | 579 | 3.671875 | 4 |
def caesar_cipher(s, k):
alpha = "abcdefghijklmnopqrstuvwxyz"
length = 25
cypher = ""
yup = False
for ch in s:
if(not ch.isalpha()):
cypher += ch
continue
if(ch.isupper()):
yup = True
current_index = alpha.find(ch.lower())
for i in range(k,0,-1):
if(current_index == 25):
current_index = 0
else:
current_index += 1
new_index = current_index
nxt = alpha[new_index]
if(yup):
cypher += nxt.upper()
yup = False
else:
cypher += nxt
return cypher
|
0fd11a4dfafdc5db0041929e7300c6f3c2bac9da | daniel-reich/ubiquitous-fiesta | /oepiudBYC7PT7TXAM_12.py | 203 | 3.75 | 4 |
def parse_roman_numeral(num):
d = {'M':1000,'D':500,'C':100,'L':50,'X':10,'V':5,'I':1}
return sum(d[num[i]] if (i+1 == len(num) or d[num[i]]>=d[num[i+1]]) else -d[num[i]] for i in range(len(num)))
|
d77ed9dce80e3f45bd44948ea7503e1fefd9c0a2 | daniel-reich/ubiquitous-fiesta | /QB6kPXQkFgMkzcc2h_20.py | 321 | 3.953125 | 4 |
def remove_abc(txt):
letterA = "a"
letterB = "b"
letterC = "c"
if letterA or letterB or letterC in txt :
newStringa = txt.replace('a', '')
newStringb = newStringa.replace('b','')
newStringc = newStringb.replace('c', '')
if newStringc == txt:
return None
else :
return newStringc
|
89feffa47bafb835ae27ee82fa5e6908e5d129fa | daniel-reich/ubiquitous-fiesta | /hfivDc24QmqWWc5Ws_22.py | 255 | 3.84375 | 4 |
def check_prime(num):
if num == 2 or num == 3: return True
for i in range(2,num):
if num % i ==0:
return False
return True
def eratosthenes(num):
L = []
for i in range(2,num+1):
if check_prime(i):
L.append(i)
return L
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.