Categorize Password as Strong or Weak using Regex in Python

Given a password, we have to categorize it as a strong or weak one. There are some checks that need to be met to be a strong password. For a weak password, we need to return the reason for it to be weak.

Conditions to be fulfilled are:

  • Minimum 9 characters and maximum 20 characters.
  • Cannot be a newline or a space
  • There should not be three or more repeating characters in a row.
  • The same string pattern(minimum of two character length) should not be repeating.
[mai mult...]

Python program to check the validity of a Password

In this program, we will be taking a password as a combination of alphanumeric characters along with special characters, and check whether the password is valid or not with the help of few conditions.

Primary conditions for password validation :

  1. Minimum 8 characters.
  2. The alphabets must be between [a-z]
  3. At least one alphabet should be of Upper Case [A-Z]
  4. At least 1 number or digit between [0-9].
  5. At least 1 character from [ _ or @ or $ ].
[mai mult...]

Check if all digits of a number divide it with Python3

Given a number n, find whether all digits of n divide it or not.

Examples:

Input : 128
Output : Yes
128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.

Input : 130
Output : No

We want to test whether each digit is non-zero and divides the number. For example, with 128, we want to test d != 0 && 128 % d == 0 for d = 1, 2, 8. To do that, we need to iterate over each digit of the number.

[mai mult...]

Python Script for Number of solutions to Modular Equations

Given A and B, the task is to find the number of possible values that X can take such that the given modular equation (A mod X) = B holds good. Here, X is also called a solution of the modular equation.

Examples:

Input : A = 26, B = 2
Output : 6
Explanation
X can be equal to any of {3, 4, 6, 8,
12, 24} as A modulus any of these values
equals 2 i. e., (26 mod 3) = (26 mod 4) 
= (26 mod 6) = (26 mod 8) =Output:2 

Input : 21 5
Output : 2
Explanation
X can be equal to any of {8, 16} as A modulus 
any of these values equals 5 i.e. (21 mod 
8) = (21 mod 16) = 5
[mai mult...]