summaryrefslogtreecommitdiff
path: root/mobile.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-11-16 11:48:11 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2014-11-16 11:48:11 +0100
commit13fd59d27f953423b697c051ae7dc0d30bb191f2 (patch)
treeb118489c299a3cba86a98c7ba6a5a061189c3a2e /mobile.py
parent0b39ce96668d7e00aceb40994b1995cdfc33704d (diff)
downloadbwinf-33-13fd59d27f953423b697c051ae7dc0d30bb191f2.tar.gz
bwinf-33-13fd59d27f953423b697c051ae7dc0d30bb191f2.zip
Versuche zu Mobile
Diffstat (limited to 'mobile.py')
-rwxr-xr-xmobile.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/mobile.py b/mobile.py
new file mode 100755
index 0000000..2d62e91
--- /dev/null
+++ b/mobile.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+from math import floor
+import random
+
+# python dict in der Form {Position: Gewicht}, wobei Position auf der linken Seite negativ ist
+mobile = {-4: {-2: 1, 1: 2}, -1: 2, 2: 3, 4: 2}
+
+figuren = [2, 3, 1, 2, 3]
+
+def split(fig):
+ _fig = fig[:]
+ if len(_fig) > 4:
+ b = [[] for j in range(4)]
+ for k, item in enumerate(_fig):
+ b[k % 4].append(item)
+
+ _fig = list(filter(None, b))
+
+ b = []
+ for f in _fig:
+ weight = sum(f)
+ b.append({weight: split(f)})
+
+ _fig = b
+ return _fig
+
+def weight(fig):
+ res = dict()
+ for j in range(len(fig)):
+ #res[j] = {-list(fig[j][len(fig) - j - 1].keys())[0], fig[j]}
+ print(list(fig)[j])#[len(fig) - j - 1])
+ #res[-list(fig)[len(fig) - j - 1]] = fig[j]
+
+ return res
+
+r = list(range(1, 6))
+random.shuffle(r)
+print(r)
+f = split(r)
+print(f)
+w = weight(f)
+print(w)