Created
September 12, 2019 14:25
-
-
Save BrunoxD/7d44713c2007c2eefb53d09f0588ab0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://pypi.org/project/validate-docbr/ | |
| from validate_docbr import CPF | |
| cpf = CPF() | |
| """ | |
| Quantos CPFs existem com os mesmos últimos 6 dígitos? | |
| Y - Dígitos conhecidos | |
| X - Dígitos a serem descobertos | |
| XXX.XXY.YYY-YY | |
| """ | |
| cpfs = [] | |
| last_digits = cpf.generate()[5:] | |
| start_size = 11 - len(last_digits) | |
| # Validando cada um dos CPFs. | |
| [cpfs.append(f"{i:0{start_size}}" + last_digits) | |
| for i in range(int("9"*start_size)) | |
| if(cpf.validate(f"{i:0{start_size}}" + last_digits))] | |
| # Quantidade de CPFs descobertos. | |
| print(f"{len(last_digits)} Dígitos: {len(cpfs)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment