Skip to content

Instantly share code, notes, and snippets.

@torazuka
torazuka / plotnum.py
Last active April 28, 2022 03:13
To plot ternary numbers which do not contain 1
import matplotlib.pyplot as plt
import math as math
def get_exp(n):
if n <= 0:
return 0
return math.floor(math.log(n, 3))
def conv_to_deci(n):
s = str(n)
@torazuka
torazuka / ex1.rb
Last active January 12, 2016 11:30
オフラインリアルタイムどう書く#参考問題01 Ruby解答
#!/usr/bin/ruby
def is_fourcards (cs)
return cs.has_value?(4)
end
def is_threecards (cs)
return cs.has_value?(3)
end
@torazuka
torazuka / spriwa.rb
Last active August 29, 2015 14:14
オフラインリアルタイムどう書く#28 十字の壁がそそり立つ世界の中を君は螺旋状に歩く Ruby解答
#!/usr/bin/ruby
# http://nabetani.sakura.ne.jp/hena/ord28spirwa/
def parse(input)
wall, day = input.split(":")
n, e, s, w = wall.split(",")
rs = [0,0]
1.upto(n.to_i) { |y| rs << [0, y] }
1.upto(e.to_i) { |x| rs << [x, 0] }
1.upto(s.to_i) { |y| rs << [0, -y] }
@torazuka
torazuka / raswi.rb
Created February 7, 2015 06:00
オフラインリアルタイムどう書く#27 分岐と行き止まり Ruby解答
#!/usr/bin/ruby
# http://nabetani.sakura.ne.jp/hena/ord27raswi/
def init()
rale = Struct.new(:name, :inp, :out)
rales = []
rales << rale.new("a", ["1"], ["b"])
rales << rale.new("b", ["a", "3"], ["c", "5"])
rales << rale.new("c", ["b", "d", "g"], ["4", "6"])
rales << rale.new("d", ["2"], ["c", "e"])
@torazuka
torazuka / get_days.rb
Last active August 29, 2015 14:12
調整さん問題
#!/usr/bin/ruby
# coding: utf-8
require 'date'
# INPUT: 1/7-1/16 9:30-17:30 1.5
# OUTPUT: 01/07(水) 09:30-11:00\n .. 1/16(金) 15:30-17:00\n
MIN = 60
def get_day(day)
@torazuka
torazuka / fizzbuzz.go
Last active August 29, 2015 14:04
Go's FizzBuzz
package main
import "fmt"
func main() {
for i :=1 ; i < 100; i++ {
if i % 15 == 0 {
fmt.Println("FizzBuzz")
} else if i % 5 == 0 {
fmt.Println("Buzz")
@torazuka
torazuka / SnakemonicNotParse.java
Created July 5, 2014 17:01
第23回オフラインリアルタイムどう書くのJava解答(別解)
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
/**
* http://nabetani.sakura.ne.jp/hena/ord23snakemoinc/
*/
public class SnakemonicNotParse {
@torazuka
torazuka / Snakemonic.java
Last active August 29, 2015 14:03
第23回オフラインリアルタイムどう書くのJava解答
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
/**
* http://nabetani.sakura.ne.jp/hena/ord23snakemoinc/
*/
public class Snakemonic {
@torazuka
torazuka / Meetime.java
Last active August 29, 2015 13:58
第20回オフラインリアルタイムどう書くの解答
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
@torazuka
torazuka / SummerTimeTest.java
Created March 30, 2014 13:31
Javaの夏時間対応を確認
import static org.junit.Assert.assertEquals;
import java.time.*;
import java.time.format.DateTimeFormatter;
import org.junit.Test;
public class SummerTimeTest {
@Test