All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Pandigital W numbers (Posted on 2023-05-30) Difficulty: 3 of 5
A "W" number is one whose digits are initially decreasing, then alternate between decreasing and increasing making exactly three changes of direction. Defining the first and last digit as always being either a peak or a valley, a W number has 3 peaks and 2 valleys.

For example 98246417 is a W number, with peaks at 9, 6, and 7; and valleys at 2 and 1. But 874679642 is not, because it only has 2 peaks and 2 valleys making only two changes of direction.

How many 10-digit pandigital W numbers are there?

See The Solution Submitted by Larry    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution | Comment 1 of 4
clc
p=perms('0123456789');
ct=0;
for i=1:length(p)
  n=p(i,:);
  if n(2)<n(1)
    chDir=0;
    for j=2:9
      if (n(j+1)-n(j))*(n(j)-n(j-1))<0
        chDir=chDir+1;
      end
    end
    if chDir==3
       ct=ct+1;
       if mod(ct,1000)==1
         disp(n)
       end
    end
  end
end
ct

finds 100530.

A sampling, every 1000th:

9876542301
9872104635
9862753104
9852130467
9840356712
9821360457
9802365147
9762103845
9751368402
9738210456
9720513468
9701358426
9650371248
9632701458
9617502348
9578012346
9532871046
9518203467
9478650123
9425013678
9405312678
9324587106
9304612578
9218543067
9178654302
9107864325
9036752148
8795102346
8760543129
8750146329
8732156049
8714695302
8659102347
8643701259
8631259407
8612570349
8543971026
8531469207
8512794036
8456792013
8421037659
8401695327
8320671459
8301476259
8213940567
8156920347
8103764259
8026941357
7654302189
7643098512
7630541289
7610582349
7543168029
7530891246
7510894236
7436895012
7420358169
7401239568
7319865204
7296410358
7210943568
7146932058
7102864359
7024831569
6543279108
6531079248
6512394078
6438975201
6420597318
6401378259
6320457819
6301248759
6213504789
6149520378
6103487529
6025798134
5439862107
5420861379
5401678239
5320496178
5301286479
5213704689
5149876203
5103687429
5026974138
4367801259
4312589706
4258976013
4205897136
4135670289
4078532169
4016235789
3245697108
3198654207
3124570689
3048965217
3012457689
2134597608
2049751368
2013469857
1034689257
ct =
      100530


  Posted by Charlie on 2023-05-30 10:02:36
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (9)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information