Elementary cellular automaton/Random number generator: Difference between revisions
Content added Content deleted
Line 375: | Line 375: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Making the minimum possible changes to [[Elementary_cellular_automaton#Phix]], output matches C, D, Go, J, Kotlin, Racket, and zkl, |
Making the minimum possible changes to [[Elementary_cellular_automaton#Phix]], output matches C, D, Go, J, Kotlin, Racket, and zkl, |
||
and with the changes marked [2] C++, Haskell, Perl, Python, Ruby, Scheme, and Sidef, but completely different to Rust and Tcl. |
|||
No attempt to optimise. |
No attempt to optimise. |
||
<lang Phix>--string s = ".........#.........", |
<lang Phix>--string s = ".........#.........", --(original) |
||
string s = "...............................#"& |
string s = "...............................#"& |
||
"................................", |
"................................", |
||
--string s = "#"&repeat('.',100), -- [2] |
|||
t=s, r = "........" |
t=s, r = "........" |
||
integer rule = 30, k, l = length(s), w = 0 |
integer rule = 30, k, l = length(s), w = 0 |
||
Line 389: | Line 390: | ||
for i=0 to 80 do |
for i=0 to 80 do |
||
w = w*2 + (s[32]='#') |
w = w*2 + (s[32]='#') |
||
-- w = w*2 + (s[1]='#') -- [2] |
|||
if mod(i+1,8)=0 then res&=w w=0 end if |
if mod(i+1,8)=0 then res&=w w=0 end if |
||
for j=1 to l do |
for j=1 to l do |
||
Line 402: | Line 404: | ||
<pre> |
<pre> |
||
{220,197,147,174,117,97,149,171,100,151} |
{220,197,147,174,117,97,149,171,100,151} |
||
</pre> |
|||
{{out}} |
|||
with the changes marked [2] |
|||
<pre> |
|||
{220,197,147,174,117,97,149,171,240,241} |
|||
</pre> |
</pre> |
||