#!ruby -paF\n* gsub(/./){$F.slice!$F.index{|x|$&!=x&&($F-[x]).all?{|y|$F.count(y).<=$'.count'^ '+y}}}