Skip to content

Instantly share code, notes, and snippets.

@Clashbuster
Created January 2, 2021 00:55
data = IO.read('test-floor.txt').lines.map(&:chomp)
def surround(data)
3.times do
data.map! do |item|
item = item.split("") if item.is_a? String
item.unshift("w")
item.push("w")
end
data.push(Array.new(data[0].length, "w"))
data.unshift(Array.new(data[0].length, "w"))
end
data.map! do |item|
item = item.split("") if item.is_a? String
item.unshift("x")
item.push("x")
end
data.push(Array.new(data[0].length, "x"))
data.unshift(Array.new(data[0].length, "x"))
data.map! do |item|
item.push("\n")
item.join("")
end
return data
end
surround(data).each do |line|
File.write("floor.txt", line, mode: "a")
end
# File.write("floor.txt", surround(data).join(""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment