Python Python Book Error: Solving a Math Problem with Aliens and Multiple Heads

  • Thread starter Thread starter OrbitalPower
  • Start date Start date
  • Tags Tags
    Book Error Python
AI Thread Summary
The discussion centers around a riddle involving an alien with three heads that grows additional heads based on a specific formula. The initial interpretation of the problem led to confusion regarding the correct calculation of the total number of heads. The formula proposed was (3 * 2) + 1, which resulted in a misunderstanding of the phrasing. The correct interpretation clarifies that the alien first grows one head and then doubles the total number of heads, leading to a total of 10 heads. The phrasing of the problem was noted as awkward, contributing to the confusion, particularly since the relevant part was only visible in the console window and not in the source code provided.
OrbitalPower
In python for the absolute beginner, we have this (page 28):

"If an alien has 3 heads, grows 1 more than double his total number of
heads, how many heads does the alien have?"

My formula is: (3 * 2) + 1

(For example, in this sequence, each sequential number is one more than double the next one: 2, 5, 11, 23, 47.)

but he gives (3 + 1) * 2 = 8. But he says one more than double his (current) total. So that seems incorrect.

Who is right?
 
Technology news on Phys.org
OrbitalPower said:
"If an alien has 3 heads, grows 1 more than double his total number of heads, how many heads does the alien have?"

I would have thought

3 + (3*2 + 1) = 10

heads.
 
Yes. That's right. The error was my own. It says "if an alien has 3 heads, grows 1 more THEN doubleS his total number of heads, how many heads does the alien have."

In fairness, I couldn't really see. That part of the program is only in the console window, not in the source code he gives (for some reason).
 
Maybe it's meant to say:
"If an alien has 3 heads, grows 1 more then doubles his total number of heads, how many heads does the alien have?"

It's awkwardly-phrased as it is.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
10
Views
3K
Replies
2
Views
2K
Replies
1
Views
1K
Replies
4
Views
5K
Replies
2
Views
3K
Replies
1
Views
4K
Replies
6
Views
4K
Back
Top