De Bruijn sequences: Difference between revisions

m
→‎{{header|zkl}}: minor rewrite
m (→‎{{header|Perl 6}}: Fix off-by-one error. Thanks Purefox!)
m (→‎{{header|zkl}}: minor rewrite)
Line 434:
chk:=Dictionary();
foreach n in ([0..seqText.len()-1]){ chk[seqText[n,4]]=True }
(9999).pump(List,"%04d".fmt,'wrap(k){ if(chk.holds(k)) Void.Skip else k })
foreach n in ([0..9999]){
k:="%04d".fmt(n);
if(not chk.find(k)) print(k," ")
}
println();
}
println("\nMissing 4 digit PINs in this sequence: ", chk(seqText).concat(" "));
print("Missing 4 digit PINs in the reversed sequence: ",chk(seqText.reverse()).concat(" "));
chk(seqText);
print("Missing 4 digit PINs in the reversed sequence:");
chk(seqText.reverse());
 
println("\n4444th character in the sequence: ", seqText[4444]);
println("Adding 1 to the 4444th character and reruning checks:");
dbSeq[4444]+=1;
println("Adding 1 to the 4444th character and reruning checks: ",chk(dbSeq.text).concat(" "));</lang>
{{out}}
<pre>
Line 459 ⟶ 452:
6898689969697769786979698769886989699769986999777787779778877897798779978787978887889789878997979887989799879998888988998989999000
 
Missing 4 digit PINs in this sequence:
Missing 4 digit PINs in the reversed sequence:
 
Missing 4 digit PINs in the reversed sequence:
 
4444th character in the sequence: 5
Adding 1 to the 4444th character and reruning checks: 1459 4591 5914 8145
1459 4591 5914 8145
</pre>
Anonymous user