r/shittyprogramming • u/CVh655FDBcZ1l • Apr 10 '19
One Line of Code™
https://gist.github.com/WorryingWonton/ce8a3a74b0298f0b734fe4dd0a883a63
101
Upvotes
r/shittyprogramming • u/CVh655FDBcZ1l • Apr 10 '19
23
u/K900_ Apr 10 '19
Sounds like you'll enjoy the onelinerizer.
15
u/djcraze Apr 10 '19
Their solution isn’t even correct!
8
u/LowB0b Apr 10 '19
3
u/Athandreyal Apr 10 '19
amusing that they are missing an obvious test case though.
2
u/huntertur Apr 11 '19
I love the little
else 0after all the brackets at the end2
u/mindbleach Apr 11 '19
return input.map( (v,i,a) => { if(v==13){ return 0 } if(a[i-1]==13){ return 0 } return v } ).reduce( (a,e) => a+e )
JS, but still - the fuck?
1
u/NihilistDandy Apr 11 '19
I wanted to just write
but this site doesn't want to let you use imports. Fine, I'll write my own.
What in the absolute hell is this site?