Skip to content

Instantly share code, notes, and snippets.

View Woodsphreaker's full-sized avatar
🎯
Focusing

Carlo Enrico Woodsphreaker

🎯
Focusing
  • São Paulo
View GitHub Profile
@Woodsphreaker
Woodsphreaker / staircase.js
Created May 30, 2017 19:02
Hacker Rank - Desafio Staircase
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
@Woodsphreaker
Woodsphreaker / simpleArraySum.js
Created May 30, 2017 19:05
Hacker Rank - Desafio Simple Array Sum
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
@Woodsphreaker
Woodsphreaker / compareTheTriplets.js
Created May 30, 2017 19:08
Hacker Rank - Desafio Compare the Triplets
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function(data) {
input_stdin += data;
});
@Woodsphreaker
Woodsphreaker / birthdayCakeCandles.js
Created May 31, 2017 00:10
Hacker Rank - Desafio Birthday Cake Candles
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
const initTime = (id) => console.time(id)
const endTime = (id) => console.timeEnd(id)
const testTime = (delay, id) => {
initTime(id)
setTimeout(() => endTime(id), delay)
}
testTime(3000, "T0")
testTime(2000, "T1")
@Woodsphreaker
Woodsphreaker / multipleObjectsValuesReduce.js
Last active May 31, 2017 23:53
multipleObjectsValuesReduce
const arr1 = [
{ val1_1: 1, val1_2: 2, val1_3: 3, val1_4: 4 },
{ val1_5: 5, val1_6: 6, val1_7: 7, val1_8: 8 }
];
const arr2 = [
{ val2_1: 1, val2_2: 2, val2_3: 3, val2_4: 4 },
{ val2_5: 5, val2_6: 6, val2_7: 7, val2_8: 8 }
].reverse();
@Woodsphreaker
Woodsphreaker / primeNumberCheck.js
Last active June 19, 2017 01:23
Prime Number Check
const generateRangeOfNumbers = (start = 0, end = 1) =>
Array.from({ "length": (end + 1) - start }, (notUsed, index) => start + index)
const isInteger = (number) => Number.isInteger(number)
const squareRoot = (number) => Math.sqrt(number)
const isIntegerSqrt = (number) => isInteger(squareRoot(number))
const isBiggerThan = (divisors) => (number) =>
@Woodsphreaker
Woodsphreaker / changePosition.js
Created June 5, 2017 14:47
Change position of element in array without loop
const arr = [1,2,3,4,5,6,7,8,9]
const fnMove = (list) => (ele, newPos) => {
const _arr = [].concat(list)
const arrPos = Array.from({length:2})
arrPos[0] = _arr.indexOf(ele)
arrPos[1] = _arr[newPos]
_arr[newPos] = ele
@Woodsphreaker
Woodsphreaker / umbrella.js
Created June 6, 2017 15:58
Given a number of people and an array of integers which are umbrellas people capacity, return the min number umbrellas needed
const sort = (list) => list.sort((a,b) => a < b)
const minus = (a) => (b) => a - b
const size = (list) => list.length
const obelus = (a) => (b) => Math.floor(a / b)
const times = (a) => (b) => a * b
const calc = (a) => (b) => minus(a)(times(b)(obelus(a)(b)))
const solve = (peoples) => (umbrellas) => {
return sort(umbrellas).reduce((acc, cur, i) => {
const solve = (str1) => (str2) => (str1 + str2).split('').reduce((acc, cur, i) => acc.concat(str1.slice(i, i + 1) , str2.slice(i , i + 1)), []).join('')
console.log(solve('Carlo')('Enrico'))