x 面のダイスがある。それを n 回振り、ダイスの数ごとに出た回数をカウントする。
この時、出た回数が 1 回の目の種類と 2 回以上の目の種類の比率が
1:1 となるには x は何である必要があるか。n を使って表せ。
x = 12 (12 面ダイス)
n = 10 (10 回振った)
# enum 定義の後で include すること。 | |
module EnumValueGetter | |
extend ActiveSupport::Concern | |
included do | |
defined_enums.keys.each do |name| | |
define_method("#{name}_value") { self[name] } | |
end | |
end | |
end |
ruby '2.3.0' | |
source 'https://rubygems.org' | |
gem 'rails', '~> 5.0.0.beta2' |
const int LED4 = 13; | |
const int LED3 = 12; | |
const int LED2 = 11; | |
const int LED1 = 10; | |
const int BTN1 = 7; | |
int old_input = LOW; | |
int new_input = LOW; | |
int count = 0; | |
export PROMPT=$'%{$fg[magenta]%}|%c|*\'-\'\) %{$reset_color%}' | |
export PROMPT=$'|%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[red]%}%30<...<%~%<<%{$reset_color%}|*\'-\'\) %(!.#.$) ' |
// ==UserScript== | |
// @name Highlight followers | |
// @namespace quanon | |
// @version 0.1 | |
// @author QUANON | |
// @match https://twitter.com/following | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js | |
// @grant none | |
// ==/UserScript== |
calc_rems = fn (n) -> {rem(n, 3), rem(n, 5), n} end | |
fizzbuzz = fn | |
{0, 0, _} -> "FizzBuzz" | |
{0, _, _} -> "Fizz" | |
{_, 0, _} -> "Buzz" | |
{_, _, n} -> n | |
end | |
IO.inspect(1..50 |> Enum.map(calc_rems) |> Enum.map(fizzbuzz)) |
module ArrayExtention | |
def reject_if(&block) | |
rejected = [] | |
delete_if do |value| | |
if block.call(value) # or if yield | |
rejected << value | |
true # なくてもいいけど僕の好み的に明示的に true を返したかった。 | |
end | |
end |
module Extension::ActiveRecordExtension | |
extend ActiveSupport::Concern | |
included do | |
# (参考) | |
# OR operator in WHERE clause with Arel in Rails 4.2 | |
# http://stackoverflow.com/questions/27627390/or-operator-in-where-clause-with-arel-in-rails-4-2 | |
# | |
# ActiveRecord::QueryMethods::WhereChain | |
# https://github.com/rails/rails/blob/v4.2.1/activerecord/lib/active_record/relation/query_methods.rb |
// ==UserScript== | |
// @name j-motto Userscript | |
// @namespace quanon | |
// @version 0.1.0 | |
// @author QUANON | |
// @include https://gws45.j-motto.co.jp/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js | |
// @grant none | |
// ==/UserScript== |