This file contains 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
https://paiza.jp/poh/ando | |
glasses | |
https://paiza.jp/poh/ando/share/f872136d | |
santa | |
https://paiza.jp/poh/ando/share/b8c73b8b | |
swimwear | |
https://paiza.jp/poh/ando/share/841f1803 |
This file contains 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
n = gets.to_i | |
table = [] | |
n.times do | |
table << gets.split(' ').join('').to_i(2) | |
end | |
m = gets.to_i | |
panel = [] | |
m.times do | |
panel << gets.split(' ').join('').to_i(2) | |
end | |
x = 0 | |
y = 0 | |
limit = n-m | |
loop do | |
mask = ('1'*m).to_i(2) << x | |
targets = table.map{|t| (mask & t) >> x} | |
y = 0 | |
hit = false | |
loop do | |
list = targets[y, m] | |
if list == panel | |
hit = true | |
break | |
end | |
y += 1 | |
break if y > limit | |
end | |
break if hit | |
x += 1 | |
break if x > limit | |
end | |
puts "#{y} #{limit - x}" |
This file contains 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
x, y, z, n = gets.split(' ').map(&:to_i) | |
xlist = [0, x] | |
ylist = [0, y] | |
n.times do | |
dir, num = gets.split(' ').map(&:to_i) | |
dir == 0 ? (xlist << num) : (ylist << num) | |
end | |
xlist.sort! | |
ylist.sort! | |
ax = (0...(xlist.length-1)).map do |i| | |
xlist[i+1] - xlist[i] | |
end.min | |
ay = (0...(ylist.length-1)).map do |i| | |
ylist[i+1] - ylist[i] | |
end.min | |
puts ax * ay * z |
This file contains 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
n = gets.to_i | |
def reduce(n, size) | |
cs = n.to_s.chars.reverse.drop_while{|i| i == '0'}.take(size) | |
cs.reverse.join('').to_i | |
end | |
ans = 1 | |
(2..n).each do |i| | |
ans *= i | |
next unless i % 50 == 0 | |
ans = reduce(ans, 11) | |
end | |
puts reduce(ans, 9) |
This file contains 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
# cat ear | |
puts gets.scan(/cat/).size | |
# cat | |
cs = gets.chomp.chars | |
cl, cs = cs.partition{|c| c == 'c'} | |
cc = cl.count | |
al, tl = cs.partition{|c| c == 'a'} | |
ac = al.count | |
tc = tl.count | |
max = [cc, ac, tc].max | |
puts [cc, ac, tc].min | |
puts max - cc | |
puts max - ac | |
puts max - tc | |
# maid | |
gets.to_i.times do | |
h, m = (gets.to_i / 3).divmod(60) | |
ph, pm = (m > 0 ? [-h, 60-m] : [1-h, 0]) | |
ph += 24 if ph < 0 | |
puts "#{format("%02d", ph)}:#{format("%02d", pm)}" | |
end |
This file contains 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
# eye | |
puts 'Ann' * gets.to_i | |
# eyepatch | |
gets; gets | |
has = gets.split(' ').map(&:to_i) | |
gets | |
sell = gets.split(' ').map(&:to_i) | |
ts = sell - has | |
puts ts.empty? ? 'None' : ts.sort.join(' ') | |
# short hair | |
puts (gets.to_i + gets.to_i) | |
# long hair | |
y = 0 | |
5.times do | |
y += 1 if gets.chomp == 'yes' | |
end | |
puts (y >= 3 ? 'yes' : 'no') | |
# pony tail | |
n = gets.to_i | |
(0..n).to_a.reverse.each do |i| | |
puts (i == 0 ? '0!!' : i) | |
end | |
# twin tail | |
c1, p1 = gets.split(' ').map(&:to_i) | |
c2, p2 = gets.split(' ').map(&:to_i) | |
a1 = c1.to_f / p1 | |
a2 = c2.to_f / p2 | |
puts (a1 > a2 ? 1 : 2) | |
# sailor | |
n = gets.to_i | |
arr = [] | |
n.times { arr << gets.chomp } | |
puts arr.join('_') | |
# cardigan | |
puts (1..gets.to_i).inject(:*) | |
# nee socks | |
n = gets.to_i | |
s = gets.to_i | |
str = '' | |
loop do | |
str << 'R' * n | |
str << 'W' * n | |
break if str.size >= s | |
end | |
puts str[0, s] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment