|
|
1.1 ! root 1: # ! 2: # M E A N D E R I N G S T R I N G S ! 3: # ! 4: ! 5: # This main procedure accepts specifications for meandering strings ! 6: # from standard input with the alphabet separated from the length by ! 7: # a colon. ! 8: ! 9: procedure main() ! 10: local line, alpha, n ! 11: while line := read() do { ! 12: line ? if alpha := tab(upto(':')) then { ! 13: move(1) ! 14: if n := integer(tab(0)) then write(meander(alpha,n)) ! 15: else write("erroneous input") ! 16: } ! 17: else write("erroneous input") ! 18: } ! 19: end ! 20: ! 21: procedure meander(alpha,n) ! 22: local result, t, i, c, k ! 23: i := k := *alpha ! 24: t := n-1 ! 25: result := repl(alpha[1],t) ! 26: while c := alpha[i] do { ! 27: if find(result[-t:0] || c,result) ! 28: then i -:= 1 ! 29: else {result ||:= c; i := k} ! 30: } ! 31: return result ! 32: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.