Skip to content

Instantly share code, notes, and snippets.

@HelixSpiral
Created May 19, 2014 01:18
Show Gist options
  • Save HelixSpiral/aee70397805f36725217 to your computer and use it in GitHub Desktop.
Save HelixSpiral/aee70397805f36725217 to your computer and use it in GitHub Desktop.
How many integers between 1500 and 8000 (inclusive) contain no repeated digits?
#!/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