We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defminimumNumber(n,password):# Return the minimum number of characters to make the password strongnumbers="0123456789"lower_case="abcdefghijklmnopqrstuvwxyz"upper_case="ABCDEFGHIJKLMNOPQRSTUVWXYZ"special_characters="!@#$%^&*()-+"not_spl=1not_lower=1not_upper=1not_num=1foriinrange(n):ifnot_numandpassword[i]innumbers:not_num=0elifnot_lowerandpassword[i]inlower_case:not_lower=0elifnot_upperandpassword[i]inupper_case:not_upper=0elifnot_splandpassword[i]inspecial_characters:not_spl=0req_char=not_lower+not_num+not_spl+not_upperifn<6:returnmax(req_char,6-n)else:returnreq_char
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strong Password
You are viewing a single comment's thread. Return to all comments →
Python solution