Last active
December 24, 2018 04:09
-
-
Save dmi3y/f24979b888c91721b8041ab11d9e61f1 to your computer and use it in GitHub Desktop.
Revisions
-
dmi3y revised this gist
Dec 24, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ const christmasPresentsPerDaysRec = (days = 12, day = 1, collect = [0]) => { } } const argvDays = process.argv.length > 2 ? process.argv.pop() : 12 console.log(christmasPresentsPerDays(argvDays) ) console.log(christmasPresentsPerDaysRec(argvDays)) console.log(`For ${argvDays} days you got ${christmasPresentsPerDays(argvDays)} presents!`) -
dmi3y revised this gist
Dec 24, 2018 . 1 changed file with 15 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,31 @@ #!/usr/bin/env node const sumit = (sum, it) => sum + it // Christmas is around us! const christmasPresentsPerDays = (days = 12) => { const bag = []; for (let i = 0; i < days; i++) { bag.push(i + 1 + bag[i - 1] || 1); } return bag.reduce(sumit, 0); } const christmasPresentsPerDaysRec = (days = 12, day = 1, collect = [0]) => { if (day > days){ day collect return collect.reduce(sumit) } else { day collect let nsum = collect.reduce(sumit) + day collect.push(nsum) let nday = day + 1 return christmasPresentsPerDaysRec(days, nday, collect) } } const argvDays = process.argv.length > 2 ? process.argv.pop() : 3 console.log(christmasPresentsPerDays(argvDays) ) console.log(christmasPresentsPerDaysRec(argvDays)) console.log(`For ${argvDays} days you got ${christmasPresentsPerDays(argvDays)} presents!`) -
dmi3y revised this gist
Dec 24, 2018 . 1 changed file with 16 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,5 +8,19 @@ const christmasPresentsPerDays = (days = 12) => { } return bag.reduce((sum, it) => sum + it, 0); } const christmasPresentsPerDaysRec = (days = 12) => { if (days > 1 ) { return days + christmasPresentsPerDaysRec(days - 1) } else { return 1 } } const argvDays = process.argv.length > 2 ? process.argv.pop() : 2 console.log(christmasPresentsPerDays(argvDays) ) console.log(christmasPresentsPerDaysRec(argvDays)) console.log(`For ${argvDays} days you got ${christmasPresentsPerDaysRec(argvDays)} presents!`) let sum = 2 * 3 - 1 + (2 * 2 - 1 + (1)) sum -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,4 +9,4 @@ const christmasPresentsPerDays = (days = 12) => { return bag.reduce((sum, it) => sum + it, 0); } const argvDays = process.argv.length > 2 ? process.argv.pop() : 12 console.log(`For ${argvDays} days you got ${christmasPresentsPerDays(argvDays)} presents!`) -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,5 +9,4 @@ const christmasPresentsPerDays = (days = 12) => { return bag.reduce((sum, it) => sum + it, 0); } const argvDays = process.argv.length > 2 ? process.argv.pop() : 12 console.log(`For ${argvDays} you got ${christmasPresentsPerDays(argvDays)} presents!`) -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,6 @@ const christmasPresentsPerDays = (days = 12) => { } return bag.reduce((sum, it) => sum + it, 0); } const argvDays = process.argv.length > 2 ? process.argv.pop() : 12 console.log(argvDays, 'days') console.log(christmasPresentsPerDays(argvDays)) -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,4 +9,5 @@ const christmasPresentsPerDays = (days = 12) => { return bag.reduce((sum, it) => sum + it, 0); } const argvDays = process.argv > 2 ? process.argv.pop() : 12 console.log(argvDays, 'days') console.log(christmasPresentsPerDays(argvDays)) -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,5 +8,5 @@ const christmasPresentsPerDays = (days = 12) => { } return bag.reduce((sum, it) => sum + it, 0); } const argvDays = process.argv > 2 ? process.argv.pop() : 12 console.log(christmasPresentsPerDays(argvDays)) -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,5 +8,5 @@ const christmasPresentsPerDays = (days = 12) => { } return bag.reduce((sum, it) => sum + it, 0); } const = argvDays = process.argv > 2 ? process.argv.pop() : 12 console.log(christmasPresentsPerDays(argvDays)) -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,4 +9,4 @@ const christmasPresentsPerDays = (days = 12) => { return bag.reduce((sum, it) => sum + it, 0); } console.log(christmasPresentsPerDays(), process.argv) -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,3 +8,5 @@ const christmasPresentsPerDays = (days = 12) => { } return bag.reduce((sum, it) => sum + it, 0); } console.log(christmasPresentsPerDays()) -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ #!/usr/bin/env node // Christmas is around us! const christmasPresentsPerDays = (days = 12) => { const bag = []; for (let i = 0; i < days; i++) { -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ {"name": "12-days-of-christmas", "version": "0.0.0", "bin": "./12daysOfChristmas.js"} -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,9 @@ // Christmas is around us! const christmasPresentsPerDays = (days = 12) => { const bag = []; for (let i = 0; i < days; i++) { bag.push(i + 1 + bag[i - 1] || 1); } return bag.reduce((sum, it) => sum + it, 0); } -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 9 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,12 @@ // Christmas is around us! const christmasPresentsPerDays = days => { const bag = []; for (let i = 0; i < days; i++) { bag.push(i + 1 + bag[i - 1] || 1); } return bag.reduce((sum, it) => sum + it, 0); }; const presents = christmasPresentsPerDays(12); return presents -
dmi3y revised this gist
Dec 22, 2018 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,7 @@ // Christmas is around us! const christmasPresentsPerDays = (days) => { } christmasPresentsPerDays(1) -
dmi3y created this gist
Dec 22, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ // Christmas is around us!