Narcissistic decimal number: Difference between revisions

m
→‎{{header|AppleScript}}: Updated preamble.
m (→‎{{header|AppleScript}}: "Natively written" solution modified to store digit collections as numbers instead of lists, incidentally finding results in order without needing a sort. Also reprefaced, and reheadered.)
m (→‎{{header|AppleScript}}: Updated preamble.)
Line 246:
{{Trans|JavaScript}}
{{Trans|Haskell}}
AppleScript is a little out of its depth here, evenand withimposes anunproductively algorithmtime-consuming hand-optimisation on the scripter, even with whichrestriction restrictsof the search space (see the JavaScript and Haskell discussions).
 
(For comparison,an equivalentalgorithm codewhich in JavaScript for Automation – the alternative idiom for osascript use on macOS – returns all 25 numbers in about 120 milliseconds, nearly 14 minutes are required in the AppleScript version (on the system here). for the full 7 digit search that finds the 25th number
The full 7 digit search that finds the 25th number takes nearly 14 minutes on the system here (four seconds to scan the 5 digit combinations, and find the first 20, and 103 seconds to scan the six digit combinations for the first 21 narcissi).
 
The full 7 digit search that finds the 25th number takes nearly 14 minutes on the system here (four seconds to scan the 5 digit combinations, and find the first 20, and 103 seconds to scan the six digit combinations for the first 21 narcissi).
(For comparison, equivalent code in JavaScript for Automation – the alternative idiom for osascript use on macOS – returns all 25 numbers in about 120 milliseconds).
 
For an imperative hand-optimisation, and a contrasting view, see below :-)
 
<lang AppleScript>-- NARCISSI -------------------------------------------------------------------
9,659

edits