Last active
December 2, 2021 06:14
-
-
Save asonge/4848680eede5ae8f55ec750cb82c0c67 to your computer and use it in GitHub Desktop.
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
a=b=0;require('fs').readFileSync(0,{encoding:'utf8'}).replace(/^(.).*(\d+)$/gm,(_,v,d)=>{a+=d*(v=='f'),b+=v=='d'?+d:v=='u'?-d:0});console.log(a*b) |
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
console.log([...require('fs').readFileSync(0,{encoding:'utf8'}).matchAll(/^(.).*(\d+)$/gm)].reduce(([a,b],[_,v,d])=>[a+=d*(v=='f'),b+=v=='d'?+d:v=='u'?-d:0],[0,0]).reduce((a,b)=>a*b)) |
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
a=b=c=0;require('fs').readFileSync(0,{encoding:'utf8'}).replace(/^(.).*(\d+)$/gm,(_,v,d)=>{a+=v=='d'?+d:v=='u'?-d:0,b+=(v=='f')*d,c+=(v=='f')*a*d});console.log(b*c) |
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
console.log([...require('fs').readFileSync(0,{encoding:'utf8'}).matchAll(/^(.).*(\d+)$/gm)].reduce(([a,b,c],[_,v,d])=>[a+=v=='d'?+d:v=='u'?-d:0,b+=(v=='f')*d,c+=(v=='f')*a*d],[0,0,0]).slice(1).reduce((a,b)=>a*b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment