This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten(input, output = []) | |
input.each do |el| | |
if el.is_a? Array | |
flatten(el, output) | |
else | |
output << el | |
end | |
end | |
output | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
IF NOT "%~f0" == "~f0" GOTO :WinNT | |
ECHO.This version of Ruby has not been built with support for Windows 95/98/Me. | |
GOTO :EOF | |
:WinNT | |
@"%~dp0ruby.exe" "%~dpn0" %* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './lib/scheme' | |
describe Scheme do | |
describe '.check' do | |
let(:scheme) { Scheme.new(:height => 4, :width => 4, | |
:cells => [ | |
['0', '0', '.', '0'], | |
['0', '.', '0', '0'], | |
['.', '0', '.', '0'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync = true # DO NOT REMOVE | |
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
@surface_n = gets.to_i # the number of points used to draw the surface of Mars. | |
@surface_n.times do | |
# land_x: X coordinate of a surface point. (0 to 6999) | |
# land_y: Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars. | |
land_x, land_y = gets.split(" ").collect {|x| x.to_i} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync = true # DO NOT REMOVE | |
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
# game loop | |
loop do | |
highest = 0 | |
index = 0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync = true # DO NOT REMOVE | |
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
# --- | |
# Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders. | |
# light_x: the X position of the light of power | |
# light_y: the Y position of the light of power | |
# initial_tx: Thor's starting X position | |
# initial_ty: Thor's starting Y position |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync = true # DO NOT REMOVE | |
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
@road = gets.to_i # the length of the road before the gap. | |
@gap = gets.to_i # the length of the gap. | |
@platform = gets.to_i # the length of the landing platform. | |
required_speed = @gap + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
@n = gets.to_i # the number of temperatures to analyse | |
@temps = gets.chomp # the n temperatures expressed as integers ranging from -273 to 5526 | |
if @n == 0 | |
puts 0 | |
return | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync = true # DO NOT REMOVE | |
# Don't let the machines win. You are humanity's last hope... | |
@width = gets.to_i # the number of cells on the X axis | |
@height = gets.to_i # the number of cells on the Y axis | |
@cells = Array.new | |
@height.times do | |
line = gets.chomp # width characters, each either 0 or . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync = true # DO NOT REMOVE | |
# Don't let the machines win. You are humanity's last hope... | |
@width = gets.to_i # the number of cells on the X axis | |
@height = gets.to_i # the number of cells on the Y axis | |
cells = Array.new | |
@height.times do | |
line = gets.chomp # width characters, each either 0 or . |
NewerOlder