Skip to content

Instantly share code, notes, and snippets.

@gingeleski
Created January 22, 2015 21:26
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 gingeleski/28265d2f554f9806f427 to your computer and use it in GitHub Desktop.
Save gingeleski/28265d2f554f9806f427 to your computer and use it in GitHub Desktop.
Finds the next date when all digits in the date sequence will be unique.
# Finds the next date when all digits in the date sequence will be unique.
require "date"
day_test = Date.today
while true
day_test = day_test.next
query = day_test.year.to_s
query << "0" if day_test.month < 10
query << day_test.month.to_s
query << "0" if day_test.day < 10
query << day_test.day.to_s
break if ("0".."9").all?{|c| query.count(c) <= 1}
end
puts day_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment