Skip to content

Instantly share code, notes, and snippets.

@parrot-studio
Last active June 26, 2016 05:43
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 parrot-studio/d657f61ce60969685995b6e7f22bf119 to your computer and use it in GitHub Desktop.
Save parrot-studio/d657f61ce60969685995b6e7f22bf119 to your computer and use it in GitHub Desktop.
https://paiza.jp/poh/hatsukoi/
# drooping eyes
sheets, members = gets.split(' ').map(&:to_i)
puts ( sheets >= members ? 'OK' : 'NG')
# fishing eyes
points = (gets.to_i / 100)
puts (points >= 10 ? points + 10 : points)
# glass
size = gets.to_i
list = gets.split(' ').map(&:to_i).sort
puts list[(size - 1) / 2]
# short hair
count = gets.to_i
puts ("#{gets.chomp}\n" * count)
# long hair
puts ((gets.to_i % 7 == 0) ? 'lucky' : 'unlucky')
# pony tail
count = 0
5.times do
target, ans = gets.chomp.split(' ')
count += 1 if target == ans
break if count >= 3
end
puts (count >= 3 ? 'OK' : 'NG')
# twin tail
line = '-' * gets.to_i
line[gets.to_i - 1] = '+'
puts line
# osage
length = gets.to_i * 60
all = gets.to_i
count = 0
all.times do
length -= gets.to_i
break if length <= 0
count += 1
end
puts (all == count ? 'OK' : count)
# school uniform
def use!(cards, c)
cards[c] -= 1
cards.delete(c) if cards[c] <= 0
cards.keys.max
end
table = {}
(3..10).each{|n| table[n.to_s] = n - 3}
table.merge!({'J' => 8, 'Q' => 9, 'K' => 10, 'A' => 11, '2' => 12})
cards = {}
(0..12).each{|n| cards[n] = 4}
players = {}
gets.chomp.split(' ').each.with_index do |c, i|
players[i] = table[c]
end
nums = (0..51).to_a
ranking = []
rank = 1
now = -1
loop do
break if nums.empty?
nums.sort.each do |n|
c = players[n]
next unless c > now
ranking[n] = rank
rank += 1
nums.delete(n)
max = use!(cards, c)
break unless max
now = (c >= max ? -1 : c)
end
end
puts ranking
# microphone
work = gets.to_f * 2
count = gets.to_f
puts (count / work).ceil
# headband
fans, sheet = gets.split(' ').map(&:to_i)
writes, pen_cost = gets.split(' ').map(&:to_i)
pen = (fans.to_f / writes).ceil
puts fans * sheet + pen * pen_cost
# swim wear
def to_hash(cs)
cs.chars.each_with_object(Hash.new(0)){|c, h| h[c] += 1}
end
gets
before = to_hash(gets.chomp)
after = to_hash(gets.chomp)
count = 0
after.keys.each do |k|
c = after[k] - before[k]
count += c if c > 0
end
puts count
# cute
mem, all = gets.split(' ').map(&:to_i)
puts (all % mem == 0 ? 'ok' : 'ng')
# sexy
step, down = gets.split(' ').map(&:to_i)
forward = step - down
puts (forward > 0 ? forward : 0)
# yukata
temp = 0
now = 0
price = 0
forward = lambda do
break if now > 23
if temp > 0
temp -= 1
price += 2
else
price += 1
end
now += 1
end
gets.to_i.times do
time, act = gets.chomp.split(' ')
(time.to_i - now).times { forward.call }
case act
when 'in'
temp += 5
when 'out'
temp += 3
end
end
(24 - now).times{ forward.call }
puts price
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment