summaryrefslogtreecommitdiffstats
path: root/test_20121121/helpers.py
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-11-22 00:21:11 +0100
committerbnewbold <bnewbold@robocracy.org>2012-11-22 00:21:11 +0100
commitf0fdd4b91cd4dded9e029a7a3a8b6a158d721a30 (patch)
treebca519a7ad0bf91a8ede0f04088753e1de1862e4 /test_20121121/helpers.py
parentc179ad73391f5ce441156dc852104b9b18a296c5 (diff)
downloadzufallig_gerat-master.tar.gz
zufallig_gerat-master.zip
add Nov 22nd notes and scriptsHEADmaster
Diffstat (limited to 'test_20121121/helpers.py')
-rw-r--r--test_20121121/helpers.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/test_20121121/helpers.py b/test_20121121/helpers.py
new file mode 100644
index 0000000..abe991a
--- /dev/null
+++ b/test_20121121/helpers.py
@@ -0,0 +1,30 @@
+
+def stats(s):
+ high = s.count('#')
+ low = s.count('.')
+ print "total: %d" % (high + low)
+ print "percent: %f" % (100.0 * (high / (high + low * 1.0)))
+
+# total: 3499
+# percent: 46.156045
+
+def hex_stats(s):
+ d = dict()
+ for k in "0123456789ABCDEF":
+ d[k] = s.count(k)*1.0
+ bitmap = dict()
+ for k in d.keys():
+ bitmap[k] = bin(int("0x"+k, 16))[2:].count('1')
+ chars = sum(d.values())
+ bits = chars*4
+ zeros = 0
+ ones = 0
+ print "chars: %d" % chars
+ for k in "0123456789ABCDEF":
+ v = d[k]
+ print "\t%s: %d\t%f\t%f" % (k, v, v/chars, v/chars*16)
+ ones += bitmap[k] * v
+ zeros += (4 - bitmap[k]) * v
+ print "bits: %d" % bits
+ print "\tzeros: %d\t%f" % (zeros, zeros/bits)
+ print "\tones: %d\t%f" % (ones, ones/bits)