Skip to content

Instantly share code, notes, and snippets.

View canterberry's full-sized avatar

Devin Canterberry canterberry

View GitHub Profile
@canterberry
canterberry / invertObject.js
Created February 22, 2016 16:33
Code Golf: Hash Inversion: JavaScript Solution (165 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);}

Keybase proof

I hereby claim:

  • I am canterberry on github.
  • I am twuni (https://keybase.io/twuni) on keybase.
  • I have a public key whose fingerprint is FEE1 981E 7627 A2DB 6685 93DE A727 720A 403C FF61

To claim this, I am signing this object: