+ 9

[challenge] how many fishes does Tom have?

Tom decides to sell all his fishes he sells: 1/2 of all his fishes and 1/2 fish 1/3 of the rest and 1/3 fish 1/4 of the rest and 1/4 fish 1/5 of the rest and 1/5 fish now he still has 11 fishes Tom would never be able, to kill even one of his fishes. How many fishes did Tom have at the beginning? find out with a program. Have fun

27th Nov 2017, 9:18 PM
Oma Falk
Oma Falk - avatar
13 odpowiedzi
+ 12
some of you say, it is too easy. It is indeed.... . but it is a special case of program follows brain ( for beginners )
28th Nov 2017, 9:41 AM
Oma Falk
Oma Falk - avatar
+ 8
This is a simple mathematical puzzle; Suppose the number of fishes he has at the start is x. The first time he sells, he has (0.5x - 0.5) fishes left. Next, he sells 1/3 of his fishes + 1/3 of a fish, meaning he has (2(0.5x - 0.5) / 3) - (1/3) fishes left. This is getting complicated, so let's call that number y. Next, he sells 1/4 of his fishes and 1/4 of a fish. That would mean he has 3y/4 - 1/4 fishes left. This is z. Finally, he sells 1/5 of his fishes, and 1/5 of a fish. So, he has 4z/5 - 1/5 of a fish. Which we know is equal to 11. Now, to solve the equation backwards... 4z/5 - 1/5 = 11 4z = 56 z = 14 3y/4 - 1/4 = 14 y = 19 2(0.5x - 0.5) / 3) - 1/3 = 19 x = 59 Therefore, he started with 59 fish. //QED. 😉 [Edit] I could write a program if you wanted me to, but there's no point.
28th Nov 2017, 12:56 AM
blackcat1111
blackcat1111 - avatar
+ 6
print(((((11+1/5)*5/4+1/4)*4/3+1/3)*3/2+1/2)*2
28th Nov 2017, 8:43 AM
Jaydeep Khatri
Jaydeep Khatri - avatar
+ 5
Use the branching method, it will be very helpful
28th Nov 2017, 2:13 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
Yeah, here's my complete search solution; https://code.sololearn.com/coqIKaj0grI8/?ref=app
28th Nov 2017, 2:18 AM
blackcat1111
blackcat1111 - avatar
+ 5
https://code.sololearn.com/ck1oyPDVpIS5/?ref=app
28th Nov 2017, 4:45 AM
...
+ 4
This is hmmm... kindergarten drill not a challenge! besides I don't understand your question
27th Nov 2017, 11:04 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 4
@Batman Actually, if you solve it mathematically, there is no point writing a program. Let's say you have an algorithm for tic-tac-toe where you cannot be beaten if you follow it. If you want to create an unbeatable program, you'd just give it to the computer, instead of complete searching every single possibility every turn. Hence, math over program over brain. 😉
28th Nov 2017, 10:07 AM
blackcat1111
blackcat1111 - avatar
+ 4
@ Batman (( as u love patterens )) I DERIVED 4 INTERESTING THINGS OUT THERE FROM THIS CHALLENGE ** taking initial case with 59 fishes as 1 // ✔ The casewhen the no . of fishes reaches 1 ✔ The case when it gets the LAST +ve Value ✔ For which cases No. Of Fishes are PERFECT - INTEGERS ✔ a nice " PATTERN " >>>> CAREFULLY LOOK :::::: if for case 'x' no. of remaining fishes is 'y' for case 'y' no. of remaining fishes is 'x' https://code.sololearn.com/c0dGHZX37F8q/?ref=app
28th Nov 2017, 1:21 PM
sayan chandra
sayan chandra - avatar
+ 3
no loop... one liner... 😂😂😂😂😂 https://code.sololearn.com/cK0s9J6Je97w/?ref=app
28th Nov 2017, 4:51 AM
sayan chandra
sayan chandra - avatar
+ 3
class A{ public class void main(String args[]){ int x; x=11; x=x+(4*x/5)+1/5; x=x+(3*x/4)+1/4; x=x+(2*x/3)+1/3; x=x+(x/2)+1/2; System.out.println(x); } }
28th Nov 2017, 6:08 AM
Hemanth Varma
Hemanth Varma - avatar