Intersecting number wheels: Difference between revisions
Content added Content deleted
m (→{{header|Python}}: added zkl header) |
(→{{header|zkl}}: added code) |
||
Line 465: | Line 465: | ||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
<lang zkl>fcn intersectingNumberWheelsW(wheel1, wheel2, etc){ // ("A",(a,b,"C")), ("C",(d,e)) ...) |
|||
⚫ | |||
ws:=vm.arglist.pump(Dictionary().add,fcn(w){ return(w[0],Walker.cycle(w[1])) }); |
|||
⚫ | |||
Walker.zero().tweak(fcn(w,wheels){ |
|||
while(1){ |
|||
w=wheels[w].next(); // increment wheel w |
|||
if(Int.isType(w)) return(w); |
|||
} |
|||
}.fp(wheel1[0],ws)) |
|||
⚫ | |||
<lang zkl>wheelSets:=T( T( T("A",T(1,2,3)) ), |
|||
T( T("A",T(1,"B",2)), T("B",T(3,4)) ), |
|||
T( T("A",T(1,"D","D")), T("D",T(6,7,8)) ), |
|||
T( T("A",T(1,"B","C")), T("C",T(5,"B")), T("B",T(3,4)) ) ); |
|||
foreach ws in (wheelSets){ |
|||
println("Wheel set:"); |
|||
ws.pump(String,fcn(w){ " %s: %s\n".fmt(w[0],w[1].concat(" ")) }).print(); |
|||
println("-->",intersectingNumberWheelsW(ws.xplode()).walk(20).concat(" ")); |
|||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Wheel set: |
|||
A: 1 2 3 |
|||
-->1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 |
|||
Wheel set: |
|||
A: 1 B 2 |
|||
B: 3 4 |
|||
-->1 3 2 1 4 2 1 3 2 1 4 2 1 3 2 1 4 2 1 3 |
|||
Wheel set: |
|||
A: 1 D D |
|||
D: 6 7 8 |
|||
-->1 6 7 1 8 6 1 7 8 1 6 7 1 8 6 1 7 8 1 6 |
|||
Wheel set: |
|||
A: 1 B C |
|||
C: 5 B |
|||
B: 3 4 |
|||
-->1 3 5 1 4 3 1 4 5 1 3 4 1 3 5 1 4 3 1 4 |
|||
</pre> |
</pre> |