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

Home > Numbers
Vaivém Numbers (Posted on 2024-07-13) Difficulty: 3 of 5
A positive integer is called vaivém when, considering its representation in base ten, the first digit from left to right is greater than the second, the second is less than the third, the third is bigger than the fourth and so on alternating bigger and smaller until the last digit. For example, 2021 is vaivém, as 2 > 0 and 0 < 2 and 2 > 1. The number 2023 is not vaivém, as 2 > 0 and 0 < 2, but 2 is not greater than 3.

a) How many vaivém positive integers are there from 2000 to 2100?
b) What is the largest vaivém number without repeating digits?
c) How many distinct 7-digit numbers formed by all the digits 1, 2, 3, 4, 5, 6 and 7 are vaivém?

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution | Comment 2 of 3 |

a)
clearvars,clc
ct=0;
for n=2000:2100
  ns=num2str(n);
  if ns([2 4])<ns([1 3])
    fprintf('%d ',n)
    ct=ct+1;
  end
end
disp(' ')
ct

2010 2020 2021 2030 2031 2032 2040 2041 2042 2043 2050 2051 2052 2053 2054 2060 2061 2062 2063 2064 2065 2070 2071 2072 2073 2074 2075 2076 2080 2081 2082 2083 2084 2085 2086 2087 2090 2091 2092 2093 2094 2095 2096 2097 2098  
ct =
    45


b) Strategy: start with high digit then go just low enough go allow just one higher digit to immediately follow:  9785634120.

c) 
ct=0;
a=perms(1:7);
for i=1:length(a)
  n=a(i,:);
  if n([3 5 7]) > n([2 4 6]) & n([1 3 5]) > n([2 4 6])
    ct=ct+1;
    fprintf('%s ', erase(num2str(n),' '))
  end
end
disp(' ')
ct

7563412 7562413 7562314 7561423 7561324 7463512 7462513 7462315 7461523 7461325 7453612 7452613 7452316 7451623 7451326 7364512 7362514 7362415 7361524 7361425 7354612 7352614 7352416 7351624 7351426 7342615 7342516 7341625 7341526 7264513 7263514 7263415 7261534 7261435 7254613 7253614 7253416 7251634 7251436 7243615 7243516 7241635 7241536 7231645 7231546 7164523 7163524 7163425 7162534 7162435 7154623 7153624 7153426 7152634 7152436 7143625 7143526 7142635 7142536 7132645 7132546 6573412 6572413 6572314 6571423 6571324 6473512 6472513 6472315 6471523 6471325 6453712 6452713 6452317 6451723 6451327 6374512 6372514 6372415 6371524 6371425 6354712 6352714 6352417 6351724 6351427 6342715 6342517 6341725 6341527 6274513 6273514 6273415 6271534 6271435 6254713 6253714 6253417 6251734 6251437 6243715 6243517 6241735 6241537 6231745 6231547 6174523 6173524 6173425 6172534 6172435 6154723 6153724 6153427 6152734 6152437 6143725 6143527 6142735 6142537 6132745 6132547 5473612 5472613 5472316 5471623 5471326 5463712 5462713 5462317 5461723 5461327 5374612 5372614 5372416 5371624 5371426 5364712 5362714 5362417 5361724 5361427 5342716 5342617 5341726 5341627 5274613 5273614 5273416 5271634 5271436 5264713 5263714 5263417 5261734 5261437 5243716 5243617 5241736 5241637 5231746 5231647 5174623 5173624 5173426 5172634 5172436 5164723 5163724 5163427 5162734 5162437 5143726 5143627 5142736 5142637 5132746 5132647 4375612 4372615 4372516 4371625 4371526 4365712 4362715 4362517 4361725 4361527 4352716 4352617 4351726 4351627 4275613 4273615 4273516 4271635 4271536 4265713 4263715 4263517 4261735 4261537 4253716 4253617 4251736 4251637 4231756 4231657 4175623 4173625 4173526 4172635 4172536 4165723 4163725 4163527 4162735 4162537 4153726 4153627 4152736 4152637 4132756 4132657 3275614 3274615 3274516 3271645 3271546 3265714 3264715 3264517 3261745 3261547 3254716 3254617 3251746 3251647 3241756 3241657 3175624 3174625 3174526 3172645 3172546 3165724 3164725 3164527 3162745 3162547 3154726 3154627 3152746 3152647 3142756 3142657 2175634 2174635 2174536 2173645 2173546 2165734 2164735 2164537 2163745 2163547 2154736 2154637 2153746 2153647 2143756 2143657  
ct =
   272

  Posted by Charlie on 2024-07-13 10:53:49
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (4)
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