Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created September 24, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/4653b1686b51e81c84fca7cbf83b7157 to your computer and use it in GitHub Desktop.
Save whatalnk/4653b1686b51e81c84fca7cbf83b7157 to your computer and use it in GitHub Desktop.
Code Festival 2017 Qual A; D: Four Coloring
h, w, d = gets.chomp.split(" ").map(&:to_i)
colors = [['R', 'Y'], ['G', 'B']]
mat = Array.new(h){Array.new(w)}
h.times do |i|
w.times do |j|
x = i + j
y = i - j
xx = (x / d) % 2
yy = (y / d) % 2
mat[i][j] = colors[xx][yy]
end
end
mat.each do |row|
puts row.join("")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment