Skip to content

Instantly share code, notes, and snippets.

@dukeimg
dukeimg / solution.rb
Created April 22, 2016 03:46
Power of Thor
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
@dukeimg
dukeimg / solution.rb
Created April 22, 2016 03:48
The Descent
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
@dukeimg
dukeimg / solution.rb
Created April 22, 2016 03:51
Mars Lander
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
@dukeimg
dukeimg / apu_spec.rb
Last active April 26, 2016 13:42
APU redux
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'],
@dukeimg
dukeimg / .bat
Created April 26, 2016 19:28
Railsinstaller missiong gems fix
@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" %*
def flatten(input, output = [])
input.each do |el|
if el.is_a? Array
flatten(el, output)
else
output << el
end
end
output
end