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 |
|---|---|---|---|---|---|---|
888701a148bfd655e744628eb3866e8121ada012 | daniel-reich/ubiquitous-fiesta | /4afgmFpLP6CpwtRMY_11.py | 447 | 3.625 | 4 |
from itertools import product
def row_check(mtx):
for i in mtx:
if sorted(i) != [a for a in range(1,10)]:
return False
return True
def sudoku_validator(x):
y = [[x[a][b] for a in range(9)] for b in range(9)[::-1]]
R = range(3)
z = [[x[3*j[0]+i[0]][3*j[1]+i[1]] for i in product(R,R)] for j in product(R,R)]
if row_check(x) == True and row_check(y) == True and row_check(z) == True:
return True
return False
|
675890c281b239caaea80b0938782df5d6dc4fe1 | daniel-reich/ubiquitous-fiesta | /Cp3JRpooAqfA4kGkv_3.py | 156 | 3.609375 | 4 |
def node_type(_N, _P, n):
if not n in _N: return "Not exist"
if not n in _P: return "Leaf"
if _P[_N.index(n)] == -1: return "Root"
return "Inner"
|
51a1c44cb3567706b8239dcfeafab2a4d4a5ddc8 | daniel-reich/ubiquitous-fiesta | /9cNxcMjfEMzKYoBZY_3.py | 309 | 3.546875 | 4 |
def factors(num):
factors = []
for i in range(1, num):
if num % i == 0:
factors.append(i)
return factors
def num_type(n):
sum_factors = sum(factors(n))
if sum_factors == n:
return "Perfect"
elif sum(factors(sum_factors)) == n:
return "Amicable"
else:
return "Neither"
|
c12b019f2e49df44e1cf19b6994389810147d1e7 | daniel-reich/ubiquitous-fiesta | /b67PHXfgMwpD9rAeg_4.py | 122 | 3.609375 | 4 |
import re
def plus_sign(txt):
return len(re.findall(r'(?=(\+[a-zA-Z]\+))',txt)) == sum(1 for i in txt if i.isalpha())
|
6a43a9b648f21e36efafeac12161f48b20de728e | daniel-reich/ubiquitous-fiesta | /kPHmvQPLbdEKYeM9L_7.py | 833 | 3.59375 | 4 |
def asteroid_collision(asteroids):
done = False
print(asteroids)
while not done:
original_size = len(asteroids)
print('Original Size: ' + str(original_size))
for count, asteroid in enumerate(asteroids):
if asteroid < 0:
# Something to the left?
if count > 0:
# Evaluate
if asteroids[count - 1] < 0:
continue
elif abs(asteroid) > asteroids[count - 1]:
del asteroids[count - 1]
elif abs(asteroid) == asteroids[count - 1]:
del asteroids[count]
del asteroids[count - 1]
else:
del asteroids[count]
print(asteroids)
break
if original_size == len(asteroids):
print('Final Size: ' + str(len(asteroids)))
done = True
return asteroids
|
68e87f1e449a28533bbe0735bd287dd07c63a79c | daniel-reich/ubiquitous-fiesta | /fBzF8TuQQxx6C7dWm_3.py | 119 | 3.65625 | 4 |
def add(char, txt):
new_txt = ''
for i in txt:
if i == ' ':
i = char
new_txt += i
return new_txt
|
b9e2dbe2897c55005626ea2fed8fe35a8fc476ca | daniel-reich/ubiquitous-fiesta | /woA74HtrheoQva87R_12.py | 187 | 3.734375 | 4 |
def concat(*args):
z =''
for num in args:
for i in range(0,len(num)):
z= z+str(num[i])
return list(float(num) if num.isalpha()==False else num for num in z )
|
191245a318fe2c6280033527665629d9f3749b3c | daniel-reich/ubiquitous-fiesta | /cGaTqHsPfR5H6YBuj_1.py | 101 | 3.6875 | 4 |
def make_sandwich(i,f):
return ' '.join(x if x != f else 'bread '+x+' bread' for x in i).split()
|
e917393210b4d791013266577c7d86904842d199 | daniel-reich/ubiquitous-fiesta | /yuPWwSbCGPm2KzSzx_11.py | 1,901 | 3.65625 | 4 |
prices = {
"Strawberries" : "$1.50",
"Banana" : "$0.50",
"Mango" : "$2.50",
"Blueberries" : "$1.00",
"Raspberries" : "$1.00",
"Apple" : "$1.75",
"Pineapple" : "$3.50"
}
class Smoothie:
ingredientlist = []
cost = 0
taxcost = 0
strcost = ''
finalsentence = ''
def __init__(self, ingredients):
self.ingredients = ingredients
self.ingredientlist = ingredients
def get_cost(self):
for i in range(0, len(self.ingredientlist)):
self.cost = self.cost + float(prices[self.ingredientlist[i]][1 : ])
self.strcost = str(self.cost * 1.5)
return "${:,.2f}".format(self.cost)
def get_price(self):
if str(self.cost * 1.5)[-2] != '.' and str(self.cost * 1.5)[-3] != '.' and str(self.cost * 1.5)[list(str(self.cost * 1.5)).index('.') + 3] == '5':
self.cost = self.cost + round((self.cost * 1.5) + 0.001, 2)
else:
self.cost = self.cost + round(self.cost * 1.5, 2)
return "${:,.2f}".format(self.cost)
def get_name(self):
self.ingredientlist.sort()
for i in range(0, len(self.ingredientlist)):
if self.ingredientlist[i] == "Blueberries":
self.finalsentence = self.finalsentence + "Blueberry "
elif self.ingredientlist[i] == "Raspberries":
self.finalsentence = self.finalsentence + "Raspberry "
elif self.ingredientlist[i] == "Strawberries":
self.finalsentence = self.finalsentence + "Strawberry "
else:
self.finalsentence = self.finalsentence + self.ingredientlist[i] + ' '
if len(self.ingredientlist) == 1:
self.finalsentence = self.finalsentence + "Smoothie"
else:
self.finalsentence = self.finalsentence + "Fusion"
return self.finalsentence
|
c98bc116abed13408379d2dc9a497bc630cdb10d | daniel-reich/ubiquitous-fiesta | /dsAPLuCpkKCBELk24_14.py | 198 | 3.5625 | 4 |
def get_products(lst):
res = []
for i in range(len(lst)):
product = 1
for j in range(len(lst)):
if i != j: product *= lst[j]
res.append(product)
return res
|
e455215e481be79dc6dafb5631159358a86cbb01 | daniel-reich/ubiquitous-fiesta | /4kwft4k6zebmM2BDX_20.py | 1,227 | 3.75 | 4 |
def chi_squared_test(data):
alpha1 = 6.635
alpha5 = 3.841
totalRow = 0
totFirstCol = 0
totSecondCol = 0
chi_squared_val = 0
colTotal = []
# 1st step
for key in data.keys():
vl = list(data.get(key))
totFirstCol += vl[0]
totSecondCol += vl[1]
for x in data.get(key):
totalRow += x
data[key].append(totalRow)
totalRow = 0
colTotal.append(totFirstCol)
colTotal.append(totSecondCol)
colTotal.append(totFirstCol + totSecondCol)
# 2nd step and chi squared value calculation
for key in data.keys():
for j in range(len(colTotal)-1):
val = data[key][2] * colTotal[j] / colTotal[-1]
data[key].append(val)
for key in data.keys():
for i in range(2):
data[key][i] = ((data[key][i] - data[key][i+3]) ** 2) / data[key][i+3]
print(data[key][i])
chi_squared_val += data[key][i]
chi_squared_val = round(chi_squared_val,1)
print(chi_squared_val)
if(chi_squared_val > alpha1):
return [chi_squared_val, "Edabitin effectiveness = 99%"]
elif(alpha5 < chi_squared_val < alpha1):
return [chi_squared_val, "Edabitin effectiveness = 95%"]
elif(chi_squared_val < alpha5):
return [chi_squared_val, "Edabitin is ininfluent"]
|
1102af71d0eb9ea9fbe0846913549be8ab59e3c8 | daniel-reich/ubiquitous-fiesta | /gQgFJiNy8ZDCqaZb4_17.py | 151 | 3.546875 | 4 |
def overlap(s1, s2):
index = len(s1)
for i in range(len(s1)):
if s2.startswith(s1[i:]):
index = i
break
return s1[:index] + s2
|
9e72839a9454171d31da9893abfb41e133288eeb | daniel-reich/ubiquitous-fiesta | /NbZ2cMeEfH3KpQRku_23.py | 640 | 3.859375 | 4 |
#A 1 is unhappy if the digit to its left and the digit to
#its right are both 0s. A 0 is unhappy if the digit to
#its left and the digit to its right are both 1s.
#If a number has only one neighbor, it is unhappy
#if its only neighbor is different. Otherwise,
#a number is happy.
def percentage_happy(numbers):
h = 0
t = 0
for i in range(0, len(numbers)):
t += 1
if i == 0:
if numbers[i] == numbers[i+1]:
h += 1
elif i == len(numbers) - 1:
if numbers[i-1] == numbers[i]:
h += 1
else:
if numbers[i-1] == numbers[i] or numbers[i] == numbers[i+1]:
h += 1
return h/t
|
1c3e117010a28a44c7e6c1492afef179bc6fbdd5 | daniel-reich/ubiquitous-fiesta | /eAnhzXPeGbobqk2P2_9.py | 283 | 3.5 | 4 |
def century(year):
cen = (year - 1)//100 + 1
suffix = "th"
if cen >= 20:
lastDigit = cen%10
if lastDigit == 1:
suffix = "st"
elif lastDigit == 2:
suffix = "nd"
elif lastDigit == 3:
suffix = "rd"
return str(cen) + suffix + " century"
|
5fc1410bf2fa6c6c2a876f4b46cb62d292951e87 | daniel-reich/ubiquitous-fiesta | /fDfh3WJPPiiJwgTrW_16.py | 121 | 3.53125 | 4 |
def num_of_sublists(lst):
count = 0
for item in lst:
if isinstance(item,list):
count += 1
return count
|
b3750b30907485ded72018481669e23d912d69af | daniel-reich/ubiquitous-fiesta | /oyS6TX4NXzpbfjL4a_5.py | 705 | 3.671875 | 4 |
def best_start(lst, word):
scores = {"A": 1, "B": 3,"C": 3,"D": 2,"E": 1,"F": 4,"G": 2,"H": 4,"I": 1,"J": 8,"K": 5,"L": 2,"M": 3,"N": 1,"O": 1,"P": 3,"Q": 10,"R": 1,"S": 1,"T": 1,"U": 1,"V": 4,"W": 4,"X": 8,"Y": 4,"Z": 10}
index = 0
max = -1
for i in range(len(lst)-len(word) + 1):
score = 0
doubles = 0
for j in range(len(word)):
if lst[i+j] == 'TL':
score += scores[word[j].upper()] * 3
else:
if lst[i+j] == 'DW':
doubles += 1
score += scores[word[j].upper()]
for j in range(doubles):
score *= 2
if score > max:
max = score
index = i
return index
|
00598e280c203bbe29bc99e73e43fde2525dd179 | daniel-reich/ubiquitous-fiesta | /hCAStny5sJwYP3evS_4.py | 602 | 3.921875 | 4 |
def is_early_bird(length, n):
'''
Returns a list of the indices of the positions where n appears in the
sequence of integers from 0 to length as per instructions, plus 'Early Bird'
if the number appears before its natural position.
'''
n_str = str(n)
size = len(n_str)
seq = ''.join(map(str, list(range(length + 1))))
indices = []
idx = seq.find(n_str)
while idx != -1:
indices.append([idx + i for i in range(size)])
idx = seq.find(n_str, idx+1)
if len(indices) > 1:
indices.append('Early Bird!')
return indices
|
05353b725f08cedde8088762ca5d1642f0ce582d | daniel-reich/ubiquitous-fiesta | /SYmHGXX2P26xu7JFR_19.py | 492 | 3.515625 | 4 |
def number_groups(group1, group2, group3):
a, b, c = set(group1), set(group2), set(group3)
lst = []
for i in a:
if (i in b) or (i in c):
if not(i in lst):
lst.append(i)
for j in b:
if (j in a) or (j in c):
if not(j in lst):
lst.append(j)
for x in c:
if (x in a) or (x in b):
if not(x in lst):
lst.append(x)
lst.sort()
return lst
|
628c5ad008c401773773490b7a3a60e912154c98 | daniel-reich/ubiquitous-fiesta | /nm8zFcqcQ9Rzu45Fm_20.py | 442 | 3.5625 | 4 |
def bridge_shuffle(lst1, lst2):
if not lst1 and not lst2:
return []
elif not lst1:
return lst2
elif not lst2:
return lst1
result = [lst1[0], lst2[0]]
for i in range(1, min(len(lst1), len(lst2))):
result.append(lst1[i])
result.append(lst2[i])
if len(lst1) > len(lst2):
result.extend(lst1[len(lst2):])
else:
result.extend(lst2[len(lst1):])
return result
|
5dad9aea23b129a44814691dc95a09ac927c2aef | daniel-reich/ubiquitous-fiesta | /bo4REhn9paGcFoMBs_11.py | 256 | 3.6875 | 4 |
def age_difference(ages):
oldest = max(ages)
ages.remove(oldest)
a = oldest - max(ages)
if a == 0:
return "No age difference between spouses."
elif a == 1:
return "1 year"
else:
return "{} years".format(a)
|
502e645e2d32811de313a90a917dd2263502e622 | daniel-reich/ubiquitous-fiesta | /r8jXYt5dQ3puspQfJ_1.py | 163 | 3.65625 | 4 |
def split(txt):
vowels = ''.join(ch for ch in txt if ch in 'aeiouAEIOU')
others = ''.join(ch for ch in txt if ch not in 'aeiouAEIOU')
return vowels+others
|
ffecdc4669ec71658c4a87868fec7b4e6110b7a4 | daniel-reich/ubiquitous-fiesta | /JPfqYkt6KGhpwfYK7_15.py | 185 | 3.5625 | 4 |
def replace_the(txt):
A=txt.split()
for i in range(len(A)):
if A[i]=='the':
if A[i+1][0] in 'aeiou':
A[i]='an'
else:
A[i]='a'
return ' '.join(A)
|
ad8f9db5a84ce074f0a7697f6d1da82b139f0ca4 | daniel-reich/ubiquitous-fiesta | /fDkAuAwR4PMWZwBKs_14.py | 154 | 3.765625 | 4 |
def find_bob(names):
index = 0
for x in names:
if names[index] == 'Bob':
return index
else:
index=index+1
else:
return -1
|
af80a3afef682351d53560c1d8c38a87b5af86f1 | daniel-reich/ubiquitous-fiesta | /DjyqoxE3WYPe7qYCy_7.py | 136 | 4.125 | 4 |
def reverse_odd(string):
words = string.split(" ");
return " ".join(word[::-1] if len(word) %2 != 0 else word for word in words);
|
cca1a9ca72a650c62239f6a8df1bdc212278026a | daniel-reich/ubiquitous-fiesta | /ncLp4ZXvz4x4oEHYh_16.py | 258 | 3.6875 | 4 |
def sum_of_two(a, b, v):
complement = v-a[0]
if complement in b:
return True
else:
complement = v-a[1]
if complement in b:
return True
else:
complement = v-a[2]
if complement in b:
return True
return False
|
52da0c999fdde5204964de19a6656d98290ad60c | daniel-reich/ubiquitous-fiesta | /fNQEi9Y2adsERgn98_20.py | 151 | 3.5 | 4 |
def perimeter(lst):
a,b,c = lst
return round(leng(a,b)+leng(a,c)+leng(b,c),2)
def leng(a,b):
return ((a[0]-b[0])**2+(a[1]-b[1])**2)**.5
|
f2cb2449e31eac8a7f3001a503cf34bb953440db | daniel-reich/ubiquitous-fiesta | /NNhkGocuPMcryW7GP_6.py | 598 | 4.21875 | 4 |
import math
def square_areas_difference(r):
# Calculate diameter
d = r * 2
# Larger square area is the diameter of the incircle squared
lgArea = d * d
# Use the diameter of the circle as the hypotenuse of the smaller
# square when cut in half to find the edges length
# When the legs are equal length (because it's a square), you just
# divide the hypotenuse by the sqrt of 2
# Smaller square area is the legs squared
smLeg = d / math.sqrt(2)
smArea = smLeg * smLeg
# We then return the difference between the large area and small area
return lgArea - round(smArea)
|
e6cc4b331c9cba80e61593f3b9d2cedfdc1236eb | daniel-reich/ubiquitous-fiesta | /oGkwLhmpys95rjtQ2_24.py | 82 | 3.5625 | 4 |
def match_last_item(lst):
return ''.join(str(x) for x in lst[:-1]) == lst[-1]
|
c613c865c3d02c0c9fba139211132d733c577574 | daniel-reich/ubiquitous-fiesta | /WXqH9qvvGkmx4dMvp_15.py | 139 | 3.546875 | 4 |
def fizz_buzz(num):
x = ""
if num % 3 == 0:
x = "Fizz"
if num % 5 == 0:
x = x + "Buzz"
return x if x != "" else str(num)
|
579969ec4398925a4e36367859bb2ab29e999693 | daniel-reich/ubiquitous-fiesta | /YTf8DZbTkzJ3kizNa_3.py | 189 | 3.578125 | 4 |
def moran(n):
N = sum(int(i) for i in str(n))
if n/N == int(n/N):
if all((n / N) % i != 0 for i in range(2,int(n/N))): return "M"
if n % N == 0: return "H"
return "Neither"
|
daa93b91dc2f45b7053bbf488bf228d64692ff10 | daniel-reich/ubiquitous-fiesta | /KEsQGp7LsP3KwmqJ7_19.py | 146 | 3.546875 | 4 |
def check(lst):
index = lst.index(min(lst))
if lst[index:] + lst[:index] == sorted(lst) and index:
return "YES"
else:
return "NO"
|
279c7ed49738cebd8980b2c61b1538d756d93c88 | daniel-reich/ubiquitous-fiesta | /hvPiBiwE9TfLnsfz4_9.py | 214 | 3.71875 | 4 |
def generate_word(n):
if n < 2: return 'invalid'
out = ['b', 'a']
def _(n):
if n < 3:
return out[-2] + out[-1]
out.append(out[-2] + out[-1])
return _(n - 1)
_(n)
return ', '.join(out)
|
f0ba515169438ebd61d9518d1ed073701bc31a91 | daniel-reich/ubiquitous-fiesta | /voxWDZ9NSv8CXifec_22.py | 459 | 3.859375 | 4 |
def lemonade(bills):
fives = 0
tens = 0
for x in bills:
if x == 5:
fives += 1
elif x == 10:
if fives == 0:
return False
fives -= 1
tens += 1
else:
if tens > 0 and fives > 0:
tens -= 1
fives -= 1
elif fives > 2:
fives -= 3
else:
return False
return True
|
458949b3e4ae2d7a6e5fc0c2a1b7435cc1b4277b | daniel-reich/ubiquitous-fiesta | /4kwft4k6zebmM2BDX_4.py | 778 | 3.515625 | 4 |
def chi_squared_test(data):
tot = sum([sum(data[i]) for i in data])
col_tot = [data['E'][0]+data['T'][0],data['E'][1]+data['T'][1]]
row_tot = [sum(data['E']),sum(data['T'])]
edabitin = [round((col_tot[0]*row_tot[0])/tot,2),round((col_tot[1]*row_tot[0])/tot,2)]
tutorial = [round((col_tot[0]*row_tot[1])/tot,2),round((col_tot[1]*row_tot[1])/tot,2)]
edabitin = [((data['E'][0]-edabitin[0])**2)/edabitin[0],((data['E'][1]-edabitin[1])**2)/edabitin[1]]
tutorial = [((data['T'][0]-tutorial[0])**2)/tutorial[0],((data['T'][1]-tutorial[1])**2)/tutorial[1]]
x2 = round(sum(edabitin)+sum(tutorial),1)
if x2 > 6.6:
return [x2, "Edabitin effectiveness = 99%"]
elif x2 > 3.8:
return [x2, "Edabitin effectiveness = 95%"]
return [x2, "Edabitin is ininfluent"]
|
f6d4ad8bee67c8683b6e6b2a757dedc7913fe7c3 | daniel-reich/ubiquitous-fiesta | /3gziWsCxqGwGGZmr5_9.py | 233 | 3.75 | 4 |
def fat_prime(a, b):
is_prime = lambda n: n==2 or n>1 and n%2 and all(n%i for i in range(3,int(n**.5)+1,2))
a,b = sorted([a,b])
b = b - (b%2==0)
while a<b:
if is_prime(b):
return b
b -=2
|
c51fe547c2fb37e63ec00da2c9bfe6ba7bbf2ca4 | daniel-reich/ubiquitous-fiesta | /Jx4mjwEoFdfYuF9ky_24.py | 128 | 3.640625 | 4 |
def hello_world(num):
lst = []
if not num % 3: lst += ['Hello']
if not num % 5: lst += ['World']
return ' '.join(lst)
|
c4069aa48f57b4efac24ee43811301c9e2f0d1a1 | daniel-reich/ubiquitous-fiesta | /dMcvdFzSvvqdLJBEC_6.py | 335 | 3.9375 | 4 |
def num_of_days(cost, savings, start):
week = 0
target = cost-savings
while (7 * start + 21) * week + week*(week-1) / 2 * 7 < target:
week += 1
week -= 1
day = 0
target -= (7 * start + 21) * week + week*(week-1) / 2 * 7
while (start + week) * day + day * (day -1)/2 <= target:
day += 1
return 7 * week + day
|
d34de4b59937c1684cb4d0c42fcc5294056eb319 | daniel-reich/ubiquitous-fiesta | /2t6NvMe27HtSmqC4F_22.py | 159 | 3.75 | 4 |
def boolean_and(lst):
return not False in lst
def boolean_or(lst):
return True in lst
def boolean_xor(lst):
return lst.count(True) % 2 == 1
|
64d5fc91f75ee0551ceec29aa3f6442feff066ae | daniel-reich/ubiquitous-fiesta | /vuSXW3iEnEQNZXjAP_7.py | 180 | 3.78125 | 4 |
def create_square(n):
if n is None or n < 1:
return ''
if n == 1:
return '#'
return '\n'.join(['#'*n] + ['#{}#'.format(' '*(n-2))] * (n-2) + ['#'*n])
|
bff63daa04758bdf4daa1a704ad5a9e940493a17 | daniel-reich/ubiquitous-fiesta | /6b8Px5m82nAgudhsy_13.py | 760 | 3.53125 | 4 |
def next_number(num):
digits = [int(c) for c in str(num)]
result = next_number_r([], sorted(digits), digits)
if result:
return int(''.join([str(d) for d in result]))
return num
def next_number_r(current, digits, minimum):
if len(current) == len(minimum):
return False
for d in digits:
if d < minimum[len(current)]:
continue
if d > minimum[len(current)]:
next_digits = digits[:]
next_digits.remove(d)
if current + [d] + list(next_digits) != minimum:
return current + [d] + list(next_digits)
continue
next = current + [d]
next_digits = digits[:]
next_digits.remove(d)
result = next_number_r(current + [d], next_digits, minimum)
if result:
return result
return False
|
6d8b63a3a6bc4f81a20ed0b5d1b1237f9b149507 | daniel-reich/ubiquitous-fiesta | /hAsdEPWwufWoJos32_17.py | 180 | 3.765625 | 4 |
def no_yelling(phrase):
while phrase.endswith('??'):
phrase = phrase[:-2] + '?'
while phrase.endswith('!!'):
phrase = phrase[:-2] + '!'
return phrase
|
2bc7db64613550d789457aeb2b436f59dc7434d6 | daniel-reich/ubiquitous-fiesta | /x6McEkHer8A3Hke2q_16.py | 103 | 3.8125 | 4 |
def factorial(num,sum = 1):
if num == 1:
return sum
sum *= num
return factorial(num-1,sum)
|
e513960a7c60af47ba8d523f40aa84ef297086eb | daniel-reich/ubiquitous-fiesta | /662nTYb83Lg3oNN79_19.py | 379 | 3.859375 | 4 |
def is_parallelogram(lst):
a = ( lst[1][0] - lst[0][0], lst[1][1] - lst[0][1] )
b = ( lst[2][0] - lst[0][0], lst[2][1] - lst[0][1] )
c = ( lst[3][0] - lst[0][0], lst[3][1] - lst[0][1] )
A = a[0] == b[0] + c[0] and a[1] == b[1] + c[1]
B = b[0] == a[0] + c[0] and b[1] == a[1] + c[1]
C = c[0] == a[0] + b[0] and c[1] == a[1] + b[1]
return A or B or C
|
6874a8fc7f288dc0bed8be071dad175dfea667bc | daniel-reich/ubiquitous-fiesta | /sKXWQym3xg6uBLrpY_0.py | 374 | 3.515625 | 4 |
def iqr(lst):
lst = sorted(lst)
first_half = lst[:len(lst) // 2]
second_half = lst[-(-len(lst) // 2):]
first_half_median = (first_half[len(first_half) // 2] + first_half[~(len(first_half) // 2)]) / 2
second_half_median = (second_half[len(second_half) // 2] + second_half[~(len(second_half) // 2)]) / 2
return second_half_median - first_half_median
|
a256e25a893c5d953efc6828852bb2f52c0c6a63 | daniel-reich/ubiquitous-fiesta | /3ucrYGBkvJwjbFL4G_1.py | 235 | 3.5625 | 4 |
def reversible_inclusive_list(start, end, step=None):
if step is None:
step = 1 if start <= end else -1
return ([start] + reversible_inclusive_list(start + step, end, step)
if start != end + step else [])
|
612e51d9f4c991762d3652275e7a230cf1a4f060 | daniel-reich/ubiquitous-fiesta | /Kv8DMmwfuKTLyZD5E_0.py | 220 | 3.53125 | 4 |
def make_dartboard(n):
row, top = 0, []
for i in range(n, 0, -2):
row += int('{:0^{}}'.format('1'*i, n))
top.append(row)
bottom = top[::-1][1:] if n%2 else top[::-1]
return top + bottom
|
2aa206c121f43ca549bdff98540406dc54f92838 | daniel-reich/ubiquitous-fiesta | /JmyD5D4KnhzmMPEKz_15.py | 705 | 3.765625 | 4 |
def constraint(s): # Constrained writting
alphabet, s = "abcdefghijklmnopqrstuvwxyz", "".join([x.lower() for x in s if x.isalpha() or x==" "])
is_pangram = lambda s: sorted(set("".join(s.split()))) == sorted(set(alphabet))
is_heterogram = lambda s: len("".join(s.split()))==len(set("".join(s.split())))
is_tautogram = lambda s: all(s.split()[i][0]==s.split()[i+1][0] for i in range(len(s.split())-1))
is_transgram = lambda s: bool([set(x) for x in s.split()][0].intersection(*[set(x) for x in s.split()][1:]))
return "Pangram" if is_pangram(s) else "Heterogram" if is_heterogram(s) else "Tautogram" if is_tautogram(s) else "Transgram" if is_transgram(s) else "Sentence"
|
b509007fa483bb3fb735dbe32d548370cacf608e | daniel-reich/ubiquitous-fiesta | /fTXXkQ7bfuQDjgNyH_11.py | 856 | 3.78125 | 4 |
class Date:
def is_leapyear(year):
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return True
return False
return True
return False
thirty_one_days = [1, 3, 5, 7, 8, 10, 12]
def __init__(self, date):
self.date = date
d = [int(dte) for dte in date.split('/')]
self.month = d[0]
self.day = d[1]
self.year = d[2]
self.ly = Date.is_leapyear(self.year)
self.days_in_year = self.day
for n in range(1, self.month):
if n == 2:
if self.ly == True:
self.days_in_year += 29
else:
self.days_in_year += 28
elif n in Date.thirty_one_days:
self.days_in_year += 31
else:
self.days_in_year += 30
def day_of_year(date):
date = Date(date)
return date.days_in_year
|
1f4fde85089bcd9ab7eff252f667f3e4f0969e17 | daniel-reich/ubiquitous-fiesta | /FqFGnnffKRo8LKQKP_23.py | 166 | 3.515625 | 4 |
def simple_numbers(a, b):
res = []
for i in range(a, b + 1):
if i == sum(int(x) ** (j + 1) for j, x in enumerate(str(i))):
res.append(i)
return res
|
c1e51a9030bce9b9da74a24e973601462d4f41dc | daniel-reich/ubiquitous-fiesta | /iasdc3ihqt9hkZWfi_23.py | 258 | 3.515625 | 4 |
def can_give_blood(donor, receiver):
if donor=="O-":
return True
elif receiver=="AB+":
return True
elif donor=="O+":
return receiver[-1:]=="+"
elif donor==receiver:
return True
else:
return False
|
cd8cfcf3180a7963527bb18932f7afa30e27d736 | daniel-reich/ubiquitous-fiesta | /yvJbdkmKHvCNtcZy9_23.py | 119 | 3.5 | 4 |
def is_disarium(n):
answer = 0
for i,j in enumerate(str(n)):
answer += int(j)**int(i+1)
return answer == n
|
26e086b356bfd35d02ae71e527250cafde7b7c0e | daniel-reich/ubiquitous-fiesta | /p6uXeD7JC7cmxeD2Z_21.py | 326 | 3.515625 | 4 |
def calculate_score(games):
def comp(a, b):
if a + b in ["RS", "SP", "PR"]:
return 1
elif a + b in ["SR", "PS", "RP"]:
return -1
else:
return 0
v = 0
for i in games:
v = v + comp(i[0], i[1])
if v == 0:
return "Tie"
elif v > 0:
return "Abigail"
else:
return "Benson"
|
cd824ee7ca6e3e3d0f215108a0c39175875ce7c6 | daniel-reich/ubiquitous-fiesta | /3JX75W5Xvun63RH9H_5.py | 481 | 3.5 | 4 |
def describe_num(n):
res = "The most brilliant"
if n % 2 == 0:
res += " exciting"
if n % 3 == 0:
res += " fantastic"
if n % 4 == 0:
res += " virtuous"
if n % 5 == 0:
res += " heart-warming"
if n % 6 == 0:
res += " tear-jerking"
if n % 7 == 0:
res += " beautiful"
if n % 8 == 0:
res += " exhilarating"
if n % 9 == 0:
res += " emotional"
if n % 10 == 0:
res += " inspiring"
res += " number is " + str(n) + "!"
return res
|
28c70a9a1eed40a621eb269f25a350b78e393664 | daniel-reich/ubiquitous-fiesta | /qJcbCe2mGotP9svkg_2.py | 3,218 | 3.75 | 4 |
class Encryption:
one, two, three, four = 'g, o, l, e'.split(', ')
def __init__(self, stack = []):
self.stack = stack
def add(self, item):
if isinstance(item, int) == True:
item = str(item)
if '345' in item:
item = item.replace('345', '3545')
zero_in_item = False
num = ''
for l8r in item:
print(self.stack)
if zero_in_item == False:
if l8r in '1234':
dic = {1: Encryption.one, 2: Encryption.two, 3: Encryption.three, 4: Encryption.four}
self.stack.append(dic[int(l8r)])
elif l8r == '5':
self.stack[-1] = self.stack[-1].upper()
elif l8r == '6':
self.stack.append('.')
elif l8r == '7':
if self.stack[0].islower() == True:
self.stack[0] = self.stack[0].upper()
else:
self.stack[0] = self.stack[0].lower()
elif l8r == '8':
if '7' not in item:
self.stack = list(reversed(self.stack))
else:
if self.stack[0].islower() == True:
self.stack[0] = self.stack[0].upper()
else:
self.stack[0] = self.stack[0].lower()
self.stack = list(reversed(self.stack))
if self.stack[0].islower() == True:
self.stack[0] = self.stack[0].upper()
else:
self.stack[0] = self.stack[0].lower()
elif l8r == '9':
for n in range(item.index('9')):
self.stack.pop(-1)
elif l8r == '0':
zero_in_item = True
zero_index = item.index('0')
else:
num += l8r
print(self.stack)
if zero_in_item == True:
if '9' in item:
if zero_index - 1 == item.index('9'):
return True
for n in range(int(num) - 1):
for index in range(zero_index):
l8r = item[index]
if l8r in '1234':
dic = {1: Encryption.one, 2: Encryption.two, 3: Encryption.three, 4: Encryption.four}
self.stack.append(dic[int(l8r)])
elif l8r == '5':
self.stack[-1] = self.stack[-1].upper()
elif l8r == '6':
self.stack.append('.')
elif l8r == '7':
if self.stack[0].islower() == True:
self.stack[0] = self.stack[0].upper()
else:
self.stack[0] = self.stack[0].lower()
elif l8r == '8':
if '7' not in item:
self.stack = list(reversed(self.stack))
else:
if self.stack[0].islower() == True:
self.stack[0] = self.stack[0].upper()
else:
self.stack[0] = self.stack[0].lower()
self.stack = list(reversed(self.stack))
if self.stack[0].islower() == True:
self.stack[0] = self.stack[0].upper()
else:
self.stack[0] = self.stack[0].lower()
elif l8r == '9':
for n in range(item.index('9')):
self.stack
return True
def display(self):
return ''.join(self.stack)
def num_to_google(arr):
e = Encryption([])
for item in arr:
e.add(item)
return e.display()
|
2b009422a5c2009869eff8eb3d2b6d763767ee0f | daniel-reich/ubiquitous-fiesta | /WyttgdGuQGaRBqhhP_24.py | 360 | 3.765625 | 4 |
def min_palindrome_steps(txt):
txt_list = list(txt)
temp = txt_list.copy()
if txt == txt[::-1]:
return 0
for i in range(1, len(txt_list)+1):
reverse = reversed(txt_list[0:i])
temp.extend(reverse)
if temp == temp[::-1]:
return i
else:
temp = txt_list.copy()
continue
|
4c8868a5781ad1991e6261eead5303cc2b20b8a3 | daniel-reich/ubiquitous-fiesta | /iHfq7KA8MBuZqBGgo_12.py | 295 | 3.65625 | 4 |
def is_legitimate(backyard):
if 1 in backyard[0] or 1 in backyard[-1]:
return False
left_fence = [backyard[i][0] for i in range(len(backyard))]
right_fence = [backyard[i][-1] for i in range(len(backyard))]
if 1 in left_fence or 1 in right_fence:
return False
return True
|
1c52d90d5a036c37f01e78068b516e95d508bd26 | daniel-reich/ubiquitous-fiesta | /cBzYRBbBA7gHwKpor_5.py | 578 | 3.5625 | 4 |
def secret_password(message):
if len(message) != 9 or any(x.isupper() for x in message)\
or any(not x.isalpha() for x in message):
return "BANG! BANG! BANG!"
threes = [message[x:x + 3] for x in range(0, len(message), 3)]
part_1 = str((ord(threes[0][0])-96))+threes[0][1]+str((ord(threes[0][2])-96))
part_2 = threes[1][::-1]
part_3_1 = []
for x in threes[2]:
if x == 'z':
part_3_1.append('a')
else:
part_3_1.append(chr(ord(x)+1))
part_3 = ''.join(part_3_1)
return part_2+part_3+part_1
|
f43eaa25b79b4d404880bdefec5c398cec3ef74a | daniel-reich/ubiquitous-fiesta | /JiLom4d6aBk7wAJcZ_23.py | 100 | 3.515625 | 4 |
def is_sastry(number):
a = int(str(number) + str(number+1)) ** (1/2)
return a == round(a)
|
9b25c4ba224e3ab4f7905ba517e64f11af7eeb87 | daniel-reich/ubiquitous-fiesta | /uerTkWm9K3oMtMZKz_19.py | 374 | 3.59375 | 4 |
def sweetest_icecream(lst):
sweetness_value_dictionary = {"Plain": 0, "Vanilla": 5, "ChocolateChip": 5, "Strawberry": 10, "Chocolate":10}
ice_cream_values = []
for icecream in lst:
sweetness_value_icecream = sweetness_value_dictionary[icecream.flavor] +icecream.num_sprinkles
ice_cream_values.append(sweetness_value_icecream)
return max(ice_cream_values)
|
13821533695b84cab42b1daca172891a03a58afb | daniel-reich/ubiquitous-fiesta | /fpJXv7Qn9LCxX8FYq_13.py | 161 | 3.640625 | 4 |
def solve(eq):
lst = eq.split(' ')
if lst[1] == '+':
return eval(lst[-1] + '-' + lst[2])
elif lst[1] == '-':
return eval(lst[-1] + '+' + lst[2])
|
486719366234afa96540f3ddb7a008a454777f1e | daniel-reich/ubiquitous-fiesta | /WKJwo2xDNjKxwtGoH_19.py | 120 | 3.59375 | 4 |
def to_int(txt):
return int(txt)
def to_str(num):
return str(num)
print(to_int("87"))
print(to_str(87))
|
aac8ac19d14eb2db8a9e509fdd145cd818291715 | daniel-reich/ubiquitous-fiesta | /kPHmvQPLbdEKYeM9L_9.py | 915 | 3.5 | 4 |
def asteroid_collision(asteroids):
'''
Returns asteroids with any exploded ones removed, as per instructions.
'''
def winner(ast, rights):
'''
Returns True if ast survives collision with rights and updates
rights appropriately
'''
for i in range(len(rights)-1, -1, -1):
if ast > rights[i]:
del rights[i] # left moving asteroid destroyed this one
elif ast == rights[i]:
del rights[i]
return False # both destroyed
else:
return False # ast destroyed
return True # ast survived
rights, survivors = [], []
for ast in asteroids:
if ast < 0:
if winner(abs(ast), rights):
survivors.append(ast)
else: # moving right
rights.append(ast)
return survivors + rights
|
5c14b5473eef15c3e27e157a04d29266c7144ef1 | daniel-reich/ubiquitous-fiesta | /dHGpjWHJ265BCthiM_16.py | 311 | 3.515625 | 4 |
from datetime import datetime as dt, timedelta
def current_streak(today, lst):
dates = [dt.strptime(d['date'], "%Y-%m-%d") for d in lst]
today = dt.strptime(today, "%Y-%m-%d")
if today not in dates:
return 0
ans = 0
while today in dates:
ans += 1
today -= timedelta(days=1)
return ans
|
af7d8d130539fc835c9218271427e7b5868a891d | daniel-reich/ubiquitous-fiesta | /Yp8crKmgxZ3HiSBAZ_18.py | 723 | 3.65625 | 4 |
def freq_count(lst, el):
results = [[0,0]]
investigate = [[0,lst]]
while investigate:
current_list = investigate.pop(0)
for item in current_list[1]:
if isinstance(item,list):
depth = current_list[0]+1
investigate.append([depth,item])
if depth==len(results):
results.append([depth,0])
else:
if item==el:
results[current_list[0]][1] += 1
return results
print(freq_count([1, [2], 1, [[2]], 1, [[[2]]], 1, [[[[2]]]]], 2))
#[[0, 0], [1, 1], [2, 1], [3, 1], [4, 1]]
print(freq_count([1, 5, 5, [5, [1, 2, 1, 1], 5, 5], 5, [5]], 5))
# [[0, 3], [1, 4], [2, 0]]
print(freq_count([1, 4, 4, [1, 1, [1, 2, 1, 1]]], 1))
#[[0, 1], [1, 2], [2, 3]]
|
09b05af8fbebc1f812a5ecf986741b6d4c350217 | daniel-reich/ubiquitous-fiesta | /f48nSAebxBNMfmc9D_7.py | 978 | 3.5 | 4 |
############################################################
# Sub Function
############################################################
def FNC_Comparison_Tool(Word, Template):
if (len(Word) != len(Template)):
return False
Counter = 0
Length = len(Word)
while (Counter < Length):
Item_A = Word[Counter]
Item_B = Template[Counter]
if (Item_A == Item_B):
Counter += 1
elif (Item_B == "*"):
Counter += 1
else:
return False
return True
############################################################
# MAIN FUNCTION
############################################################
def scrambled(words, mask):
Wanted = []
Counter = 0
Length = len(words)
while (Counter < Length):
Template = str(mask)
Word = words[Counter]
if (FNC_Comparison_Tool(Word, Template)):
Wanted.append(Word)
Counter += 1
else:
Counter += 1
return Wanted
|
2e3b4aa365d3dffda0110f32705bc6c4585fcb96 | daniel-reich/ubiquitous-fiesta | /xFme9FBuvHLveh5nE_15.py | 220 | 3.5625 | 4 |
def is_zygodrome(num):
num = str(num)+'%'
a = list(num[i] if num[i]==num[i+1] else num[i]+'%' for i in range(len(num)-1))
b = list(len(i) for i in "".join(a).split('%'))[:-1]
return False if min(b)<2 else True
|
4c768e4897c6a6d6def72d5babf21c5345270f2b | daniel-reich/ubiquitous-fiesta | /dy3WWJr34gSGRPLee_3.py | 187 | 3.75 | 4 |
def make_box(n):
a = []
for i in range(1,n+1):
if i == 1 or i == n:
a.append("#"*n)
elif 1<i<n:
a.append("#"+" "*(n-2)+"#")
return a
|
ef8dcebdb77956f1d4ea5f30616dc843959565ce | daniel-reich/ubiquitous-fiesta | /iRvRtg2xxL9BnSEvf_5.py | 328 | 3.640625 | 4 |
class Person:
def __init__(self, name, likes, hates):
self.name = name
self.likes = likes
self.hates = hates
def taste(self, food):
tag = ""
if food in self.likes: tag = " and loves it"
if food in self.hates: tag = " and hates it"
return "{} eats the {}{}!".format(self.name, food, tag)
|
e91b68ef76a673f9974131a89c54751da94e3581 | daniel-reich/ubiquitous-fiesta | /MGALfBAXhXqqdFyqo_15.py | 124 | 3.53125 | 4 |
def atbash(txt):
return "".join(chr(219-ord(x)) if x.islower() else chr(155-ord(x)) if x.isupper() else x for x in txt)
|
062d4e7e6488953a3c08db4344850290612ba71d | daniel-reich/ubiquitous-fiesta | /i5kcGmT7gFKkf3mTi_6.py | 489 | 3.546875 | 4 |
from datetime import date
def data_type(value):
value_type=type(value)
types=["list","dictionary","string","integer","float","boolean","date"]
if value_type == list:
return types[0]
elif value_type == dict:
return types[1]
elif value_type == str:
return types[2]
elif value_type == int:
return types[3]
elif value_type == float:
return types[4]
elif value_type == bool:
return types[5]
elif value_type == datetime.date:
return types[6]
|
4c7455e53de1920b02ef3706e3a91fa0e5d6625d | daniel-reich/ubiquitous-fiesta | /6BXmvwJ5SGjby3x9Z_20.py | 381 | 3.6875 | 4 |
def hours_passed(time1, time2):
diff = get_hour(time2) - get_hour(time1)
if diff == 0:
return "no time passed"
else:
return str(diff) + ' hours'
def get_hour(txt):
hm, ampm = txt.split()
h, m = hm.split(':')
h = int(h)
if h == 12 and ampm == 'AM':
h = 0
elif 1 <= h <= 11 and ampm == 'PM':
h += 12
return h
|
661170d01ba0f6d64fb19068d6217e210fcfd644 | daniel-reich/ubiquitous-fiesta | /XgJ3L3GF7o2dEaPAW_6.py | 214 | 3.515625 | 4 |
def sharedLetters(a, b):
count = ""
a = a.lower()
b = b.lower()
for i in range (len(a)):
if a[i] in b:
if a[i] not in count:
count +=a[i]
count = ''.join(sorted(count))
return count
|
216ab9b86de4d41cbd314d4ad0ca8bca7447daf9 | daniel-reich/ubiquitous-fiesta | /yuPWwSbCGPm2KzSzx_19.py | 839 | 3.671875 | 4 |
prices = {
"Strawberries" : "$1.50",
"Banana" : "$0.50",
"Mango" : "$2.50",
"Blueberries" : "$1.00",
"Raspberries" : "$1.00",
"Apple" : "$1.75",
"Pineapple" : "$3.50"
}
class Smoothie:
def __init__(self, ingredients):
self.ingredients = ingredients
def get_cost(self):
cost = sum(
float(prices[ingredient][1:])
for ingredient in self.ingredients)
return '${:.2f}'.format(cost)
def get_price(self):
cost = float(self.get_cost()[1:])
price = cost + cost * 1.5
return '${:.2f}'.format(price)
def get_name(self):
ingredients = sorted(
ingredient.replace('berries', 'berry')
for ingredient in self.ingredients)
smoothie_type = 'Fusion' if len(self.ingredients) > 1 else 'Smoothie'
return '{} {}'.format(' '.join(ingredients), smoothie_type)
|
3b0c37ffd3bd64aebeeaf854405ec07c61a9834a | daniel-reich/ubiquitous-fiesta | /Box2A6Rb94ao8wAye_10.py | 221 | 3.65625 | 4 |
def leader(lst):
greaterList = []
length = len(lst)
for i in range(length):
for j in range(i+1,length):
if lst[i] <= lst[j]:
break
else:
greaterList.append(lst[i])
return greaterList
|
92a4c5db4d3b7ba829736ed0d0fd1abf098c4139 | daniel-reich/ubiquitous-fiesta | /4QLMtW9tzMcvG7Cxa_3.py | 1,068 | 3.984375 | 4 |
def resistance_calculator(resistors):
Top_Part_01 = 1
Top_Part_02 = 0
Bottom = 0
Counter = 0
Length = len(resistors)
if (Length == 2):
Parallel = (resistors[0] * resistors[1]) / (resistors[0] + resistors[1])
Parallel = round(Parallel,2)
Series = sum(resistors)
Series = round(Series,2)
Answer = []
Answer.append(Parallel)
Answer.append(Series)
return Answer
else:
while (Counter < Length):
Item = resistors[Counter]
if (Item == 0):
Value = 0
Top_Part_02 += Value
Bottom += Item
else:
Value = 1 / Item
Top_Part_02 += Value
Bottom += Item
Counter += 1
if (Top_Part_02 == 0):
Parallel = 0
else:
Parallel = round(Top_Part_01 / Top_Part_02,2)
Series = sum(resistors)
Series = round(Series,2)
Answer = []
Answer.append(Parallel)
Answer.append(Series)
return Answer
|
d4bd8259aa466f46e9cb5c77cf2675a8515d93aa | daniel-reich/ubiquitous-fiesta | /ksZrMdraPqHjvbaE6_20.py | 150 | 3.90625 | 4 |
def largest_even(lst):
largest = -1
for num in lst:
if num % 2 == 0 and num > largest:
largest = num
return largest
|
4e5654515ddb5cd3c612299c41551ed87452e411 | daniel-reich/ubiquitous-fiesta | /WY7r2XtarpupNDWE8_1.py | 464 | 3.6875 | 4 |
import math
def tower_of_hanoi(disks, move):
assert move <= 2**disks-1
disk_locs = [0 for i in range(disks)]
for i in range(move):
x = int(math.log2((i^(i+1))+1))-1
disk_locs[x] = (disk_locs[x] + 1 - 2*(x%2!=disks%2))%3
return (
[i+1 for i in range(disks-1,-1,-1) if disk_locs[i]==0],
[i+1 for i in range(disks-1,-1,-1) if disk_locs[i]==1],
[i+1 for i in range(disks-1,-1,-1) if disk_locs[i]==2]
)
|
e8321eab1bf3ecb09c63cec90dd056dd492a0bcf | daniel-reich/ubiquitous-fiesta | /iHdZmimb82rAvEDkG_20.py | 365 | 3.828125 | 4 |
def bitwise_index(lst):
m = -10
index = -10
for i in range(len(lst)):
e = (lst[i] // 2) * 2
if e == lst[i] and lst[i] > m:
m = lst[i]
index = i
if m == -10 and index == -10: return 'No even integer found!'
if (index // 2) * 2 != index:
return {'@odd index ' + str(index) : m}
else:
return {'@even index ' + str(index) : m}
|
8d2ef2cadc4cce44b4b2938a2ebafd832a90b80c | daniel-reich/ubiquitous-fiesta | /Hg2gFcJDg7Rz5bd5m_14.py | 179 | 3.53125 | 4 |
def intersection(h1, h2):
tempDict1 = {}
tempDict2 = {}
for i in h1:
if i in h2:
tempDict1[i] = h1[i]
tempDict2[i] = h2[i]
return [tempDict1, tempDict2]
|
47613f091d83a167299851f7110c56bdad1bfa5e | daniel-reich/ubiquitous-fiesta | /Y4gwcGfcGb3SKz6Tu_3.py | 372 | 3.5 | 4 |
def max_separator(s):
lst, length = [], 2
for i in range(len(s)-1):
for j in range(i,len(s)):
if s[i] == s[j] and s[i:j+1].count(s[i]) == 2:
if j-i+1 == length:
lst.append(s[i])
elif j-i+1 > length:
length = j-i+1
lst = [s[i]]
return sorted(lst)
|
741546fb7cca7ffce49ff1a237b8fe1a3a03255f | daniel-reich/ubiquitous-fiesta | /aqDGJxTYCx7XWyPKc_2.py | 70 | 3.546875 | 4 |
def squares_sum(n):
return sum(num*num for num in range (1, n+1))
|
beb363b44ad6d095a294af40b07efc8dfc862640 | daniel-reich/ubiquitous-fiesta | /bfz7kTgPujtfcHR9d_15.py | 240 | 3.734375 | 4 |
def x_pronounce(sentence):
return ' '.join([word(w) for w in sentence.split()])
def word(w):
if w[0] == 'x':
if len(w) == 1:
return 'ecks'
w = 'z' + w[1:]
w = w.replace('x', 'cks')
return w
|
e51d240ce674881138433fb8e78f8bc2aac2d157 | daniel-reich/ubiquitous-fiesta | /YrNKDhmWPsm735J8L_16.py | 172 | 3.96875 | 4 |
def sort_word(word):
upper = [ch for ch in word if ch.isupper()]
lower = [ch for ch in word if ch.islower()]
return "".join(sorted(upper)) + "".join(sorted(lower))
|
7f96bf4553339a9a4ab259147aa8d35d4405dd04 | daniel-reich/ubiquitous-fiesta | /ZWEnJEy2DoJF9Ejqa_14.py | 464 | 3.84375 | 4 |
def edabit_in_string(string):
find = "edabit"
word2make = []
if "edabit" in string:
return "YES"
else:
for j in range(len(find)):
for i in range(len(string)):
if string[i] == find[j]:
word2make.append(string[i])
string = string[i+1:]
break
if "".join(word2make) == find:
return "YES"
else:
return "NO"
|
a357ac86d632dacea29987cd07fc38f988c84d72 | daniel-reich/ubiquitous-fiesta | /TBCujkw9D8hrEgFc4_15.py | 800 | 3.921875 | 4 |
def validate_email(txt):
passed = {"@": '', ".com": '', "name position": '', \
"email_position": ''}
pos_at = 0
pos_dotcom = 0
answer = True
for i in range(len(txt)):
if txt[i] == "@":
pos_at = i
passed["@"] = "Passed"
print("Passed: @")
for i in range(len(txt) - 3):
if txt[i] == '.' and txt[i : i+ 4] == '.com':
pos_dotcom = i
passed[".com"] = 'Passed'
print("Passed: .com")
if pos_at < pos_dotcom and (pos_dotcom - pos_at) > 1:
passed["email_position"] = "Passed"
print('Passed: gmail.com')
if pos_at != 0 and pos_dotcom != 0:
print(txt[:pos_at])
passed["name position"] = 'Passed'
print("Passed: name")
print(passed)
for item in passed:
if passed[item] == '':
answer = False
return(answer)
|
fc20c4edca43f4227ff306e903ecc22ccf2588f1 | daniel-reich/ubiquitous-fiesta | /Fe6wvtjcNFwuANuLu_5.py | 181 | 3.796875 | 4 |
def ping_pong(lst, win):
lst2=[]
for i in range(len(lst)):
lst2.append(lst[i])
lst2.append("Pong!")
if win==True: return lst2
else :
lst2.pop(-1)
return lst2
|
d0a828492fb3ef517b3f4e23ab14889b1b85e769 | daniel-reich/ubiquitous-fiesta | /QoavwQhmrDpXJhBW9_7.py | 316 | 3.546875 | 4 |
def flip_list(lst):
ls= []
for i in lst :
k=[]
if type (i)==list :
for j in i :
ls.append (j)
else :
k.append(i)
ls.append (k)
return ls
|
ac32279360361618de7235cd86766ede18339668 | daniel-reich/ubiquitous-fiesta | /9yk63KrKDHzNFWKBJ_23.py | 269 | 3.640625 | 4 |
def is_it_inside(d1,ch,pa):
def get_key(val):
if val == pa:
return True
for k1,v1 in d1.items():
if val in v1:
if k1==pa:
return True
else:
while k1!=pa:
return get_key(k1)
return False
return get_key(ch)
|
a6c81596ac97c29fea4b4f06eae67e09e032899b | daniel-reich/ubiquitous-fiesta | /tgd8bCn8QtrqL4sdy_9.py | 394 | 3.609375 | 4 |
def minesweeper(grid):
for y in range(3):
for x in range(3):
if grid[y][x] == "?":
minecount = 0
for yoffset in [y-1,y,y+1]:
for xoffset in [x-1,x,x+1]:
if yoffset>=0 and xoffset>=0 and yoffset<=2 and xoffset<=2:
if grid[yoffset][xoffset] == "#":
minecount += 1
grid[y][x] = str(minecount)
return grid
|
d1762fe0bd721b24eaec4529a10bb1acf20f0eef | daniel-reich/ubiquitous-fiesta | /iqaQLvS7yfGR2wJyL_5.py | 150 | 3.75 | 4 |
def num_of_digits(num):
if num == 0:
return 1
count = 0
num = abs(num)
while (num > 0):
num = num//10
count += 1
return count
|
0b11a219e1184061ffa39681223072ab763199df | daniel-reich/ubiquitous-fiesta | /aBbZfPAM8pKRZjC6p_6.py | 197 | 3.609375 | 4 |
def fruit_salad(fruits):
result = []
for word in fruits:
mid_index = len(word)//2
result.append(word[:mid_index])
result.append(word[mid_index:])
return "".join(sorted(result))
|
a6ee52805fa04fe686740d027611280774389005 | daniel-reich/ubiquitous-fiesta | /zJSF5EfPe69e9sJAc_23.py | 360 | 3.515625 | 4 |
def censor_string(txt, lst, char):
new=txt.split(" ")
new_string=[]
for word in new:
for censor in lst:
if word == censor:
word=list(word)
for n in range(len(word)):
word[n]=char
word="".join(word)
new_string.append(word)
return " ".join(new_string)
|
f67772b5e56ef6e1fce17762cb77d4f588d0d3cf | daniel-reich/ubiquitous-fiesta | /TDrfRh63jMCmqzGjv_17.py | 200 | 3.6875 | 4 |
def is_anti_list(lst1, lst2):
return all([True if x != y else False for x,y in zip(lst1,lst2)]) and all([True if x in set(lst2) and y in set(lst1) else False for x,y in zip(set(lst1),set(lst2))])
|
93e04e650d8eb1324f752cf698abcc36ba166943 | daniel-reich/ubiquitous-fiesta | /5x4uruF77BzWFFiQM_4.py | 192 | 3.53125 | 4 |
def pH_name(pH):
if pH>0 and pH<7:
return 'acidic'
elif pH>7 and pH<14:
return 'alkaline'
elif pH==7:
return 'neutral'
else:
return 'invalid'
|
9e8f0cc4d6282c90b33d65dde27b4ac950cae29d | daniel-reich/ubiquitous-fiesta | /iHdZmimb82rAvEDkG_17.py | 305 | 3.71875 | 4 |
def bitwise_index(lst):
a=['odd','even']
m=-999;msg=''
for i in range(len(lst)):
d=lst[i]//2
if d==lst[i]/2 and d>m:
m=d
msg=a[i//2==i/2]
f=i
if msg:
return {'@'+msg+' index '+str(f):lst[f]}
return 'No even integer found!'
|
7ff2de81faee76b4dc3827ab8ee15f1ac91c24bd | daniel-reich/ubiquitous-fiesta | /a6XHqehbttHnjE7bK_6.py | 275 | 3.625 | 4 |
def is_repdigit(num):
num = list(str(num))
lis = []
for i in range(len(num)):
if i >= len(num)-1:
break
elif num[i] == num[i+1]:
lis.append(True)
else: lis.append(False)
return False if False in lis else True
|
e4f0aec30639742af9754bc8bfade1705acec4b4 | daniel-reich/ubiquitous-fiesta | /jzCGNwLpmrHQKmtyJ_6.py | 99 | 3.671875 | 4 |
def parity_analysis(num):
x = 0
for i in str(num):
x += int(i)
return x % 2 == num % 2
|
46f3b321a69e5b4a02d849784aa91d269eefbd57 | daniel-reich/ubiquitous-fiesta | /4bX7qAqELq9XJeB26_16.py | 131 | 3.5625 | 4 |
import re
def to_camel_case(txt):
A=re.split('[-_]', txt)
B=[x.capitalize() for x in A[1:]]
C=[A[0]]+B
return ''.join(C)
|
64cd7846f60cbc3cd435989bbbfbd42515b7cf51 | daniel-reich/ubiquitous-fiesta | /zZyeau2MYcEc8Fdtk_2.py | 121 | 3.5625 | 4 |
def round_number(num, n):
m, o = num +0, num + 0
while m%n and o%n:
m-=1
o+=1
return o if not o%n else m
|
3efb91262157750eb7049ae048a1ad17d5067a20 | daniel-reich/ubiquitous-fiesta | /PCtTk9RRPPKXCxnAx_17.py | 180 | 3.5625 | 4 |
from numpy import sign
def modulo(x, y):
if abs(x) < abs(y):
return x
if sign(x) == sign(y):
return modulo(x-y, y)
else:
return modulo(x+y,y)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.