aboutsummaryrefslogtreecommitdiff
path: root/challenge-043/lubos-kolouch/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-043/lubos-kolouch/python/ch-1.py')
-rw-r--r--challenge-043/lubos-kolouch/python/ch-1.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-043/lubos-kolouch/python/ch-1.py b/challenge-043/lubos-kolouch/python/ch-1.py
new file mode 100644
index 0000000000..39d4aa8bb9
--- /dev/null
+++ b/challenge-043/lubos-kolouch/python/ch-1.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from itertools import permutations
+
+# Initialize the ring numbers and available numbers
+rings = {"Blue": 8, "Black": None, "Red": 9, "Yellow": 7, "Green": 5}
+available = [1, 2, 3, 4, 6]
+
+# Generate all possible permutations of the available numbers
+for b, k, r, y, g in permutations(available):
+ # Skip if any number is repeated
+ if b == k or b == r or b == y or b == g:
+ continue
+ if k == r or k == y or k == g:
+ continue
+ if r == y or r == g:
+ continue
+ if y == g:
+ continue
+ # Check if the sum of numbers in each ring is 11
+ if b + k + r == 11 and r + y + g == 11:
+ # Save the solution
+ rings["Blue"] = b
+ rings["Black"] = k
+ rings["Red"] = r
+ rings["Yellow"] = y
+ rings["Green"] = g
+ print(rings)