Created
February 22, 2016 16:33
-
-
Save canterberry/342f70bb815b57a0c9dd to your computer and use it in GitHub Desktop.
Code Golf: Hash Inversion: JavaScript Solution (165 characters)
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
var i,x,y,f,k=[],v=[];for(i in h){k.push(i);v.push(h[i]);}h={};for(i in v){x=v[i];y=k[i];f=(a,b)=>{b=h[a];h[a]=(b?b.map?b.concat([y]):[b,y]:y)};x.map?x.map(f):f(x);} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment