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
package main | |
import ( | |
"fmt" | |
"log" | |
"strconv" | |
"strings" | |
) | |
var daysInMonth = make(map[string]int) |
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
/** | |
* Given two integers, generate a “fibonacci-like” sequence of n digits | |
* (where the next number in the pattern is the sum of the previous two numbers). | |
* Extra credit: Given a sequence, determine if the sequence is “fibonacci-like”. | |
*/ | |
let n = 5 |
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
/** | |
* Write a function to output the ordinal suffix of a positive integer | |
* concatenated to an inputted number. | |
* | |
* > ordinal(3) | |
> '3rd' | |
> ordinal(57) | |
> '57th' | |
*/ |
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
// This week’s question: | |
// Given a list, swap every two adjacent nodes. Something to think about: How would your code change if this were a linked list, versus an array? | |
const args = [2, 1, 4, 3]; | |
const swapPairs = (args) => { | |
let secondInPair = []; | |
let firstInPair = []; | |
let swapedPairs = []; | |
let error = 'Input Array not even, please provide an array with an even number of children' |
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
const numberOfOnes = (num) => { | |
let total = 0; | |
let arraysToEval = []; | |
for (let i = 1; i <= num; i++) { | |
let iStr = i.toString(); | |
let iStrArray = [...iStr]; | |
if (iStrArray.indexOf('1') != -1) { | |
arraysToEval = [...arraysToEval, iStrArray]; | |
} | |
}; |
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
type List = number[]; | |
let listA: List = [1, 4, 5, 6]; | |
let listB: List = [2, 3, 4, 5, 6]; | |
const biggerArray = (listA: List, listB: List) => { | |
let greater: List; | |
let lesser: List; | |
if (listA.length > listB.length) { | |
greater = listA; |
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
let listA = [1, 4, 5, 6]; | |
let listB = [2, 3, 4, 5, 6]; | |
const biggerArray = (listA, listB) => { | |
let greater; | |
let lesser; | |
if (listA.length > listB.length) { | |
greater = listA | |
lesser = listB; | |
}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
const hideEmail = (email) => { | |
let emailParts = email.split('@'); | |
let letters = [...emailParts[0]]; | |
let lettersCopy = [...letters] | |
const first = lettersCopy.shift() | |
const last = lettersCopy.pop() | |
let blanks = [] | |