Skip to content

Commit 060988b

Browse files
author
Christian Bender
authored
Merge pull request TheAlgorithms#293 from TheAlgorithms/changed_chaosmachine
added a option for termination the program
2 parents 6211929 + c1422ec commit 060988b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

hashes/chaos_machine.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
"""example of simple chaos machine"""
22
from __future__ import print_function
33

4+
try:
5+
raw_input
6+
input = raw_input
7+
except:
8+
pass
9+
410
# Chaos Machine (K, t, m)
511
K = [0.33, 0.44, 0.55, 0.44, 0.33]; t = 3; m = 5
612

@@ -32,8 +38,8 @@ def push(seed):
3238
r # Saving to Parameters Space
3339

3440
# Logistic Map
35-
assert(max(buffer_space) < 1)
36-
assert(max(params_space) < 4)
41+
assert max(buffer_space) < 1
42+
assert max(params_space) < 4
3743

3844
# Machine Time
3945
machine_time += 1
@@ -91,7 +97,11 @@ def reset():
9197
for chunk in message:
9298
push(chunk)
9399

100+
# for controlling
101+
inp = ""
102+
94103
# Pulling Data (Output)
95-
while True:
104+
while inp != "e" and inp != "E":
96105
print("%s" % format(pull(), '#04x'))
97106
print(buffer_space); print(params_space)
107+
inp = input("(e)exit? ")

0 commit comments

Comments
 (0)