Skip to content

Instantly share code, notes, and snippets.

@Tuman1
Tuman1 / The Supermarket Queue.py
Created October 7, 2017 13:46
The Supermarket Queue created by Tuman - https://repl.it/MP0z/3
'''There is a queue for the self-checkout tills at the supermarket. Your task is write a function to calculate the total time required for all the customers to check out!
The function has two input variables:
customers: an array (list in python) of positive integers representing the queue. Each integer represents a customer, and its value is the amount of time they require to check out.
n: a positive integer, the number of checkout tills.
The function should return an integer, the total time required.'''
def queue_time(customers, n):
tills = [0]*n
@Tuman1
Tuman1 / Array.diff.py
Created October 1, 2017 17:17
Array.diff created by Tuman - https://repl.it/LtwW/2
# Your goal in this kata is to implement an difference function, which subtracts one list from another
def array_diff(a, b):
for i in b:
while(i in a):
a.remove(i)
return a
ar = [1,2,2,3]
br = [2]
array_diff(ar, br)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@Tuman1
Tuman1 / isSameNum(arg).py
Created September 25, 2017 19:14
isSameNum(arg) created by Tuman - https://repl.it/LbK4/0
def isSameNum(arg):
arg = str(arg)
if len(set(arg)) > 1:
return False
else:
return True
print(isSameNum(1111))
print(isSameNum(0000))
print(isSameNum(123456))
@Tuman1
Tuman1 / isPalindrom().py
Created September 25, 2017 18:03
isPalindrom() created by Tuman - https://repl.it/Latr/1
def isPalindrom(arg):
arg = str(arg)
if len(arg)==2 or len(arg)==3:
return arg[0] == arg[-1]
else:
return arg[0] == arg[-1] and isPalindrom(arg[1:-1])
a= 1771
@Tuman1
Tuman1 / Valid Braces v3.py
Created September 23, 2017 11:23
Valid Braces v3 created by Tuman - https://repl.it/L5d1/7
a1 = "(){}[]" #True
a2 = "(}" #False
a3 = "[(])" #False
a4 = "([{}])" #True
a5 = "({}{}[()])" #True
a6 = "{}({})[]" #True
inp = [a1, a2, a3, a4, a5, a6]
def isPair(*arg):
temp = arg[0]+arg[-1]
@Tuman1
Tuman1 / Rectangle into Squares.py
Created September 21, 2017 21:38
Rectangle into Squares created by Tuman - https://repl.it/L1j4/4
def sqInRect(lng, wdth):
if lng > wdth:
result = []
while lng%wdth != 0:
result += [wdth]*int(lng/wdth)
temp = lng%wdth
lng = wdth
wdth = temp
result = result + [wdth]*(int(lng/wdth))
return result
@Tuman1
Tuman1 / Write Number in Expanded Form.py
Created September 21, 2017 08:08
Write Number in Expanded Form created by Tuman - https://repl.it/LZRV/3
a = 50226
def expanded_form(num):
result = []
divider = 10
while divider < num:
temp = num%divider
if temp != 0:
result.insert(0, str(temp))
num -= temp