Ok this has been a long gap, almost of a week. Well, the week has been quite interesting for me. Couple of doubts over Kapil's solution, Lots of tension about the end-sem (it still carries!! :P ). This week I have a couple of interesting things. But before that, lets say "Great Work!" to Aditya Nema for solving all the three problems from last week's post.
Before going, as always let me give you the solutions:
1. a&!(a-1) gives you the last set bit (Phew! wasnt that simple yet elegant).
2. 59 is the number which on divided by 2,3,4,5,6 gives 1,2,3,4,5 as remainders repectively.
3. the Algorithm:
int count_bits(int A)
{
int ret=0;
while(A)
{
ret++;
A=A&(A-1);
}
return ret;
}
Ok! Lets see the doubts over Kapil's solution, as pointed out by Jasveer Singh Maan :).
Please refer the diagram in the previous post.
AEG and FEG are equilateral triangles. So each angle of these must be 60 degrees. Hence AEF= AEG+FEG=120 degree.
Now, AEFCB is a regular pentagon. So each internal angle should be 102 degrees (I think it is a requirement of regular polygon!). So there is a contradiction as AEF is internal angle of pentagon. I still havent drawn it with proper geometrical instruments but the argument seems to be very strong. So at the moment, Kapil's solution is not perfectly valid, the doubt being, is such a figure practically possible, and does a C actually exists?
Edit:
Well, with doubts I never meant that Kapil's solution is wrong, and I would like to apologise if any wrong meanings were conveyed. Anyways, Kapil's solution seems to be, infact are correct. There can be always a polygon with equal sides and un-equal internal angles. Jasveer perhaps mis-interpreted to call that as a "regular polygon", which essentially requires all the sides and internal angles to be equal (108 degrees).
Obviously, the best way to confirm is to draw using a compass, and cause of not finding one (you know how we keep things in hostel! :P, I am sorry about that as well ), I could not draw the diagram but yeah, it is correct cause an appproximation does confirm its validity.
Well, Mr. Kapil, we are not taking any credit from your side. Its just that someone had a small doubt and we couldn't comprehend it properly. Full points to your solution as before :). Cheer up, dude!
Ok so now this week's post.
And yes! I will try keeping this short, since last post had reviews of being a bit longer. I dont have much to share today except for a couple of sites that I came across.
If you have an appetite for maths puzzles, a bit of interest in simple programming, and a great insight, you cannot stop missing the site http://www.projecteuler.net, once you have seen it. 264 problems, each one requires a simple yet smart approach. Do try it and comment whether you liked it.
Again, if you love programming and want to get hand on some good IARCS problems, try this http://opc.iarcs.org.in
You have it graded in IOI style and you also get partial points. This helps in realising the efficiency of your solutions.
At last, a simple puzzle.
Shankey, our friend, wants to buy fruits. He has Rs 100 in his pocket and being a lover of numbers, he wants to buy exaclty 100 fruits. The market has 3 kinds of fruits available at different rates. An apple sould cost Shanket Rs 5, a banana would be for Re 1 and the cheapest of all oranges cost 5p each (Ohk that is very cheap, I know!). Help Shankey find the right combination of fruits so that he spends all the money in his pocket and end up buying 100 fruits. Remember, he loves variety and would like to take at least 1 kind of each fruit back with him.
I would appreciate if you can mail me the method by which you arrived at the solution.
Cheers,
Vivek Agarwal
nitkkr.vivek@gmail.com
Well let me remind jassi if he is missing out on some basics that with an exception of a triangle no polygon has any restriction such that if all its all sides are equal then all the angles should also be equal. Before trying to prove it incorrect with some baseless geometry try drawing it out.
ReplyDeleteHi Vivek..
ReplyDeletewww.projecteuler.net is a great site, I've solved 22 and cant wait to do more :)
http://www.greylabyrinth.com/
This is again a nice and well maintained site for puzzles if you like
well, thanks for the link mate. And its great that we have people, who like solving maths and programming puzzles. If you wont mind, can you please also post your email id, so that if needed by our users, they may contact you for your help on solving the problems at projecteuler.net.
ReplyDeleteRegards,
Vivek