Intersecting number wheels: Difference between revisions

Line 933:
Group 3, First 20 values: 1 6 7 1 8 6 1 7 8 1 6 7 1 8 6 1 7 8 1 6
Group 4, First 20 values: 1 3 5 1 4 3 1 4 5 1 3 4 1 3 5 1 4 3 1 4
</pre>
 
=={{header|Phix}}==
<lang Phix>function terms(sequence wheels, integer n)
sequence res = repeat(' ',n),
pos = repeat(2,length(wheels)),
wvs = vslice(wheels,1)
integer wheel = 1, rdx = 1
while rdx<=n do
integer p = pos[wheel],
c = wheels[wheel][p]
p = iff(p=length(wheels[wheel])?2:p+1)
pos[wheel] = p
if c>'9' then
wheel = find(c,wvs)
else
res[rdx] = c
rdx += 1
wheel = 1
end if
end while
return res
end function
 
constant wheels = {{"A123"},
{"A1B2","B34"},
{"A1DD","D678"},
{"A1BC","B34","C5B"}}
 
for i=1 to length(wheels) do
?terms(wheels[i],20)
end for</lang>
{{out}}
<pre>
"12312312312312312312"
"13214213214213214213"
"16718617816718617816"
"13514314513413514314"
</pre>
 
7,794

edits