De Bruijn sequences: Difference between revisions

→‎{{header|Wren}}: Now uses Wren-str module.
(→‎{{header|Wren}}: Library name change.)
(→‎{{header|Wren}}: Now uses Wren-str module.)
Line 1,564:
{{trans|Phix}}
{{libheader|Wren-fmt}}
{{libheader|Wren-str}}
<lang ecmascript>import "/fmt" for Fmt
import "/str" for Str
 
var deBruijn = ""
for (n in 0..99) {
Line 1,586 ⟶ 1,588:
System.print("First 130 characters:\n%(deBruijn[0...130])\n")
System.print("Last 130 characters:\n%(deBruijn[-130..-1])\n")
var allDigits = Fn.new { |s|
for (b in s) {
var c = b.bytes[0]
if (c < 48 || c > 57) return false
}
return true
}
var check = Fn.new { |text|
var res = []
Line 1,601 ⟶ 1,595:
for (i in 0...(text.count-3)) {
var s = text[i..i+3]
if (allDigitsStr.callallDigits(s)) {
k = Num.fromString(s)
found[k] = found[k] + 1
Line 1,623 ⟶ 1,617:
return res
}
 
System.print("Missing 4 digit PINs in this sequence: %(check.call(deBruijn))")
System.print("Missing 4 digit PINs in the reversed sequence: %(check.call(deBruijn[-1..0]))")
9,490

edits