Skip to content

Instantly share code, notes, and snippets.

@elissonmichael
Last active April 14, 2019 16:41

Revisions

  1. elissonmichael revised this gist Apr 14, 2019. No changes.
  2. elissonmichael revised this gist Apr 14, 2019. No changes.
  3. elissonmichael revised this gist Apr 14, 2019. 1 changed file with 0 additions and 0 deletions.
    Binary file added charada.jpeg
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  4. elissonmichael created this gist Apr 14, 2019.
    16 changes: 16 additions & 0 deletions brute_force.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    (100..999).each do |x|
    (100..999).each do |y|
    (100..999).each do |z|
    soma = x + y + z
    condicao1 = soma.digits.size == 3
    condicao2 = soma.digits.uniq.size == 1
    n = soma.digits.uniq.first
    condicao3 = n == x.digits.first && n == y.digits.first && n == z.digits.first
    condicao4 = x.digits.last == y.digits.last && y.digits.last == z.digits.last
    condicao5 = x.digits[1] == y.digits[1] && y.digits[1] == z.digits[1]
    if condicao1 && condicao2 && condicao3 && condicao4 && condicao5
    puts "#{x} + #{y} + #{z} = #{soma}"
    end
    end
    end
    end