Skip to content

Instantly share code, notes, and snippets.

@hagiyat
Created June 2, 2015 01:50
Show Gist options
  • Save hagiyat/3512625378966bcfcbd4 to your computer and use it in GitHub Desktop.
Save hagiyat/3512625378966bcfcbd4 to your computer and use it in GitHub Desktop.
# No.4
list = [50, 2, 1, 9]
list.sort_by(&:to_s).reverse.join
# No.5
[*2..9].reduce(['1']) do
|res, v| res.map { |r| ['', ' + ', ' - '].map { |oper| "#{r}#{oper}#{v}" } }.flatten
end.select { |v| eval(v) == 100 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment