-module(challenge). -export([main/0]). main() -> [worker(X, 0, , [1,2,3,4,5,6,7,8,9]) || X <- [1,10,100,1000,10000,100000,1000000,10000000,100000000]], true. worker(Mod, Number, Used, ToUse) -> if Mod == 1 -> [Number+X || X <- ToUse]; true -> [worker(Mod div 10, Number+(X*Mod), [X]++Used, ([0,1,2,3,4,5,6,7,8,9]--Used)--[X]) || X <- ToUse] end.
I feel this is pretty good. To get the results just remove the “true.“ statement from main().
Unfortunately it is not as fast as I would like, taking 5 seconds to run, but I’m not sure I’m using lists in the smartest way..