Categories
Problems Project Euler

Calculating N^2 as a series?

I am working on a problem from project Euler solving for Pythagorean triplets. I think it is supposed to be a simple coding problem solved brute force with two for loops. Something about the problem has my gut telling to try to solve the problem a little more elegantly.  To that end I was looking at trying to calculate N^2 as a series so I could break up the triplets into over common and different components to manipulate.

This is the first thing that jumped out at me – obvious pattern when I thought about N^2 having 2N as the first derivative and 2 as the second – but I did not see it right away. Might be useful.

Categories
Problems Project Euler

Project Euler – Solution to problem #1

Project Euler Problem #1:

Problem: “If we list all the natural numbers below 10 that are multiples of 3 or 5 we get 3,5,6,9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.”

Solution:

Categories
Logic

The pearl merchant

Testing out another problem for my book. This is really just my trying to re-word a centuries old classic. So let me know if the wording is acceptable here:

On his twentieth year working for a pearl merchant Isaac was offered a reward. He was presented with three vases. He was told that each vase contains an equal number of pearls however the vases contain different types of pearls. One vase is labeled as containing white pearls, one vase is labeled as containing black pearls, and the remaining vase is labeled as contain an equal mixture of black and white pearls. The vases are opaque and have long throats the drawer has no way of seeing what the vases contain or the color of the pearl they have chosen until the pearl is removed from the vase.

The merchant tells Isaac that each vase is labeled inaccurately. The merchant suggests that they take turns drawing pearls from the vases in an effort to correctly re-label them.

As a reward for faithful service he tells Isaac that if he can identify how to correctly label each vase first – he can keep any pearls he has drawn. However if the merchant can correctly re-label the jars first Isaac has to return any pearls he has drawn.

The merchant offers Isaac the chance to draw first, should he accept?

Categories
Book Notes Lateral Thinking

An impossible game of catch?

Tristan and his friend Joe are playing a game of catch. They are fifty feet apart from each other and tossing the ball back and forth at approximately seventy-five feet per second. Two thirds of a second elapse between each of the throws of the ball and the corresponding catch. During that time the ball travels one hundred and sixty seven feet. How is this possible?

Ok, so my first attempt at a lateral thinking problem was a bit of a disaster. Konrad and Jason both were not happy with it and I am trying to figure out a way to re-work it so that the problem is not trying to figure out what the heck I am thinking!

Apparently since I want to publish I need to hold off on posting answers here for copy write reasons. So I will post the answers on a separate  site and use comments here as a way to discuss the problems.

Categories
Book Notes

Book Notes: lateral thinking problem(s)

So I hate “lateral thinking” problems. Seriously. They usually seem to be more of an exercise in thinking about how other people think – normally an interesting if not enjoyable topic – but somehow sucked dry of the positives of the experience. Never thought much about why I feel that way but I will certainly give it more thought now that I need to write some for my puzzle / math book.

So at some stage I need a tutorial on how to approach these sorts of problems algorithmically – to that end I wrote up this example.

A problem I found online for “lateral thinking” was stated as:

Problem: “How can you throw a ball such that it always comes back to you?”

I am paraphrasing the problem but this restatement has the critical property of the original – at least one answer that is obvious from reading it. Answer: “Throw the ball straight up!”.

These problems always have a basis set of assumptions. For example that the person is in a gravity field or on Earth, that that they can’t throw the ball at escape velocity. I broke down some examples below that have easy graphical representations of the problem. The graphics should help with the book and relaying understanding.

Book notes: examples on breaking down lateral thinking
Book notes: examples on breaking down lateral thinking

Categories
Algrebra Programming

Correction – find missing / extra element in set of values 1..(N-1)

So I already noted this correction in the previous post – but this is what they find a repeated / missing element in a collection of values from 1…N-1 should have looked like.

Correction - find a repeated / missing element in set of values 1..(N-1)
Correction - find a repeated / missing element in set of values 1..(N-1)

Just writing this problem down is making me realize how much I have forgotten. Time to crack open the books. I mean I even forgot my notation for mapping into a set with conditions!

Categories
Algrebra Problems

Up and Down

This is another one from hard to solve brain teasers. It is just another algebra story problem that I have no idea why the included in the book. You just write down what they tell you as equations and end up with two linear equations with two unknowns – so it is fairly straightforward to solve . I do like the way they present the information here as it acts as a good example problem for introducing the idea of graphing or drawing a problem in order help set up equations to solve it.

It would still be a fairly simple problem to solve, but making the problem 3 equations in two unknowns, and using the extra information to nail one of several solutions might make it more fun. So one like this should go in the book.

Good example on graphical representations to solve a problem
Good example on graphically representing a story problem
Categories
Algrebra Problems

Irregular Circuit

So this was problem 5 from hard to solve brain teasers. I am working through the book and this problem is representative of about 60-70% of the problems which are just annoying. This would not be a hard problem in a 6th or 7th grade algebra course. I am fairly sure the book is targeted at adults – so are these problems hard because you are supposed to not remember junior high? Ugh.

The problem:

“Two cars start from point A at the same time and drive around a circuit more than one mile in length. While they are driving laps around the circuit, each car must maintain a steady speed. SInce one car is faster than the other, one car will pass the other at certain points. The first pass occurs 150 yards from point A.

At what distance from A will one car pass the other again?”

Irregular CIrcuit
Irregular CIrcuit

The thing I don’t like about this problem is it really is just a story problem where you just get the answer reading it. How? Because the problem lacks enough information to have any other way to set it up. You either get that starting at 0 and ending at A away from 0 means the second pass will be 2A away from the origin as long as the track is longer than 4A in length.

This could be turned into an interesting problem if the speed around the track was not constant in such a way that for the Nth lap A would be in the lead, for the Mth B would be in the lead. Then knowing who wins the race would require knowing the track length. If that was not given but was instead easily calculable the way to solve the problem would not jump out so much. I will have to try and write up a version like that for the book.

Update: Interesting – the problem directly before this one in the book is the same problem class I was proposing to modify this too. I wonder if the author was thinking that when clustering these problems of if that was just on my mind since I just solved that problem two hours ago or so. Huh.

Categories
Geometry

Is this useful to know?

So after that last problem I got to thinking that the area between a circle and its bounding or contained square would be potentially useful to know. Really. It just seemed cool. Only problem is that every use for it I could think of I could think of other ways to get there. Grrrr. Is this really cool – or is it the mathematical equivalent of carrying around a small dog in a shoulder bag?

Is this useful to know?
Is this useful to know?
Categories
Geometry Logic Problems

Mathematicians suck!

Finally I have some time to work through daily problems again. Worked this one last week and forgot to write it up.

When I saw this problem I just saw the trigonometry solution and it blinded me to the symmetry. I guess math is good at showing how what we already know can blind us to the better paths.

So why do mathematicians suck? Well that seemed politer for Konrad than saying he sucks – I worked on this problem for a while and just did not see it. He saw the answer before I was finished describing the problem. So I guess I am the one who sucks, – apologies to mathematicians everywhere.

Area of a square - inside a circle - inside a square
Area of a square - inside a circle - inside a square