about | help | code help+videos | done | prefs |
Write a method that returns the "strength" of a password according to a particular scheme explained here. The input parameter 'passwrd' will be a user's password. Return the "strength" based on several factors. Those factors include the length of the password, how many times it changes from an alphabetic character to a non-alphabetic character of vis-versa, and how many times the special symbols "#", "$", and "%" appear. The strength is based on each of these factors in the following ways: For every character over 10 in the password, the strength goes up by 1. Each occurrence of "#", "$", or "%" increases the strength by 1. Each time the password changes from alphabetic to non-alphabetic or from non-alphabetic to alphabetic increases the strength by 1. For example, "Once#I%ran45miles" has a strength of 15. This string has 17 characters, so there are 7 characters over 10. Those 7 extra characters are worth a point each. So far the strength is 7. We also have two special symbols, so now the strength is 9. There are also 6 transitions from or to alphabetic characters, for a grand total of a strength of 15. The transitions are from "e" to "#", from "#" to "I", from "I" to "%", from "%" to "r", from "n" to "4", and from "5" to "m". There is also a single bonus point if your password STARTS with a non-alphabetic character. Look at the test data for more examples. test2021_01_15_SLHL_passwordStrength("password") → 0 test2021_01_15_SLHL_passwordStrength("alksdfj32") → 1 test2021_01_15_SLHL_passwordStrength("35dsfa3425") → 3 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 250
Copyright Nick Parlante 2017 - privacy