I hereby claim:
- I am p1366 on github.
- I am p1366 (https://keybase.io/p1366) on keybase.
- I have a public key ASCRKzujDR7HVs_qkzfobKxR6L0IPB11lHF53FHWi1OxjAo
To claim this, I am signing this object:
N = 8 | |
GOOD = 4 | |
CHECKS = [ | |
[1, 2], | |
[1, 3], | |
[2, 3], | |
[2, 4], | |
[5, 6], | |
[7, 8], |
cups = (0..12).to_a | |
combs = cups.combination(4).to_a | |
res = [] | |
while combs.any? | |
res << combs.shift | |
combs.each_with_index do |e, i| | |
next unless e | |
res.last.combination(2).each do |(a1, a2)| | |
if e.include?(a1) && e.include?(a2) |
def win(d1, d2) | |
d1.reduce(0) do |sum, x| | |
sum + d2.count { |y| x > y } - d2.count { |y| x < y } | |
end | |
end | |
dice = (1..6).to_a.repeated_combination(6).to_a | |
wins = dice.map { |a| dice.map { |b| win(a, b) } } |
# -*- frozen-string-literal: true -*- | |
# Syntax sugar module | |
module Db | |
extend self | |
delegate :transaction, to: ApplicationRecord | |
def sanitize( *args ) | |
ApplicationRecord.send( :sanitize_sql, args ) | |
end |
namespace :deploy do | |
desc 'Start application upstart service.' | |
task :service_start do | |
on roles(:all) do | |
execute :sudo, 'service', app_name, 'start' | |
end | |
end | |
desc 'Stop application upstart service.' | |
task :service_stop do |
products = Hash.new { 0 } | |
2.upto(100) do |a| | |
a.upto(100) do |b| | |
product = a * b | |
products[product] += 1 | |
end | |
end | |
products = products.select { |_, count| count > 1 } |
# Есть ненормальная монетка, в которой вероятность выпадения орла и решки различны. | |
# Какие именно эти вероятности неизвестно. | |
# Вопрос, как с помощью этой монетки смоделировать событие - выпадение целого числа от 1 до 8. | |
# Чтобы все исходы были равновероятны. | |
require 'benchmark' | |
class BadCoin | |
def initialize(a) | |
@a = a | |
end |
require 'active_support/all' | |
module Quering | |
extend ActiveSupport::Concern | |
included do | |
cattr_accessor(:_query_tail) { {} } | |
include Paginable | |
include Sortable |
I hereby claim:
To claim this, I am signing this object:
class Simalation | |
TOPICS = (0..21).to_a | |
N = 1_000_000 | |
def call( k ) | |
success = 0 | |
N.times do | |
success += 1 if sample.any?{ |e| e < k } | |
end | |
success.to_f / N |