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
const timeConversion = (s) => { | |
const hours = s.slice(0, 2) | |
const meridiem = s.slice(-2) | |
switch (true) { | |
case hours === '12' && meridiem === 'AM': | |
return `00${s.slice(2, -2)}` | |
case meridiem === 'PM' && hours !== '12': | |
return `${Number(hours) + 12}${s.slice(2, -2)}` | |
case hours === '12' && meridiem === 'PM': | |
default: |
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
const fs = require('fs') | |
const mkdirp = require('mkdirp') | |
const path = require('path') | |
const write = (filePath, code) => { | |
mkdirp.sync(path.dirname(filePath)) | |
return new Promise((resolve, reject) => { | |
fs.writeFile(filePath, code, (err) => { | |
if (err) { | |
reject(err) |
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
const request = require('request') | |
const token = require('./.SECRET') | |
const user = '' | |
request( | |
`https://gitlab.com/api/v4/users/${user}/projects?private_token=${token}`, | |
(error, response, body) => { | |
JSON.parse(body) | |
.map((project) => project.id) | |
.forEach((projectId) => { |
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
const birthdayCakeCandles = (ar) => { | |
const max = Math.max(...ar); | |
return ar.filter(i => i === max).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
const miniMaxSum = (arr) => { | |
const arrLength = arr.length; | |
const arrSorted = arr.sort(); | |
const sum = a => a.reduce((acc, val) => acc = acc + val); | |
const minSum = sum(arrSorted.slice(0, -1)); | |
const maxSum = sum(arrSorted.slice(1)); | |
console.log(minSum, maxSum); | |
}; |
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
const staircase = (n) => { | |
console.log( | |
Array(n) | |
.fill() | |
.map( | |
(ignore, index) => `${' '.repeat(n - (index + 1))}${'#'.repeat(index + 1)}` | |
) | |
.join('\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
const plusMinus = (arr) => { | |
let arrLength = arr.length; | |
let positives = 0; | |
let negatives = 0; | |
let zeroes = 0; | |
arr.forEach(num => { | |
switch (true) { | |
case num > 0: | |
positives++; | |
break; |
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
const diagonalDifference = (arr, n) => { | |
const sum = a => a.reduce((acc, val) => acc += val); | |
const getFirstDiagonal = (gridSize, a) => | |
Array(gridSize).fill().map((ignore, index) => a[index][index]); | |
const getSecondDiagonal = (gridSize, a) => | |
Array(gridSize).fill().map((ignore, index) => { | |
gridSize--; | |
return a[index][gridSize]; | |
}); | |
return (Math.abs( |
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 maxProfit(prices): | |
minPrice = 9223372036854775807 | |
maxProfit = 0 | |
maxPrice = 0 | |
for price in prices: | |
if price < minPrice: | |
minPrice = price | |
elif price > maxPrice: | |
maxPrice = price | |
maxProfit = maxPrice - minPrice |
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 href="javascript:rulesEngine.global.persistantState={};rulesEngine.global.sessionState={};localStorage.clear();sessionStorage.clear();location.reload(true);"> | |
Clear cache (SLT) | |
</a> | |
<br><br> | |
^^ Drag that to your bookmark bar! |