Skip to content

Instantly share code, notes, and snippets.

@hamajyotan
Created May 22, 2015 18:22
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 hamajyotan/fbe65ca6e313f2ba57fd to your computer and use it in GitHub Desktop.
Save hamajyotan/fbe65ca6e313f2ba57fd to your computer and use it in GitHub Desktop.
Five programming problems every Software Engineer should be able to solve in less than 1 hour
def f *args
args.map(&:to_s).permutation.map { |x| x.join.to_i }.max
end
def f *args
["", "+", "-"].repeated_permutation(args.size-1).each do |op|
args.map(&:to_s).zip(op).join.tap { |s| puts s if eval(s) == 100 }
end
end
@hamajyotan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment