Upload solution.py
This commit is contained in:
		
							parent
							
								
									e2a2d2c408
								
							
						
					
					
						commit
						f76fc1af01
					
				
							
								
								
									
										20
									
								
								battleship/solution.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								battleship/solution.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | |||||||
|  | 
 | ||||||
|  | msg = "EYTAQCTQRA{EYTCTARYEYRCTAEARYWQRCWQEYTQQHTQQHEQWAQHEYTY}" | ||||||
|  | 
 | ||||||
|  | pfix = "EYTAQCTQRA" | ||||||
|  | flag  = "EYTCTARYEYRCTAEARYWQRCWQEYTQQHTQQHEQWAQHEYTY" | ||||||
|  | 
 | ||||||
|  | board = [['Q', 'W', 'E', 'R', 'T'], ['Y', 'U', 'I', 'O', 'P'], ['A', 'S', 'D', 'F', 'G'], ['H', 'K', 'L', 'Z', 'X'], ['C', 'V', 'B', 'N', 'M']] | ||||||
|  | cols = ['Q', 'Y', 'A', 'H', 'C'] | ||||||
|  | flat = sum(board, []) | ||||||
|  | 
 | ||||||
|  | def secret(enc): | ||||||
|  |     out = '' | ||||||
|  |     pairs = [enc[i:i+2] for i in range(0, len(enc), 2)] | ||||||
|  |     for p in pairs: | ||||||
|  |         col = flat.index(p[0]) % 5 | ||||||
|  |         row = cols.index(p[1]) | ||||||
|  |         out += board[row][col] | ||||||
|  |     return out | ||||||
|  | 
 | ||||||
|  | print(secret(pfix), '{', secret(flag), '}') | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user