Skip to content

Instantly share code, notes, and snippets.

@kota
Created May 31, 2016 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kota/dd2a29031ec32d9f70dbbf3dc669357d to your computer and use it in GitHub Desktop.
Save kota/dd2a29031ec32d9f70dbbf3dc669357d to your computer and use it in GitHub Desktop.
#MAX = 10000000
#n = 10
#m = rand(MAX)
#k = [rand(MAX)] * n
m = 10
k = [1,2,3,4,5,6,7,8,9]
k.combination(4) do |k1,k2,k3,k4|
if k1 + k2 + k3 + k4 == m
puts "YES"
exit
end
end
puts "NO"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment