find an integer that multiplied by 4 gives a number that has the same digits, but with opposite order compared to the original number.
Example with n digits:
X1X2...Xn-1Xn * 4 = XnXn-1...X2X1
where X1 is the first digit, X2 the second digit....Xn the n-th digit.
Pay attention: we don't know how many digits compose the number.
If you have the solution, post it in the comment.
The next step is to write a simple algorithm that would be able to find the solution by itself. I'm trying to do it using the C++...or maybe I should just go out.
Definitely, I need to go out.
Bye.
Here we are with a couple of solutions.
ReplyDeleteIn the first solution, the dumb one, I simply check if property you gave in the statement is verified: is x1x2..xn * 4 equal to xn..x2x1? http://ideone.com/HlTZQ
It works, slowly but it works.
However we can study the output in order to devise a clever algorithm which produces this fastest solution: http://ideone.com/yUh2R
Regards,
Matteo
@Matteo
ReplyDeleteOf course the solution is right and as i have always said....you're fucking brilliant!
Surely it is not the best solution, but it works.
ReplyDeletehttp://ideone.com/CUpP6
@kinglizad
ReplyDeleteOh you're a clever little bastard too...in a good way :)
See guys what great Python minds!
You are very STRINATI
ReplyDeleteand for information i have solved without cpu, only with my mind prrrrrr
ReplyDelete@Silvio
ReplyDeleteGnè gnè gnè...envious!
@Silvio:
ReplyDeleteYou're #1: pencil and sheet of paper is the way!
Matteo
Isn't the solution simple?
ReplyDelete0.0