Skip to content

Instantly share code, notes, and snippets.

@simonszu
Created June 16, 2015 17:40
Show Gist options
  • Save simonszu/a68d1ede23554dae5bbb to your computer and use it in GitHub Desktop.
Save simonszu/a68d1ede23554dae5bbb to your computer and use it in GitHub Desktop.
A script to bruteforce a task for the dropbox spacerace
#! /usr/bin/env ruby
99999.times do |i|
test = i+1
puts "Teste #{test}"
array = test.to_s.split('')
condition1 = ((array[0].to_i * array[1].to_i) == 24)
condition2 = ((array[3].to_i * 2) == array[1].to_i)
condition3 = ((array[3].to_i + array[4].to_i) == (array[0].to_i + array[2].to_i))
condition4 = ((array[0].to_i + array[1].to_i + array[2].to_i + array[3].to_i + array[4].to_i) == 26)
condition5 = ((array[1].to_i + array[2].to_i) == array[4].to_i)
puts "Bedingung 1: #{condition1}"
puts "Bedingung 2: #{condition2}"
puts "Bedingung 3: #{condition3}"
puts "Bedingung 4: #{condition4}"
puts "Bedingung 5: #{condition5}"
if (condition1 && condition2 && condition3 && condition4 && condition5)
puts "Die Zahl ist #{test}"
Process.exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment