30.11.2020: Updated with the new patchseries and instructions for Windows
02.12.2020: Added tweaks
08.12.2020: Updated with patchseries v4
31.01.2020: Updated with patchseries v6
class Metrics | |
def self.euclidean_distance(a,b) | |
return unless a.any? && (a.size == b.size) | |
diff_squared = (0..a.size-1).reduce(0) do |sum, i| | |
sum + (a[i] - b[i])**2 | |
end | |
Math.sqrt(diff_squared) | |
end |
type ApiResponse<T> = | |
| { status: 'success'; data: T; timestamp: Date } | |
| { status: 'error'; message: string; timestamp: Date } | |
const response1: ApiResponse<number> = { | |
status: 'success', | |
data: 100, | |
timestamp: new Date(), | |
} | |
type Props = { | |
name: string | |
} & (MaleProps | FemaleProps) | |
type MaleProps = { | |
gender: 'male' | |
salary: number | |
} | |
type FemaleProps = { |
IO.popen(["file", "--brief", "--mime-type", 'test.gif'], in: :close, err: :close) { |io| io.read(35).chomp } |
operation = "1 + 1 + 20 - 3 " | |
Kernel.eval operation | |
# 19 | |
raw_ops = operation.split /(\+|-)/ | |
ops = raw_ops.map { |raw_op| Integer(raw_op, exception: false) || raw_op } | |
# [1, "+", 1, "+", 20, "-", 3] | |
while ops.size > 1 | |
operator = ops.delete_at(1) |
STDOUT.sync = true # DO NOT REMOVE | |
w, h = gets.split(" ").collect { |x| x.to_i } | |
n = gets.to_i # maximum number of turns before game over. | |
x0, y0 = gets.split(" ").collect { |x| x.to_i } | |
x1 = x0 | |
y1 = y0 | |
max_x = w - 1 | |
min_x = 0 | |
max_y = h - 1 |
STDOUT.sync = true # DO NOT REMOVE | |
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
# w: width of the building. | |
# h: height of the building. | |
@w, @h = gets.split(" ").collect {|x| x.to_i} | |
@n = gets.to_i # maximum number of turns before game over. | |
@x, @y = gets.split(" ").collect {|x| x.to_i} |
path = URI.parse(params[:url]).path.presence || "/" | |
redirect_to path |