completed 2017.04.2
This commit is contained in:
		
							parent
							
								
									0349bf6d0e
								
							
						
					
					
						commit
						f6089b46b3
					
				
							
								
								
									
										25
									
								
								2017/04/2passphrases.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								2017/04/2passphrases.py
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,25 @@ | ||||
| #!/usr/bin/env python3 | ||||
| # passphrase validity checker. see file `notes` for details | ||||
| # only strings with NO DUPLICATE words are valid | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     total_valid = 0 | ||||
| 
 | ||||
|     def check_for_duplicates(list): | ||||
|         has_duplicate = False | ||||
|         for i in range(1, len(list)): | ||||
|             for j in range(i): | ||||
|                 if list[i] == list[j]: | ||||
|                     has_duplicate = True | ||||
|         return has_duplicate | ||||
| 
 | ||||
|     with open("input", "r", encoding="utf-8") as passphrase_input: | ||||
|         for passphrase in passphrase_input: | ||||
|             is_valid = False | ||||
|             passwords = passphrase.split() | ||||
|             for i in range(len(passwords)): | ||||
|                 passwords[i] = "".join(sorted(passwords[i])) | ||||
|             is_valid = not check_for_duplicates(passwords) | ||||
|             if is_valid: | ||||
|                 total_valid += 1 | ||||
|     print(total_valid) | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user