Skip to content

Instantly share code, notes, and snippets.

@lithtle
lithtle / main.rb
Last active September 23, 2021 03:52
目標ろんめんぺいになるまでどれだけCEを周回すればいいのか
# deepcopyに必要なやつ
require 'active_support'
require 'active_support/core_ext'
# 目標ろんめんぺい金額
START = 808888
GOAL = 888888
# 各種CEで取得可能な金額とラベル
PATTERN = {
@lithtle
lithtle / answer.rb
Created May 25, 2015 08:56
「Five programming problems every Software Engineer should be able to solve in less than 1 hour」をrubyで解いてみた
# encoding: sjis
# 1
# using for
def sum_for(list)
sum = 0
for i in list
sum += i
end
sum
@lithtle
lithtle / taxi_fee.rb
Last active August 29, 2015 14:19
"第30回オフラインリアルタイムどう書くの問題" 解いてみた ref: http://qiita.com/lithtle/items/25f465f7a28393f99755
# encoding: sjis
#
# とある世界のタクシー料金を計算する
# Author:: lithtle
# Created_At:: 2015-04-21
# Link:: http://nabetani.sakura.ne.jp/hena/ord30taxi/
# 都市の地点と経路
CITY = {
@lithtle
lithtle / 3d_dirichlet.png
Created December 4, 2012 08:59
ディリクレ分布をプロットして遊ぶ
3d_dirichlet.png
@lithtle
lithtle / range.rb
Created November 5, 2012 07:23
python の range みたいな。(yield の練習)
#! /usr/bin/env ruby -Ku
# -*- coding:utf-8 -*-
def range(s, e, jump=1)
(s...e).step(jump) do |i|
yield i
end
end
# test
@lithtle
lithtle / calc_weight.rb
Created November 4, 2012 11:26
elona、羽の生えた巻物シミュレータ?のようなもの
#! /usr/bin/env ruby -Ku
# -*- coding: utf-8 -*-
# なるべく少ない回数で指定した重さのものをある一定の重さ(>=1.0)以上にするのに
# 必要な羽の生えた巻物の試行回数と重さを計算する
# 祝福羽の生えた巻物と通常時の巻物の重さ軽減倍率
RATIO = {
"blessed" => 0.78,
"normal" => 0.85
@lithtle
lithtle / arith_4.rb
Created October 23, 2012 11:49
再挑戦四則演算
# -*- coding:utf-8 -*-
Inf = 1.0 / 0
class Operator
def initialize(a, b)
@left = a
@right = b
end
attr_reader :left, :right
rspec の練習
http://d.hatena.ne.jp/t-wada/20100228/p1 より
#! /usr/bin/ruby -Ku
# -*- coding:utf-8 -*-
# 突然の死(AA略 を表示して遊ぶ
#
# Date:: 2012-06-07
# Author:: lithtle
# Copyright:: copyright (c) 2012 lithtle
# Example::
# _人人人人_
@lithtle
lithtle / .gitignore
Created May 30, 2012 13:25
maximum likefood estimation and EM algorithm(エディタのインデント幅を2にするのが面倒だったので4のまま)
*~
sample10*
sample100*
sample1000*
sample10000*
sample100000*