So, like the title says, today you are going to guess my password (sort of). You need to make a big long list of every possible password I might be using on my 4 digit online vault.


  • It could contain any 26 letters of the alphabet in UPPER CASE.
  • It could contain any numbers 0-9.
  • So, basically, each digit has 36 different possibilities.
  • There are four digits.
  • Repeat characters are allowed! (Hint: Sample space is 1,679,616 or 36^4)

Program Requirements/Rules:

  • Program must output all possible answers to a text file or to the console, line by line. (One answer per line)
  • You may not make use of any premade tools for this (Idk if any exist, but just in case)
  • It must generate all 36^4 possible answers

Remember, this is a Code-golf. So shortest answer in bytes wins. Please use the standard title format of ##Language Name, Byte Size. Even if there is a winner, feel free to post your answer. (It's always fun to see the different solutions in different languages).

Edit: Not a duplicate of sugested, mines has different context, and different paremeters. (I require numbers, duplicate characters, and only UPPERCASE)

  • \$\begingroup\$ I'm not sure if this should be closed as a duplicate of that question; it requires digits as well as letters, so answers can't just be copied over. Then again, it is pretty similar... \$\endgroup\$ Dec 1 '15 at 2:27
  • \$\begingroup\$ @ETHproductions yeah, IDK. I think its sort of different. I mean, the practice/methods to solve are similar/same but then the application is different. \$\endgroup\$ Dec 1 '15 at 3:28
  • \$\begingroup\$ Both questions are "Count in base B" for some B. There may be superficial differences, but they're fundamentally the same question. \$\endgroup\$ Dec 1 '15 at 6:58
  • \$\begingroup\$ If it didn't have the word "password" in it, there is now way it could be thought of as a copy of that question. Answer to this question in Perl 6 .say for [X~] (0..35)».base(36)xx 4, answer to the other question is say 'a'.../password/ ( or print "$_ " for 'a'.../password/ if you want it to start printing immediately. ) There is no easy way to answer either question starting out with the answer for the other one. I say remove all mention of the word password, and try to re-open. \$\endgroup\$ Dec 1 '15 at 18:09
  • \$\begingroup\$ @BradGilbertb2gills thank you. Thats what I'm trying to say here... \$\endgroup\$ Dec 2 '15 at 1:34

Pyth - 8 bytes


Try smaller password length online here.

  • \$\begingroup\$ I'm not entirely sure I understand, the output I got when I ran your program is in pairs of two? I said the password is 4 digit. \$\endgroup\$ Dec 1 '15 at 1:49
  • \$\begingroup\$ @AshwinGupta yes, because the online interpreter would reject a program with 36^4 permutations. \$\endgroup\$
    – cat
    Dec 1 '15 at 1:50
  • \$\begingroup\$ Ah wait nevermind, I see, you changed the 4 to 2 for running purposes. Sorry my bad. \$\endgroup\$ Dec 1 '15 at 1:50
  • 6
    \$\begingroup\$ I'm afraid to upvote when your score is 7 777 :) \$\endgroup\$
    – J Atkin
    Dec 1 '15 at 1:50
  • \$\begingroup\$ You are currently the winner unless someone can beat you. Where are the Japt and Seriously guys? They both are short-syntax golfing languages with a chance. \$\endgroup\$ Dec 1 '15 at 2:00

Haskell, 38 Bytes


yeah, it's not gonna beat Pyth. Oh well...

  • 1
    \$\begingroup\$ Don't worry, not much beats Pyth. from what little I've seen here on CodeGolf SE in the last week or so. Still a great answer. \$\endgroup\$ Dec 1 '15 at 1:56
  • \$\begingroup\$ :p too true... I'll take beating another non-golf language for now... \$\endgroup\$ Dec 1 '15 at 1:57
  • \$\begingroup\$ Well, you beat Ruby! @quartata although it was close. 15 Bytes... \$\endgroup\$ Dec 1 '15 at 2:01

Ruby, 64 53 bytes

[*'A'..'Z',*'0'..'9'].repeated_permutation(4){|a|p a}

Probably golfable further, I'm not that good at Ruby.


Not the answer you're looking for? Browse other questions tagged or ask your own question.