Skip to content

Instantly share code, notes, and snippets.

@linc01n
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save linc01n/9210768 to your computer and use it in GitHub Desktop.

Select an option

Save linc01n/9210768 to your computer and use it in GitHub Desktop.
Interview question
#!/usr/bin/env ruby
# It is a base 36 number system
# 6 digit means 36^6 different combination
0.upto(36 ** 6 - 1) do |n|
# to_s(36) convert the number to base 36 system
# rjust(6, '0') pad 0 for the number less than 6 digit
puts n.to_s(36).rjust(6, '0')
end

###[Interview question]:

Write a program/pseudo code which list out all the possible combinations of this regular expression:

[0-9a-z]{6}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment