This file contains hidden or 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 dist(a, b) | |
case | |
when a[1, 2] == b[0, 2] then 1 | |
when a[-1] == b[0] then 2 | |
else 3 | |
end | |
end | |
L = 64 | |
start_t = 171 |
This file contains hidden or 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 parse(text) | |
splited = text.scan(/[0-9\.]+|\+|\-|\*|\/|\(|\)|=/) | |
output = [] | |
stack = [] | |
a = nil | |
until (token = splited.shift) == "=" | |
case token | |
when "(" then stack << token | |
when ")" |
This file contains hidden or 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/env ruby | |
# encoding : utf-8 | |
require 'socket' | |
require 'thwait' | |
def file_send | |
host = ARGV[0] | |
q = Queue.new | |
30.times {q.push(:unlock)} | |
This file contains hidden or 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/env ruby | |
require 'socket' | |
require 'thwait' | |
def file_send | |
host = ARGV[0] | |
q = Queue.new | |
30.times {q.push(:unlock)} | |
send_file = ->(name) { |
This file contains hidden or 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
Node = Struct.new(:key, :value) | |
class MaxHeap | |
def initialize | |
@heap = [nil] | |
@size = 0 | |
end | |
attr_reader :heap, :size | |
def insert(key, value) |
This file contains hidden or 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 Node < Struct.new(:key, :value, :left, :right) | |
def inspect | |
l, r = "", "" | |
l = ", @left='#{left}'" if left | |
r = ", @right='#{right}'" if right | |
"#<Node:@key='#{key}', @value='#{value}'#{l}#{r}>" | |
end | |
alias :to_s :inspect | |
end |
This file contains hidden or 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
module Kernel | |
def Thunk(&bl) | |
a = Thunk.new | |
a.value = bl | |
a | |
end | |
def Lambda(&bl) | |
Lambda.new(bl) | |
end |
This file contains hidden or 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_relative 'es' | |
L = 14 #一辺の長さ(偶数にする) | |
print ES.safe_scroll(L) | |
i = 0 | |
x, y = ES.cursor_position | |
x -= 1 | |
square = ->(width) { |
This file contains hidden or 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 'prime' | |
module Kernel | |
def Root(*args) | |
Root.new(*args) | |
end | |
end | |
module ExRoot | |
def to_root |
This file contains hidden or 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
package main | |
import "fmt" | |
import "math/rand" | |
import "time" | |
var goal = 31 | |
func min_max(cards []int, turn bool, sum int) int { | |
if sum == goal { if turn {return -10} else {return 10} } | |
if sum > goal { if turn {return 10} else {return -10} } |