This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
NewerOlder