Skip to content

Instantly share code, notes, and snippets.

@tsnow
Created July 21, 2013 13:43
Show Gist options
  • Save tsnow/6048610 to your computer and use it in GitHub Desktop.
Save tsnow/6048610 to your computer and use it in GitHub Desktop.
(10000000..99999999). #change to e.g. 1000..9999 for all 4 digit, 100000..999999 for all 6 digit nums
select do |i|
start=i.to_s.split('');
bk= (start.length / 2) - 1;
first = start[0..bk].join('').to_i;
last = start[-(bk+1)..-1].join('').to_i;
next if last > first;
prod = (first * last).to_s.split('');
prod.sort == start.sort;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment