Reggie Wilcox - MATLAB Cody - MATLAB Central

Reggie Wilcox

7638
Rank
5
Badges
810
Score
1 – 50 of 90

Reggie Wilcox submitted a Comment to Problem 44316. Pandigital Multiples of 11 (based on Project Euler 491)

My combinatoric approach and brute force method both agree for x = 10 with 1454400 and for x = 11 with 9072000. I can't brute force beyond that, but an reasonably I am handling the redundant permutations introduced when we have duplicate digits due to these two cases. For reference, I get 3216477600 for x = 14.

on 19 Oct 2017

Reggie Wilcox submitted a Comment to Problem 44316. Pandigital Multiples of 11 (based on Project Euler 491)

I don't think the case for x > 9 is handled correctly. Consider x = 11. My interpretation is that a pandigital number of order 11 will contain exactly two 0's, two 1's and one of every digit 2 through 9. Using a brute force approach, I can check every pandigital number of order 11 and see if it is a multiple of 11: count = 0; digs = 0:11; for d0 = 1:9 strs = unique(perms(char(mod(setdiff(digs, d0), 10) + '0')), 'rows'); nums = str2num([repmat(char(d0 + '0'), size(strs, 1), 1) strs]); count = count + sum(mod(nums, 11) == 0); end Quite simply, this loops over each starting digit, except zero, takes all possible unique permutations of the remaining digits, then counts the number divisible by 11. This yields a solution of 9072000. Note that this approach is not a suitable answer for Cody, since its runtime is on the order of an hour, but is the simplest way to demonstrate a correct solution for x = 11.

on 19 Oct 2017

1 – 50 of 90
Go to top of page