0

PY Exponentiation challenge mistake, or did I misunderstand the challenge?

The given answer in the Python exponentiation challenge "0.01 * 2**30" tells us how much we would get on Day 31, since on Day 1 we get "0.01 * 2**0". Code follows: # your code goes here x = 0.01 n = 30 # on the 1st day we get $0.01 (=0.01*(2**0)), on the 2nd day we get $0.02 (=0.01*(2**1)), etc. #first two days combined equal 0.01*((2**2)-1) #using the given expresion (0.01)*(2**5) we are calculating how much we are getting on the 6th dsy #using the combined equation (2**5)-1 we see that we have accumulated ($0.31) on the 5th day #5th day accumulation = $0.01 + $0.02 + $0.04 + $0.08 + $0.16 = $0.31 print (x*(2**n)) #this is actually how much we would get on day 31, so the "correct" answer is wrong any way we look at it #print (x*((2**n)-1)) #this is how much we've accumulated on day 30

12th Jan 2021, 9:09 PM
Mika Hämäläinen
Mika Hämäläinen - avatar
7 ответов
+ 2
Take a close look at the hint: You basically only have to change the number of days in the formula Try without "-1" part
12th Jan 2021, 9:27 PM
Lisa
Lisa - avatar
+ 1
https://code.sololearn.com/cloxZJ45Bxoo/?ref=app Well, it doesn't matter how we call starting day or when we start as long as we double FOR the time of 30 days, right?
13th Jan 2021, 6:51 PM
Lisa
Lisa - avatar
+ 1
Well demonstrated. Maybe I got hung up with the age old story of the peasant who did a favor to a rich king, and the king granted the peasant with one wish. The peasant asked for rice grains on a chess board, where the amount of grains doubled on each square. His wish was granted, but of course never fulfilled. Calculating this problem one has to count like I did in the challenge, omitting the *0.01 of course.
13th Jan 2021, 7:30 PM
Mika Hämäläinen
Mika Hämäläinen - avatar
0
I understand, but it's still wrong. If you follow my line on thought, 0.01 * 2**30 tells us how much we would get on day 31, not day 30. This is because: On day 1, we get 0.01 * 2**0, which equals 0.01 * 1. On day 2, we get 0.01 * 2**1, which equals 0.01 * 2. On day 3, we get 0.01 * 2**2, which equals 0.01 * 4. On day 4, we get 0.01 * 2**3, which equals 0.01 * 8. On day 5, we get 0.01 * 2**4, which equals 0.01 * 16. . . On day 30, we get 0.01 * 2**29, which equals 0.01 * 536 870 912 = 5 368 709,12 On day 31, we get 0.01 * 2**30, which equals 0.01 * 1 073 741 824 = 10 737 418,24. (The "wanted" answer.) But the total accumulated sum (day 1 + day 2 + day 3 + ... + day 30) on day 30 is 0.01 less than what we would get on day 31. To me, this is exactly what the challenge is about. I hope this clarifies my point. Correct me if I miscalculated.
13th Jan 2021, 1:28 PM
Mika Hämäläinen
Mika Hämäläinen - avatar
0
So according to your calculation, we do not double from day 1 but only from day 2: 2**0 = 1 --> day1 = 0.01 But if we start doubling from day 1, we would start by 2**1 = 2 --> day1 = 0.02 (day0 = 0.01) What do you think about it?
13th Jan 2021, 2:17 PM
Lisa
Lisa - avatar
0
Why would we get doubled on day 1? It sounds silly and confusing to me. But maybe it's just me. 😄 Anyway, I can't see the challenge anymore, so I can't refer the exact wording. If memory serves I thought it was worded ambiguously, but then again, english isn't my first language.
13th Jan 2021, 6:36 PM
Mika Hämäläinen
Mika Hämäläinen - avatar
0
Oh, yeah, the chess board and the rice grains! I remember that! 😊
13th Jan 2021, 7:33 PM
Lisa
Lisa - avatar