Browse Source

master > master: code py - darstellung von Summen verbessert

RD 2 months ago
parent
commit
a3093d4c99
  1. 7
      code/python/src/algorithms/rucksack/display.py

7
code/python/src/algorithms/rucksack/display.py

@ -150,10 +150,13 @@ def display_sum(
def render(x: Tuple[bool, Fraction, float]):
b, u, value = x;
expr = f'\x1b[91m{value:g}\x1b[0m' if b else f'\x1b[0m{value:g}\x1b[0m';
if u == 0:
expr = f'\x1b[94;2m{value:g}\x1b[0m' if b else f'\x1b[2m{value:g}\x1b[0m';
else:
expr = f'\x1b[94m{value:g}\x1b[0m' if b else f'\x1b[0m{value:g}\x1b[0m';
if not show_all_weights and u == 1:
return expr;
return f'\x1b[2m{u}\x1b[0m\x1b[2m·\x1b[0m{expr}';
return f'\x1b[2;4m{u}\x1b[0m\x1b[2m·\x1b[0m{expr}';
parts = [ (i in indexes, u, x) for i, (u, x) in enumerate(zip(choice, values)) ];
if not (order is None):

Loading…
Cancel
Save