Advertisement
nicoviale_

Untitled

Feb 11th, 2024
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. def verify_password(pair):
  2.  
  3.     pw=pair[0]
  4.     hash=pair[1]
  5.  
  6.     chars = sorted(list(pw))
  7.  
  8.     for i in range(0,len(hash)-len(pw)+1):
  9.         appoggio=[]
  10.  
  11.         if hash[i] in chars:
  12.  
  13.             for j in range(i,i+len(pw)):
  14.                 appoggio.append(hash[j])
  15.  
  16.             if sorted(appoggio)==chars:
  17.                 return True
  18.            
  19.  
  20.     return False
  21.  
  22.  
  23. T = int(input())
  24. pairs = []
  25. for _ in range(T):
  26.     P = input()
  27.     H = input()
  28.     pairs.append((P, H))
  29.  
  30.  
  31. for i in range(T):
  32.     if(verify_password(pairs[i])):
  33.         print("1")
  34.     else:  
  35.         print("0")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement