I pick a number. You guess it. You can guess at most 25 times. For every guess you make, I will tell…
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
Is this possible to solve this with Python 3.7. I can’t find any other way. Here is my code:
import random
x = 1000000
y = 0
for i in range(25):
a = random.randint(y, x)
print(a)
b = input()
if b == "Bigger":
y = a+1
elif b == "Smaller":
x = a
elif b == "Bingo!":
break
else:
break
@Abdullah_1234, yes it is absolutely possible to solve this problem with python.
Toph already has a tutorial about it !!!
However, it might have been removed so I cannot find it.
Any clue, @hjr265 ?
You are using a random number. You can’t use random number because it gives random number
every time. You need to use binary search. You just need to replace a = random.randint(y, x) with a = int((x + y) / 2)
Your’re using wrong qutations
The one you used “ ”
But it should be " "
if you fix these you will get an Accepted verdict.
Here is the AC code: [REDACTED]
I didn’t know about binary search before I started this problem that’s why I posted a silly question. I got AC after solving this problem with binary search🙂.