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
S = 724.4744301 | |
R = 0.8271973364 | |
perfs = DATA.map(&:to_i) | |
Q = [] | |
perfs.each do |perf| | |
1.upto(100) do |j| | |
Q << perf - S * Math.log(j) | |
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
// C++17 | |
#include <cassert> | |
#include <cmath> | |
#include <chrono> | |
#include <algorithm> | |
#include <iostream> | |
#include <iomanip> | |
#include <climits> | |
#include <unordered_map> | |
#include <queue> |
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
require 'json' | |
require 'time' | |
user_name = 'simanman' | |
body = JSON.parse(File.read('ranking.json')) | |
submissions = body.select { |b| b['createdBy'] == user_name } | |
submissions.sort_by! { |sub| Time.parse(sub['submittedDate']) } | |
last_sub = submissions.last |
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
class RedBlackTree | |
RED = :red | |
BLACK = :balck | |
Node = Struct.new(:value, :parent, :left, :right, :color, keyword_init: true) | |
NUL = Node.new(value: nil, parent: nil, left: nil, right: nil, color: BLACK) | |
def initialize | |
@tree = [] | |
@root = NUL | |
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
class BinarySearchTree | |
Node = Struct.new(:value, :parent, :left, :right, keyword_init: true) | |
NUL = Node.new(value: nil, parent: nil, left: nil, right: nil) | |
attr_reader :root | |
def initialize | |
@root = NUL | |
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
# 'Hello World' を出力するようにプログラムを修正してください。 | |
# Q1 | |
n = 314 | |
if n > 4782968 | |
puts 'Hello World' | |
else | |
puts 'Hello Ruby' | |
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
RubyVM::InstructionSequence.compile_option = false | |
class RubyVM::InstructionSequence | |
def self.load_iseq(fpath) | |
RubyVM::InstructionSequence.compile_file(fpath) | |
end | |
end | |
require_relative 'add' |
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
def extract_source(parent) | |
$source ||= File.readlines(__FILE__) | |
if parent.first_lineno == parent.last_lineno | |
src = $source[parent.first_lineno][parent.first_column..parent.last_column] | |
else | |
src = ' ' * parent.first_column + $source[parent.first_lineno][parent.first_column..] | |
((parent.first_lineno + 1)...(parent.last_lineno)).each do |lineno| | |
src << $source[lineno] | |
end | |
src << $source[parent.last_lineno][0..parent.last_column] |
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
require 'pathname' | |
class PathFinder | |
SUFFIXES = ['', | |
'.rb', | |
*%w(DLEXT DLEXT2).map { |key| | |
val = RbConfig::CONFIG[key] | |
next unless val and not val.empty? | |
".#{val}" | |
} |
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
require 'parser/current' | |
class SinatraRoutes | |
attr_reader :filepath | |
def initialize(filepath) | |
@filepath = filepath | |
end | |
def routes |
NewerOlder