Created
May 19, 2014 01:18
-
-
Save HelixSpiral/aee70397805f36725217 to your computer and use it in GitHub Desktop.
How many integers between 1500 and 8000 (inclusive) contain no repeated digits?
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
#!/usr/bin/env ruby | |
# Author: Shawn Smith | |
# Purpose: Do nins math work | |
# Problem: How many integers between 1500 and 8000 (inclusive) contain no repeated digits? | |
total = 0 | |
for x in 1500..8000 do | |
number = x.to_s | |
number_array = number.split('') | |
if number_array.uniq.length == number_array.length | |
total += 1 | |
end | |
puts total | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment