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

Home > Numbers
Flipflop the digits, octuple the number (Posted on 2022-03-30) Difficulty: 3 of 5
Define the flipflop function, applied to a positive integer, as the result of having the 10^2i and 10^(2i+1) digits switch places.
Moreover, if the integer has an odd number of digits, append a leading zero to the left side of the number so that it can flipflop with the first nonzero digit.

For example, flipflop(9876) = 8967 and flipflop(1234567) is 10325476.

warm-up:
What is the smallest positive integer such that flipflop(m) = m*4?

octuple the number:
What is the smallest positive integer such that flipflop(n) = n*8?
In the case of multiplication by 8, I have found only one solution: are there any others?

No Solution Yet Submitted by Larry    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 5
The program does some base-100 arithmetic so that a conversion can be made one base-100 digit at a time via the flipper array.

clearvars
global flipper
for i=0:99   
   u=mod(i,10);
   t=floor(i/10);
   i2=10*u+t;
   flipper(i+1)=char(i2);
   flipper(i2+1)=char(i);
end

n=char(0);
while length(n)<4
   psn=length(n);
   n(psn)=n(psn)+1;
   while n(psn)>99
      n(psn)=char(0);
      psn=psn-1;
      if psn==0
         n=[char(0) n]; 
         psn=1;
      end
      n(psn)=n(psn)+1;
   end
   
   if isequal(flipflop(n),quadruple(n))
      for i=1:length(n)
         fprintf('%02d',double(n(i))); 
      end
      fprintf('\n')
   end
end



function f=flipflop(n)
  global flipper
  f=n;
  for i=1:length(n)
     f(i)=flipper(n(i)+1);
  end
end

function q=quadruple(n)
   q=n;
   psn=length(n);
   pr=q(psn)*4;
   quot=floor(pr/100);
   rem=mod(pr,100);
   q(psn)=rem;
   while quot>0 || psn>1
       psn=psn-1;
       if psn==0
           q=[char(0) q];
           psn=1;
       end
       pr=q(psn)*4+quot;
       quot=floor(pr/100);
       rem=mod(pr,100);
       q(psn)=rem;
   end
end

function o=octuple(n)
   o=n;
   psn=length(n);
   pr=o(psn)*8;
   quot=floor(pr/100);
   rem=mod(pr,100);
   o(psn)=rem;
   while quot>0 || psn>1
       psn=psn-1;
       if psn==0
           o=[char(0) o];
           psn=1;
       end
       pr=o(psn)*8+quot;
       quot=floor(pr/100);
       rem=mod(pr,100);
       o(psn)=rem;
   end
end

is in the warmup mode and finds

1782
178200
179982

as each of these, when divided into its flipflop, gives a quotient of 4:

7128/1782 = 4
712800/178200 = 4
719928/179982 = 4

The octuple version required changing the length limit so that length of 4 base-100 digits would actually be processed, and of course the comparison had to be changed to call the octuple function instead of the quadruple function.  With the changes, it found

02519748

20157984 / 02519748 = 8

It was run for a few minutes and when it was manually stopped, n was still only 4 base-100 digits, but the leftmost digit had reached 40 -- quite bit higher than the 02 in the solution.

  Posted by Charlie on 2022-03-30 11:45:13
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 (0)
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