Last active
March 19, 2016 18:31
-
-
Save pdxwolfy/8d140c536245da09e459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# | |
# Copyright (c) 2016 Pete Hanson | |
def lowest_number(number_list) | |
number_list.map(&:to_s) | |
.permutation | |
.map(&:join) | |
.map(&:to_i) | |
.min | |
end | |
puts lowest_number([23, 550, 1, 80]) # -> 12355080 | |
puts lowest_number([1, 1, 1, 1]) # -> 1111 | |
puts lowest_number([10000, 123, 1890, 11]) # -> 10000111231890 | |
puts lowest_number([1890, 18901]) # -> 189011890 | |
puts lowest_number([12, 33, 11, 9]) # -> 1112339 | |
puts lowest_number([1, 1, 0, 1]) # -> 111 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment