Skip to content

Instantly share code, notes, and snippets.

View daniel-g's full-sized avatar

Daniel Gaytán daniel-g

View GitHub Profile
@daniel-g
daniel-g / buggy_outcome.rb
Created November 27, 2012 16:13
Outcome for the same influent changes
Influent.find(349).outcomes(1)
=> "{ \"outcome\" : { \"rank\" : 1, \"satisfaction\" : 1, \"options\" : [ { \"id\" : \"214\" }, { \"id\" : \"216\" }, { \"id\" : \"223\" }, { \"id\" : \"225\" }, { \"id\" : \"226\" }, { \"id\" : \"227\" } ] } }"
Influent.find(349).outcomes(1)
=> "{ \"outcome\" : { \"rank\" : 1, \"satisfaction\" : 1, \"options\" : [ { \"id\" : \"223\" } ] } }"
require 'prime'
def divisors_count(n)
Prime.prime_division(n).reduce(1) do |mem, prime_factor|
mem * (prime_factor[1] + 1)
end
end
def triangle_number(n)
(n)*(n+1)/2