Skip to content

Commit 2ce5c87

Browse files
committed
simplified code
1 parent c5adbcf commit 2ce5c87

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

bin/latex.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,9 @@ def problem_data(problem: "Problem", language: str):
210210
"ffffff",
211211
)
212212
# Source: https://github.com/DOMjudge/domjudge/blob/095854650facda41dbb40966e70199840b887e33/webapp/src/Twig/TwigExtension.php#L1056
213-
foreground = (
214-
"000000" if sum(int(background[i : i + 2], 16) for i in range(0, 6, 2)) > 450 else "ffffff"
215-
)
216-
border = "".join(
217-
("00" + hex(max(0, int(background[i : i + 2], 16) - 64))[2:])[-2:] for i in range(0, 6, 2)
218-
)
213+
background_rgb = [int(background[i : i + 2], 16) for i in [0, 2, 4]]
214+
foreground = "000000" if sum(background_rgb) > 450 else "ffffff"
215+
border = "".join(f"{max(0, color - 64):02x}" for color in background_rgb)
219216

220217
return {
221218
"problemlabel": problem.label,

0 commit comments

Comments
 (0)