completed 2017.04.1
This commit is contained in:
		
							parent
							
								
									e01bd4c86d
								
							
						
					
					
						commit
						0349bf6d0e
					
				
							
								
								
									
										23
									
								
								2017/04/1passphrases.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										23
									
								
								2017/04/1passphrases.py
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,23 @@ | ||||
| #!/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() | ||||
|             is_valid = not check_for_duplicates(passwords) | ||||
|             if is_valid: | ||||
|                 total_valid += 1 | ||||
|     print(total_valid) | ||||
							
								
								
									
										7
									
								
								2017/04/notes
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								2017/04/notes
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| high-entropy passphrases! | ||||
| 
 | ||||
| passphrases have all-lowercase space-separated strings of words. | ||||
| valid passphrases have NO DUPLICATE words. | ||||
| 
 | ||||
| how many of the provided passphrases ARE VALID, i.e., have NO DUPLICATE words? | ||||
| provided passphrases are in file `input` | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user