WC '17 Contest 3 J3 - Uncrackable

View as PDF

Submit solution

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

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 8 and 12 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 100 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


Sample Output 1


Sample Input 2


Sample Output 2


Sample Explanations

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

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


  • 0
    sanj15  commented on Dec. 29, 2022, 2:20 a.m.

    whats wrong with my code

  • 0
    Yoltzuin  commented on Dec. 24, 2022, 4:48 p.m. edit 4

    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.)

  • 0
    mehulkschool  commented on Dec. 20, 2022, 1:51 p.m.

    Remember that the password must be between 8 to 12 characters in order to be valid!

  • 0
    PolstarD  commented on Dec. 15, 2022, 12:06 p.m.

    a bit of thought and done

  • 0
    cretin  commented on Nov. 30, 2022, 2:51 a.m.

    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.

  • 0
    cretin  commented on Nov. 28, 2022, 4:56 p.m.

    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.

  • 0
    Hackerman_567  commented on Nov. 9, 2022, 8:59 p.m.

    When and what are the conditions for Valid and Invalid

  • 1
    arvinaz  commented on Oct. 11, 2022, 8:54 p.m.

    Can it take symbols such as *&^%$#@!?

  • 0
    mostar1661  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?

  • 4
    Payne  commented on April 18, 2022, 1:35 a.m.

  • 1
    Dukkering  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!

  • 4
    aikon  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.

  • -1
    nubblet  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.

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

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

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

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

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

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

    • 2
      Spitfire720  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 :)

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

        This saved me!! Thank you so much!

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

        Thank you! I think I got it now.

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

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

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

      You might wanna try the sample test cases.

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

    Could someone tell me why does my code not work?

    • 2
      uselessleaf  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 :)

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

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

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

      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

      • 0
        masajjad  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.

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

        len(password) >= 8 and len(password) <= 12

        how password length can be >= 8 AND <= 12 at the same time?

      • 0
        Stringvalues56  commented on Feb. 11, 2022, 2:12 p.m.

        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)