String Injection

Run and understand.

Novice:

name = “Bob the n00b”

puts “hi #{name}, this is your string”

Programmer:

formatter = “%s %s %s %s”

puts formatter % [“one”, “two”, “three”, “four”]

Hacker:

formatter = (“%s ” * 4)

x = 4

puts “testing, ” + [formatter * x].flatten[0] % (x.times.collect {[“one”, “two”, “three”, “four”]}).flatten