Skip to main content
added 46 characters in body
Source Link
G B
  • 23.4k
  • 1
  • 24
  • 55

Ruby, 6262 57 bytes

->a,w{a.product(*[*[a]*a*a.size]map{a}).map(&:uniq).sort.uniq.index w} 

Try it online!Try it online!

Thanks Jordan for the hint that saved 5 bytes.

Ruby, 62 bytes

->a,w{a.product(*[*[a]*a.size]).map(&:uniq).sort.uniq.index w} 

Try it online!

Ruby, 62 57 bytes

->a,w{a.product(*a.map{a}).map(&:uniq).sort.uniq.index w} 

Try it online!

Thanks Jordan for the hint that saved 5 bytes.

Source Link
G B
  • 23.4k
  • 1
  • 24
  • 55

Ruby, 62 bytes

->a,w{a.product(*[*[a]*a.size]).map(&:uniq).sort.uniq.index w} 

Try it online!