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 |
|---|---|---|---|---|---|---|
824aeac794518b7701e7c412845f918c98ac1918 | daniel-reich/ubiquitous-fiesta | /vnzjuqjCf4MFHGLJp_1.py | 257 | 3.59375 | 4 |
def shift_letters(txt, n):
letters = ''.join(i for i in txt if i.isalpha())
move = -(n % len(letters))
shifted = iter(letters[move:] + letters[:move])
return ''.join(
next(shifted) if t.isalpha()
else t for t in txt
)
|
36ad059b28f1d2213cb50860551ccb41ba4f3c4a | daniel-reich/ubiquitous-fiesta | /sfqudQHQ3HPpd7dZb_23.py | 295 | 3.65625 | 4 |
def rps(p1, p2):
myDict = {
'Rock': 2,
'Scissors': 1,
'Paper': 0
}
result = myDict[p1] - myDict[p2]
if result == 1 or result == -2:
return 'The winner is p1'
elif result == -1 or result == 2:
return 'The winner is p2'
elif result == 0:
return "It's a draw"
|
d7e00e6889e066674a227e4340e4f7eba9188a03 | daniel-reich/ubiquitous-fiesta | /iXabTtWEX8xegqFds_6.py | 199 | 3.765625 | 4 |
def alternate_sort(lst):
n = sorted(filter(lambda v: isinstance(v, str), lst))
a = sorted(filter(lambda v: isinstance(v, int), lst))
return [val for pair in list(zip(a, n)) for val in pair]
|
9b55ab6de9b74261d18334d6a4fac62a7ecc8520 | daniel-reich/ubiquitous-fiesta | /FnyAGdwgcH4whynjR_14.py | 505 | 3.5 | 4 |
def get_subsets(lst, target):
results=[]
for x in range(1, len(lst)+1):
rr=[]
subsets(lst,target,x,[],0,rr)
if len(rr)>0:
rr.sort()
results=results+rr
print(results)
return results
def subsets(lst,target, n, ll, sm, result):
if len(ll)==n:
if sm==target:
result.append(ll)
return
for i in range(0, len(lst)):
ll2 = ll.copy()
ll2.append(lst[i])
sm2 = sm + lst[i]
lst2 = lst[i+1:len(lst)]
subsets(lst2, target, n, ll2, sm2, result)
|
2827bc94b65acbb2c25e24161e9265500dce811d | daniel-reich/ubiquitous-fiesta | /auLEvdvBT5PRnALvn_11.py | 322 | 3.9375 | 4 |
from string import ascii_lowercase as al
def mirror_cipher(message, key=al):
message, key = message.lower(), key.lower()
result = ""
for letter in message:
if not letter in key:
result += letter
else:
index = key.find(letter)
mirror = key[-index-1]
result += mirror
return result
|
241d0beeba01f22a13ce4b90c82e5216049016d7 | daniel-reich/ubiquitous-fiesta | /fYMjhe7BnijXwfNpF_6.py | 161 | 3.515625 | 4 |
def stmid(string):
lst = string.split()
txt = ''
for i in lst:
if len(i) % 2:
txt += i[(len(i) // 2)]
else:
txt += i[0]
return txt
|
df59dfe88e99a9cf6acec9b5faafba7132382f42 | daniel-reich/ubiquitous-fiesta | /YN33GEpLQqa5imcFx_2.py | 179 | 3.65625 | 4 |
def pascals_triangle(row):
n, res = 1, [1, 1]
while n < row:
res = [1] + [sum(res[n:n+2]) for n in range(n+1)]
n += 1
return ' '.join(map(str, res))
|
a2b543641ebe7bd3b9fd6012b7fdf47565b7f326 | daniel-reich/ubiquitous-fiesta | /KSQPoma9iaz5bkSnv_11.py | 271 | 3.59375 | 4 |
def pyramid_lists(n):
n_range = list(range(1, n + 1))
output = []
for list_values in n_range:
list_length = []
for thing in range(list_values):
list_length.append(list_values)
output.append(list_length)
return output
|
48d9d502b12feb2a2c6c637cc5050d353a6e45d0 | daniel-reich/ubiquitous-fiesta | /tgd8bCn8QtrqL4sdy_2.py | 776 | 4.15625 | 4 |
def minesweeper(grid):
'''
Returns updated grid to show how many mines surround any '?' cells, as
per the instructions.
'''
def mines(grid, i, j):
'''
Returns a count of mines surrounding grid[i][j] where a mine is
identified as a '#'
'''
count = 0
locs = ((i-1,j-1), (i-1,j), (i-1,j+1),(i,j-1),
(i,j+1), (i+1,j-1), (i+1,j), (i+1,j+1)) # possible neighbours
for r, c in locs:
if 0 <= r < len(grid) and 0 <= c < len(grid[0]):
if grid[r][c] == '#':
count += 1
return str(count)
return [[mines(grid,i,j) if grid[i][j] == '?' else grid[i][j] \
for j in range(len(grid[0]))] for i in range(len(grid))]
|
5de367aefef19745b4d74955a61ad49a3d62d937 | daniel-reich/ubiquitous-fiesta | /K4aKGbfmzgyNNYEcM_2.py | 128 | 3.5 | 4 |
def is_shape_possible(n, a):
if n <=2 or any(i > 180 for i in a):
return False
return (180 - (360 / n)) * n == sum(a)
|
d75076a5bbcc0963fd01481f799bd84236b8311d | daniel-reich/ubiquitous-fiesta | /bKfxE7SWnRKTpyZQT_20.py | 150 | 4.0625 | 4 |
def replace_vowel(word):
vowel={"a":1,"e":2,"i":3,"o":4,"u":5}
return "".join([str(i) if i not in vowel else str(vowel[i]) for i in word])
|
7c344d82c02cfb786f6865cd2049e7c3f890c791 | daniel-reich/ubiquitous-fiesta | /kmruefq3dhdqxtLeM_11.py | 113 | 3.640625 | 4 |
def sum_digits(a, b):
sum = 0
for i in range(a,b+1):
for j in str(i):
sum += int(j)
return sum
|
19372ec8aacd943b2c34e0158423a405224ac015 | daniel-reich/ubiquitous-fiesta | /zp64GNJQpZyGpYWL8_1.py | 330 | 3.796875 | 4 |
def score_it(s):
p=left=score=0
while p<len(s)-1:
left+=1*(s[p]=='(')-1*(s[p]==')')
if s[p].isnumeric():
num='0'
while s[p].isnumeric() and p<len(s)-1:
num+=s[p]
p+=1
score+=left*int(num)
else:
p+=1
return score
|
5a3939e38fc3d4044a7184564144fcf30dce8819 | daniel-reich/ubiquitous-fiesta | /stAFzKqQnWHztzrAW_15.py | 111 | 3.515625 | 4 |
def add_nums(nums):
a = nums.split(', ')
b = []
for elem in a:
b.append(int(elem))
return sum(b)
|
74f0d03bc7652afd9cbaf4446de7ed7a5300fe5b | daniel-reich/ubiquitous-fiesta | /wqBnr3CDYByA5GLxo_11.py | 382 | 3.765625 | 4 |
def unravel(txt):
poss = [""]
while txt:
if txt[0] != "[":
if "]" not in txt:
add, txt = txt, ""
else:
r = txt.index("[")
add, txt = txt[:r], txt[r:]
poss = [p+add for p in poss]
else:
r = txt.index("]")
add, txt = txt[1:r], txt[r+1:]
poss = [p+a for p in poss for a in add.split("|")]
return sorted(poss)
|
5b8f8a96db289b6e92639d1c12e02bb6bb8dc611 | daniel-reich/ubiquitous-fiesta | /i747Wtc7pCukr8GRC_6.py | 445 | 3.578125 | 4 |
import itertools
def mult(j):
h = 1
for i in j:
h=h*i
return h
def max_product(lst):
l = []
for i in range(len(lst)+1):
for j in itertools.combinations(lst,i):
if len(j)==3:l.append(mult(list(j)))
return max(l)
def min_product(lst):
l = []
for i in range(len(lst)+1):
for j in itertools.combinations(lst,i):
if len(j)==3:l.append(mult(list(j)))
return min(l)
|
c3c79c36b3393c150648c8f5aed21216bbaf23c6 | daniel-reich/ubiquitous-fiesta | /nC7iHBbN8FEPy2EJ2_10.py | 445 | 3.65625 | 4 |
import math
class Rectangle:
def __init__(self, sideA=0, sideB=0):
self.sideA = sideA
self.sideB = sideB
def getArea(self):
return self.sideA * self.sideB
def getPerimeter(self):
return 2 * (self.sideA + self.sideB)
class Circle:
def __init__(self, rad=0):
self.rad = rad
def getArea(self):
return math.pi * self.rad**2
def getPerimeter(self):
return 2 * math.pi * self.rad
|
ba38393baa60056a4ac82a6f95e68c3b5adcf241 | daniel-reich/ubiquitous-fiesta | /MAzBohC2PxchT3wqK_16.py | 192 | 3.546875 | 4 |
from itertools import zip_longest
def shadow_sentence(a, b):
return all((len(i) == len(j)) and not any(k in i for k in j) for i, j in zip_longest(a.split(), b.split(), fillvalue= ''))
|
916e2d48a857477e72f0659199cbe484658c7ace | daniel-reich/ubiquitous-fiesta | /pGRAtBbwSMjpXNGnP_9.py | 474 | 3.8125 | 4 |
def is_sorted(words, alphabet):
if words == []:
return True
for i in range(len(words)-1):
min_len = min(len(words[i]), len(words[i+1]))
if words[i+1] == words[i][0:min_len] and len(words[i]) > min_len:
return False
for j in range(min_len):
if all(words[i][k] == words[i+1][k] for k in range(j)) and alphabet.find(words[i][j]) > alphabet.find(words[i+1][j]):
return False
return True
|
aa7bd85b04ac745b7b3614517972256d4ad63bb5 | daniel-reich/ubiquitous-fiesta | /j9zed4GnykS48W6vh_15.py | 465 | 3.75 | 4 |
def dlen(num):
return len(str(num))
def decrease_to_next_digit(number):
num_digits = dlen(number)
next_num_str = (num_digits-1)*"9"
if next_num_str == "":
return 0
return int(next_num_str)
def digits(number):
number = number-1
total = 0
while number > 0:
num_digits = dlen(number)
next_number = decrease_to_next_digit(number)
diff = number - next_number
total += diff*num_digits
number = next_number
return total
|
209ea27d0ce94020c0d9c8f545374a0230cacf78 | daniel-reich/ubiquitous-fiesta | /5h5uAmaAWY3jSHA7k_9.py | 915 | 3.71875 | 4 |
def landscape_type(lst):
for i in range(1, len(lst)-1):
lfttop = False
rghttop = False
for j in range(0,i-1):
if lst[j]>lst[j+1]:
lfttop = True
break
if lfttop == False:
for k in range(i,len(lst)-1):
if lst[k]<lst[k+1]:
rghttop = True
break
if lfttop == False and rghttop == False:
if lst[0]==max(lst) or lst[len(lst)-1]==max(lst): return "neither"
return "mountain"
for i in range(1, len(lst)-1):
lfttop = False
rghttop = False
for j in range(0,i-1):
if lst[j]<lst[j+1]:
lfttop = True
break
if lfttop == False:
for k in range(i,len(lst)-1):
if lst[k]>lst[k+1]:
rghttop = True
break
if lfttop == False and rghttop == False:
if lst[0]==min(lst) or lst[len(lst)-1]==min(lst): return "neither"
return "valley"
return "neither"
|
48833d838c23df7b3532151204955da20d6e1034 | daniel-reich/ubiquitous-fiesta | /n5Ar5F2CJMpGRXz3o_4.py | 320 | 3.71875 | 4 |
def mineral_formation(cave):
stalac = False
stalag = False
for x in cave[0]:
if x != 0:
stalac = True
for x in cave[3]:
if x != 0:
stalag = True
if (stalag and stalac) == True:
return "both"
elif stalag == True:
return "stalagmites"
elif stalac == True:
return "stalactites"
|
3dcdd4799971cf8a1833066c1054fa11678c109c | daniel-reich/ubiquitous-fiesta | /PLdJr4S9LoKHHjDJC_0.py | 210 | 3.78125 | 4 |
def identify(*cube):
m = len(cube)
n = max(len(row) for row in cube)
missing = sum(n-len(row) for row in cube)
if missing:
return "Missing " + str(missing)
return "Full" if m==n else "Non-Full"
|
b52a0beddf0edd7fba99af67aa235b06fd853360 | daniel-reich/ubiquitous-fiesta | /Ggq8GtYPeHJQg4v7q_2.py | 174 | 3.8125 | 4 |
def replace_vowels(txt, ch):
for char in txt:
if char in "aeiou":
txt = txt.replace(char,ch)
return txt
|
c0db57d00d46ad400278961be7e17f6707aa6cc9 | daniel-reich/ubiquitous-fiesta | /qgtKJx6tEMwP4JSAQ_8.py | 234 | 3.609375 | 4 |
def twins(age, distance, velocity):
jill = round(age + 2 * distance / velocity, 1)
jack = round(age + (1 - velocity ** 2) ** 0.5 / velocity * distance * 2, 1)
return "Jack's age is {}, Jill's age is {}".format(jack, jill)
|
8bb0d701dcc9672f9885aa2e5ab35e8671ee997f | daniel-reich/ubiquitous-fiesta | /gbybFzt2tLa5zfpHc_22.py | 219 | 3.59375 | 4 |
from itertools import combinations
def three_sum(lst):
result = []
for i in combinations(lst, 3):
if sum(i) == 0:
tmp = list(i)
if tmp not in result:
result.append(tmp)
return result
|
202c34d38e23b3f7d5bb8a6dfbec4f7715564287 | daniel-reich/ubiquitous-fiesta | /7FyTyi68Df2CxLx6C_8.py | 418 | 3.546875 | 4 |
order_number = 0
class Pizza:
def __init__(self, ingredients):
global order_number
self.ingredients = ingredients
order_number += 1
self.order_number = order_number
def garden_feast():
a = Pizza(['spinach', 'olives', 'mushroom'])
return a
def hawaiian():
a = Pizza(['ham', 'pineapple'])
return a
def meat_festival():
a = Pizza(['beef', 'meatball', 'bacon'])
return a
|
614a11b147a283bc32db33558c93d4cfc3261f10 | daniel-reich/ubiquitous-fiesta | /YN33GEpLQqa5imcFx_16.py | 211 | 3.734375 | 4 |
def pascals_triangle(row):
def fact(n):
if n == 0:
return 1
else:
return n*fact(n-1)
return "".join([str(int((fact(row))/(fact(i)*fact(row-i)))) + " " for i in range(row+1)]).strip()
|
6b2923ca041dc11213ab837e583b602bf25f4684 | daniel-reich/ubiquitous-fiesta | /wwN7EwvqXKCSxzyCE_3.py | 225 | 3.640625 | 4 |
def reorder_digits(lst, direction):
new_lst = []
for i in lst:
num = ''.join(sorted(str(i)))
if direction == 'asc':
new_lst.append(int(num))
else:
new_lst.append(int(num[::-1]))
return new_lst
|
bf83beaeb505f67568d2d89daad354ece92ccce1 | daniel-reich/ubiquitous-fiesta | /2Tr4gAzWimWvGpJW7_14.py | 146 | 3.625 | 4 |
def is_there_consecutive(lst, n, times):
if str(n)*times == "":
return not n in lst
else : return str(n)*times in "".join(map(str,lst))
|
85a124cb206c3e3835a414936ae666178dbc85a5 | daniel-reich/ubiquitous-fiesta | /L2nw2N2YqZCboiaYM_19.py | 244 | 3.671875 | 4 |
def repeated(s):
if(len(s)<2):
return False
for i in range(0,len(s)):
z=s[i+1:]
check=0
while(z.startswith(s[:i+1])):
check=1
z=z[len(s[:i+1]):]
if(len(z)==0 and check==1):
return True
return False
|
1b592ed5b066632ad8a0c9404431cc03a961a53c | daniel-reich/ubiquitous-fiesta | /GZ5gCe5jnbNRWqc5J_0.py | 193 | 3.703125 | 4 |
from datetime import date
def first_tuesday_of_the_month(year, month):
for day in range(1, 8):
if date(year, month, day).weekday() == 1:
return date(year, month, day).isoformat()
|
e07c8e937363164c6a83778de6812098453d9fbe | daniel-reich/ubiquitous-fiesta | /JzBLDzrcGCzDjkk5n_21.py | 268 | 4.1875 | 4 |
def encrypt(word):
#Step 1: Reverse the input: "elppa"
rword = word[::-1]
rword = rword.replace('a','0')
rword = rword.replace('e','1')
rword = rword.replace('o','2')
rword = rword.replace('u','3')
rword = rword+'aca'
return rword
|
9167f212b0c303aa54ce50e4e4a5c91e83bdc5b0 | daniel-reich/ubiquitous-fiesta | /Y8uyMM8ax37wQLkNQ_5.py | 614 | 3.53125 | 4 |
def matrix(n):
result =[]
for _ in range(n):
result.append([0 for _ in range(n)])
k = 1
row = 0
column = n
while row < n/2:
for j in range(n - column, column):
result[row][j] = k
k += 1
for i in range(row + 1, n - row):
result[i][column-1] = k
k += 1
for j in range(column - 2, n - column-1, -1):
result[n-row-1][j] = k
k += 1
for i in range(n - 2- row, row, -1):
result[i][n - column] = k
k += 1
row += 1
column -= 1
return result
|
a1626bed0a06c9a97435ccde112d2af54a3a9fe0 | daniel-reich/ubiquitous-fiesta | /HpJCBwggQMDLWTHsM_14.py | 152 | 3.734375 | 4 |
def average_word_length(txt):
words = [word.strip(',.?!') for word in txt.split()]
return round(sum(len(word) for word in words) / len(words), 2)
|
65f2a3dbc8f392e0b9929f4bd45a29de0fc968e8 | daniel-reich/ubiquitous-fiesta | /f3jX2BwzAuR8DXsy4_15.py | 164 | 3.578125 | 4 |
def fact_of_fact(n):
res = 1
for i in range(1,n+1):
res*=fact(i)
return res
def fact(n):
res = 1
for i in range(1,n+1):
res*=i
return res
|
d9e03e0b0e2fb537914b624181acaced96287520 | daniel-reich/ubiquitous-fiesta | /A9iPfSEZ9fCrPQSwC_14.py | 197 | 3.703125 | 4 |
def points_in_circle(points, centerX, centerY, radius):
count = 0
for point in points:
if ((point["x"] - centerX)**2 + (point["y"] - centerY)**2)**0.5 < radius: count += 1
return count
|
ffa87268935394a1406f736908c6e5db3e47b542 | daniel-reich/ubiquitous-fiesta | /fvHLv9f5t6xoTWwXT_17.py | 98 | 3.515625 | 4 |
import re
def grab_number_sum(s):
return sum(int(num) for num in re.findall("[0-9]+", s))
|
130935300423718de3f9163e9558e1b07471f2f4 | daniel-reich/ubiquitous-fiesta | /763oGpb5JvctX5tAc_19.py | 93 | 3.578125 | 4 |
def is_anagram(s1,s2):
return ''.join(sorted(s1.lower())) == ''.join(sorted(s2.lower()))
|
551dbc7c805b95c074df669c5415a8ec988c5b9f | daniel-reich/ubiquitous-fiesta | /Q9EkExy6BYLnqBCQB_10.py | 188 | 3.578125 | 4 |
def wrap_around(string, offset):
if abs(offset) < len(string):
return string[offset:]+string[:offset]
else:
a = offset%len(string)
return string[a:]+string[:a]
|
5adb98a419983f9ac8674393fef11e28b363416b | daniel-reich/ubiquitous-fiesta | /A9iPfSEZ9fCrPQSwC_22.py | 166 | 3.59375 | 4 |
def points_in_circle(points, centerX, centerY, radius):
cnt=0
for pt in points:
if (pt['x']-centerX)**2+(pt['y']-centerY)**2<radius**2: cnt+=1
return cnt
|
df438e7df265d1dcf99caddc64bd926b92116de7 | daniel-reich/ubiquitous-fiesta | /kBXHbwQZPiLmwjrMy_7.py | 454 | 3.65625 | 4 |
import re
def translate_word(word):
if not word:
return ''
if word[0] not in 'aeiouAEIOU':
i = re.search('[aeiouAEIOU]', word).start()
res = word[i:] + word[:i] + "ay"
if word[0].isupper():
res = res[0].upper() + res[1:].lower()
else:
res = word + 'yay'
return res
def translate_sentence(sentence):
return re.sub(r'\w+', lambda w: translate_word(w.group(0)), sentence)
|
e395b1fa6da4b6c810807f7dd0ef3b1505023e2e | daniel-reich/ubiquitous-fiesta | /fYMjhe7BnijXwfNpF_4.py | 129 | 3.5625 | 4 |
def stmid(string):
return ''.join([letter[int(len(letter)/2)] if len(letter)%2 else letter[0] for letter in string.split()])
|
54c6ae8255b8c67e8ee460188195edce9468060d | daniel-reich/ubiquitous-fiesta | /jyqcRv6giw8an8KB2_20.py | 94 | 3.828125 | 4 |
def invert(s):
return ''.join(c.upper() if c.islower() else c.lower() for c in s[::-1])
|
a7a794e1c56a9a1b99bf62eec8ef6c95fccbbe1b | daniel-reich/ubiquitous-fiesta | /ZwmfET5azpvBTWoQT_8.py | 307 | 3.765625 | 4 |
def valid_word_nest(word, nest):
if nest.count(word)>1: return False
while len(nest)>len(word):
for i in range(0, len(nest)):
if nest[i:i+len(word)]==word:
return valid_word_nest(word, nest[:i] + nest[i+len(word):])
return False
return word == nest
|
a026322aaf70ce5a8751e59341050fd1c16919c8 | daniel-reich/ubiquitous-fiesta | /rFK7WftrcrEu6rbu8_2.py | 624 | 3.71875 | 4 |
class Node:
def __init__(self,d):
self.d=d
self.l=self.r=None
class BST:
def __init__(self):self.h=None
def insert(self,d):
n=Node(d)
if self.h==None:self.h=n
else:
c=self.h
while 1:
if d>c.d and c.r:c=c.r
elif d<c.d and c.l:c=c.l
elif d>c.d:c.r=n;break
else:c.l=n;break
return self.h
def traverse(self):
r,v=[],[]
o=self.h
if o:v.append(o);r.append(o.d)
c=o
while c:
if c.l:r.append(c.l.d);v.append(c.l)
if c.r:r.append(c.r.d);v.append(c.r)
v.pop(0)
if not v:break
c=v[0]
return r
|
cc1b288eef2b0edcb4b3945bc6d6a42d911259f6 | daniel-reich/ubiquitous-fiesta | /vuSXW3iEnEQNZXjAP_4.py | 257 | 4.03125 | 4 |
def create_square(length):
if length == None or length < 1: return ""
if length == 1: return "#"
square = '#' * length + "\n"
for x in range(1, length - 1):
square += "#" + (" " * (length - 2)) + "#\n"
square += "#" * length
return square
|
03a80c6fa52a4deac538ff61d40e3217b1c30b10 | daniel-reich/ubiquitous-fiesta | /cEzT2e8tLpwYnrstP_14.py | 252 | 3.640625 | 4 |
def swap_d(k, v, swapped):
dic = {}
if(swapped):
index = 0
while index < len(k):
dic[v[index]] = k[index]
index += 1
else:
index = 0
while index < len(k):
dic[k[index]] = v[index]
index += 1
return dic
|
bcaadfa913f197863fd830ac722e2ca991a97da5 | daniel-reich/ubiquitous-fiesta | /xzisrRDwWT8prHtiQ_12.py | 107 | 3.5 | 4 |
def difference_two(lst):
l=[]
for x in sorted(lst):
if x+2 in lst:
l+=[[x,x+2]]
return l
|
8ad4a86c0bf6fd71613cb14602846678e4ad77d4 | daniel-reich/ubiquitous-fiesta | /JgD9KHBYrDnKrGJ7a_5.py | 191 | 3.765625 | 4 |
def swap_dict(dic):
A=[(y,x) for x,y in dic.items()]
B=set([x[0] for x in A])
d={x:[] for x in B}
for x in A:
for k in d:
if x[0]==k:
d[k].append(x[1])
return d
|
d48c23413db63bcfadccc9ef0f7877e916dbf0ce | daniel-reich/ubiquitous-fiesta | /hZ4HzhboCJ5dDiNve_14.py | 453 | 3.75 | 4 |
def special_reverse_string(txt):
caps=[i for i,c in enumerate(txt) if c.isupper()]
spaces=[i for i,c in enumerate(txt) if c==" "]
str1="".join(txt.lower().split(" "))
str2=str1[::-1]
str3=""
j=0
for i,x in enumerate(str2):
if j in spaces:
j+=1
str3=str3+" "+x
else:
str3=str3+x
j+=1
return "".join([x.upper() if i in caps else x for i,x in enumerate(str3) ])
|
8121a76d45784eca606a54b1b63b5d737692deff | daniel-reich/ubiquitous-fiesta | /djDJHv3nwWsRM9mtu_20.py | 265 | 3.5 | 4 |
import re
def validate_spelling(txt):
txt.replace(' ','')
print(txt)
words = txt.split('. ')
print(words)
w = ''.join(words[0:(len(words)-1)])
w = w.title()
t = re.compile('[,\.!?]')
out = t.sub('',words[-1])
print(w)
print(t)
return w==out
|
fca03ff3ceaac656a1ca71dc34860cd8f7f57040 | daniel-reich/ubiquitous-fiesta | /xmyWLvzP5df6okDTG_18.py | 126 | 3.84375 | 4 |
def binary_to_decimal(binary):
decimal = 0
for digit in binary:
decimal = decimal*2 + int(digit)
return decimal
|
d89688063879410b530c15eda15179b934385d9c | daniel-reich/ubiquitous-fiesta | /di7ZjxgvLgz72PvCS_12.py | 407 | 3.65625 | 4 |
def validate_swaps(lst, txt):
return [False if diff(word, txt) > 2 else True for word in lst]
def diff(test_word, ideal_word):
if len(test_word) != len(ideal_word) or set(test_word) != set(ideal_word):
return 3
else:
count = 0
for a in range(len(test_word)):
if test_word[a] != ideal_word[a]:
count += 1
if count > 2:
return count
return count
|
d5022b53b54c87aeb66009b0811436c3be7a86fc | daniel-reich/ubiquitous-fiesta | /LyzKTyYdKF4oDf5bG_4.py | 276 | 3.84375 | 4 |
def find_longest(s,m=''):
if not m:
s = s.lower().split()
try:
m = s[0]
if m.endswith("'s"):
m = m[:-2]
if not m.isalpha():
m = ''.join(i for i in m if i.isalpha())
return max((m, find_longest(s[1:], m)), key=len)
except:
return ''
|
3e9a0ae945e9177bae3955e3e401b2664d77f301 | daniel-reich/ubiquitous-fiesta | /7shokLkiNu2PEpWtP_17.py | 86 | 3.6875 | 4 |
lst = [1, 2, 3, 4, 5, 6, 7, 8]
first = lst[0]
last = lst[-1]
print(first, last)
|
55aaeb3c6a23e87078b4bb546769cd4dcb056c18 | daniel-reich/ubiquitous-fiesta | /6o5wkfmSaFXCJYqDx_19.py | 117 | 3.640625 | 4 |
def abcmath(a, b, c):
for i in range(b):
a += a
if a % c == 0:
return True
else:
return False
|
1725d2c07b965c80af3ab6bfd9de26f403ac1634 | daniel-reich/ubiquitous-fiesta | /KgBqna3XhRkoL2mo7_4.py | 349 | 3.703125 | 4 |
letters = {str(i - 96): chr(i) for i in range(97, 123)}
def decrypt(s):
len_s = len(s)
i = 0
res = []
while i < len_s:
if i + 2 < len_s and s[i + 2] == "#":
res.append(letters[s[i: i + 2]])
i += 3
else:
res.append(letters[s[i: i + 1]])
i += 1
return "".join(res)
|
33baf95da6429ab1159b1131ec0049ff715dc11c | daniel-reich/ubiquitous-fiesta | /q3zrcjja7uWHejxf6_20.py | 118 | 3.578125 | 4 |
import re
def negative_sum(txt):
return sum([int(a) for a in re.split('(-\d+)', txt) if a.startswith('-')])
|
1cdd2ff6b68e46a2d9bbea22e065a8e81ece40e5 | daniel-reich/ubiquitous-fiesta | /4Y5Zk5f9LckvWjFf3_15.py | 192 | 3.703125 | 4 |
def special_reverse(x, y):
s = ''
for each in x.split():
if each.startswith(y):
s += each[::-1] + " "
else:
s += each + " "
return s[:-1]
|
8bde3d376b1b3676acf43203171314bbdc0958f7 | daniel-reich/ubiquitous-fiesta | /BokhFunYBvsvHEjfx_11.py | 105 | 3.546875 | 4 |
def seven_boom(lst):
return "Boom!" if '7' in ''.join(map(str,lst)) else "there is no 7 in the list"
|
5fa9c508215aa1e8eacb007fe375ecaaed2a5345 | daniel-reich/ubiquitous-fiesta | /qNQkYzY8GpiFMmndh_16.py | 644 | 3.546875 | 4 |
def get_overlap(word1, word2):
if len(word2) < len(word1) and word1[-len(word2):] == word2:
return len(word2)
L = min(len(word1), len(word2))
for k in range(L):
if word1[-k:] == word2[:k]:
return k
return 0
def join(lst):
min_ov = min([get_overlap(lst[i-1], lst[i]) for i in range(1, len(lst))])
if min_ov == 0:
return [''.join(lst), 0]
concat = lst[0]
prev = lst[0]
for word in lst[1:]:
ov = get_overlap(prev, word)
if ov == 0:
concat += word
else:
concat += word[ov:]
prev = word
return [concat, min_ov]
|
8cc3d97dc534f853670509fb056fb3fda32a8f0e | daniel-reich/ubiquitous-fiesta | /u3kiw2gTY3S3ngJqo_21.py | 159 | 3.671875 | 4 |
def superheroes(heroes):
l = [i for i in heroes if i.endswith("man")]
final = [i for i in l if not i.endswith(("Woman","woman"))]
return sorted(final)
|
17cb44b6a7a39fa64513bcee2322242cd8fe33a3 | daniel-reich/ubiquitous-fiesta | /iuenzEsAejQ4ZPqzJ_9.py | 120 | 3.859375 | 4 |
def mystery_func(num):
ans, p = "", 2
while p<num:
ans+= "2"
p*=2
ans+= str(num-p//2)
return int(ans)
|
4da468882b44f3f02f7fe4120a61c4ef741a6ec1 | daniel-reich/ubiquitous-fiesta | /9Q5nsEy2E2apYHwX8_8.py | 625 | 3.5625 | 4 |
class programer():
def __init__(self,sallary,work_hours):
self.sallary = sallary
self.work_hours = work_hours
def __del__(self):
return "oof, {}, {}".format(str(self.sallary),str(self.work_hours))
def compare(self,other):
if self.sallary > other.sallary:
return other
elif self.sallary < other.sallary:
return self
elif self.sallary == other.sallary:
if self.work_hours < other.work_hours:
return self
elif self.work_hours > other.work_hours:
return other
|
7b70ed4d752c7258b294814dad4deee7c3383727 | daniel-reich/ubiquitous-fiesta | /ruPm4LX6fEvvLJk9j_12.py | 325 | 3.859375 | 4 |
def to_base(num, base):
digits = []
while num > 0:
digits.append(num % base)
num //= base
return digits
def esthetic(num):
res = []
for b in range(2, 11):
digits = to_base(num, b)
if all(abs(i - j) == 1 for i, j in zip(digits, digits[1:])):
res.append(b)
return res or "Anti-Esthetic"
|
d716c61b73dde04336a86f49e13b7212086ebec0 | daniel-reich/ubiquitous-fiesta | /nmoohLwP962r6P355_3.py | 367 | 3.59375 | 4 |
def straight_digital(number):
a = 1
if number < 0:
number = abs(number)
a = -1
n = [int(x) for x in str(number)]
n[0] = n[0]*a
if len(n) < 3:
return 'Not Straight'
if sum(n)//len(n) == n[0]:
return 'Trivial Straight'
check = n[1]-n[0]
for i in range(2,len(n)):
if n[i]-n[i-1] != check:
return 'Not Straight'
return check
|
683ecf3055abf4fa0b764f7e9971b01ea9ac43d6 | daniel-reich/ubiquitous-fiesta | /kgMEhkNNjRmBTAAPz_23.py | 189 | 3.6875 | 4 |
def remove_special_characters(txt):
from string import punctuation
from re import sub
rep = "[{stg}]".format(stg=sub("[-_ ]", "", punctuation))
return (sub(rep, "", txt))
|
609222ee7445156fc497444c301f841adae72041 | daniel-reich/ubiquitous-fiesta | /C45TKLcGxh8dnbgqM_19.py | 275 | 3.703125 | 4 |
def caesar_cipher(s, k):
a = "abcdefghijklmnopqrstuvwxyz"
b = ""
for i in s:
if i.isalpha():
if i.isupper():
b += a[(a.index(i.lower())+k)%26].upper()
else:
b += a[(a.index(i)+k)%26]
else: b += i
return b
|
13d44e4d306fa3ee34bec9b205768e45f8895c44 | daniel-reich/ubiquitous-fiesta | /8vBvgJMc2uQJpD6d7_9.py | 529 | 3.96875 | 4 |
def prime_factors(n):
a = [] # Prepare an empty list.
f = 2 # The first possible factor.
while n > 1: # While n still has remaining factors...
if n % f == 0: # The remainder of n divided by f might be zero.
a.append(f) # If so, it divides n. Add f to the list.
n /= f # Divide that factor out of n.
else: # But if f is not a factor of n,
f += 1 # Add one to f and try again.
return a
|
ff3b32c653046de4d01c7327b2ed533907355466 | daniel-reich/ubiquitous-fiesta | /iHdZmimb82rAvEDkG_12.py | 369 | 3.890625 | 4 |
def bitwise_index(lst):
largest = -2**31
idx = -1
for i in range(len(lst)):
a = lst[i]
if a > largest and (a // 2) * 2 == a:
largest = a
idx = i
if idx < 0:
return "No even integer found!"
parity = "even" if (idx // 2) * 2 == idx else "odd"
return {"@" + parity + " index " + str(idx): largest}
|
9a349147b29c0b4be6a192bea920738ae07b842c | daniel-reich/ubiquitous-fiesta | /Emdzxs23PRzSDuvk3_9.py | 302 | 3.5625 | 4 |
def pizza_points(customers, min_orders, min_price):
s = list(map(lambda x:list(x),list(customers.items())))
s = list(map(lambda x:[x[0], list(filter(lambda x:x>=min_price,x[1]))], s))
ans = list(filter(lambda x:len(x[1]) >= min_orders,s))
return sorted(list(map(lambda x:x[0], ans)))
|
70e7111dde65600a0afc9d18876e60e529d3a6cd | daniel-reich/ubiquitous-fiesta | /KZFEAv8Sqh9zW5eLS_2.py | 164 | 3.609375 | 4 |
def is_val_in_tree(tree, val):
for i in tree:
if i == val or isinstance(i, list) and is_val_in_tree(i, val):
return True
return False
|
55808634eecbc343e40c9003da25a30e85c263b3 | daniel-reich/ubiquitous-fiesta | /JXnrdo4naPg9pYSvm_4.py | 294 | 3.515625 | 4 |
def frac_round(frac, n):
value=round(eval(frac), n)
value_str=str(value)
ind = value_str[value_str.index(".")+1:]
if len(ind) <n:
value_str += "0" *(n-len(ind))
else:
pass
return "{} rounded to {} decimal places is {}" .format(frac, n, value_str)
|
ed80e132a7f43349226f03909928f0cd322aa6a1 | daniel-reich/ubiquitous-fiesta | /cH3WN6TsqEC3qDg8f_12.py | 95 | 3.5 | 4 |
def rectangle_in_circle(w, h, radius):
import math
return math.sqrt(w*w+h*h) <= 2*radius
|
c8e7410ced516b6049e3b52995a794d41ee31f66 | daniel-reich/ubiquitous-fiesta | /yuPWwSbCGPm2KzSzx_0.py | 637 | 3.703125 | 4 |
prices = {"Strawberries" : 1.5, "Banana" : 0.5, "Mango" : 2.5,
"Blueberries" : 1, "Raspberries" : 1, "Apple" : 1.75,
"Pineapple" : 3.5}
class Smoothie:
def __init__(self,ingredients):
self.ingredients = ingredients
self.cost = sum(prices[fruit] for fruit in self.ingredients)
self.price = self.cost * 2.5
def get_cost(self):
return '${:.2f}'.format(self.cost)
def get_price(self):
return '${:.2f}'.format(self.price)
def get_name(self):
lst = sorted(i.replace('ies','y') for i in self.ingredients)
return '{} {}'.format(' '.join(lst), 'Fusion' if len(lst)>1 else 'Smoothie')
|
40c3f0092ca163f07a2c08fc054124893fd6660e | daniel-reich/ubiquitous-fiesta | /es6qJTs5zYf8nEBkG_7.py | 537 | 3.671875 | 4 |
import re
from collections import defaultdict
pattern = re.compile(r'(-?\d+), *(-?\d+)')
def is_rectangle(coordinates):
x_entries = defaultdict(int)
y_entries = defaultdict(int)
for coord_pair_str in coordinates:
match = pattern.search(coord_pair_str)
if match is not None:
x_entries[match.group(1)] += 1
y_entries[match.group(2)] += 1
for k in x_entries.keys():
if x_entries[k] != 2:
return False
for k in y_entries.keys():
if y_entries[k] != 2:
return False
return True
|
17a41876ca157b2cea5c1ba6b0e0f42c895d29b4 | daniel-reich/ubiquitous-fiesta | /xjC7TM77RbrT6PhQ2_1.py | 126 | 3.5625 | 4 |
def switches(n):
if n == 1:
return 1
elif n == 2:
return 2
else:
return switches(n-1)+2*switches(n-2) + 1
|
6ba7360160d0453c79ccfc93d3db7c49211ed922 | daniel-reich/ubiquitous-fiesta | /h4SrMDnwPpmotn2cZ_23.py | 173 | 3.890625 | 4 |
def sum_of_cubes(nums):
l = []
for x in nums:
l.append(x**3)
return sum(l)
print(sum_of_cubes([1, 5, 9]))
print(sum_of_cubes([3, 4, 5]))
print(sum_of_cubes([]))
|
91d0c2cd469e52fc4793a4ef0e945db913af8fca | daniel-reich/ubiquitous-fiesta | /RxHjtFqu3w8L9i5fx_5.py | 146 | 3.703125 | 4 |
def f(n):
return 1 if n <1 else n*f(n-1)
def bell(n):
return n or 1 if n <3 else sum(bell(k)*f(n-1)//(f(k)*f(n-1-k)) for k in range(n))
|
1056f9eb6443372373afb9652e1f2d8a3e2e161f | daniel-reich/ubiquitous-fiesta | /EZMCpHaNFg2Yfsnxx_1.py | 141 | 3.5 | 4 |
def unique_sort(lst):
purgedList = []
for i in sorted(lst):
if i not in purgedList:
purgedList.append(i)
return purgedList
|
2054a38509772a05c1860466d819e6c3cb8d8415 | daniel-reich/ubiquitous-fiesta | /FWh2fGH7aRWALMf3o_22.py | 611 | 3.515625 | 4 |
def cleave(string, lst):
def words(word, string, i):
while True:
if string[0:i] in lst:
word.append(string[0:i])
string = string[i::]
i = 0
if string == '':
break
elif i == len(string):
a = word.pop()
words(word, a + string, len(a) + 1)
elif i > len(string):
break
i += 1
word = []
try:
words(word, string, 1)
except:
word = ['Cleaving stalled: Word not found']
return ' '.join(word)
|
68d4542468db8df2685ec5b1534efa40bb5998bb | daniel-reich/ubiquitous-fiesta | /8gE6FCdnWbECiR7ze_4.py | 946 | 3.8125 | 4 |
def prime_factors(n):
factors = []
while n%2 == 0:
factors.append(2)
n //= 2
for i in range(3, int(n**0.5) + 1, 2):
while n%i == 0:
factors.append(i)
n //= i
return factors + [n] if n > 1 else factors
def digital_root(n):
while n > 9:
n = sum(map(int, str(n)))
return n
def is_smith(n):
factors = prime_factors(n)
if len(factors) == 1:
return False
return digital_root(n) == digital_root(sum(factors))
def smith_type(n):
if n == 1:
return 'Not a Smith'
if len(prime_factors(n)) == 1:
return 'Trivial Smith'
young, middle, old = (is_smith(n-1), is_smith(n), is_smith(n+1))
if not middle:
return 'Not a Smith'
d = {(True, True, False): 'Oldest Smith',
(False, True, True): 'Youngest Smith',
(False, True, False): 'Single Smith'}
return d[young, middle, old]
|
de10f9d93d5b487bd27f38782acf7db481e55b6a | daniel-reich/ubiquitous-fiesta | /8xwqLZuTAsLpNSPEn_15.py | 303 | 3.5625 | 4 |
def award_prizes(names):
prize = ["Gold", "Silver", "Bronze", "Participation"]
t = sorted(list(names.items()), key=lambda x: x[1], reverse=True)
dic = {}
i = 0
for x,y in t:
if i < 3:
dic.update({x:prize[i]})
i += 1
else:
dic.update({x:prize[i]})
return dic
|
8e8688a8f049ebdd1cf3d0bbaa7bbf22a7b68a41 | daniel-reich/ubiquitous-fiesta | /CD5nkQ6ah9xayR3cJ_9.py | 65 | 3.546875 | 4 |
def add_odd_to_n(n):
return sum([i for i in range(1,n+1,2)])
|
29bd5eb22f1bf1c9775181f4c88379be7c776dc2 | daniel-reich/ubiquitous-fiesta | /YcKh5TokDmm8MZ9Dk_24.py | 408 | 3.796875 | 4 |
def hidden_anagram(text, phrase):
textClean = ''.join([i.lower() for i in text if i.isalpha()])
phraseClean = ''.join([i.lower() for i in phrase if i.isalpha()])
ngrams = [textClean[i:i+len(phraseClean)] for i in range(len(textClean)-(len(phraseClean)-1))]
for i in ngrams:
if sorted(i) == sorted(phraseClean):
return i
return 'noutfond'
|
29d618dde06e64ad57566b359f45f72d666efd7d | daniel-reich/ubiquitous-fiesta | /yGhSu82pSoGjZCRDy_1.py | 267 | 3.734375 | 4 |
def seesaw(num):
try:
left = int(str(num)[:len(str(num))//2])
right = int(str(num)[round(len(str(num))/2):])
dct = {"left": left, "right": right}
if left == right: return "balanced"
return max(dct, key=dct.get)
except:
return "balanced"
|
fefb4a97b1399ecdccdb8e2175a5863aafe869a7 | daniel-reich/ubiquitous-fiesta | /gphnuvoHDANN2Fmca_14.py | 249 | 3.796875 | 4 |
def odd_sort(lst):
temp = []
for i in range(len(lst)):
if lst[i] % 2 == 1:
temp.append(lst[i])
lst[i] = '#'
temp = sorted(temp)
for i in range(len(lst)-1,-1,-1):
if lst[i] == '#':
lst[i] = temp.pop()
return lst
|
8a1d3a923d3fdfe3c842a4c9538b42b9750c2f01 | daniel-reich/ubiquitous-fiesta | /XKSwuu4ddzBvkXjvf_13.py | 531 | 3.671875 | 4 |
def sentence_primeness(txt):
txt = ''.join(ch for ch in txt if ch.isalnum() or ch == ' ')
words = txt.split()
get_value = lambda x: sum(ord(ch.lower())-96 if ch.isalpha() else int(ch) for ch in x if ch.isalnum())
if is_prime(get_value(txt)):
return 'Prime Sentence'
for w in words:
if is_prime(get_value(txt) - get_value(w)):
return 'Almost Prime Sentence ({})'.format(w)
return 'Composite Sentence'
def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5) + 1))
|
25e60f76edb179d4fe5159660de74ba90afa915f | daniel-reich/ubiquitous-fiesta | /hxr3ZyPw2bZzrHEsf_19.py | 103 | 3.515625 | 4 |
def make_title(s):
lst = [word[0].upper() + word[1:] for word in s.split()]
return " ".join(lst)
|
f6217f44b8d3d431427b65666447b732d6f65551 | daniel-reich/ubiquitous-fiesta | /nmoohLwP962r6P355_18.py | 322 | 3.75 | 4 |
def straight_digital(number):
if number < 100:
return "Not Straight"
digits = str(number)
step = int(digits[1])-int(digits[0])
for i in range(1,len(digits)-1):
if int(digits[i+1]) - int(digits[i]) != step:
return "Not Straight"
if step == 0:
return "Trivial Straight"
else:
return step
|
fc8efa8f7c9fb2b738211e92569266a9839af649 | daniel-reich/ubiquitous-fiesta | /wW2z9bRi2bTeAbcqY_20.py | 154 | 3.6875 | 4 |
def solve(a,b):
if a != 1:
return round((b-1)/(a-1), 3)
elif b != 1:
return "No solution"
else:
return "Any number"
|
7cca65f137dd0b83c4a7c4ae1a2908b51d9c373d | daniel-reich/ubiquitous-fiesta | /jwiJNMiCW6P5d2XXA_10.py | 184 | 3.71875 | 4 |
def does_rhyme(txt1, txt2):
vowels = "aeiou"
txt1 = txt1.lower().split()
txt2 = txt2.lower().split()
return all([(i in txt1[-1]) == (i in txt2[-1]) for i in vowels])
|
b5043b5b77e43a0bc5559240ab711dd57bb076b8 | daniel-reich/ubiquitous-fiesta | /ycaiA3qTXJWyDz6Dq_2.py | 214 | 3.625 | 4 |
def consonants(word):
vol="aouie"
return len([c for c in word.lower() if c not in vol and c.isalpha()])
def vowels(word):
vol="aouie"
return len([c for c in word.lower() if c in vol and c.isalpha()])
|
e81b927b0ca5b2d680eae24b0c6fc3871b37efd3 | daniel-reich/ubiquitous-fiesta | /hpJsoWBBHWKZ9NcAi_17.py | 457 | 3.625 | 4 |
def bird_code(lst):
num_of_letters = ([4], [2, 2], [1, 1, 2], [1, 1, 1, 1])
code_lst = []
for bird in lst:
first_letter_index = [i for i in range(len(bird)) if bird[i].isupper()]
num_of_words = len(first_letter_index)
code = ""
for i in range(num_of_words):
start = first_letter_index[i]
end = start + num_of_letters[num_of_words - 1][i]
code += bird[start: end]
code_lst.append(code.upper())
return code_lst
|
e0508d151224766c0291e28394b156a064b9b875 | daniel-reich/ubiquitous-fiesta | /5ZDz5nDDPdfg5BH8K_12.py | 552 | 3.515625 | 4 |
def only_5_and_3(n):
is_prim = True
lst_numbers_lim = list(range(2, int(n/3)))
for num_lim in lst_numbers_lim:
if int(n/3) % num_lim == 0:
is_prim = False
break
else:
continue
for i in range(100):
for j in range(100):
if (3**i + 5 * j == n and i != 0 and j != 0) or ((3 + (5*i))*3**j == n and i != 0 and j != 0) or not is_prim:
return True
if (n - (n//5)*5) == 3 or n % 15 == 0 or n % 5 == 0:
return True
return False
|
4f526983290c8e661db8bf20bbe11b1d0490de17 | daniel-reich/ubiquitous-fiesta | /N7zMhraJLCEMsmeTW_16.py | 270 | 3.546875 | 4 |
def min_swaps(string):
zero_one = "".join([str(x % 2) for x in range(len(string))])
zero_result = 0
one_result = 0
for i in range(len(string)):
if string[i] != zero_one[i]: zero_result += 1
else: one_result += 1
return min([zero_result, one_result])
|
0526bac9cb6f35d71dc5c7057baac33da5ea1460 | daniel-reich/ubiquitous-fiesta | /bo4REhn9paGcFoMBs_22.py | 367 | 3.5625 | 4 |
def age_difference(ages):
if[max(ages)-i for i in sorted(ages,reverse=True)[0:2]][1]==0:return "No age difference between spouses."
if[max(ages)-i for i in sorted(ages,reverse=True)[0:2]][1]==1:return '{} year'.format([max(ages)-i for i in sorted(ages,reverse=True)[0:2]][1])
return '{} years'.format([max(ages)-i for i in sorted(ages,reverse=True)[0:2]][1])
|
ee2a9001c80d9b0d1bc82b3c823620f69abc599c | daniel-reich/ubiquitous-fiesta | /gphnuvoHDANN2Fmca_22.py | 147 | 3.78125 | 4 |
def odd_sort(lst):
lst1 = sorted([x for x in lst if x%2], reverse=True)
return [lst1.pop() if lst[x]%2 else lst[x] for x in range(len(lst))]
|
ae8ca0b4d09d48f38cde51f287a098edcb12294f | daniel-reich/ubiquitous-fiesta | /jecvfH5eyGLrSwzNh_23.py | 255 | 3.59375 | 4 |
import re
def fauna_number(txt):
fauna = ["muggercrocodile", "one-hornedrhino",
"python", "moth", "monitorlizard", "bengaltiger"]
return [(name, number) for number, name in re.findall(r"(\d+)\s([a-z-]+)", txt) if name in fauna]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.