Sichanov

barcode_generator

Dec 11th, 2021
1,801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.33 KB | None | 0 0
  1. start_barcode = int(input())
  2. end_barcode = int(input())
  3. start_barcode_string = str(start_barcode)
  4. end_barcode_string = str(end_barcode)
  5. if int(start_barcode_string[3]) % 2 == 0:
  6.     start_barcode += 1
  7. for each_barcode in range(start_barcode, end_barcode + 1, 2):
  8.     string_barcode = str(each_barcode)
  9.     a = int(string_barcode[0])
  10.     b = int(string_barcode[1])
  11.     c = int(string_barcode[2])
  12.     d = int(string_barcode[3])
  13.     if a % 2 == 1 and b % 2 == 1 and c % 2 == 1 and d % 2 == 1:
  14.         if start_barcode_string[0] <= str(a) <= end_barcode_string[0]:
  15.             if start_barcode_string[1] <= str(b) <= end_barcode_string[1]:
  16.                 if start_barcode_string[2] <= str(c) <= end_barcode_string[2]:
  17.                     if start_barcode_string[3] <= str(d) <= end_barcode_string[3]:
  18.                         print(string_barcode, end=' ')
  19. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  20. range_start = int(input())
  21. range_end = int(input())
  22.  
  23. range_start_as_str = str(range_start)
  24. range_end_as_str = str(range_end)
  25.  
  26. for barcode in range(range_start, range_end + 1):
  27.     is_valid_barcode = True
  28.     barcode_as_str = str(barcode)
  29.     for index, digit in enumerate(barcode_as_str):
  30.         if int(digit) % 2 == 0:
  31.             is_valid_barcode = False
  32.             break
  33.         if int(digit) < int(range_start_as_str[index]):
  34.             is_valid_barcode = False
  35.             break
  36.         if int(digit) > int(range_end_as_str[index]):
  37.             is_valid_barcode = False
  38.             break
  39.  
  40.     if is_valid_barcode:
  41.         print(barcode, end=' ')
  42. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  43. start = int(input())
  44. end = int(input())
  45. thousands_start = start // 1000
  46. hundreds_start = start // 100 % 10
  47. tens_start = start // 10 % 10
  48. units_start = start % 10
  49. thousands_end = end // 1000
  50. hundreds_end = end // 100 % 10
  51. tens_end = end // 10 % 10
  52. units_end = end % 10
  53. for number1 in range(thousands_start, thousands_end + 1):
  54.     for number2 in range(hundreds_start, hundreds_end + 1):
  55.         for number3 in range(tens_start, tens_end + 1):
  56.             for number4 in range(units_start, units_end + 1):
  57.                 if number1 % 2 == 1 and number2 % 2 == 1 and number3 % 2 == 1 and number4 % 2 == 1:
  58.                     print(f'{number1}{number2}{number3}{number4}', end=' ')
Advertisement
Add Comment
Please, Sign In to add comment