Lychrel numbers: Difference between revisions
m
→{{header|AppleScript}}: Further minor optimisation.
m (→{{header|AppleScript}}: Speeded up with additional subgrouping of digit list storage. Number range constrained to start at 1.) |
m (→{{header|AppleScript}}: Further minor optimisation.) |
||
Line 312:
property stigid : missing value -- Reverse thereof.
property digitLists : missing value -- Copies of the digit lists in the current sequence.
-- The digit lists from earlier
--
property earlierDigitLists :
property subgroup : missing value --
-- Lychrel output.
property seeds : {}
Line 323:
-- Subhandler: Has the current list of digits come up in the sequence for an earlier Lychrel?
on isRelated()
--
set
if (digitCount > 2) then set
if (item i of my subgroup = digits) then return true
end repeat
end if
return false
end isRelated
end script
repeat 10 times▼
end repeat▼
repeat with startNumber from 1 to numberLimit
Line 396 ⟶ 395:
end if
if (startNumberIsPalindrome) then set end of o's palindromics to startNumber
-- Store this sequence's digit lists based on their last three digits. There won't be any
-- single-digit lists (they're palindromes), but there may be some with only two digits.
repeat with thisList in o's digitLists
set
if (digitCount > 2) then set
end repeat
end if
Line 410 ⟶ 409:
return {seeds:o's seeds, relateds:o's relateds, palindromics:o's palindromics}
end Lychrels
on listOfLists(len)
script o
property lst : {}
end script
set end of o's lst to {}
▲ end repeat
return o's lst
end listOfLists
on join(lst, delim)
|