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
# [Problem - A - Codeforces](http://codeforces.com/contest/595/problem/A) | |
n, m = gets.chomp.split(" ").map(&:to_i) | |
ans = 0 | |
n.times do |i| | |
rooms = gets.chomp.split(" ").map(&:to_i) | |
rooms.each_slice(2) do |a, b| | |
if (a == 1) or (b == 1) then | |
ans += 1 | |
end | |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
$forbuild = <<SCRIPT | |
apt-get update -y | |
apt-get install -y git |
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
from collections import defaultdict | |
class BearSong(): | |
def countRareNotes(self, notes): | |
d = defaultdict(int) | |
for i in notes: | |
d[i] += 1 | |
return(len([i for i in d.values() if i == 1])) |
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
t = gets.chomp.to_i | |
t.times do | |
n = gets.chomp.to_i | |
power2 = [] | |
snd = 1 | |
i = 1 | |
while snd <= n | |
power2 << snd | |
snd = 2**i | |
i += 1 |
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.chomp.to_i | |
coors = [] | |
n.times do | |
coors << gets.chomp.split(" ").map(&:to_i) | |
end | |
if n == 3 or n == 4 then | |
coors_t = coors.transpose | |
dx = coors_t[0].max - coors_t[0].min | |
dy = coors_t[1].max - coors_t[1].min | |
puts dx * dy |
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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
my $stdout = `pandoc --to=markdown --no-wrap --reference-links --atx-headers $ARGV[0]`; | |
my @lines = split(/(?<=[.])\s/, $stdout); | |
print join("\n", @lines) |
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
# [Problem - A - Codeforces](http://codeforces.com/contest/599/problem/A) | |
d1, d2, d3 = gets.chomp.split(" ").map(&:to_i) | |
puts [2*(d1+d2), d1+d2+d3, 2*(d1+d3), 2*(d2+d3)].min |
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
a, d = gets.chomp.split(" ").map(&:to_i) | |
if a == d then | |
puts a * (a + 1) | |
elsif a < d then | |
puts (a + 1) * d | |
else | |
puts a * (d + 1) | |
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
n, bx = gets.chomp.split(" ").map(&:to_i) | |
xs = gets.chomp.split(" ").map(&:to_i) | |
m, by = gets.chomp.split(" ").map(&:to_i) | |
ys = gets.chomp.split(" ").map(&:to_i) | |
bxx = (0..(n-1)).map{|i| bx**i}.reverse | |
byy = (0..(m-1)).map{|i| by**i}.reverse | |
x = xs.zip(bxx).map{|i, j| i*j}.inject(:+) | |
y = ys.zip(byy).map{|i, j| i*j}.inject(:+) |
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
# [Problem - A - Codeforces](http://codeforces.com/contest/600/problem/A) | |
s = gets.chomp.split(/[,;]/, -1) | |
number = [] | |
nonnumber = [] | |
s.each do |w| | |
if w.match(/^[0-9]+$/) then | |
if w.length >= 2 and w[0] == "0" then | |
nonnumber << w | |
else | |
number << w |