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
# Print all duplicates from a list. | |
lis = [1,3,2,5,6,7,3,3,1,4,4] | |
def printDuplicates(lis): | |
results = [] | |
for num in lis: | |
dupe = lis.count(num) > 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
// Log all duplicate numbers in an array. | |
const arr = [1,3,2,5,6,7,3,3,1,4,4] | |
const logDuplicates = arr => { | |
const results = [] | |
arr.map(num => { | |
const dupe = arr.filter(i => i === num).length > 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
""" | |
Return TRUE or FALSE whether the string has valid closures. | |
A valid closure can be: () or ({}) or []({}). | |
An invalid closure interrupts open/close characters. | |
Each opener character must have a closer character. | |
Each closer character must have an opener character. | |
""" | |
patterns = { | |
'{': '}', |
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
# Compare TWO strings and return TRUE if the 2nd String only requires one change to match the original string. | |
# Otherwise return FALSE. | |
def compareStrings(orig, diff): | |
count = 0 | |
for char in list(diff): | |
match = [i for i in list(orig) if i == char] | |
if len(match) == 1: count += 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
""" | |
Return an array of User IDs that have logged the correct actions | |
taken at least once in the performance logs with this sequence: | |
A -> B -> C | |
""" | |
logs = [ | |
{ 'userID': 1, 'action': 'C' }, | |
{ 'userID': 2, 'action': 'B' }, |
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
/* | |
Return TRUE or FALSE whether the string has valid closures. | |
A valid closure can be: () or ({}) or []({}). | |
An invalid closure interrupts open/close characters. | |
Each opener character must have a closer character. | |
Each closer character must have an opener character. | |
*/ | |
const patterns = { | |
'{': '}', |
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
// Compare TWO strings and return TRUE if the 2nd String | |
// only requires one change to match the original string. | |
// Otherwise return FALSE. | |
const compareStrings = (orig, diff) => { | |
let count = 0 | |
diff.split('').map(char => { | |
const match = orig.split('').find(i => i === char) |
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
// Return an array of User IDs that have | |
// logged the correct actions taken at least once | |
// in the performance logs with this exact sequence: A => B => C | |
const logs = [ | |
{ userID: 1, action: 'C' }, | |
{ userID: 2, action: 'B' }, | |
{ userID: 3, action: 'B' }, | |
{ userID: 2, action: 'A' }, |
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
// Assume a large array as the main argument with the following schema and manipulate accordingly. | |
// EXAMPLE SCHEMA: | |
// name: String | |
// weight: Number | |
// price: Number | |
// size: Number | |
// id: Number | |
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
// DESCRIPTION | |
// Counting from 0 to 100, print out each number in the console. | |
// RULES | |
// 1. If the number is a multiple of 3, print "fizz" instead of the number. | |
// 2. If the number is a multiple of 5, print "buzz" instead of the number. | |
// 3. If the number is a multiple of both 3 and 5, print "fizzbuzz" in place of the number. | |
// 4. Otherwise just print the number itself. | |
// 5. Each entry should be printed on a new line. |
NewerOlder