-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.rb
More file actions
32 lines (28 loc) · 815 Bytes
/
main.rb
File metadata and controls
32 lines (28 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 勝手にコードゴルフ王選手権 in RubyKaigi 2024
#
# Copyright (c) freee K.K.
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
m = []
26.times do
line = gets.split
m << [line[0], "\e[#{line[1]}m", line[2].to_i, line[3].to_i]
end
# ここを回答 Answer here
# example:
# initialize a map
a = Array.new(20) { Array.new(16) { [" ", ""] } }
# configure the map
m.each do |mapping|
name = mapping[0] + " "
row = mapping[3] * 2
col = mapping[2] * 2
color = mapping[1]
# Place the string in a 2x2 block
a[row][col] = [name[0], color]
a[row][col + 1] = [name[1], color]
a[row + 1][col] = [name[2], color]
a[row + 1][col + 1] = [name[3], color]
end
a.each { |row| puts row.map { |cell| "#{cell[1]}#{cell[0]}\e[0m" }.join }