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 |
|---|---|---|---|---|---|---|
93f2d96e44542e1c8291af7a8ad1219844c0788f | daniel-reich/ubiquitous-fiesta | /MiAnCNYivnAc9AFXn_8.py | 239 | 3.71875 | 4 |
def change(el):
if type(el) == bool:
return not el
if type(el) == int:
return el + 1 if el % 2 == 0 else el
return el[0].upper() + el[1:] + '!'
def change_types(lst):
return [change(el) for el in lst]
|
d087cbda04f6a39793b6d89f0b1ccd11657c92d6 | daniel-reich/ubiquitous-fiesta | /iuenzEsAejQ4ZPqzJ_17.py | 126 | 3.859375 | 4 |
def mystery_func(num):
power = 0
while 2**(power+1) < num:
power += 1
return int("2"*power + str(num-(2**power)))
|
d2b4456816a5f3e34031cf22fcd1e6cf767082e3 | daniel-reich/ubiquitous-fiesta | /XoBSfW4j6PNKerpBa_6.py | 380 | 3.78125 | 4 |
def complete_factorization(number):
primes = [2,3]
arr = []
for i in range(4,number+1):
if is_prime(i):
primes.append(i)
while number > 1:
for x in primes:
if number % x == 0:
number /= x
arr.append(x)
return sorted(arr)
def is_prime(num):
for i in range(2,num):
if num % i == 0:
return False
return True
|
ca5fa45d11d74f9d414945680b676d08d3f5bebc | daniel-reich/ubiquitous-fiesta | /nh3daaT8LHbv8mKXA_23.py | 283 | 3.703125 | 4 |
def text_to_num(phone):
numbers = {'ABC': 2, 'DEF': 3, 'GHI': 4, 'JKL': 5, 'MNO': 6, 'PQRS': 7, 'TUV': 8, 'WXYZ': 9}
x = list(phone)
for i in range(len(x)):
for eachkey in numbers.keys():
if x[i] in eachkey:
x[i] = str(numbers[eachkey])
return ''.join(x)
|
78002fe8da8a14a15ac6a9a3f4a91461fc4af483 | daniel-reich/ubiquitous-fiesta | /Nr33pizZC2XdHXAm6_19.py | 632 | 3.6875 | 4 |
def months_interval(dateStart, dateEnd):
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
if abs(dateStart.year - dateEnd.year)>1:
return months
elif dateStart.year == dateEnd.year:
return months[min(dateStart.month, dateEnd.month)-1: max(dateStart.month, dateEnd.month)]
else:
if dateStart.year < dateEnd.year:
return sorted(set(months[:dateEnd.month] + months[dateStart.month-1:]), key=lambda x:months.index(x))
return sorted(set(months[:dateStart.month] + months[dateEnd.month-1:]), key=lambda x:months.index(x))
|
bfccca973772bf4064af3c8c90ad9f887d21b0f6 | daniel-reich/ubiquitous-fiesta | /trPQbGEb9p2yjMAWb_20.py | 161 | 3.640625 | 4 |
def every_some(test, val, a, b, c, d, e):
lst = []
for x in 'abcde':
lst.append(eval(str(x)+test))
return all(lst) if val=='everybody' else any(lst)
|
936017ef369cc0a8b18fe8b1c74e0908fbd9d6c2 | daniel-reich/ubiquitous-fiesta | /WyttgdGuQGaRBqhhP_14.py | 710 | 3.890625 | 4 |
def min_palindrome_steps(txt):
# deal with one-letter text
if len(txt)==1:
return 0
# for every letter in the second half, check if it
# can be the middle of a possible palindrome
for mid in range(len(txt)//2, len(txt)-1):
after_mid = txt[mid:]
before_mid = txt[mid+1-len(after_mid):mid+1]
print("%s %d %s %s" % (txt, mid, after_mid, before_mid))
if (after_mid[::-1] == before_mid):
return (mid + 1 - len(before_mid))
# take into account how many times the last letter appears in sequence
last_char = len(txt)-1
while last_char - 1 >= 0 and txt[last_char - 1] == txt[last_char]:
last_char -= 1
return len(txt) - 1 - (len(txt) - 1 - last_char)
|
b9f351b41d36bbdc24c819d32411fddbbec52acf | daniel-reich/ubiquitous-fiesta | /PYEuCAdGJsRS9AABA_7.py | 1,626 | 3.6875 | 4 |
class CoffeeShop:
def __init__(self, name, menu, list=[]):
self.name = name
self.menu = menu
self.orders = list
def add_order(self, other):
listname = []
d = "This item is currently unavailable!"
for dictionary in self.menu:
listname.append(dictionary["item"])
if other in listname:
d = 'Order added!'
self.orders.append(other)
return d
def list_orders(self):
return self.orders
def fulfill_order(self):
if self.orders:
c = self.orders.pop(0)
return "The {} is ready!".format(c)
else:
return "All orders have been fulfilled!"
def due_amount(self):
due = 0
for dict2 in self.menu:
if dict2['item'] in self.orders:
due += dict2['price']
return round(due, 2)
def cheapest_item(self):
pricelist = []
for dict2 in self.menu:
pricelist.append(dict2["price"])
a = min(pricelist)
for dict2 in self.menu:
if dict2["price"] == a:
cheap = dict2["item"]
return cheap
def food_only(self):
listfood = []
for dict0 in self.menu:
if dict0['type'] == "food":
listfood.append(dict0['item'])
return listfood
def drinks_only(self):
drinks = []
for dict3 in self.menu:
if dict3["type"] == "drink":
drinks.append(dict3['item'])
return drinks
|
7898d85d4c55bcae1bbc6eb0326017c3fad9e66f | daniel-reich/ubiquitous-fiesta | /HXkpnCxJgxkFwaReT_5.py | 261 | 3.515625 | 4 |
def count_datatypes(*args):
types = {int:0, str:0, bool:0, list:0, tuple:0, dict:0}
for t in types:
for arg in args:
if type(arg) == t:
types[t] += 1
return [types[int], types[str], types[bool], types[list], types[tuple], types[dict]]
|
0757f23d7f0ad873ff39c1c35918ee0baa4b4ebb | daniel-reich/ubiquitous-fiesta | /kfXz49avvohsYSxoe_24.py | 307 | 3.890625 | 4 |
def binary_search(lst, left, right, elem):
boolean_condition = True
while boolean_condition:
middle = (left + right) // 2
if left > right:
return False
elif lst[middle] < elem:
left = middle + 1
elif lst[middle] > elem:
right = middle - 1
else:
return True
|
e0b3d5b3ed4c45e254bda555b5082f1c110c68e6 | daniel-reich/ubiquitous-fiesta | /xCXdch4XLpXZZagxm_12.py | 218 | 3.765625 | 4 |
import calendar
def num_of_leapyears(years):
low = int(years.split("-")[0])
high = int(years.split("-")[1])
count = 0
for i in range(low, high+1):
if calendar.isleap(i):
count+=1
return count
|
7e4b74e3f1ab3b26693a97e39d2551446aa1dcc7 | daniel-reich/ubiquitous-fiesta | /aW8mz7Tky3gGiuQsX_15.py | 545 | 3.640625 | 4 |
def get_prime_factors(n):
i = 2
prime_factors = []
while i * i <= n:
if n % i == 0:
prime_factors.append(i)
n //= i
else:
i += 1
if n > 1:
prime_factors.append(n)
return prime_factors
def is_powerful(n):
prime_factors = get_prime_factors(n)
unique_prime_factors = tuple(dict.fromkeys(prime_factors))
for p in unique_prime_factors:
if n % p != 0 or n % (p * p) != 0:
return False
return True
|
2163c89bda23d7bb9c02adc2729b3b678a695785 | daniel-reich/ubiquitous-fiesta | /gJSkZgCahFmCmQj3C_21.py | 276 | 4.125 | 4 |
def de_nest(lst):
l = lst[0] #Define 'l' so a while loop can be used
while isinstance(l,list): #repeat until l is not a list
l = l[0]
#This is a neat little trick in recursion, you can keep diving
#into list by just taking the 0 index of itself!
return l
|
575055541a46fb31201d0fe570316224d8696bb8 | daniel-reich/ubiquitous-fiesta | /928sxbEt8gyZ5uBBt_0.py | 248 | 3.640625 | 4 |
def wurstIsBetter(str):
sausages = ["Kielbasa", "Chorizo", "Moronga", "Salami", "Sausage", "Andouille", "Naem", "Merguez", "Gurka", "Snorkers", "Pepperoni"]
return " ".join(["Wurst" if x.title() in sausages else x for x in str.split() ])
|
6d4698feff1a83cf315dc8c2472c41afca4605c0 | daniel-reich/ubiquitous-fiesta | /hZi6AhWEzGASB7tWR_2.py | 332 | 3.9375 | 4 |
def check(lst):
for i in range(len(lst)-1):
if lst[i+1] <= lst[i]:
direction = 'down'
break
direction = 'increasing'
if direction == 'down':
for i in range(len(lst)-1):
if lst[i+1] >= lst[i]:
direction = 'neither'
break
direction = 'decreasing'
return direction
|
993291035a22447ba7c83bc0c89b88576d4aa39e | daniel-reich/ubiquitous-fiesta | /JFLADuABfkeoz8mqN_23.py | 408 | 3.875 | 4 |
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def compare_age(self, other):
diff = 'younger'
if self.age > other.age:
diff = 'younger than'
elif self.age < other.age:
diff = 'older than'
else:
diff = 'the same age as'
return '{} is {} me.'.format(other.name, diff)
|
3df68cffa5d628ee099abd3ed209165db67747d9 | daniel-reich/ubiquitous-fiesta | /eXRfoKp8m9Q6qvpRv_2.py | 88 | 3.5 | 4 |
def sum_five(l):
sum1 = 0
for i in l:
if i > 5:
sum1 += i
return sum1
|
0d1c75de8132a45841daf7be836d4d4001596b0f | daniel-reich/ubiquitous-fiesta | /HaxQfQTEpo7BFE5rz_15.py | 614 | 3.640625 | 4 |
def alternate_pos_neg(lst):
if 0 in lst:
return False
if lst[0] > 0: # List starts with positive number
for num in range(len(lst)):
if num % 2 == 0: # Positive index
if lst[num] < 0:
return False
if num % 2 != 0: # Negative index
if lst[num] > 0:
return False
return True
if lst[0] < 0: # List starts with negative number
for num in range(len(lst)):
if num % 2 == 0: # Positive index
if lst[num] > 0:
return False
if num % 2 != 0: # Negative index
if lst[num] < 0:
return False
return True
|
cc10dd98ad804cfb403913a6e16befe155e72b37 | daniel-reich/ubiquitous-fiesta | /yiEHCxMC9byCqEPNX_24.py | 278 | 3.921875 | 4 |
def is_palindrome(p,normal = False):
if not normal:
p = ''.join(i.lower() for i in p if i.isalpha())
if len(p) == 1 or len(p) == 0:
return True
if p[0] != p[-1]:
return False
if p[0] == p[-1]:
return is_palindrome(p[1:-1],True)
|
55ca7febcec83e186da2fef582c5ec58f676ed31 | daniel-reich/ubiquitous-fiesta | /Bm3JCT6rFrnAhHohy_17.py | 217 | 3.8125 | 4 |
def alphabet_index(txt):
string=""
for i in txt:
if (ord(i)>=65 and ord(i)<=90):
string+=str(ord(i)-64)+" "
if(ord(i)>=97 and ord(i)<=122):
string+=str(ord(i)-96)+" "
return string.strip()
|
c703c87c9fd08359665a6972302bbac19e84e026 | daniel-reich/ubiquitous-fiesta | /yvJbdkmKHvCNtcZy9_4.py | 115 | 3.5625 | 4 |
def is_disarium(n):
return True if n==sum([int(str(n)[i-1])**(i) for i in range(1,len(str(n))+1) ]) else False
|
44eaf86aeb9044def8230986ba600f821db405df | daniel-reich/ubiquitous-fiesta | /QHuaoQuAJfWn2W9oX_16.py | 820 | 3.65625 | 4 |
def check_board(col, row):
board = [[0 for c in range(8)] for r in range(8)]
row, col = 8 - row, ord(col) - 97
for c in range(col + 1, 8):
board[row][c] = 1
for c in range(col - 1, -1, -1):
board[row][c] = 1
for r in range(row + 1, 8):
board[r][col] = 1
for r in range(row - 1, -1, -1):
board[r][col] = 1
r, c = row + 1, col + 1
while r < 8 and c < 8:
board[r][c] = 1
r += 1
c += 1
r, c = row - 1, col + 1
while r >= 0 and c < 8:
board[r][c] = 1
r -= 1
c += 1
r, c = row + 1, col - 1
while r < 8 and c >= 0:
board[r][c] = 1
r += 1
c -= 1
r, c = row - 1, col - 1
while r >= 0 and c >= 0:
board[r][c] = 1
r -= 1
c -= 1
return board
|
af7b616ad779195477daf5e5b323b0462b778177 | daniel-reich/ubiquitous-fiesta | /NJw4mENpSaMz3eqh2_4.py | 114 | 3.84375 | 4 |
def is_undulating(num):
num = str(num);
return len(num) >= 3 and ( (num[:2]*len(num))[:len(num)] == num)
|
51dc3518740c5da4e819fa3283a19a0707ab61a0 | daniel-reich/ubiquitous-fiesta | /kjph2fGDWmLKY2n2J_21.py | 910 | 3.515625 | 4 |
def valid_color (color):
if color[:4] == "rgba":
colorrange = color[5:-1]
listcolors = colorrange.split(",")
count = 0
for i in listcolors[:-1]:
if "%" in i:
if float(i[:-1]) >= 0 and float(i[:-1]) <= 100:
count += 1
else:
if float(i) >= 0 and float(i) <= 255:
count += 1
if float(listcolors[-1]) >= 0 and float(listcolors[-1]) <= 1:
count += 1
return count == 4
elif color[:3] == "rgb":
#do things for rgb specific
if " (" in color:
return False
else:
colorrange = color[4:-1]
listcolors = colorrange.split(",")
count = 0
for i in listcolors:
if i == "":
return False
elif "%" in i:
if float(i[:-1]) >= 0 and float(i[:-1]) <= 100:
count += 1
elif float(i) >= 0 and float(i) <= 255:
count += 1
return count == 3
|
0e73cfd07110a390eb64bcddc0407fe805ce1647 | daniel-reich/ubiquitous-fiesta | /mDuDhhMWrdHJSGdtm_22.py | 263 | 3.8125 | 4 |
import math
def is_prime(n):
ret=True if n>1 else False
for i in range(2,math.floor(math.sqrt(n))+1):
if n%i==0:
ret=False
break
return ret
def is_exactly_three(n):
a=math.sqrt(n)
b=math.floor(a)
return n!=1 and a==b and is_prime(b)
|
5052b6e6edcc97259409135aa4a70864f1be0d22 | daniel-reich/ubiquitous-fiesta | /LgvppFDZoMpBKf8JW_7.py | 389 | 3.953125 | 4 |
def digital_clock(seconds):
hours = 0
minutes = 0
seconds2 = 0
while seconds != 0:
if seconds >= 86400:
seconds -= 86400
elif seconds > 3600:
seconds -= 3600
hours += 1
elif seconds >= 60:
seconds -= 60
minutes += 1
else:
seconds2 += seconds
seconds -= seconds
return '{:02}:{:02}:{:02}'.format(hours,minutes,seconds2)
|
e1f47ea015986a89fffa46ea15dd0378847cfc10 | daniel-reich/ubiquitous-fiesta | /oKjqFFzaybbs8csiE_24.py | 469 | 3.703125 | 4 |
def cons(lst):
lst = sorted(lst)
count = {}
for f in lst:
count[f] = lst.count(f)
if 2 in count.values():
return False
smallest = lst[0]
biggest = lst[0]
for num in lst:
if num > biggest:
biggest = num
elif num < smallest:
smallest = num
l_st = [x for x in range(smallest , biggest+1)]
print(lst , l_st)
for index in range(len(l_st)):
if l_st[index] != lst[index]:
return False
return True
|
bbdc9791defa799698d22be0845ce80561d574ad | daniel-reich/ubiquitous-fiesta | /tDswMNY7X9h7tyTS4_11.py | 194 | 3.65625 | 4 |
from math import factorial
def pascals_triangle(n):
tab=[]
for i in range(0,n):
for j in range(0,i+1):
x=factorial(i)/(factorial(j)*factorial(i-j))
tab.append(x)
return tab
|
d7ed3df4a3e47bddb98cd1f35b2144cf39517546 | daniel-reich/ubiquitous-fiesta | /A8gEGRXqMwRWQJvBf_21.py | 480 | 3.8125 | 4 |
def tic_tac_toe(board):
if board[0][0]==board[0][1]==board[0][2] or board[0][0]==board[1][0]==board[2][0] or board[0][0]==board[1][1]==board[2][2] :
return board[0][0]
elif board[1][0]==board[1][1]==board[1][2]:
return board[1][0]
elif board[2][0]==board[2][1]==board[2][2] or board[2][0]==board[1][1]==board[0][2]:
return board[2][0]
elif board[0][1]==board[1][1]==board[2][1]:
return board[0][1]
else:
return 'Draw'
|
67c33cbc9c34ebbe6bbe90f036834268f9779809 | daniel-reich/ubiquitous-fiesta | /vYYfFAAfjoc8crCqu_8.py | 184 | 3.578125 | 4 |
def tree(h):
primes=[x*'#' for x in range(1,h*2) if x%2!=0]
lst1=[]
for x in range(1,h+1):
lst1.append((h-x)*(' ')+primes[x-1]+(h-x)*(' '))
return (lst1)
|
5f929194d533d4511ddc500fb3d499f41c44cafd | daniel-reich/ubiquitous-fiesta | /djDJHv3nwWsRM9mtu_10.py | 777 | 3.609375 | 4 |
def validate_spelling(txt): #w/o built-in
d = {"A": "a", "B": "b", "C": "c", "D": "d", "E": "e", "F": "f",
"G": "g", "H": "h", "I": "i", "J": "j", "K": "k", "L": "l",
"M": "m", "N": "n", "O": "o", "P": "p", "Q": "q", "R": "r",
"S": "s", "T": "t", "U": "u", "V": "v", "W": "w", "X": "x", "Y": "y", "Z": "z"}
t = ""
for i in txt:
if i in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ':
if i in d:
t += d[i]
else:
t += i
s, tmp = [], ""
for i in t:
if i == " ":
s += [tmp]
tmp = ""
else:
tmp += i
if tmp:
s += [tmp]
same = ""
for i in s[:-1]:
same += i
return same == s[-1]
|
35664a45167f3e1ed633c065f5f88d40f1d61fee | daniel-reich/ubiquitous-fiesta | /ZZsnGAjYLyosG9zmH_16.py | 410 | 3.671875 | 4 |
def flash(flashcard):
if flashcard[1] == '+':
return flashcard[0] + flashcard[2]
if flashcard[1] == 'x':
return flashcard[0] * flashcard[2]
if flashcard[1] == '/' and flashcard[2] == 0:
return None
if flashcard[1] == '/' and flashcard[2] != 0:
return round(flashcard[0] / flashcard[2],2)
if flashcard[1] == '-':
return flashcard[0] - flashcard[2]
|
85a27d780def201c4ce6481fef6c6e48d2fe2e4e | daniel-reich/ubiquitous-fiesta | /dHGpjWHJ265BCthiM_17.py | 696 | 3.921875 | 4 |
import datetime
def current_streak(today, lst):
streak = 0
all_dates = []
today = tuple(map(int, today.split("-")))
today = datetime.date(today[0], today[1], today[2])
for i in range(len(lst)):
for k, v in lst[i].items():
cur_date = tuple(map(int, v.split("-")))
cur_date = datetime.date(cur_date[0], cur_date[1], cur_date[2])
all_dates.append(cur_date)
if not all_dates:
return 0
if all_dates[-1].day == today.day:
streak += 1
for y in range(2, len(all_dates) + 1):
if all_dates[-y].day == today.day - y + 1:
streak += 1
print(streak)
return streak
|
7d64130f2ed5a5a053d6e1f24de456c05a821c7d | daniel-reich/ubiquitous-fiesta | /a7WiKcyrTtggTym3f_6.py | 159 | 3.671875 | 4 |
def lcm(a, b):
starting = max(a,b)
while True:
if starting % a == 0 and starting % b == 0:
return starting
starting += 1
|
c91327b63f1a84d62b6ffaacaf7db0725320abc6 | daniel-reich/ubiquitous-fiesta | /CNpZrDFf3Ct7MzQrw_20.py | 466 | 3.609375 | 4 |
def trouble(num1, num2):
lst_num_strs = []
for i in str(num1):
lst_num_strs.append(i)
unique_nums = list(set(lst_num_strs))
unique_nums_tripled = []
for num in unique_nums:
unique_nums_tripled.append(num * 3)
triple_num = ""
double_num = ""
for num in unique_nums_tripled:
if num in str(num1):
triple_num += num
double_num = triple_num[0] + triple_num[1]
if double_num in str(num2):
return True
return False
|
dcf81f650e94351a45906b73bd1d016ce651ca98 | daniel-reich/ubiquitous-fiesta | /Dp9oYY4faMbdzufxR_18.py | 364 | 3.609375 | 4 |
def remove_zero(row):
ans = []
for i in row:
if i:
ans.append(i)
return ans
def left_slide(row):
merging = remove_zero(row.copy())
for i in range(len(merging)-1):
if merging[i] == merging[i+1]:
merging[i], merging[i+1] = merging[i]*2, 0
merged = remove_zero(merging)
merged = merged + [0]*(len(row)-len(merged))
return merged
|
90bfea526d1fa9eb2d0cda693093b26f917582b5 | daniel-reich/ubiquitous-fiesta | /X8fNb5EouWxrMMjZL_8.py | 133 | 3.875 | 4 |
def collatz(num):
count=0
while num!=1:
if num%2==0:
num/=2
else:
num=num*3+1
count+=1
return count
|
77e3c84046b009eb9b7698d524ce29946b0b1799 | daniel-reich/ubiquitous-fiesta | /2jcxK7gpn6Z474kjz_8.py | 149 | 3.734375 | 4 |
import re
def security(txt):
s=''
for x in txt:
if x!='x':
s+=x
p=r'\$T|T\$'
return "ALARM!" if bool(re.search(p,s)) else "Safe"
|
b2e9260e7c4801a18869dc1742a58d8aae27e0d9 | daniel-reich/ubiquitous-fiesta | /uojwbCn2yyqqk9Wpf_10.py | 291 | 3.546875 | 4 |
def is_untouchable(n):
touch = [i for i in range(2,1+n**2) if div_sum(i)==n]
return "Invalid Input" if n<2 else touch if touch else True
def div_sum(n):
half = [i for i in range(1,1+int(n**.5)) if not n%i]
return sum(half)+sum(n//i for i in half) - (n**.5)*(n**.5%1==0) -n
|
eb848eb436cb0ce317e667c25e2e79f090b09a19 | daniel-reich/ubiquitous-fiesta | /gphnuvoHDANN2Fmca_4.py | 108 | 3.640625 | 4 |
def odd_sort(lst):
os = sorted([i for i in lst if i%2])
return [os.pop(0) if i%2 else i for i in lst]
|
bffd84a94ab9726329a8b64a3b9cb4c3b35efd21 | daniel-reich/ubiquitous-fiesta | /nHxBoXmRYq5vnoEnq_18.py | 199 | 3.84375 | 4 |
def vowels(string):
if len(string) == 0:
return 0
elif string[0] in ["a", "u", "e", "o", "i"]:
return 1 + vowels(string[1:])
else :
return vowels(string[1:])
|
bde2e3b215e3efa4d9b8515aff66c26bebf31e9d | daniel-reich/ubiquitous-fiesta | /pEG8G4se5WBQkckF2_4.py | 209 | 3.859375 | 4 |
def reverse_sort(txt):
lst=txt.split(' ')
l1=sorted(sorted(lst,reverse=True),key=lambda x:x.lower(),reverse=True)
l2=sorted(l1,key=len,reverse=True)
s=''
for i in l2:
s=s+i+' '
return s[:-1]
|
d59776d6a08d89683ebe331b77ce884ce812a641 | daniel-reich/ubiquitous-fiesta | /dHGpjWHJ265BCthiM_21.py | 318 | 3.765625 | 4 |
def current_streak(today, lst):
today=today.split('-')
today1=int(today[2])
lst1=[]
x=0
for i in range(len(lst)):
lst1=lst[len(lst)-1-i]['date'].split('-')
lst1[2]=int(lst1[2])
if today1==lst1[2]:
today1-=1
x+=1
else: return x
return x
|
e7de8a5ddd436f5d11a2bc9a86d4ad0159e55446 | daniel-reich/ubiquitous-fiesta | /mCNwMqca9R3hBY6fY_8.py | 133 | 3.53125 | 4 |
def make_happy(txt):
return "".join(txt[i] if txt[i] != '(' else ')' if txt[i-1] in ':;x8' else txt[i] for i in range(len(txt)))
|
77e8e32af835b20bd00eebc1416ddef2babc9532 | daniel-reich/ubiquitous-fiesta | /xPmfKHShmuKL5Qf9u_16.py | 246 | 3.625 | 4 |
def scale_tip(lst):
l = 0;r = 0
for i in range(len(lst)):
if lst[i] != 'I':
l += lst[i]
else:
for j in range(i+1, len(lst)):
r += lst[j]
break
return 'left' if l > r else 'right' if l < r else 'balanced'
|
019ac9c6daa4a539c7d26137b55f05dfc24b9617 | daniel-reich/ubiquitous-fiesta | /Y4gwcGfcGb3SKz6Tu_9.py | 289 | 3.5 | 4 |
def max_separator(txt):
res = {}
for i,c in enumerate(txt):
for j in range(i+1,len(txt)):
if txt[j] == c:
if c not in res or res[c] < j+1-i:
res[c] = j+1-i
break
return sorted([k for k,v in res.items() if v == max(res.values())]) if res else []
|
7ddfb64e8283fcce6efacdec202b679079de2aed | daniel-reich/ubiquitous-fiesta | /CvChvza6kwweMjNRr_16.py | 231 | 3.53125 | 4 |
def split_code(item):
strhold = ''
inthold = ''
for x in range(len(item)):
if item[x].isalpha():
strhold = strhold + item[x]
else:
inthold = inthold + item[x]
lst = [strhold,int(inthold)]
return lst
|
6b5c7289d1daca81be0770bc18c8fbbcc606efe9 | daniel-reich/ubiquitous-fiesta | /MvgCxPkSgtQ8hQjwx_16.py | 227 | 3.703125 | 4 |
def remove_vowels(words):
new_words = ""
vowels = "aAeEiIoOuU"
for i in words:
add_cond = True
for x in vowels:
if i == x:
add_cond = False
if add_cond:
new_words += i
return new_words
|
8d175264224e59ef13018b3c02a4a9d073b91819 | daniel-reich/ubiquitous-fiesta | /YnsBcniRG9k77SSvA_12.py | 216 | 3.671875 | 4 |
def print_all_groups():
nums = "123456"
chars = "abcde"
retlist = []
for num in nums:
for char in chars:
retlist.append(num + char)
retstr = ', '.join(retlist)
print(retstr)
return (retstr)
|
ac0a7d79576b3e0daf2381c6f073f1f7a88a7e5e | daniel-reich/ubiquitous-fiesta | /6dnhESWBcTMMF3gsa_3.py | 158 | 3.765625 | 4 |
def stupid_addition(a, b):
if not type(a) == type(b): return None
if type(a) is int: return str(a) + str(b)
if type(b) is str: return int(a) + int(b)
|
beeb7c73ae683152593c6145596e14f8ef86a48a | daniel-reich/ubiquitous-fiesta | /eSxvC27HnDtM6MCCb_7.py | 481 | 3.65625 | 4 |
def base_n(base, values, num):
if len(values) != base:
return False
answ = []
highest_multiple = 0
for i in range(num):
if (num // (base ** i)) < base:
highest_multiple = base ** i
break
while highest_multiple >= 1:
res = int(num // highest_multiple)
answ.append(values[res])
num -= res * highest_multiple
highest_multiple /= base
return ''.join([str(_) for _ in answ])
|
5343475048b405321843c30cb1c5e1900dbcaee1 | daniel-reich/ubiquitous-fiesta | /GP6CEr9a5CMqPHY7C_22.py | 319 | 3.765625 | 4 |
def words_to_sentence(words):
if words == None:
return ""
elif (len(words) == 0 or words[0] == ""):
return ""
elif len(words) == 1:
return words[0]
else:
if "" in words:
words.remove("")
temp = ", ".join([words[i] for i in range(len(words)-1)])
return temp + " and " + words[-1]
|
46849e4a721f4e5a455154dabd2ab30a998fd6ae | daniel-reich/ubiquitous-fiesta | /aqDGJxTYCx7XWyPKc_19.py | 63 | 3.5 | 4 |
def squares_sum(n):
return sum([x**2 for x in range(n+1)])
|
0b2be6792e5f8b6b85c3430235d5c2c2310ede81 | daniel-reich/ubiquitous-fiesta | /egWRSXEE8dbKujvHw_5.py | 200 | 3.84375 | 4 |
import math
def is_circle_collision(c1, c2):
x = c2[1] - c1[1]
y = c2[2] - c1[2]
r = c2[0] + c1[0]
d = math.sqrt((x**2) + (y**2))
if d < r:
return True
else:
return False
|
27cca128a6ad83c77f9247b77c7f7bd1e1eabcbf | daniel-reich/ubiquitous-fiesta | /n4KPv4eaLmkYeD6gq_11.py | 189 | 3.5625 | 4 |
def face_interval(num):
if num == str(num):
return(':/')
num.sort(reverse=False)
if (num[len(num)-1] - num[0]) in num:
return':)'
else:
return':('
|
72fffe37aaf501e73cd4255146c0b9b65228dadf | daniel-reich/ubiquitous-fiesta | /zXACKeaEzLK9XwBwp_21.py | 204 | 3.5 | 4 |
def split_bunches(bunches):
result = []
for element in bunches:
for i in range(element["quantity"]):
result.append({"name":element["name"], "quantity": 1})
return result
|
6b516e09105f824313acefcb5ea3b627a6d22242 | daniel-reich/ubiquitous-fiesta | /yiEHCxMC9byCqEPNX_22.py | 317 | 3.90625 | 4 |
def is_palindrome(p):
if len(p) <2:
return True
elif not p.isalpha():
newP = ''
for _,char in enumerate(p):
if char.isalpha():
newP += char
return is_palindrome(newP.lower())
else:
first = p[0];last = p[-1]
return first.lower() == last.lower() and is_palindrome(p[1:-1])
|
106f25d827e5fe4c0bb2ca0fb2b8a5a68b1ede47 | daniel-reich/ubiquitous-fiesta | /cH3WN6TsqEC3qDg8f_7.py | 292 | 3.9375 | 4 |
import math
def rectangle_in_circle(w, h, radius):
# a**2 + b**2 = c**2 --> Pythagorean Theorem, solve for c
c_squared = math.sqrt(w**2 + h**2)
# c_squared is the diameter, so need to compare it to radius * 2
if c_squared <= radius * 2:
return True
else:
return False
|
87e8f2165e1cc6b60b98eec8995a3252d63cee72 | daniel-reich/ubiquitous-fiesta | /arobBz954ZDxkDC9M_15.py | 234 | 3.703125 | 4 |
def next_prime(num):
prime = []
for i in range(num, num*2):
count = 0
for k in range(1,i+1):
if not (i % k) : count +=1
if count == 2:
prime.append(i)
return (prime[0])
|
21751614b2617bb13dece97257d02f05a913db6b | daniel-reich/ubiquitous-fiesta | /k9usvZ8wfty4HwqX2_18.py | 277 | 3.515625 | 4 |
def ip(n):
f = []
for i in range(1, n):
if n%i==0:f+=[i]
return len(f)==1
def cuban_prime(num):
a = []
for y in range(100):
a+=[3*y**2 + 3*y + 1]
if num in a and ip(num): return str(num) + ' is cuban prime'
else: return str(num) + ' is not cuban prime'
|
95151cad40e304a886b4fe3213943c05b711d2c9 | daniel-reich/ubiquitous-fiesta | /ntpgCFga2rRzB53QZ_17.py | 222 | 3.828125 | 4 |
def staircase(n):
return staircase_r(1, n)[1:] if n > 0 else staircase_r(n, abs(n))[1:]
def staircase_r(n, l):
if n == 0 or n == l+1:
return ''
return '\n' + '_'*(l-abs(n)) + '#'*(abs(n)) + staircase_r(n+1, l)
|
35ee969b55b31014fb7b7b42d257b6edc0dbeaa5 | daniel-reich/ubiquitous-fiesta | /aqA6KSHRCwfE44Q9m_9.py | 157 | 3.671875 | 4 |
def normalize(txt):
if '.' in txt.lower():
return txt.capitalize()
elif '!' not in txt:
return txt.capitalize()+'!'
else:
return txt.capitalize()
|
e69e095d89f84cc01d32513d5852cab577ffcc92 | daniel-reich/ubiquitous-fiesta | /2FR33kRmz87xRMZuq_18.py | 146 | 3.640625 | 4 |
def histogram(lst, char):
st = ""
for i in lst:
if i != lst[-1]:
st += i * char + "\n"
else:
st += i * char
return st
|
99f75301bef2a78422278279f13d35655e144381 | daniel-reich/ubiquitous-fiesta | /LyzKTyYdKF4oDf5bG_20.py | 239 | 3.75 | 4 |
import re
def find_longest(s):
s = re.sub("[^A-Za-z]", ' ', s.lower())
return __find_longest(s.split())
def __find_longest(s):
if len(s) == 1:
return s[0]
return max(s[0], __find_longest(s[1:]), key=len)
|
1671a8fa02d178e64f150b1bc507ea7b00d3a9db | daniel-reich/ubiquitous-fiesta | /i747Wtc7pCukr8GRC_24.py | 245 | 3.90625 | 4 |
def max_product(nums):
nums = sorted(nums)
return max(nums[-1]*nums[-2]*nums[-3], nums[0]*nums[1]*nums[-1])
def min_product(nums):
nums = sorted(nums)
return min(nums[0]*nums[1]*nums[2], nums[0]*nums[-1]*nums[-2])
|
4d6976e404683468d5ca3b4bea60273a31380a4f | daniel-reich/ubiquitous-fiesta | /iuenzEsAejQ4ZPqzJ_6.py | 334 | 3.875 | 4 |
def mystery_func(num):
numbers = []
sum_numbers = 1
while sum_numbers <= num:
numbers.append(2)
sum_numbers = sum_numbers * 2
sum_numbers = sum_numbers / 2
numbers = numbers[1:]
numbers.append(int(num - sum_numbers))
result = ""
for i in numbers:
result = result + str(i)
return int(result)
|
155716d6dcea5c2236c5895702ceece89887f8c2 | daniel-reich/ubiquitous-fiesta | /QuxCNBLcGJReCawjz_19.py | 243 | 3.921875 | 4 |
def palindrome_type(n):
binary = bin(n)[2:]
if str(n)==str(n)[::-1]:
if binary == binary[::-1]:
return "Decimal and binary."
return "Decimal only."
if binary == binary[::-1]:
return "Binary only."
return "Neither!"
|
3b1f7f7a5871b1db7addd5549a4b6f78e9d5e8f1 | daniel-reich/ubiquitous-fiesta | /9ED9zbHHhaPaBz2xi_20.py | 732 | 3.640625 | 4 |
class Mod3Seq:
def mod3(num):
return num%3
def __init__(self, seq = [0, 1]):
self.seq = seq
self.iter = len(seq)
def advance(self):
if self.iter == 0:
self.seq = [0]
self.iter = 1
elif self.iter == 1:
self.seq.append(1)
self.iter += 1
else:
num = self.seq[-1] + self.seq[-2]
self.seq.append(Mod3Seq.mod3(num))
self.iter += 1
return True
def advance_to_iter(self, itr):
while self.iter < itr:
self.advance()
return True
def get_element(self, elem):
try:
return self.seq[elem-1]
except IndexError:
return 2
m3 = Mod3Seq()
m3.advance_to_iter(1000)
def normal_sequence(n):
return m3.get_element(n)
|
0f9457472ff2f8be89280b91adddbbb4e332b260 | daniel-reich/ubiquitous-fiesta | /FLgJEC8SK2AJYLC6y_18.py | 457 | 4 | 4 |
def possible_path(rooms):
'''
Returns whether the path through the rooms in rooms is possible
'''
ROOMS = {'1': ('2'), '2': ('1','H'), 'H':('2','4'),
'4': ('H','3'), '3': ('4')}
current = str(rooms[0])
for i in range(1, len(rooms)):
possibles = ROOMS[current]
next_room = str(rooms[i])
if next_room not in possibles:
return False
current = next_room
return True
|
97b984fe55db4f305f54ce7270eae483b63eb452 | daniel-reich/ubiquitous-fiesta | /MAzBohC2PxchT3wqK_24.py | 307 | 3.53125 | 4 |
def shared_letters(a, b):
for i in a:
if i in b: return True
return False
def shadow_sentence(a, b):
a = a.split()
b = b.split()
if len(a)!=len(b): return False
for i in range(len(a)):
if len(a[i])!=len(b[i]): return False
if shared_letters(a[i], b[i]): return False
return True
|
e37755b7e421f8ca84a99a8c8a2224ad024e6277 | daniel-reich/ubiquitous-fiesta | /A8gEGRXqMwRWQJvBf_15.py | 486 | 3.84375 | 4 |
def tic_tac_toe(board):
f = lambda *a: board[a[0]][a[1]] == board[a[2]][a[3]] == board[a[4]][a[5]]
horizontal = [(0, 0, 0, 1, 0, 2), (1, 0, 1, 1, 1, 2), (2, 0, 2, 1, 2, 2)]
vertical = [(0, 0, 1, 0, 2, 0), (0, 1, 1, 1, 2, 1), (0, 2, 1, 2, 2, 2)]
diagonal = [(0, 0, 1, 1, 2, 2), (-1, -1, -2, -2, -3, -3)]
for direction in horizontal + vertical + diagonal:
if f(*direction):
return board[direction[0]][direction[1]]
return "Draw"
|
ea54f8be0eae035bafbbe36e0d747c50c4588e5f | daniel-reich/ubiquitous-fiesta | /jozLzME3YptxydiQm_19.py | 110 | 3.984375 | 4 |
def is_plural(word):
words = str(word)
if words.endswith("s"):
return True
else:
return False
|
43dfe2df6e9d0da4614a6a8560547d0fc53aeb20 | daniel-reich/ubiquitous-fiesta | /f6X7pa38iQyoytJgr_16.py | 215 | 3.5625 | 4 |
def increasing_word_weights(sentence):
x = [[ord(i) for i in n if i.isalpha()] for n in sentence.split(' ')]
y = [sum(i) for i in x]
z = [y[i]>y[i-1] for i in range(len(y)) if i !=0]
return False not in z
|
44fee4b628899a7a7a8a98aa7190690ef453dccd | daniel-reich/ubiquitous-fiesta | /p8iNsRCtj3AdJsYjS_19.py | 117 | 3.515625 | 4 |
def title_to_number(s):
if not s:
return 0
return 1 + ord(s[-1]) - ord('A') + 26 * title_to_number(s[:-1])
|
5ad5ea5d2661693ed8b94ca76d5ae3a57120756a | daniel-reich/ubiquitous-fiesta | /Akx92Ldcy78xp5zCF_2.py | 274 | 3.71875 | 4 |
def custom_sort(t, s):
aux = ''
for c1 in s:
if c1 in t:
aux += c1
s = s.replace(c1, '')
aux2 = ''
for c2 in t:
for c3 in aux:
if c2 == c3:
aux2 += c3
return aux2 + ''.join(sorted(s))
|
91d00e07c34323b0397a4bc11ff336bafe1d7c5e | daniel-reich/ubiquitous-fiesta | /2zKetgAJp4WRFXiDT_17.py | 116 | 3.6875 | 4 |
def number_length(num):
num = str(num)
count = 0
for char in num:
count += 1
return count
|
bd80dbe1c4d3fad590b3a8f0d545d365b43becfe | daniel-reich/ubiquitous-fiesta | /SQo9Jx5ih2iHG8JAn_0.py | 132 | 3.84375 | 4 |
def expanded_form(num):
num = str(num)
return ' + '.join(x + '0' * (len(num) - i - 1) for i, x in enumerate(num) if x != '0')
|
4be7678298270635509e16b30af8b73539dea0c4 | daniel-reich/ubiquitous-fiesta | /pEozhEet5c8aFJdso_9.py | 605 | 3.5625 | 4 |
def midOc(txt):
count = 0
countTwo = -1
for ctr in txt:
countTwo += 1
if count == 0 and ctr == txt[1]:
count += 1
elif count == 1 and ctr == txt[1]:
return "@ index " + str(countTwo)
elif txt.count(txt[1]) < 2:
return "not found"
def findMid(str):
lstStr = [a for a in str]
if len(str) % 2 == 0:
return lstStr[int((len(str)/2)-1)] + lstStr[int(len(str)/2)]
else:
return lstStr[int((len(str)/2)-.5)]
def all_about_strings(txt):
lstTxt = [m for m in txt]
Attributes = [len(txt),lstTxt[0],lstTxt[-1],findMid(txt),midOc(txt)]
return Attributes
|
ffa1b585b7f17be573072ae010b2b5ce51ee60d8 | daniel-reich/ubiquitous-fiesta | /MiAnCNYivnAc9AFXn_19.py | 502 | 3.671875 | 4 |
def changeTypes(lst):
x=[]
for i in lst:
if(type(i) ==str):
i=i+"!"
i= i.capitalize()
x.append(i)
elif(type(i)==bool):
if(i==True):
i=False
x.append(i)
else:
i=True
x.append(i)
if(type(i)==int):
if(i%2==0):
i=i+1
x.append(i)
else:
x.append(i)
return x
|
4ac453a9abcc30539027fefd20a64346e695ae2d | daniel-reich/ubiquitous-fiesta | /iLLqX4nC2HT2xxg3F_6.py | 245 | 3.6875 | 4 |
def deepest(lst):
count=0
maxi=0
print(str(lst))
for i in range(len(str(lst))):
if(str(lst)[i]=='['):
count+=1
if(count>maxi):
maxi=count
if(str(lst)[i]==']'):
count-=1
print(count)
return(maxi)
|
dee1ad393924fb56d1b776dae5570bdd7776de4a | daniel-reich/ubiquitous-fiesta | /wsCshmu5zkN5BfeAC_9.py | 273 | 3.625 | 4 |
def divisible_by_left(n):
div_left = [False]
n = str(n)
for i in range(1, len(n)):
try:
if int(n[i]) % int(n[i - 1]) == 0:
div_left.append(True)
else:
div_left.append(False)
except:
div_left.append(False)
return div_left
|
3097f39eff0f9d931d2d94849cbc62c576a0cd3c | daniel-reich/ubiquitous-fiesta | /qwDPeZeufrHo2ejAY_11.py | 307 | 3.5 | 4 |
def eval_algebra(eq):
(a,b),(c,d) = map(eval_coef,eq.split(' = '))
return (d-b)/(a-c)
def eval_coef(expr):
a = b = 0
op = 1
for x in expr.split():
if x == '-' : op = -1
elif x == '+' : op = 1
elif x[-1] == 'x': a += op * int(x[:-1] or 1)
else: b += op * int(x)
return (a,b)
|
7ca8bc4d1ea8e8215e8461ae6362050245e7bb20 | daniel-reich/ubiquitous-fiesta | /iTX7sAMgekBWaq5J8_0.py | 133 | 3.765625 | 4 |
def add_up_to(n):
return sum(range(1, n + 1))
# or: return n * (n + 1) // 2
# or: return n if n == 0 else n + addUpTo(n - 1)
|
b41dc8cc1550c962ac71e968ef8327dd2a959467 | daniel-reich/ubiquitous-fiesta | /HpJCBwggQMDLWTHsM_17.py | 160 | 3.75 | 4 |
import re
def average_word_length(txt):
txt = re.sub(r'[^\w\s]','', txt)
return round(sum(len(i) for i in txt.split(' ')) / len(txt.split(' ')),2)
|
cc283f22e6ad5b03a9821343ec921566019e9889 | daniel-reich/ubiquitous-fiesta | /wsCshmu5zkN5BfeAC_21.py | 143 | 3.609375 | 4 |
def divisible_by_left(n):
return [False]+[False if str(n)[i-1]=='0' else int(str(n)[i])%int(str(n)[i-1])==0 for i in range(1,len(str(n)))]
|
ee6c613cbb5be8536a424bd649d3151d43cd5019 | daniel-reich/ubiquitous-fiesta | /MNePwAcuoKG9Cza8G_15.py | 272 | 3.6875 | 4 |
def build_staircase(height, block):
output = []
for i in range(height):
current_row = []
for c in range(i+1):
current_row.append(block)
for c in range(i+1, height):
current_row.append('_')
output.append(current_row)
return output
|
f34c79970512bfaf3cfc2273d695012b0e20f22a | daniel-reich/ubiquitous-fiesta | /fDfh3WJPPiiJwgTrW_19.py | 143 | 3.703125 | 4 |
def num_of_sublists(lst):
list_count = 0
for item in lst:
if type(item) is list:
list_count += 1
return list_count
|
1dc8da69e0228a13465dc79459fae8d76a43c5ff | daniel-reich/ubiquitous-fiesta | /D6XfxhRobdQvbKX4v_10.py | 195 | 3.828125 | 4 |
def first_before_second(s, first, second):
secFound = False
for let in s:
if secFound==True and let==first:
return False
elif let==second:
secFound = True
return True
|
3c07a20c591cf80ba8495afbb65e39c4811e84dd | daniel-reich/ubiquitous-fiesta | /K4aKGbfmzgyNNYEcM_11.py | 99 | 3.515625 | 4 |
def is_shape_possible(n, angles):
return (n-2)*180==sum(angles) and all(x<180 for x in angles)
|
0459f9f7e752558cffbc9903babc8a7edb9c3944 | daniel-reich/ubiquitous-fiesta | /3XtrKPMbxAf86QjjS_16.py | 110 | 3.5 | 4 |
def same_case(txt):
if txt.upper() == txt or txt.lower() == txt:
return True
else:
return False
|
e2b66e0de7869ef885504e9d5f6aad3b3e0d84bc | daniel-reich/ubiquitous-fiesta | /di7ZjxgvLgz72PvCS_17.py | 786 | 3.796875 | 4 |
def swap(strg,i1,i2):
strlist = []
for char in strg:
strlist.append(char)
temp = strlist[i1]
strlist[i1] = strlist[i2]
strlist[i2] = temp
joined = "".join(strlist)
return joined
def validate_swaps(lst, txt):
boolst = []
word = "No!"
for strg in lst:
word = "No!"
for i in range(len(strg)):
for j in range(i+1,len(strg)):
swappedstr = ""
if i != j:
swappedstr = swap(strg,i,j)
if swappedstr == txt:
boolst.append(True)
word ="Yes!"
break
if word == "Yes!":
break
if word == "No!":
boolst.append(False)
return boolst
|
0d23665860fd44d37aeb007ff568169877c0468a | daniel-reich/ubiquitous-fiesta | /hYiCzkLBBQSeF8fKF_16.py | 191 | 3.640625 | 4 |
def count(deck):
dict_cards = {
2:1, 3:1, 4:1, 5:1, 6:1, 7:0, 8:0, 9:0, 10:-1, "J":-1, "Q":-1,
"K":-1, "A":-1}
count = 0
for i in deck:
count += dict_cards[i]
return count
|
a1dd86b2e9982419e2227da05c3edbe57334de28 | daniel-reich/ubiquitous-fiesta | /cGaTqHsPfR5H6YBuj_16.py | 375 | 3.65625 | 4 |
def make_sandwich(i, f):
a=[]
for k,j in enumerate(i):
if k+1 in range(len(i)):
if i[k]==f and i[k+1]==f:
a=list(i[:k])+['bread']+[i[k]]+['bread']+['bread']+[i[k+1]]+['bread']+list(i[k+2:])
elif j==f:
a=list(i[:k])+['bread']+[i[k]]+['bread']+list(i[k+1:])
else:
break
return a
|
fd5fc1b2fe2c3e11f4c9d2d7ea8bf7c4ccc81e03 | daniel-reich/ubiquitous-fiesta | /oGkwLhmpys95rjtQ2_23.py | 156 | 3.578125 | 4 |
def match_last_item(lst):
ans = []
for x in range(len(lst)):
if lst[x] != lst[-1]:
ans.append(str(lst[x]))
return ''.join(ans) == lst[-1]
|
d50f54532d08e0cf4a1db01549d848e2edef67c9 | daniel-reich/ubiquitous-fiesta | /9CdF5hA7jRARpBwcF_14.py | 153 | 3.875 | 4 |
def map_letters(word):
dic = {}
for i, c in enumerate(word):
if c not in dic:
dic[c] = [i]
else:
dic[c].append(i)
return dic
|
2eca68dab27c88fafeff9cc7887b989c7ee7bc71 | daniel-reich/ubiquitous-fiesta | /o7u9hqTW5AY3SoZgT_9.py | 328 | 3.53125 | 4 |
def switcheroo(txt):
chars = [i for i in txt]
for i in range(len(chars)+3):
if chars[i:i+3] == [i for i in 'nts'] and chars[i+3] in ' ,.!?':
chars[i:i+3] = [i for i in 'nce']
elif chars[i:i+3] == [i for i in 'nce'] and chars[i+3] in ' ,.!?':
chars[i:i+3] = [i for i in 'nts']
return ''.join(chars)
|
d89616a48ede3525508c461154a28ac1fdb71b6e | daniel-reich/ubiquitous-fiesta | /gLjL4aLT2ZwbMXafq_2.py | 182 | 3.765625 | 4 |
def fair_swap(l1, l2):
S1 = sum(l1)
S2 = sum(l2)
l2 = set(l2)
if (S1-S2)%2:
return set()
delta = (S2-S1)//2
return {(x,x+delta) for x in l1 if x+delta in l2}
|
f42efe8fdd1924d60ff17598c5003e3eb97749f9 | daniel-reich/ubiquitous-fiesta | /eomsubuQLmwASWbMB_11.py | 307 | 3.53125 | 4 |
from datetime import datetime
def weekday_dutch(date):
day, month, year = map(int, date.split())
return [
"maandag",
"dinsdag",
"woensdag",
"donderdag",
"vrijdag",
"zaterdag",
"zondag",
][datetime(day=day, month=month, year=year).weekday()]
|
fda722d42022ec15aa5895f8cf330c736cec4311 | daniel-reich/ubiquitous-fiesta | /LByfZDbfkYTyZs8cD_24.py | 104 | 3.625 | 4 |
def areaofhexagon(x):
if x <=0:
return None
else:
return round((3*(3**(1/2))*(x**2))/2,1)
|
52b28d252295552a68060671bd861a441884c929 | daniel-reich/ubiquitous-fiesta | /o9jhv8LxsL8KsGgga_20.py | 211 | 3.671875 | 4 |
def bound_sort(lst, bounds):
l1=sorted(lst[bounds[0]:bounds[-1]+1])+lst[bounds[-1]+1:len(lst)]
#print(lst[bounds[0]:bounds[-1]+1],l1)
if sorted(lst)==l1:
return True
else:
return False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.