Jump to content

Elementary cellular automaton/Random number generator: Difference between revisions

(Added Go)
Line 372:
{{out}}
<pre>220 197 147 174 117 97 149 171 240 241</pre>
 
=={{header|Phix}}==
Making the minimum possible changes to [[Elementary_cellular_automaton#Phix]], output matches C, D, Go, J, Kotlin, Racket, and zkl,
almost but not quite C++, Haskell, Perl, Python, Ruby, Scheme, and Sidef, and completely different to Rust and Tcl.
No attempt to optimise.
<lang Phix>--string s = ".........#.........",
string s = "...............................#"&
"................................",
t=s, r = "........"
integer rule = 30, k, l = length(s), w = 0
for i=1 to 8 do
r[i] = iff(mod(rule,2)?'#':'.')
rule = floor(rule/2)
end for
sequence res = {}
for i=0 to 80 do
w = w*2 + (s[32]='#')
if mod(i+1,8)=0 then res&=w w=0 end if
for j=1 to l do
k = (s[iff(j=1?l:j-1)]='#')*4
+ (s[ j ]='#')*2
+ (s[iff(j=l?1:j+1)]='#')+1
t[j] = r[k]
end for
s = t
end for
?res</lang>
{{out}}
<pre>
{220,197,147,174,117,97,149,171,100,151}
</pre>
 
=={{header|Python}}==
7,794

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.