I think everyone knows that for answering a question, the first step is to understand the question. It is not a big deal, but how important is this step?
For a student this matter is quite clear and for who dealing with algorithms much more. I remember one day my teacher asked us to solve a maths exercise, I didn’t understand the question so I asked teacher to explain the question and she explained after she asked us,
Did you get it?
Everyone replied “No”,
She explained again, I didn’t get it, my classmate next to me said “yes, I got it”, so I asked my classmate to explain it for me, surprise! He didn’t understand it, the reason he said was maybe he doesn’t want to look stupid.
Ok, I asked teacher for third time and this time I got the question so the answer was so easy, I asked my classmate who previously said that he understand the question, did you get it now? He said “No”.
After teacher left our desk, I explained it for my classmate and straight away he told the answer. Oh it was so easy.
Sometimes students want to do assignment before understanding the requirement even before revising the lectures. I always tried to concentrate on the question before guessing the answer.
This matter is extremely important when you are dealing with customer and database because your art is to do whatever you have been asked to do and not whatever you think is right.

Take the digits 1,2,3 up to 9 in numerical order and put either a plus sign or a minus sign or neither between the digits to make a sum that adds up to 100. For example, one way of achieving this is:

1 + 2 + 34 - 5 + 67 - 8 + 9 = 100, which uses six plusses and minuses. What is the fewest number of plusses and minuses you need to do this? I love to challenge myself with these kind of puzzles, so I solved this and here is how:

We have 9 numbers [1 to 9] and also we have three possible separators [+, - and nothing] which to fill the gap between numbers we have 8 combinations of separators, e.g. we have 1+2+3+4+5+6+7-89 which in this case we have six times plus, one minus and one time nothing.

So, I need to find all possibilities of combination which total is: 6561

Then, hook the possible combinations into numbers and check the total, easy enough. Now print the solution.

I have written this algorithm in PHP but ea…

## Comments

## Post a Comment