So after the verbosity of my C# Solution I was wanting a neat solution, and was hoping that Erlang would deliver:
[worker(X, 0, , [1,2,3,4,5,6,7,8,9]) || X <- [1,10,100,1000,10000,100000,1000000,10000000,100000000]],
worker(Mod, Number, Used, ToUse) ->
Mod == 1 ->
[Number+X || X <- ToUse];
[worker(Mod div 10, Number+(X*Mod), [X]++Used, ([0,1,2,3,4,5,6,7,8,9]--Used)--[X]) || X <- ToUse]
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..