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
(
a
… z
), uppercase letter (A
… Z
), or digit
(0
… 9
). 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.
Comments
whats wrong with my code
Can someone help me why my code fails on batch 2, case 2 ?? I don't know what could even be wrong??? (I found out what the mistake was...I thought for some reason it needs to be between 8 and 32 characters and not 8 and 12.)
Remember that the password must be between 8 to 12 characters in order to be valid!
a bit of thought and done
My sample works perfectly now if I try it locally, but here there's something it doesn't like at all, and basically it doesn't even start. This has happened since I've tried the new solution where I counted the lower- and uppercase characters and the digits.
I wonder what I'm actually doing wrong. I've tested it as much as possible and all the tests seem to be right. But I'm still failing some of the tests here.
When and what are the conditions for Valid and Invalid
Can it take symbols such as *&^%$#@!?
I am getting an memory limit exceeded error with 22MB, but the spec says 30 MB is the limit. Any ideas why?
https://xkcd.com/936/
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!
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.
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.
Your if statement is wrong.
abcABC123
will be invalid, even though it actually is valid.Thanks for the response, I fixed that problem and now I have others :-))
Hey, could someone tell me why I'm getting an error on my code?
A few things:
Hope this helps :)
This saved me!! Thank you so much!
Thank you! I think I got it now.
I don't know what's wrong with my code, can someone help?
You might wanna try the sample test cases.
Could someone tell me why does my code not work?
There's three issues with your code:
i.isupper()
instead ofi.isupper
; since its calling a function you need the bracketsi in password
means thati
is either a character, or a string, sincepassword
was a string. It is never an integer, try usingi.isdigit()
ori.isnumeric()
instead.Fixing these issues should get you full AC :)
Hello, does anyone know why my code is not working?
You need to add brackets around the statement:
or, you can write it much more concisely as:
lol can't wrap my head around that seems to be the issue with my code. need and instead of or. sorry about that.
len(password) >= 8 and len(password) <= 12
how password length can be >= 8 AND <= 12 at the same time?
Or much more concisely as: 8 <= Len(password) <= 12
Notice how the above is almost syntactically the same as: 8 ≤ length of password ≤ 12 (its form when written with math syntax)