Skip to content

Instantly share code, notes, and snippets.

@srih4ri
Created June 14, 2011 14:34
Show Gist options
  • Save srih4ri/1025013 to your computer and use it in GitHub Desktop.
Save srih4ri/1025013 to your computer and use it in GitHub Desktop.
CheckPassword.rb
#!/usr/bin/env ruby
module PasswordChecker
def check_valid?
if length > 1
(length/2).times { |i|
return false if (self[(i+1..length)].start_with? self[(0..i)])
}
(self[(1..length)]).check_valid?
else
return true
end
end
end
class String
include PasswordChecker
end
input = ARGV[0].chomp
puts input.check_valid? ? "ACCEPTED" : "REJECTED"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment