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 convert = ([...str], type) => { | |
try { | |
const t = ['camelUp', 'camelLo', 'kebab', 'snake']; | |
if (!type || !t.includes(type)) { | |
throw `El argumento "type" es obligatorio y debe contener uno de los siguientes tipos: ${t.join(', ')}`; | |
} | |
const symbol = { | |
snake: '_', | |
kebab: '-', | |
camelUp: 'toUpperCase', |
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
(async () => { | |
const entries = (await(await fetch('https://adventofcode.com/2020/day/6/input')).text()).split('\n').map(item => item); | |
const startTime = performance.now(); | |
let arr = []; | |
let total = []; | |
entries.forEach(item => { | |
if (item.length > 0) { | |
arr.push(Array.from(item).sort((a, b) => a > b ? 1 : -1)); | |
} else { | |
let arrSet = new Set(arr.flat()); |
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
(async () => { | |
const entries = (await(await fetch('https://adventofcode.com/2020/day/6/input')).text()).split('\n').map(item => item); | |
const startTime = performance.now(); | |
let arr = []; | |
let total = []; | |
entries.forEach(item => { | |
if (item.length > 0) { | |
arr.push(Array.from(item).sort((a, b) => a > b ? 1 : -1)); | |
} else { | |
const totalSet = new Set(arr.flat()); |
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
(async () => { | |
const result = []; | |
const entries = (await(await fetch('https://adventofcode.com/2020/day/5/input')).text()).split('\n').map(item => item); | |
entries.forEach(item => { | |
let rows = { min: 1, max: 128 }; | |
let columns = { min: 1, max: 8 }; | |
let totalRows = 128; | |
let totalColumns = 8; | |
const card = Array.from(item); | |
card.forEach((letter, iCard) => { |
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
(async () => { | |
const result = []; | |
const entries = (await(await fetch('https://adventofcode.com/2020/day/5/input')).text()).split('\n').map(item => item); | |
entries.forEach(item => { | |
let rows = { min: 1, max: 128 }; | |
let columns = { min: 1, max: 8 }; | |
let totalRows = 128; | |
let totalColumns = 8; | |
const card = Array.from(item); | |
card.forEach((letter, iCard) => { |
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
(async () => { | |
const fn = item => { | |
const { | |
byr = null, | |
ecl = null, | |
eyr = null, | |
hcl = null, | |
hgt = null, | |
iyr = null, | |
pid = null |
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
(async () => { | |
const result = []; | |
let t = []; | |
let validPassport = 0; | |
const passportStruct = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid']; // cid opcional | |
const entries = (await(await fetch('https://adventofcode.com/2020/day/4/input')).text()).split('\n').map(item => { | |
if (item) { | |
t.push(item); | |
} else { | |
item = t.slice(); |
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
(async () => { | |
const fn = (right, down) => { | |
const rowLen = entries[0].length; | |
let movRight = 0; | |
let totalTree = 0; | |
console.log('---------------------------------'); | |
movRight = 0; | |
entries.forEach((row, index) => { | |
debugger; | |
if (index % down === 0) { |
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
(async () => { | |
const result = []; | |
const entries = (await(await fetch('https://adventofcode.com/2020/day/3/input')).text()).split('\n').filter(item => item || false); | |
const startTime = performance.now(); | |
const rowLen = entries[0].length; | |
const incX = 3; | |
let movRight = 0; | |
let totalTree = 0; | |
entries.forEach((row, index) => { | |
if (movRight >= rowLen) { |
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
(async () => { | |
const result = []; | |
const entries = (await(await fetch('https://adventofcode.com/2020/day/2/input')).text()).split('\n').filter(item => item || false).map(item => item.split(':')); | |
const startTime = performance.now(); | |
let totalCorrectPassword = 0; | |
entries.forEach((item, index, arr) => { | |
const [range, letter] = item[0].split(' '); | |
const [ first, second ] = range.split('-'); | |
const password = item[1].trim(); | |
const checkPassword = new String(password); |
NewerOlder