This file contains 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
function multiply(params) { | |
return function(args) { | |
if (args) { | |
return multiply(params*args) | |
} else { | |
return params | |
} | |
} | |
} |
This file contains 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
Array.prototype.customFlat = function(depth = 1) { | |
let result = [] | |
for (let arr of this) { | |
if (Array.isArray(arr) && depth > 0) { | |
result.push(...arr.customFlat(depth-1)) | |
} else { | |
result.push(arr) | |
} | |
} | |
return result |
This file contains 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
# defines the range of the numbers that will be input in the array | |
RANGE = 100 | |
def countingSort(arr): | |
# Write your code here | |
count = [0] * RANGE | |
result = [] | |
for i in arr: | |
count[i] += 1 |
This file contains 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
function parseInt(string) { | |
// TODO: it's your task now | |
const dictionary = {"zero":0,"one":1,"two":2,"three":3,"four":4,"five":5,"six":6,"seven":7,"eight":8,"nine":9,"ten":10,"eleven":11,"twelve":12,"thirteen":13,"fourteen":14,"fifteen":15,"sixteen":16,"seventeen":17,"eighteen":18,"nineteen":19, | |
"twenty":20, "thirty":30, "forty":40, "fifty":50, "sixty":60, "seventy":70, "eighty":80, "ninety":90}; | |
const multi = { | |
'hundred': 100, | |
'thousand': 1000, | |
'million': 1000000 | |
} | |
const words = string.split(/ |-/) |
This file contains 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
class Item: | |
def __init__(self, name, price): | |
self.name = name | |
self.price = price | |
item = Item('Bike', 1000) | |
class ShoppingCart: | |
# Implement the ShoppingCart here |
This file contains 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 transformSentence(sentence): | |
# Write your code here | |
words = sentence.split(' ') | |
result_arr = [] | |
for word in words: | |
if len(word) == 1: | |
result_arr.append(word) | |
continue | |
new_word = '' | |
for i in range(0, len(word)): |
This file contains 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
# 26 Z | |
# 27 AA | |
# 80 CB | |
# 702 ZZ | |
# 728 AAZ | |
# 705 AAC | |
# 13456 SWN | |
# 456977 YYZA | |
import math |
This file contains 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 MandN(string): | |
result = "" | |
string_iter = iter(string) | |
for i in string_iter: | |
if (i == "M"): | |
if (len(result) != 0): | |
result += result[-1] | |
elif (i == "N"): | |
try: | |
next(string_iter) |
This file contains 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 countCharacters(string): | |
single = [] | |
whole = [] | |
result = "" | |
for i in string: | |
if (len(single) == 0): | |
single.append(i) | |
elif (i == single[0]): | |
single.append(i) | |
else: |
This file contains 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
function StringChallenge(str) { | |
// code goes here | |
let result = "" | |
str = reversing(str) | |
for (let i = 0; i < str.length; i++) { | |
let current = str[i].charCodeAt(0) | |
if (current >= 65 && current <= 90) { | |
result = result + str[i].toLowerCase() | |
} else if (current >= 97 && current <= 122) { |
NewerOlder