Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Coding Challenge #2 - Passwords

    Coding Challenges!
    3
    5
    436
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      LucasJG25 last edited by LucasJG25

      FUZE Coding Challenge #2
      Hi everyone and welcome to the 2nd challenge. The rules are:

      1. Post your code below
      2. There will be 2 tasks per challenge, a Beginners challenge and an Advanced challenge. Anyone can participate in any one of them or both tasks.
      3. We are always open to suggestions!
      4. Have fun coding!!

      TASK #1
      LEVEL: Beginner
      Given a string, return that string with all its words reversed while maintaining the spaces between them.
      Example:
      "Hello world" -> "olleH dlrow"

      TASK #2
      LEVEL: Advanced
      Password checker:
      A password (Which is a string) must have 1 capitalized letter, 5 common letters and 1 - 3 numbers.
      Example:

      1. Abdjfk1 -> accepted
      2. dkDj2fd -> accepted
      3. DHrsfj4 -> rejected
      4. 14fdsDf -> rejected
      5. 4Ddsdfq32 -> accepted
      1 Reply Last reply Reply Quote 4
      • Ben 2.0
        Ben 2.0 last edited by

        Do we post actual code or IDs? Sorry, just a little confused. πŸ˜•

        L 1 Reply Last reply Reply Quote 0
        • L
          LucasJG25 @Ben 2.0 last edited by LucasJG25

          @ben-2-0 You'll need to post the actual code below. Not the ID's.

          1 Reply Last reply Reply Quote 0
          • Ben 2.0
            Ben 2.0 last edited by Ben 2.0

             caps = ["A", "B", etc...]
             norms = ["a", "b", etc...]
             nums = ["0", "1", etc...]
            
             loop
                  clear()
            
                  pass = input("Enter a Password")
                  clear()
            
                  secure = chechsecurity(pass)
            
                  if secure == 1 then 
                       print("Secure")
                  else
                       print("Not Secure")
                  endif
            
                  update()
                  sleep(2)
             repeat
            
             function checksecurity(password)
                  result = false
            
                  totalcaps = 0 
                  totalnorms = 0
                  totalnums = 0
            
                  for i = 0 to len(password) loop
                       for k = 0 to len(caps) loop
                            if password[i] == caps[k] then
                                 totalcaps += 1
                            endif
                       repeat
                  repeat
            
                  // use same logic for norms and nums to count amout of each
            
                  if totalcaps == 1 and totalnorms == 5 then
                       if totalnums == 1 or totalnums == 2 or totalnums == 3 then
                            result = true
                       endif
                  endif
             return result
            

            Could probably do this better but hope it makes sense. This was fun to do so thanks for posting it!

            1 Reply Last reply Reply Quote 2
            • vinicity
              vinicity F last edited by vinicity

              A recursive solution for TASK #1:

              B6388EEC-9A97-4589-A9B5-2AA67D843C14.jpeg

              Recursive solutions are probably not the best way to do things, but they are so much fun to write. Elegant solutions for a more civilised age!

              I’ll skip the other task, since it seems to me that it’s hard to come up with any solution that isn’t just loops and counters. But I would be happy to be proved wrong about that! ;)

              1 Reply Last reply Reply Quote 3
              • First post
                Last post