Advertisement
here2share

# rgb_at_sum.py

Dec 30th, 2023
1,472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. # rgb_at_sum.py
  2.  
  3. combos = []
  4. def rgb_at_sum(target_sum):
  5.     min_g = target_sum - 256
  6.     for r in range(256):
  7.         for g in range(min_g, target_sum - r + 1):
  8.             b = target_sum - r - g
  9.             rgb = r, g, b
  10.             print(rgb, sum(rgb), [target_sum])
  11.             combos.append(rgb)
  12.  
  13. target_sum = 128 * 3 # or any other desired target sum
  14. rgb_at_sum(target_sum)
  15. print(len(combos))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement