Skip to content

Instantly share code, notes, and snippets.

@FranckyU
Created December 15, 2014 13:39
Show Gist options
  • Save FranckyU/26a46a0d0d7eaa375d6d to your computer and use it in GitHub Desktop.
Save FranckyU/26a46a0d0d7eaa375d6d to your computer and use it in GitHub Desktop.
Brute force bitwise number generator
->(m, n){->(collection){collection[rand(collection.size)]}.call(("1"*n).to_i(2).up_to(("1"*m).to_i(2)).select{|i| i.to_s(2).gsub('0', '') == "#{'1'*n}"})}.call(m_value, n_value).to_i(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment