## WC '17 Contest 3 J3 - Uncrackable

View as PDF

Points: 5
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
##### Woburn Challenge 2017-18 Round 3 - Junior Division

You'd like to register an account on an extremely entertaining website. You've already selected a username, but it seems that the requirements for choosing a password are quite strict, in order to completely protect your account from being hacked into. The password must be a string between and characters long (inclusive), such that every character is either a lowercase letter (az), uppercase letter (AZ), or digit (09). Furthermore, it must contain at least three lowercase letters, at least two uppercase letters, and at least one digit.

You've got a potential password in mind, a non-empty string made up of at most characters, each of which is a lowercase letter, uppercase letter, or digit. Rather than entering the password into the site and risking rejection, you'd like to determine for yourself whether or not your password would validly satisfy all of the rules.

#### Input Specification

The first and only line of input consists of a single string, the password.

#### Output Specification

Output a single string, either Valid if the password is valid, or Invalid otherwise.

#### Sample Input 1

PassW0rd

#### Sample Output 1

Valid

#### Sample Input 2

CorrectHorseBatteryStaple

#### Sample Output 2

Invalid

#### Sample Explanations

In the first case, the password has characters, with lowercase letters, uppercase letters, and digit, meaning that all of the rules are satisfied.

In the second case, the password has two issues - it's more than characters long, and it doesn't contain at least one digit.

• commented on May 11, 2022, 7:58 p.m.

I am getting an memory limit exceeded error with 22MB, but the spec says 30 MB is the limit. Any ideas why?

• commented on April 18, 2022, 1:35 a.m.
• commented on April 1, 2022, 2:24 a.m.

Be smarter than me. Don't accidentally spend an hour trying to figure out why your code won't work only to realize you had set print = "Valid" / "Invalid" instead of print("Valid") / ("Invalid").

Just a friendly reminder to look over even the things you already know that you know!

• commented on March 22, 2022, 8:15 a.m.

The requirement "...such that every character is either a lowercase letter (a … z), uppercase letter (A … Z), or digit (0 … 9)." doesn't seem to be checked. One of my solutions was accepted without even checking for illegal characters at all ;-)

Furthermore, in Python, don't rely on isupper() and islower(), since they are locale-dependent for 8-bit strings, e.g. 'Ä'.isupper == True which means it would be counted as valid when only A-Z should be allowed for upper case characters.

• commented on Feb. 1, 2022, 4:34 a.m. edit 2

Hello, does anyone know why my code is not working? I tried a few test cases but still I can't find out the problem. Test cases were with all lower, upper, digits, and with the character length all gave "Invalid". But still I 20/24 points.

• commented on Feb. 1, 2022, 8:17 a.m.

Your if statement is wrong. abcABC123 will be invalid, even though it actually is valid.

• commented on Feb. 1, 2022, 9:08 a.m.

Thanks for the response, I fixed that problem and now I have others :-))

• commented on Jan. 8, 2022, 7:19 p.m.

Hey, could someone tell me why I'm getting an error on my code?

• commented on Jan. 9, 2022, 11:22 a.m.

A few things:

1. You cannot use the exit() function, because DMOJ disallows it. Also, if you're going to import something, import it at the beginning of your code.
2. Your code for counting the digits is wrong
3. Your elif statements could be else statements
4. Your indenting gotta get fixed

Hope this helps :)

• commented on Feb. 17, 2022, 3:12 a.m.

This saved me!! Thank you so much!

• commented on Jan. 9, 2022, 1:33 p.m.

Thank you! I think I got it now.

• commented on Jan. 8, 2022, 9:28 a.m. edit 3

I don't know what's wrong with my code, can someone help?

• commented on Jan. 8, 2022, 1:05 p.m.

You might wanna try the sample test cases.

• commented on Nov. 29, 2021, 12:47 a.m.

Could someone tell me why does my code not work?

• commented on Nov. 29, 2021, 10:01 a.m. edit 2

There's three issues with your code:

1. Line 8: should be i.isupper() instead of i.isupper; since its calling a function you need the brackets
2. Line 10: not exactly too sure, but i in password means that i is either a character, or a string, since password was a string. It is never an integer, try using i.isdigit() or i.isnumeric() instead.
3. Line 15: double check it

The password must be a string between 8 and 12 characters long (inclusive)

Fixing these issues should get you full AC :)

• commented on Sept. 30, 2020, 2:45 a.m.

Hello, does anyone know why my code is not working?

• commented on Sept. 30, 2020, 2:09 p.m. edited

You need to add brackets around the statement:

len(password) == 8 or len(password) == 9 or len(password) == ...

or, you can write it much more concisely as:

len(password) >= 8 and len(password) <= 12
• commented on Aug. 31, 2022, 8:14 p.m.

lol can't wrap my head around that seems to be the issue with my code. need and instead of or. sorry about that.

• commented on Aug. 31, 2022, 7:47 p.m.