repl.it
@anonymous/

UntrueUniformSablefish

Ruby

No description

fork
loading
Files
  • main.rb
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#$f=->a,s{a.map{|i|s.scan([/[a-z]/,/[A-Z]/,/\d/][i]).sort}*''}
$f=->a,s{s.chars.sort_by{|c|a.index(3-c.ord/32).to_s+c}*''}

class Array
	def & str
		$f[self, str]
	end
end

puts  [2, 0, 1]  &  "a1B2c3"            #   123acB
puts  [2, 1, 0]  &  "aAaA909UuHWw9gh2"  #   02999AAHUWaaghuw
puts  [2, 1, 0]  &  "6Bx43"             #   346Bx
puts  [1, 0, 2]  &  "jfjf33g"           #   ffgjj33
puts  [0, 2, 1]  &  "AbC13"             #   b13AC
puts  [1, 2, 0]  &  "Qfl0l"             #   Q0fll
puts  [0, 1, 2]  &  "9870abcABC"        #   abcABC0789
puts  [0, 2, 1]  &  "test123"           #   estt123
puts  [2, 0, 1]  &  "WHAT"              #   AHTW
puts  [2, 0, 1]  &  "WhAt"              #   htAW
puts  [1, 0, 2]  &  "102BACbac"         #   ABCabc012
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
?