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 |
|---|---|---|---|---|---|---|
8cb696ca11565152d5587949656acef8f1e1d0a8 | daniel-reich/ubiquitous-fiesta | /jSjjhzRg5MvTRPabx_14.py | 232 | 3.59375 | 4 |
def sentence(words):
v = ['a', 'e', 'i', 'o', 'u']
return ', '.join('a '+w if w[0] not in v else 'an '+w for w in words[:-1]).capitalize() + ' '.join(' and a '+w+'.' if w[0] not in v else ' and an '+w+'.' for w in words[-1:])
|
d91a2ca1f49a6f7894ea2f3cc08ab8afcf1d58ee | daniel-reich/ubiquitous-fiesta | /FqFGnnffKRo8LKQKP_24.py | 178 | 3.640625 | 4 |
def simple_numbers(a, b):
return [x for x in list(range(a,b+1)) if or_not(x)];
def or_not(x):
arr = list(str(x))
return sum([int(i)**(j+1) for j,i in enumerate(arr)])==x
|
47cd2f29ba3f9c4484c5523b6fbfca506d5531c4 | daniel-reich/ubiquitous-fiesta | /AdJNWPbfL9LunsNh9_18.py | 100 | 3.53125 | 4 |
def multiplication_table(num):
num = range(1, num+1)
return [[n*x for x in num] for n in num]
|
938826befc318292ec4090b10456e10c3fbf308a | daniel-reich/ubiquitous-fiesta | /nqvuJue4TevAERzCs_14.py | 180 | 3.640625 | 4 |
def has_digit(txt):
M=[]
for i in txt:
if(i.isdigit()):
M.append(True)
else:
M.append(False)
return any([i==True for i in M])
|
f17be3eb644df7d71be072c85bbc1f6807e2f88c | daniel-reich/ubiquitous-fiesta | /Sws7TmBqGJZfReepJ_1.py | 378 | 3.734375 | 4 |
def make_anagram(a, b):
if len(a)>len(b):
large = sorted(a)
small = sorted(b)
else:
large = sorted(b)
small = sorted(a)
res=[]
for i in range(len(large)):
if large[i] in small:
small.remove(large[i])
res.append(large[i])
return ((len(large)-len(res))+len(small))
|
5d4eb9cb5697bad83bc0d852b3a2597c9833d2b9 | daniel-reich/ubiquitous-fiesta | /xRM8yTQRL3W6Wtdfi_12.py | 391 | 3.625 | 4 |
def quartic_equation(a, b, c):
t1=(-b+(b*b-4*a*c)**.5)/(2*a)
t2=(-b-(b*b-4*a*c)**.5)/(2*a)
if t1>0 and t2>0:
return 4
elif (t1>0 and t2<0) or (t1<0 and t2>0):
return 2
elif (t1==0 and t2>0) or (t1>0 and t2==0):
return 3
elif t1==t2 and t1>0:
return 1
elif t1==t2==0:
return 1
elif (t1==0 and t2<0) or (t1<0 and t2==0):
return 1
else:
return 0
|
1d7f0831044e163996fb0e829844d89cabe146c2 | daniel-reich/ubiquitous-fiesta | /DG2HLRqxFXxbaEDX4_7.py | 110 | 3.53125 | 4 |
def return_only_integer(lst):
return [x for x in lst if isinstance(x, int) and not isinstance(x, bool)]
|
4ff2b377be3c54269662c987033145110a501cb4 | daniel-reich/ubiquitous-fiesta | /5ZDz5nDDPdfg5BH8K_5.py | 144 | 3.640625 | 4 |
def only_5_and_3(n):
if n<6: return n in {3,5}
return (only_5_and_3(n//3) if not n%3 else False) or (only_5_and_3(n-5) if n>5 else False)
|
adb5b53637d771bfb11e3e1c9d801f0dd555a559 | daniel-reich/ubiquitous-fiesta | /a55ygB8Bwj9tx6Hym_8.py | 244 | 3.90625 | 4 |
def steps_to_convert(txt):
if not txt or txt.isupper() or txt.islower():
return 0
else:
count=sum([1 for i in txt if i.isupper()])
if count>=len(txt)/2:
return len(txt)-count
else:
return count
|
3d1adc70cd541480ba5036a9efa4b5fee148a93d | daniel-reich/ubiquitous-fiesta | /YcqAY72nZNPtvofuJ_8.py | 415 | 3.546875 | 4 |
def quad_sequence(lst):
#find pattern
difference = [lst[len(lst)-2] - lst[len(lst)-3], lst[len(lst)-1] - lst[len(lst)-2]]
difference_of_difference = difference[1] - difference[0]
#workout
last_num = lst[len(lst)-1]
last_diff = difference[1]
next_nums = []
for _ in range(len(lst)):
last_diff+=difference_of_difference
last_num +=last_diff
next_nums.append(last_num)
return next_nums
|
aba856fd4312017a1811200be54380a70309563e | daniel-reich/ubiquitous-fiesta | /iuenzEsAejQ4ZPqzJ_3.py | 141 | 3.578125 | 4 |
def mystery_func(num):
s = [2**x for x in range(1,num)]
for i in s:
if num>i: c=s.index(i)+1
return int(('2'*c)+str(num-(2**c)))
|
20e6424ff6a0053af275db59bc22c4863e246564 | daniel-reich/ubiquitous-fiesta | /vSo5XWNqKiBuN5zGr_3.py | 199 | 3.8125 | 4 |
def divide(x, y, sign=1):
if x == 0:
return 0
sign = x * y // abs(x * y)
x = abs(x)
y = abs(y)
if x < y:
return 0
return sign * (1 + divide(x - y, y, sign))
|
be698882066775adb8705eacdd87d37e125fa8f9 | daniel-reich/ubiquitous-fiesta | /KcD3bABvuryCfZAYv_24.py | 301 | 3.65625 | 4 |
def most_frequent_char(lst):
st=''.join(lst)
d=dict()
for a in st:
if a not in d:
d[a]=1
else:
d[a]+=1
max_occurence = []
for a in d:
if d[a] == max(d.values()):
max_occurence.append(a)
return sorted(max_occurence)
|
3dff3bd521462c90b40630c3e40b4ffa2d958336 | daniel-reich/ubiquitous-fiesta | /RuwpKTa8grNSQkqX5_5.py | 1,122 | 3.640625 | 4 |
def fractions(decimal):
d = decimal.split('.')
s = ['']*3
s[0] = d[0]
d = d[1].split('(')
s[1] = d[0]
d = d[1].split(')')
s[2] = d[0]
ln = len(s[0]) + len(s[1])
cnt = 1
while True:
lt = ln + cnt*len(s[2])
if(lt > 10): break
cnt += 1
st = s[0] + '.' + s[1] + s[2]*cnt
flt = float(st)
delta = '.' + '0'*9 + '9'
fDelta = float(delta)
print('DEC {}'.format(decimal))
#print(delta)
print('S {} FLT {}'.format(s, flt))
res = []
num = 1
den = 2
while True:
val = float(num) / den
d = abs(flt - val)
#print('X {} {} {} {} {} {}'.format(val, flt, num, den, d, fDelta))
if(abs(d) < fDelta):
print('{} {} {}'.format(num, den, d))
break
if(val > flt):
if(den % 1000 == 0):
print('NUM {} DEN {}'.format(num, den))
den += 1
#num = 1
num = int(flt * max(1, (den- 20)))
else:
num += 1
return str(num) + '/' + str(den)
|
9ce16fc28b4678e0b58aa237f496897100f851a9 | daniel-reich/ubiquitous-fiesta | /mHRyhyazjCoze5jSL_8.py | 298 | 4.15625 | 4 |
def double_swap(string,chr1,chr2):
new_string = ""
for char in string:
if char == chr1:
new_string = new_string + chr2
elif char == chr2:
new_string = new_string + chr1
else:
new_string = new_string + char
return new_string
|
f4637ea3f944579d44494db39ae1a1b5be13c17a | daniel-reich/ubiquitous-fiesta | /8MiJwz7fdaWRiRDYc_7.py | 190 | 3.640625 | 4 |
def apocalyptic(n):
x = 2**n
x = str(x)
if "666" in x:
return "Repent! {} days until the Apocalypse!".format(x.index("666"))
else:
return "Crisis averted. Resume sinning."
|
cd6226f02b4279fa2d83ba29d5fb81e823564130 | daniel-reich/ubiquitous-fiesta | /bdsWZ29zJfJ2Roymv_16.py | 446 | 3.515625 | 4 |
def swap_two(txt):
if len(txt) < 4:
return txt
elif len(txt) % 2 != 0:
lastletter = txt[-1]
formattedtxt = txt[:-1]
emptystring = ''
for i in range(0,len(txt)-3,4):
emptystring += txt[i+2:i+4]
emptystring += txt[i:i+2]
return emptystring + txt[i+4:]
else:
emptystring = ''
for i in range(0,len(txt)-3,4):
emptystring += txt[i+2:i+4]
emptystring += txt[i:i+2]
return emptystring
|
18a87db5bd9f5b7ec8cfbf0da84cd0bc06491a17 | daniel-reich/ubiquitous-fiesta | /LM5d2b6YG5vXuYiME_1.py | 936 | 3.796875 | 4 |
def can_enter_cave(x):
higth = len(x)
width = len(x[0])
i = 0
j = 0
# find start point
while x[i][0] != 0:
i += 1
def check_vertically(x, start, stop, step, jj, horizontal_step):
for ii in range(start, stop, step):
if x[ii][jj]:
return start, jj, False
if x[ii][jj+horizontal_step] == 0:
return ii, jj+horizontal_step, True
return start, jj, False
while j < width-1:
# Check Down and Forward
i, j, found_way = check_vertically(x, i, higth, 1, j, +1)
if not found_way:
# Check Up and Forward
i, j, found_way = check_vertically(x, i - 1, -1, -1, j, +1)
if not found_way:
# Check Down and Backward
i, j, found_way = check_vertically(x, i, higth, 1, j, -1)
if not found_way:
# Check Up and Backward
i, j, found_way = check_vertically(x, i - 1, -1, -1, j, -1)
if not found_way:
return False
return True
|
e468d5b96d099bd13b27787c6dfac7042ba25472 | daniel-reich/ubiquitous-fiesta | /JFLADuABfkeoz8mqN_1.py | 321 | 3.828125 | 4 |
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def compare_age(self, other):
txt = [
'younger than',
'the same age as',
'older than'
][(self.age <= other.age) + (self.age < other.age)]
return '{} is {} me.'.format(other.name, txt)
|
351168c900052938e15a32da3bca8cc8f8f02d94 | daniel-reich/ubiquitous-fiesta | /M3oq3s8T7Nz7piBvc_2.py | 135 | 3.515625 | 4 |
def even_odd_string(txt):
return ''.join([txt[i] for i in range(0,len(txt),2)])+' '+''.join([txt[i] for i in range(1,len(txt),2)])
|
34c4c4290ea520c82ede5e5668723c70c9df1b54 | daniel-reich/ubiquitous-fiesta | /zE37mNeG4cn6HesaP_12.py | 287 | 3.5625 | 4 |
def max_ham(s1, s2):
count=0
if len(s1)!=len(s2):
return False
for i in range(0,len(s1)):
if s1[i] not in s2:
return False
elif s1[i]!=s2[i]:
count+=1
if count==len(s1):
return True
else:
return count
|
fda17a8cdeda10f4ca779595946e1f144057c892 | daniel-reich/ubiquitous-fiesta | /W73q9yML66xXbFfGY_1.py | 179 | 3.546875 | 4 |
def coloured_triangle(row, s={"R", "G", "B"}):
return row if len(row)==1 else coloured_triangle("".join(x if x==y else \
list(s - {x,y})[0] for x,y in zip(row,row[1:])))
|
18ca15b193a61febf41c891a21d26bf33c530b1e | daniel-reich/ubiquitous-fiesta | /3RuQwqfrzSR6afAgz_4.py | 218 | 3.5625 | 4 |
import itertools as it
def rail_fence_cipher(s, r):
res, rows = ['']*r, list(range(r))
cycle = it.cycle(rows + rows[::-1][1:-1])
for row, i in zip(cycle, s):
res[row] += i
return ''.join(res)
|
47b18be290915cd68325051cb3efcbd3184f62d4 | daniel-reich/ubiquitous-fiesta | /BokhFunYBvsvHEjfx_2.py | 262 | 3.6875 | 4 |
import re
def seven_boom(lst):
new_list = []
for number in lst:
new_list.append(str(number))
new_list = "".join(new_list)
pattern = re.findall(r'7', new_list)
if "7" in pattern:
return "Boom!"
else:
return "there is no 7 in the list"
|
ee0198d45c749aa6a0557682500d675a7f0414c3 | daniel-reich/ubiquitous-fiesta | /dBqLSk6qvudNdZrSx_21.py | 206 | 3.875 | 4 |
def is_boiling(temp):
unit = temp[-1]
deg = int(temp[:len(temp)-1])
if unit == 'F' and deg >= 212:
return True
if unit == 'C' and deg >= 100:
return True
return False
|
b3f8d32aa7d047cad60005b9b457955f283345fb | daniel-reich/ubiquitous-fiesta | /HcLCh8566zewZvZ2j_6.py | 158 | 3.5 | 4 |
def word(s):
num = {'one':1,'two':2,'three':3,'four':4,'five':5,'six':6,'seven':7,
'eight':8,'nine':9,'zero':0}
return num.get(s.lower())
|
aaa01d6546bc5aa89dae08aa757f67f7b1967019 | daniel-reich/ubiquitous-fiesta | /xFKwv7pAzEdNehwrt_19.py | 235 | 3.65625 | 4 |
def bracket_logic(s):
s = ''.join(i for i in s if i in "()[]{}<>")
while any(pair in s for pair in ('()', '[]', '{}', '<>')):
for pair in ('()', '[]', '{}', '<>'):
s = s.replace(pair, '')
return not s
|
c71e90ed9e85e087f65d46f2c9b1918b3b1c4221 | daniel-reich/ubiquitous-fiesta | /oLmAshdKHWLP3ck7e_15.py | 266 | 3.609375 | 4 |
def min_difference_pair(nums):
minPair = [sorted(nums)[0], sorted(nums)[1]]
for i in range(1, len(nums) - 1):
num1, num2 = sorted(nums)[i], sorted(nums)[i + 1]
if (num2 - num1) < (minPair[1] - minPair[0]):
minPair = [num1, num2]
return minPair
|
6951e1a2ee4cd0df5945994649819d7006b190d1 | daniel-reich/ubiquitous-fiesta | /8oNKM4osgxYyrFtGL_15.py | 153 | 3.546875 | 4 |
def multiply(l):
lst = []
for i in range(len(l)):
tmp = []
for j in range(len(l)):
tmp.append(l[i])
lst.append(tmp)
return lst
|
53da5e5766a4ca401fce1af0857e0fbc50fcf473 | daniel-reich/ubiquitous-fiesta | /LuBtaT9dwStbd7mnK_10.py | 152 | 3.65625 | 4 |
def tallest_building_height(lst):
for h in range(len(lst)):
if '#' in lst[h]:
break
return str((len(lst) - h) * 20) + 'm'
|
f97d7877e4392b4d0155db57f6f858ed4f8ecd48 | daniel-reich/ubiquitous-fiesta | /hfivDc24QmqWWc5Ws_20.py | 169 | 3.609375 | 4 |
def eratosthenes(num):
primes = []
for i in range(1,num+1):
if len([x for x in range(1,i//2+1) if i%x==0]) == 1:
primes.append(i)
return primes
|
d1012eea33e1b840c37ff466682a1a2d89fe7c67 | daniel-reich/ubiquitous-fiesta | /mDuDhhMWrdHJSGdtm_12.py | 346 | 3.984375 | 4 |
import math
def is_prime(n):
factors = 0
for i in range(1,n+1):
if n%i==0:
factors += 1
if factors == 2:
return True
else:
return False
def is_exactly_three(n):
root = float(math.sqrt(n))
if n == 1:
return False
elif root.is_integer():
return is_prime(int(root))
else:
return False
|
c1d5ca74d6ae7c701fe065da4b93e7a263ae1a40 | daniel-reich/ubiquitous-fiesta | /JgYPQrYdivmqN4KKX_20.py | 476 | 3.65625 | 4 |
def BMI(weight, height):
w = float(weight[:weight.index(" ")]) if "kilos" in weight else float(weight[:weight.index(" ")])*0.453592
h = float(height[:height.index(" ")]) if "meters" in height else float(height[:height.index(" ")])*0.0254
bmi = round(w/h**2,1)
if bmi < 18.5: return str(bmi) + " Underweight"
elif 18.5 <= bmi <= 24.9: return str(bmi) + " Normal weight"
elif 25 <= bmi <= 29.9: return str(bmi) + " Overweight"
else: return str(bmi) + " Obesity"
|
e5bcbe93c90b44fb9a1a422dd0599af1fcd5542d | daniel-reich/ubiquitous-fiesta | /SFAjxGWk9AbfwbXFN_22.py | 227 | 3.90625 | 4 |
def primes_below_num(n):
primes =[]
for i in range(2,n+1):
if n > 1:
for j in range(2,i):
if i%j == 0:
break
else:
primes.append(i)
return primes
print(primes_below_num(5))
|
777c98c29cf4f624db99266ba5177d1b5cf6cf02 | daniel-reich/ubiquitous-fiesta | /Fw4fFSnTJfCsPBJ5u_4.py | 96 | 3.546875 | 4 |
def how_many_missing(lst):
return 0 if not lst else len(range(lst[0],lst[-1]+1)) - len(lst)
|
282ad2bb405565b7bbc672e3fa61e484a9ebcb7d | daniel-reich/ubiquitous-fiesta | /pa7tTr3g4XaNkHoWC_19.py | 380 | 3.96875 | 4 |
def pig_latin_sentence(sentence):
vowels = "aeiou"
pig = ""
for word in sentence.split():
if word[0] in vowels:
pig += word + "way "
else:
word = list(word)
while word[0] not in vowels:
word.append(word[0])
word.pop(0)
pig += "".join(word) + "ay "
return pig[ : -1]
|
3510c87d69fcff7ca28987741ca8d7bd29d6b93f | daniel-reich/ubiquitous-fiesta | /BuwHwPvt92yw574zB_21.py | 120 | 3.859375 | 4 |
def list_of_multiples (num, length):
list = []
for i in range(1,length+1):
list.append(i * num)
return list
|
214cb5ebb0c9ffecffba33404ba0b63e4d3aceb2 | daniel-reich/ubiquitous-fiesta | /bdsWZ29zJfJ2Roymv_14.py | 201 | 3.515625 | 4 |
def swap_two(txt):
txt = list(txt)
try:
for i in range(0,len(txt),+4):
txt[i+2],txt[i+3],txt[i],txt[i+1] = txt[i:i+4]
except ValueError:
return "".join(txt)
return "".join(txt)
|
f6d3ee42987403ee09850966efa1a6ab59746ef2 | daniel-reich/ubiquitous-fiesta | /jJuMKJcS4TwoKA6Ju_11.py | 323 | 3.546875 | 4 |
def dial(txt):
conversion = {
'abc': '2',
'def': '3',
'ghi': '4',
'jkl': '5',
'mno': '6',
'pqrs': '7',
'tuv': '8',
'wxyz': '9',
}
result = []
for x in txt.lower():
if x.isalpha(): result.extend(c[1] for c in conversion.items() if x in c[0])
else: result.extend(x)
return ''.join(result)
|
c588f26c85bf33ee0d187d6332ae5ece838b902d | daniel-reich/ubiquitous-fiesta | /iRvRtg2xxL9BnSEvf_16.py | 452 | 3.8125 | 4 |
class Person:
def __init__(self, name, food_like, food_hate):
self.name = name
self.food_like = food_like
self.food_hate = food_hate
def taste(self, food):
if food in self.food_like:
return '{} eats the {} and loves it!'.format(self.name, food)
elif food in self.food_hate:
return '{} eats the {} and hates it!'.format(self.name, food)
else:
return '{} eats the {}!'.format(self.name, food)
|
c641805d6abe087895e5e1575a5eea415cb05b73 | daniel-reich/ubiquitous-fiesta | /2jcxK7gpn6Z474kjz_9.py | 1,172 | 3.78125 | 4 |
class Map:
class Space:
def __init__(self, pos, tpe):
self.pos = pos
self.type = tpe
def find_path_to(self, other):
poss = [pos for pos in range(min(self.pos,other.pos), max(self.pos,other.pos) + 1)]
return poss
def __init__(self, string):
self.raw = string
self.spaces = {}
self.theives = []
self.guards = []
self.money = []
for n in range(len(self.raw)):
space = Map.Space(n, string[n])
self.spaces[n] = space
if space.type == 'T':
self.theives.append(n)
if space.type == 'G':
self.guards.append(n)
if space.type == '$':
self.money.append(n)
def is_safe(self):
for theif in self.theives:
theif = self.spaces[theif]
for pay in self.money:
path = theif.find_path_to(self.spaces[pay])
blocked = False
for guard in self.guards:
if guard in path:
blocked = True
break
if blocked == False:
return False
return True
def security(txt):
bank = Map(txt)
return 'Safe' if bank.is_safe() == True else 'Alarm!'.upper()
|
907ae22d9fee768f62535c9fa9d998aec01c881c | daniel-reich/ubiquitous-fiesta | /X9CsA6955cKRApBNH_18.py | 646 | 4 | 4 |
def longest_run(numbers):
'''
Returns the length of the longest consecutive run in numbers, where a run is
a sequence of integers differing either by 1 (ascending) or -1 (descending).
'''
from operator import add, sub
max_count = 1
size = len(numbers)
for op in(add, sub):
i = j = 0
count = 1
while i < size-1:
while j < size-1 and op(numbers[j], 1) == numbers[j+1]:
count += 1
j+= 1
if count > max_count:
max_count = count
i, j = j, j+1
count = 1
return max_count
|
51365f7aafe3a728e335a9a25a560d21287660ec | daniel-reich/ubiquitous-fiesta | /LhMkMu46rG8EweYf7_16.py | 249 | 3.71875 | 4 |
def sort_by_letter(lst):
letters = []
for i in lst:
for j in i:
if j.isalpha():
letters.append(j)
letters.sort()
newlst = []
for i in letters:
for j in lst:
if i in j:
newlst.append(j)
return newlst
|
fae798c2baff5cb7bb82bb7ab7404b83cf442fdf | daniel-reich/ubiquitous-fiesta | /zgu7m6W7i3z5SYwa6_5.py | 158 | 3.609375 | 4 |
def digit_sum(n):
ds = 0
while n > 0:
ds += (n % 10)
n //= 10
return ds
def is_equal(lst):
return digit_sum(lst[0]) == digit_sum(lst[1])
|
b294b8e89dfb7edbf318e2e01d44868a2912ad36 | daniel-reich/ubiquitous-fiesta | /arobBz954ZDxkDC9M_1.py | 1,200 | 3.90625 | 4 |
##Alrighty, this is ugly, but it passes the tests, so let me explain.
def next_prime(num):
first_checker = [] #Checks if first number is prime
last_checker = [] #Checks if each subsequent number is prime
prime_checker = False #Assigning Boolean to a prime_checker var
new_num = num + 1 #I don't need this, but it made things handy
for i in range(2, num):
if num % i == 0: #Standard boolean checker, except wanted to see if I could implement array. After loop, if len(array) == 2, number is prime as is.
continue
else:
first_checker.append(i)
if len(first_checker) > 2: #Checking if initial number is non-prime
while prime_checker == False:
for i in range(2, new_num): #checking next number
if num % i == 0:
continue
else:
last_checker.append(i) #Same concept. If post loop, len(last_checker) == 2, num is prime
if len(last_checker) == 2: #See above
prime_checker = True #Stop while loop
return i #Return prime number
else:
new_num += 1 #If not prime, increment to next number, try again
|
5488435852fad76b38bae009cb6221a908a217f6 | daniel-reich/ubiquitous-fiesta | /QiPr3M5tsqfsbYcCQ_23.py | 110 | 3.734375 | 4 |
def square_digits(n):
digits=str(n)
res=''
for i in digits:
res+=str(int(i)**2)
return int(res)
|
2176082b94b3370180ec775e895b8d38c4d5d22c | daniel-reich/ubiquitous-fiesta | /qjB3KLrK6JkmBkMZR_20.py | 348 | 3.5 | 4 |
def can_capture(queens):
Row = {"A":1,"B":2,"C":3,"D":4,"E":5,"F":6,"G":7,"H":8}
Q1R = queens[0][0]
Q1C = queens[0][1]
Q2R = queens[1][0]
Q2C = queens[1][1]
if Row[Q1R] == Row[Q2R] or int(Q1C) == int(Q2C):
return True
else:
if abs(Row[Q1R]-Row[Q2R]) == abs(int(Q1C)-int(Q2C)):
return True
else:
return False
|
ef126b4037a5aa5dfb2a95a5b141dd27b03dd6c5 | daniel-reich/ubiquitous-fiesta | /HWxNGdeoPxzievGa3_21.py | 296 | 3.875 | 4 |
def is_strange_pair(txt1, txt2):
if len(txt1) == 0 and len(txt2) == 0:
return True
elif len(txt1) == 0 and len(txt2) != 0:
return False
elif len(txt1) != 0 and len(txt2) == 0:
return False
else:
return txt1[0] == txt2[-1] and txt2[0] == txt1[-1]
|
fbc283c9e078ec973ee8397c509e378e36260030 | daniel-reich/ubiquitous-fiesta | /XoBSfW4j6PNKerpBa_3.py | 303 | 3.90625 | 4 |
def complete_factorization(num):
div, lst = 2, []
while not is_prime(num):
if is_prime(div) and num % div == 0:
lst.append(div)
num = num//div
else: div += 1
lst.append(num)
return lst
def is_prime(n):
for i in range(2,n):
if n % i==0: return False
return True
|
e60810782816bc1f19a226021b728f1c7ce03d3a | daniel-reich/ubiquitous-fiesta | /gphnuvoHDANN2Fmca_20.py | 419 | 3.96875 | 4 |
def odd_sort(list):
even_positions = []
odd_numbers = []
final_list = []
for a in list:
if a % 2 == 0:
even_positions.append(list.index(a))
if a % 2 != 0:
odd_numbers.append(a)
odd_numbers.sort()
for b in odd_numbers:
final_list.append(b)
for c in even_positions:
final_list.insert(c, list[c])
return final_list
|
f9d47a94077a99f7d8bf4dc5a094af1d11b22755 | daniel-reich/ubiquitous-fiesta | /XKEDTh2NMtTLSyCc2_17.py | 274 | 3.5625 | 4 |
def valid_credit_card(number):
num = [int(i) for i in str(number)]
numrev = num[-2: -17: -1]
mult = [i[1]*2 if i[0] % 2 == 0 else i[1] for i in enumerate(numrev)]
remove = [i - 9 if i >= 9 else i for i in mult]
return (sum(remove) + num[len(num) - 1]) % 10 == 0
|
612f921aba9881c64144ffa75e97ada44d838e21 | daniel-reich/ubiquitous-fiesta | /c4WKPr4upiKx8GwJK_19.py | 196 | 3.796875 | 4 |
def duplicate_nums(nums):
result = []
for num in nums:
if nums.count(num) == 2 and num not in result:
result.append(num)
if result == []:
return None
return sorted(result)
|
36c1d3141daa390b1430641808bbe38d641fbd6f | daniel-reich/ubiquitous-fiesta | /vq3x6QP77d7Qwe8be_10.py | 1,067 | 3.828125 | 4 |
from collections import namedtuple
MaxArray = namedtuple("MaxArray", "array size")
def is_odd_subarray(arr, size):
for row in range(size):
for col in range(size):
if arr[row][col] % 2 == 0:
return False
return True
def get_sub(arr, r, c, size):
sub = [[0] * size for x in range(size)]
for row in range(size):
for col in range(size):
sub[row][col] = arr[row + r][col + c]
return sub
def odd_square_patch(arr):
max_sized = MaxArray(None, 0)
size_row, size_col = len(arr), len(arr[0])
size = min(size_col, size_row)
sub = []
for r in range(size_row):
for c in range(size_col):
for s in range(1, size + 1):
if (c + s) <= size_col and (r + s) <= size_row:
sub = get_sub(arr, r, c, s)
if not is_odd_subarray(sub, s):
break
elif max_sized.size < s:
max_sized = MaxArray(sub, s)
return max_sized.size
|
cbb01947b6e036c4e81025ef85f0f970391fc6ed | daniel-reich/ubiquitous-fiesta | /sfqudQHQ3HPpd7dZb_10.py | 626 | 3.671875 | 4 |
def rps(p1, p2):
retstr = 'The winner is '
if p1 == p2:
return 'It\'s a draw'
elif p1 == 'Rock' and p2 == 'Scissors':
return retstr+'p1'
elif p1 == 'Paper' and p2 == 'Rock':
return retstr+'p1'
elif p1 == 'Scissors' and p2 == 'Paper':
return retstr+'p1'
elif p2 == 'Rock' and p1 == 'Scissors':
return retstr+'p2'
elif p2 == 'Paper' and p1 == 'Rock':
return retstr+'p2'
elif p2 == 'Scissors' and p1 == 'Paper':
return retstr+'p2'
# this is pretty clunky, prone to misspellings (for me)
# looking forward to seeing other solutions
|
cf9fd7aba615a0143701fc581604f36bf636dc13 | daniel-reich/ubiquitous-fiesta | /kmruefq3dhdqxtLeM_23.py | 95 | 3.5 | 4 |
def sum_digits(a, b):
return sum([sum([int(k) for k in str(i)]) for i in range(a, b + 1)])
|
46b5cc8c3084c92a8ecdc939783c60e252102280 | daniel-reich/ubiquitous-fiesta | /HYjQKDXFfeppcWmLX_3.py | 93 | 3.5625 | 4 |
def is_curzon(num):
a = 2 ** num +1
b = 2 * num + 1
return True if a%b==0 else False
|
1aa3373d357fcfc902e77e7ad7f32791d17da7b1 | daniel-reich/ubiquitous-fiesta | /XAMKeMw7imaB3zo67_5.py | 970 | 3.59375 | 4 |
def trace_word_path(word, grid):
x, y = len(grid), len(grid[0])
target = len(word)
for row in range(x):
for col in range(y):
if grid[row][col] == word[0]:
indices = get_index(word, word[1:], grid, x, y, row, col, [(row, col)], target)
if len(indices) == target:
return indices
return 'Not present'
def get_index(word, start, grid, x, y, row, col, indices, target):
if len(indices) == target:
return indices
moves = [(1,0),(0,1),(-1,0),(0,-1)]
neighbors = [(row+i,col+j) for i, j in moves if 0 <= row+i < x and 0 <= col+j < y]
neighbors = [(i,j) for i,j in neighbors if grid[i][j] == start[0]]
for a, b in neighbors:
if (a, b) not in indices:
n_indices = indices + [(a, b)]
if len(n_indices) == target:
return n_indices
indices_r = get_index(word, start[1:], grid, x, y, a, b, n_indices, target)
if len(indices_r) == target:
return indices_r
return indices
|
d059ea218cad2420df67db0ba975bf9c249b5e26 | daniel-reich/ubiquitous-fiesta | /6RHxTTndfASnPyp8Z_11.py | 357 | 3.671875 | 4 |
def compress(chars):
chars = "".join(chars) + " "
result = ""
count = 0
for i, l in enumerate(chars):
if i == 0:
count += 1
else:
if l != chars[i-1]:
if count == 1:
result += chars[i-1]
else:
result += chars[i-1] + str(count)
count = 1
else:
count += 1
return result
|
da93bd708cb3cd8fdcf2ee9318df4011845a6837 | daniel-reich/ubiquitous-fiesta | /B5J4Bfgg7PoDHBBZQ_3.py | 400 | 3.75 | 4 |
def area(x1, y1, x2, y2, x3, y3):
return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2)
def within_triangle(p1, p2, p3, test):
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
x4, y4 = test
a = area(x1, y1, x2, y2, x3, y3)
a1 = area(x1, y1, x2, y2, x4, y4)
a2 = area(x1, y1, x3, y3, x4, y4)
a3 = area(x2, y2, x3, y3, x4, y4)
return a1 + a2 + a3 == a
|
3674605b35c4621e5ce3a3fc827dd290e13fe893 | daniel-reich/ubiquitous-fiesta | /JD9vSKZGrxQhLbA9r_24.py | 161 | 3.5625 | 4 |
def pile_of_cubes(m):
i = 1;
r = 0;
while r <= m:
r += pow(i, 3)
i += 1
if r == m:
return i-1
return None;
|
c43dcad9b1bde449ad01f94dc8be7b6295f4abff | daniel-reich/ubiquitous-fiesta | /qwDPeZeufrHo2ejAY_1.py | 269 | 3.625 | 4 |
import re
def eval_algebra(s):
s = s.replace(' ', '').replace('=', '==')
a, b = map(int, re.findall(r'-? ?\d+', s))
if eval(s.replace('x', str(a-b))):
return a - b
elif eval(s.replace('x', str(b-a))):
return b - a
return a + b
|
1c4a23c6cab806bd75cf2fc8d087fe322b76cdd2 | daniel-reich/ubiquitous-fiesta | /rsAGjGQ43qpEGschi_1.py | 199 | 3.6875 | 4 |
def newton_raphson(c):
a, b, c, d = c; x = 0
f = 'a*x**3 + b*x**2 + c*x + d'
f_prime = '3*a*x**2 + 2*b*x + c'
for i in range(20):
x = x - (eval(f)/eval(f_prime))
return round(x,3)
|
d7be1757e1978f06ab0188df65cc7d4af2ebe902 | daniel-reich/ubiquitous-fiesta | /HqpZQPZiHbPK4HgEB_18.py | 705 | 3.5625 | 4 |
def maxmin(n):
minie = str(n)
maxie = str(n)
num_list = list(str(n))
length=len(num_list)
for first in range (0,length-1):
for second in range (first+1, length):
if first == 0 and num_list [second] == "0":
continue
else:
new_list = num_list.copy()
new_list[first] = num_list [second]
new_list[second] = num_list [first]
new_string = "".join(new_list)
if new_string < minie:
minie = new_string
elif new_string > maxie:
maxie = new_string
return (int(maxie), int(minie))
|
96588d1bfa1eaebaf76d4a08aa6066227082a87d | daniel-reich/ubiquitous-fiesta | /cdhAmaCLQQ9ktBGGA_3.py | 124 | 3.5625 | 4 |
def get_multiplied_list(lst):
newLst=[]
a=len(lst)
for i in range(0,a):
newLst.append(lst[i]*2)
return newLst
|
875571ac30a9dedd88db9cdf199b4d260d4ce70e | daniel-reich/ubiquitous-fiesta | /qCsWceKoQ8tp2FMkr_18.py | 146 | 4.0625 | 4 |
def is_triangle(a, b, c):
if a<0 and b<0 and c<0:
return False
elif a+b>c and a+c>b and b+c>a:
return True
else:
return False
|
2517e68c8c09e47e998845b94a7d224b49a1356b | daniel-reich/ubiquitous-fiesta | /BDcaZaqCuBCczeKZL_23.py | 373 | 3.5625 | 4 |
def arrow(num):
w=">"
output = [">"]
input=[">"*num]
if num%2==0:
for i in range(2,num+1):
output+=[i*w]
for i in range(num-1,0,-1):
input+=[i*w]
else:
for i in range(2, num):
output += [i * w]
for i in range(num - 1, 0, -1):
input += [i * w]
return output+input
|
2344a4173488a15918f903092b706b79c4aa4422 | daniel-reich/ubiquitous-fiesta | /xRM8yTQRL3W6Wtdfi_3.py | 504 | 3.640625 | 4 |
def quartic_equation(a, b, c):
roots = 0
d = b ** 2 - 4 * a * c
if d > 0:
t1 = (-1 * b + d ** (0.5)) / (2 * a)
t2 = (-1 * b - d ** (0.5)) / (2 * a)
if t1 > 0:
roots += 2
elif t1 == 0:
roots += 1
else:
roots += 0
if t2 > 0:
roots += 2
elif t2 == 0:
roots += 1
else:
roots += 0
elif d == 0:
t1 = (-1 * b) / (2 * a)
if t1 > 0:
roots += 2
elif t1 == 0:
roots += 1
else:
roots += 0
return roots
|
164c21a4d7cd1fd7720ae37b63b107bb02815857 | daniel-reich/ubiquitous-fiesta | /TCbrjfMm2dPzQDbz5_5.py | 131 | 4 | 4 |
def insert_whitespace(txt):
k = ""
for letter in txt:
if letter.isupper():
k += " "
k += letter
return k[1:]
|
1b10b997c7ce8bb2959e0c1d26fdeb8d54f64eaa | daniel-reich/ubiquitous-fiesta | /LRevQqmaH78mwyYXi_14.py | 150 | 3.546875 | 4 |
def inches_to_feet(inches):
feet = inches / 12
if feet < 1 :
return 0
return feet
game = inches_to_feet(14)
print(game)
|
820a8edc3fd4a750edc1cab1e89ba91d02095821 | daniel-reich/ubiquitous-fiesta | /mz7mpEnMByAvBzMrc_15.py | 184 | 3.5 | 4 |
import math
def Log2(x):
if x == 0: return false;
else: return math.log10(x) / math.log10(2)
def power_of_two(num):
return math.ceil(Log2(num)) == math.floor(Log2(num))
|
9126a5391d090b58187173c147286d367445910c | daniel-reich/ubiquitous-fiesta | /MhtcQNMbkP82ZKJpm_17.py | 275 | 3.5 | 4 |
from collections import Counter
def get_notes_distribution(students):
print(students)
students_list_of_lists = [s['notes'] for s in students]
res = dict(Counter([item for sublist in students_list_of_lists\
for item in sublist if item in [1,2,3,4,5]]))
return res
|
9a6bca5abc7dcd9f4276b36d22ad51c2065c95c8 | daniel-reich/ubiquitous-fiesta | /eRY7eBD8dan54acgG_15.py | 164 | 3.546875 | 4 |
def is_checkerboard(lst):
for row in lst:
pre = 1-row[0] #inverse
for num in row:
if num==pre:
return False
pre = num
return True
|
cdf30953f2152c25d756be24bc2c0b54707a14b1 | daniel-reich/ubiquitous-fiesta | /oTzuXDWL26gnY5a5P_10.py | 233 | 3.78125 | 4 |
def prime_numbers(num):
if num < 0:
return 0
count = 1
numbers = [i for i in range(3,num+1)]
for nums in numbers:
if len([i for i in range(2, nums) if nums % i == 0]) == 0:
count += 1
else:
return count
|
44e5ff338625b1554ee4cc692dc61d2dbe484e8f | daniel-reich/ubiquitous-fiesta | /hv572GaPtbqwhJpTb_14.py | 248 | 3.828125 | 4 |
from math import ceil
def elasticize(word):
rise = list(range(1, ceil(len(word)/2 + 1)))
fall = rise[::-1][1:]if len(word)%2 else rise[::-1]
res = ''.join(letter*repeat for letter, repeat in zip(word, rise + fall))
return res
|
dda057e390164b70253c789067bc261302ba16cf | daniel-reich/ubiquitous-fiesta | /W3Hptw6ieTtrWNw4H_7.py | 422 | 3.5 | 4 |
def bifid(text):
alp = "abcdefghiklmnopqrstuvwxyz"
if " " in text:
text = "".join(l for l in text.lower() if l.isalpha())
ns = [alp.index(l)//5 for l in text] + [alp.index(l)%5 for l in text]
return "".join(alp[ns[i]*5+ns[i+1]] for i in range(0,len(ns),2))
ns = sum(([alp.index(l)//5,alp.index(l)%5] for l in text),[])
return "".join(alp[ns[i]*5+ns[i+len(ns)//2]] for i in range(len(ns)//2))
|
398687c61cce3bf5cf7c52c80c46fc63cd880447 | daniel-reich/ubiquitous-fiesta | /cBPj6yfALGfmeZQLG_0.py | 134 | 3.671875 | 4 |
from itertools import zip_longest
def vertical_txt(txt):
return [list(i) for i in zip_longest(*txt.split(), fillvalue=' ')]
|
abfdfb3fe2872cfaa05339798c4d8f96c52aced5 | daniel-reich/ubiquitous-fiesta | /3JX75W5Xvun63RH9H_10.py | 417 | 3.515625 | 4 |
def describe_num(n):
desc = ['The most']
descriptors = ['brilliant', 'exciting', 'fantastic',
'virtuous', 'heart-warming', 'tear-jerking',
'beautiful', 'exhilarating', 'emotional',
'inspiring']
for i in range(10):
if n%(i+1)==0:
desc.append(descriptors[i])
desc.append('number is {}!'.format(n))
return ' '.join(desc)
|
00a429b112dbb22ac7914359a4350b5273b17891 | daniel-reich/ubiquitous-fiesta | /aSZ28TjivazB3aErL_14.py | 432 | 3.953125 | 4 |
import string
def letters_only(s):
if s == '':
return False
else:
digits = string.digits
punctuation = string.punctuation
uppercase = string.ascii_uppercase
for eachdigit in digits:
if eachdigit in s:
return False
for eachsymbol in punctuation:
if eachsymbol in s:
return False
for eachletter in uppercase:
if eachletter in s:
return False
return True
|
9ff39ac6364e2b81a7c5fc314e0bc7a9964ff5ac | daniel-reich/ubiquitous-fiesta | /QiPr3M5tsqfsbYcCQ_3.py | 123 | 3.71875 | 4 |
def square_digits(n):
ans = ""
n = str(n)
for i in range(len(n)):
ans += str(int(n[i]) ** 2)
return int(ans)
|
db0f6498841aa04618285dd0da6b64de383722f9 | daniel-reich/ubiquitous-fiesta | /zrkRjdSwTvbijMXJs_6.py | 389 | 3.515625 | 4 |
def encrypt(plncode, pad):
result = pad[:5]
for i in range(len(plncode)):
x = int(plncode[i]) - int(pad[i+5]) + 10
result += str(x)[-1]
return result
def decrypt(cypcode, pad):
if cypcode[:5] != pad[:5]: return "Error: Key IDs don't match."
result = ""
for i in range(5,len(cypcode)):
x = int(cypcode[i]) +int(pad[i])
result += str(x)[-1]
return result
|
0a971e2cf8c75e4970a3d02ae88932f22752902d | daniel-reich/ubiquitous-fiesta | /DjyqoxE3WYPe7qYCy_14.py | 175 | 3.828125 | 4 |
def reverse_odd(txt):
a = txt.split()
temp = []
for i in a:
if len(i)%2 == 0:
temp.append(i)
else:
temp.append(i[::-1])
return " ".join(temp)
|
f95cdb5630d351880cbb57ff08c1b879f48e97ab | daniel-reich/ubiquitous-fiesta | /SChr3sBY5ZKwHBHLH_19.py | 212 | 3.6875 | 4 |
def sort_it(lst):
k={}
j=[]
for i in lst:
if type(i) is int:
k.update({i:i})
j.append(i)
else:
k.update({i[0]:i})
j.append(i[0])
j = sorted(j)
return [k[i] for i in j]
|
43f36168b4628bbbd48f713abf565fb08b834ec1 | daniel-reich/ubiquitous-fiesta | /pdMwiMpYkJkn8WY83_17.py | 137 | 4 | 4 |
def is_palindrome(word):
if len(word)<2:
return True
if word[0]!=word[-1]:
return False
return is_palindrome(word[1:-1])
|
6df3cc9c30cc942ba6133b856b89e71e44d97d19 | daniel-reich/ubiquitous-fiesta | /TrP8spqHxMiLWfsg8_16.py | 460 | 4.03125 | 4 |
class Node:
def __init__(self,data):
self.data = data
self.left = None
self.right = None
self.tree = [data]
def insert(self,data):
node = Node(data)
if data < self.data:
if not self.left:
self.left = node
else:
self.left.insert(data)
elif not self.right:
self.right = node
else:
self.right.insert(data)
self.tree.append(data)
def PrintTree(self):
return sorted(self.tree)
|
40be44f5a5d7a9bc697f1493281f5e53574a572f | daniel-reich/ubiquitous-fiesta | /XQwPPHE6ZSu4Er9ht_1.py | 658 | 3.796875 | 4 |
def prime_factors(n):
i, factors = 2, []
while i**2 <= n:
if n%i:
i += 1
else:
n //= i
factors.append(i)
if n > 1:
factors.append(n)
return factors
def is_economical(n):
factors = prime_factors(n)
groups = []
num_size = len(str(n))
for f in set(factors):
if factors.count(f) > 1:
groups += [f, factors.count(f)]
else:
groups.append(f)
size = len(''.join(str(i) for i in groups))
if size < num_size:
return 'Frugal'
if size > num_size:
return 'Wasteful'
return 'Equidigital'
|
3a8041ad3d9523f604c8d9922fd344f45682faa0 | daniel-reich/ubiquitous-fiesta | /YTf8DZbTkzJ3kizNa_23.py | 356 | 3.59375 | 4 |
def moran(n):
if ismoran(n):
return 'M'
elif harshad(n):
return 'H'
else:
return 'Neither'
def harshad(n):
return n % sum(list([int(x) for x in str(n)])) == 0
def ismoran(n):
return isprime(n // sum(list([int(x) for x in str(n)])))
def isprime(n):
for i in range(2,n):
if n % i == 0:
return False
return True
|
b8af5a0357abf09fa9a36e2987a12cbb96df8337 | daniel-reich/ubiquitous-fiesta | /xYpG6ry6CLqgcwRWC_23.py | 172 | 3.6875 | 4 |
def sum_two_smallest_nums(lst):
lst.sort()
positives = []
for number in lst:
if number > 0:
positives.append(number)
return positives[0] + positives[1]
|
f7122059a748c1d2a29f7ca1ae89cefdbee3bcae | daniel-reich/ubiquitous-fiesta | /egHeSWSjHTgzMysBX_1.py | 129 | 3.578125 | 4 |
def half_a_fraction(fract):
n, d = map(int, fract.split('/'))
return '{}/{}'.format(n if n%2 else n//2, d*2 if n%2 else d)
|
b55fcc143b40e448d5682b8cfcc65a9f8b69dba7 | daniel-reich/ubiquitous-fiesta | /2zKetgAJp4WRFXiDT_9.py | 104 | 3.5 | 4 |
def number_length(num):
counter = 0
for s in str(num):
counter = counter + 1
return counter
|
1b579260f9af4b6ab33e76f55d757d4739689fd6 | daniel-reich/ubiquitous-fiesta | /gzmFeaXwFv8X6pBGq_21.py | 234 | 3.640625 | 4 |
def series_resistance(lst):
resistance = 0
for value in lst:
resistance += value
if resistance <= 1:
output = str(resistance) + " ohm"
return output
else:
output = str(resistance) + " ohms"
return output
|
d33711b7d3b0d327455d1cecbf516e4d8220ce1a | daniel-reich/ubiquitous-fiesta | /MiCMj8HvevYzGSb8J_10.py | 263 | 3.546875 | 4 |
def fibo_word(n):
coma = ", "
lst = ["b","a"]
out = "b"
a = ""
if(n < 2):
return("invalid")
else:
for i in range(n - 2):
lst.append(lst[-1] + lst[-2])
for i in range(len(lst)-1):
out = out + coma + lst[i + 1]
return(out)
|
1b7a13a214974e7aec39f1f2957d3bac15ae2a05 | daniel-reich/ubiquitous-fiesta | /bwCDG9X8cJiAdvfxE_16.py | 935 | 3.90625 | 4 |
def add_str_nums(num1, num2):
# Bucket for Grand Total
Total = 0
# Converting num1 to List
List_A = list(num1)
# Adding Up Value of List_A (aka num1)
Multiple = 1
Cursor = -1
Length = len(List_A)
End = Length * -1
while (Cursor >= End):
Item = List_A[Cursor]
if (Item.isdigit()):
Digit = int(Item)
Value = Digit * Multiple
Total += Value
Multiple *= 10
Cursor -= 1
else:
return "-1"
# Converting num2 to List
List_B = list(num2)
# Adding Up Value of List_B (aka num2)
Multiple = 1
Cursor = -1
Length = len(List_B)
End = Length * -1
while (Cursor >= End):
Item = List_B[Cursor]
if (Item.isdigit()):
Digit = int(Item)
Value = Digit * Multiple
Total += Value
Multiple *= 10
Cursor -= 1
else:
return "-1"
# Giving Answer (if all were digits)
return str(Total)
|
6a5302fa8a58c6c009a45efe7d0278a1f04c51ee | daniel-reich/ubiquitous-fiesta | /BokhFunYBvsvHEjfx_6.py | 131 | 3.640625 | 4 |
def seven_boom(lst):
for x in lst:
if '7' in str(x):
return("Boom!")
else:
return("there is no 7 in the list")
|
adac251d4e5f65c8176f90e703cf0716de78b41a | daniel-reich/ubiquitous-fiesta | /8MiJwz7fdaWRiRDYc_18.py | 172 | 3.609375 | 4 |
def apocalyptic(n):
if '666' in str(2**n):
return 'Repent! {} days until the Apocalypse!'.format(str(2**n).index('666'))
return 'Crisis averted. Resume sinning.'
|
e19100fdb4484aacd75e117f44b0e9c351c6e74a | daniel-reich/ubiquitous-fiesta | /XTXZRmvXbhmhSfiPf_6.py | 224 | 3.53125 | 4 |
def single_number(nums):
ops = set()
disc = set()
for num in nums:
if num not in disc:
if num in ops:
ops.remove(num)
disc.add(num)
else:
ops.add(num)
return ops.pop()
|
b6d13ac6576215a116807d8051edb41ec4341543 | daniel-reich/ubiquitous-fiesta | /temD7SmTyhdmME75i_11.py | 81 | 3.59375 | 4 |
def to_boolean_list(word):
return [bool(ord(letter) % 2) for letter in word]
|
1a39dc0a559bd0accfd34bf5984a101ae454c40d | daniel-reich/ubiquitous-fiesta | /YnsBcniRG9k77SSvA_6.py | 130 | 3.515625 | 4 |
def print_all_groups():
letters = ['a','b','c','d','e']
return ', '.join([str(i) + j for i in range(1,7) for j in letters])
|
2e014963227a9ef56a95c21bae4dbe9ccf567d30 | daniel-reich/ubiquitous-fiesta | /vC4P2jGR6wxED7MBL_3.py | 248 | 3.78125 | 4 |
def larger_than_right(lst):
largest_lst = []
for num in range(len(lst)):
if num == len(lst) - 1:
largest_lst.append(lst[num])
break
if lst[num] > max(lst[num + 1:]):
largest_lst.append(lst[num])
return largest_lst
|
ffb35c43115c54a26db33a8b93eaae9875d148a4 | daniel-reich/ubiquitous-fiesta | /FbQqXepHC4wxrWgYg_24.py | 410 | 3.765625 | 4 |
def prime_divisors(num):
lst = []
lst1 = []
c = 0
for i in range(2, int(num)):
if num % i == 0:
lst.append(i)
for j in lst:
if prime(j) or j == 2:
lst1.append(j)
return lst1
def prime(num):
if num % 2 == 0:
return False
for i in range(2, num):
if num % i == 0:
return False
else:
return True
|
72744652d0efaa23349a3b1ca53507ebc8aecb58 | daniel-reich/ubiquitous-fiesta | /5x4uruF77BzWFFiQM_24.py | 173 | 3.640625 | 4 |
def pH_name(pH):
if pH <0 or pH>14:
return 'invalid'
elif pH >= 0 and pH<7:
return 'acidic'
elif pH == 7:
return 'neutral'
else:
return 'alkaline'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.