Log in

[SPOILER] "Broken Reports" golf mission, JS

  • 5 Apr '17

This is my code:
golf=a=>{r=0;a=a.match(/[A-Z][1-9]/g);for(b of a){r+=9*parseInt(b[0],36)-90+parseInt(b[1])}return r}

The mission requires me to shrink it to 100 chars, I'm at 101 now -_-
I've thought about changing the regex, but \w includes digits, \d includes the 0, so that won't work.
I tried setting another function p which does the parseInt part, but declaring it costs more chars than I gain from it.
I can't find anything to cut that last character off, can anyone help me?

BTW the mission is in the second Adamantite storage, I think.

  • 6 Apr '17

var golf=(b)=>b.match(/[A-Z][1-9]/g).reduce((a,v)=>+v[1]+a+(v.charCodeAt(0)-65)*9,0);

  • 3
  • 3 May '17

You can drop two more by removing the parenthesis around the initial "b". Another four by dropping "var ".