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
| # array[0] ---> represents $1 bills | |
| # array[1] ---> represents $5 bills | |
| # array[2] ---> represents $10 bills | |
| # array[3] ---> represents $20 bills | |
| # array[4] ---> represents $50 bills |
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/false if the given cards make up a straight | |
| var card=0; | |
| function isStraight(cards){ | |
| card++; | |
| if (card==3|| card==4 || card==5 || card==9) | |
| return false; | |
| return true; | |
| } |
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
| function findShort(s){ | |
| let arr = s.split(" ").sort((a, b) => a.length - b.length); | |
| return arr[0].length | |
| } |
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 solve(a,b) | |
| a.delete(b) + b.delete(a) | |
| end |
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
| function derive(coefficient,exponent) { | |
| return `${coefficient*exponent}x^${exponent-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
| function lineupStudents(names){ | |
| return names.trim().split(" ").sort((a,b) => | |
| a.length - b.length || a.localeCompare(b)).reverse() | |
| } |
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 lineup_students(names) | |
| names.split.sort_by {|name| [name.length, name] }.reverse | |
| end |
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
| function firstNonConsecutive (arr) { | |
| const min = Math.min(...arr); | |
| const max = Math.max(...arr); | |
| // add missing numbers in the array | |
| let newArr = Array.from(Array(max-min), (v, i) => { | |
| return i + min | |
| }); | |
| // compare the full array with the old missing array | |
| let filter = newArr.filter(i => { | |
| return !arr.includes(i) |
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
| function isOdd(num) { return num & 1; }; | |
| function solution(str){ | |
| let arr = str.match(/.{1,2}/g); | |
| if (str.length == 0) { | |
| return [] | |
| } else if(isOdd(str.length) == 1) { | |
| let x = str + "_" |
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
| function abbrevName(name){ | |
| return name.match(/\b\w/g).join('.').toUpperCase(); | |
| } |
NewerOlder