Advertisement
Robertogram

Corret implicação python

May 19th, 2022
518
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. i1 = 0
  2. i2 = 0
  3.  
  4. for x in range(0, 255):
  5.     binany = format(x, "b")
  6.     binany = binany.zfill(8)
  7.     l = len(binany) - 1
  8.     if (binany[0] == '0' and binany[1] == '1'):
  9.         i1 += 1
  10.     if (binany[l-1] == '1' and binany[l] == '0'):
  11.         i1 += 1    
  12.        
  13.     if ((binany[0] == '0' and binany[1] == '1') or (binany[l-1] == '1' and binany[l] == '0')):
  14.         i2 += 1
  15.        
  16. print(i1)
  17. print(i2)
  18.  
Advertisement
RAW Paste Data Copied
Advertisement