Skip to content

Instantly share code, notes, and snippets.

@sguzunov
Created February 18, 2018 11:52
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 sguzunov/20029c8aa4adc038b9bc308947b55cd9 to your computer and use it in GitHub Desktop.
Save sguzunov/20029c8aa4adc038b9bc308947b55cd9 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StupidPasswords
{
public class Program
{
public static void Main()
{
int n = int.Parse(Console.ReadLine());
int l = int.Parse(Console.ReadLine());
// For each position [1...5]
for (int i1 = 1; i1 < n; i1++)
{
for (int i2 = 1; i2 < n; i2++)
{
int firstSymbol = i1;
int secondSymbol = i2;
for (int i3 = 0; i3 < l; i3++)
{
for (int i4 = 0; i4 < l; i4++)
{
// The last symbol should starts with a number bigger with 1 than the biggest number from the first two.
int max = firstSymbol > secondSymbol ? firstSymbol : secondSymbol;
for (int i5 = max + 1; i5 <= n; i5++)
{
// Ascii code for 'a'
int aCharCode = 97;
// Get the next ascii code, e.i.
char thirdSymbol = (char)(aCharCode + i3);
char fourthSymbol = (char)(aCharCode + i4);
int fifthSybmbol = i5;
string output = $"{firstSymbol}{secondSymbol}{thirdSymbol}{fourthSymbol}{fifthSybmbol}";
Console.Write(output);
Console.Write(" ");
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment