my splitStringByLen function was extremely slow, and lists/iterating lists is slow in general so cahnge to splitByLen make old version 60% faster, and a version without the intermediate loop it is 4s
This commit is contained in:
parent
e9f2b69924
commit
802a8dde26
3 changed files with 67 additions and 23 deletions
|
|
@ -30,11 +30,12 @@ let
|
|||
str:
|
||||
let
|
||||
strLen = stringLength str;
|
||||
splits = reverseList (genList (i: i + 1) strLen);
|
||||
maxSplit = strLen / 2; # Only check up to half length since it must repeat at least twice
|
||||
splits = genList (i: i + 1) maxSplit;
|
||||
in
|
||||
any (
|
||||
split:
|
||||
if split < strLen && mod strLen split == 0 then
|
||||
if mod strLen split == 0 then
|
||||
let
|
||||
parts = splitStringByLength str split;
|
||||
in
|
||||
|
|
@ -51,7 +52,7 @@ let
|
|||
let
|
||||
invalidIds = flatten (
|
||||
map (
|
||||
range: (reduce (invalidIds: id: invalidIds ++ (if badIdFunc id then [ id ] else [ ])) [ ] range)
|
||||
range: (foldl' (invalidIds: id: invalidIds ++ (if badIdFunc id then [ id ] else [ ])) [ ] range)
|
||||
) fullRanges
|
||||
);
|
||||
invalidIdNums = map (v: toIntBase10 v) invalidIds;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue