dxnge

Task 9

Sep 16th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. a = input().split()
  2. a = list(map(int, a))
  3. f = [str(a[0]), str(a[1])+'x', str(a[2])+'y']
  4. x = []
  5. if f[0] != '0':
  6.     x.append(f[0])
  7. if f[1][0] != '0':
  8.     x.append(f[1])
  9. if f[2][0] != '0':
  10.     x.append(f[2])
  11.  
  12. if len(x) == 3:
  13.     x[-2] = x[-2].replace('-1x', '-x').replace('1x', 'x')
  14.     x[-1] = x[-1].replace('-1y', '-y').replace('1y', 'y')
  15.     if x[1][0] != '-':
  16.         x[1] = ('+' + x[1])
  17.     if x[2][0] != '-':
  18.         x[2] = ('+' + x[2])
  19.     print(''.join(x))
  20.    
  21. if len(x) == 2:
  22.     x[-2] = x[-2].replace('-1x', '-x').replace('1x', 'x')
  23.     x[-1] = x[-1].replace('-1y', '-y').replace('1y', 'y')
  24.     if x[1][0] != '-':
  25.         x[1] = ('+' + x[1])
  26.     print(''.join(x))
  27. if len(x) == 1:
  28.     if x[0] =='1x' or x[0] == '-1x':
  29.         x[0] = x[0].replace('-1x', '-x').replace('1x', 'x')
  30.     else:
  31.         x[0] = x[0].replace('-1y', '-y').replace('1y', 'y')
  32.     print(''.join(x))
  33. if x == []:
  34.     print(0)
Advertisement
Add Comment
Please, Sign In to add comment