September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,32 @@
|
|||
N:=0d1_000_001;
|
||||
|
||||
fcn lookAndJustSaying(seed){ // numeric String --> numeric String
|
||||
"9876543210".pump(String,'wrap(n){
|
||||
(s:=seed.inCommon(n)) and String(s.len(),n) or ""
|
||||
});
|
||||
}
|
||||
fcn sequence(seed){ // numeric string --> sequence until it repeats
|
||||
seq:=L();
|
||||
while(not seq.holds(seed)){ seq.append(seed); seed=lookAndJustSaying(seed); }
|
||||
seq
|
||||
}
|
||||
fcn decending(str) //--> True if digits are in descending (or equal) order
|
||||
{ (not str.walker().zipWith('<,str[1,*]).filter1()) }
|
||||
|
||||
szs:=List.createLong(25); max:=0;
|
||||
foreach seed in (N){
|
||||
z:=seed.toString();
|
||||
if(decending(z)){ // 321 generates same sequence as 312,132,123,213
|
||||
len:=sequence(z).len();
|
||||
if(len>max) szs.clear();
|
||||
if(len>=max){ szs.append(seed.toString()); max=len; }
|
||||
}
|
||||
}
|
||||
|
||||
// List permutations of longest seeds
|
||||
// ("9900"-->(((9,0,0,9),...))-->((9,0,0,9),...)-->("9009"...)
|
||||
// -->remove numbers w/leading zeros-->remove dups
|
||||
zs:=szs.apply(Utils.Helpers.permute).flatten().apply("concat")
|
||||
.filter(fcn(s){ s[0]!="0" }) : Utils.Helpers.listUnique(_);
|
||||
println(max," iterations for ",zs.concat(", "));
|
||||
zs.pump(Console.println,sequence,T("concat",", "));
|
||||
Loading…
Add table
Add a link
Reference in a new issue