Editor

A Repeatable Password

#597 · Modules and random · Intermediate · 70 XP · about 12 min

Write make_password(length, seed) that builds a password of length characters with these rules:

  • Every character is a letter, a digit or one of the symbols !@#$%&*.
  • It contains at least one lowercase letter, one uppercase letter, one digit and one symbol.
  • The four kinds are mixed through the password, not always in the same places.
  • The same length and seed always give the same password.

Use a generator of your own, rng = random.Random(seed), and call its methods, such as rng.choice and rng.shuffle. Calling random.seed(seed) instead would reset the shared generator that the rest of the program uses for its own random numbers.

Examples

make_password(12, 7)  # returns a password such as 'q7#Rk2!mWb4z'
make_password(12, 7)  # returns that same password again
make_password(4, 1)   # four characters, one of each kind

Constraints

  • 4 <= length <= 100

Note

The tests check the rules above for many seeds, never one exact password.

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.