Share your repls and programming experiences

← Back to all posts
THIS PROGRAM GUESSES THE NUMBER YOU PICKED
OldWizard209 (1528)

You pick a number, keep it in your mind. You won't be asked for the number. The program is then gonna ask you a few questions. Answer them and using math, it will guess your number.

ENJOY :)

Comments
hotnewtop
BrokenVessel101 (2)

Yeah its really cool how youve done this. To figure it out you take the first number in each of the lists you said yes to and add them together. Well done for putting it into code :)

KrazyOrange (27)

Nice! The list stuff is cool!

[deleted]

it didnt guess my number for 6 attempts

OldWizard209 (1528)

no offence but is is Not possible . @BRUHIP

OldWizard209 (1528)

might be a mistake from ur side? @BRUHIP

CadenGamble (3)

does not work for me at all

OldWizard209 (1528)

U have to enter yes or no ONLY @CadenGamble

CadenGamble (3)

@abdullahrajput9 thats weird tho in the code it has both in the if statment

CadenGamble (3)

@abdullahrajput9 oh ok when i was messing with this the other day it had them both in the if statement unless you fixed but that makes sense

OldWizard209 (1528)

Yeah and I guess I didn't change for all of the statements cuz I was too lazy to just copy paste the code XD @CadenGamble

[deleted]

yeah the same as @Bookie0 said

import sys, os, curses
import time

And this is the code:

st = 0.04
def sp(str):
for letter in str:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(st)
print()

Bookie0 (6268)

@ConorTseng lol why did you just copy what I wrote lol

[deleted]

@Bookie0 it was just a joke

[deleted]

i picked 2. 0 wasn't even in the list at all

OldWizard209 (1528)

It dosent have to be in all the lists that is why i am asking u if the number is in the list or no. And BTW u have to write yes or no not just y or n @AJDevelopment

Bookie0 (6268)

For slowprint, you should make it in a function:

import sys, os, curses
import time 
# And this is the code:

st = 0.04
def sp(str):
  for letter in str:
    sys.stdout.write(letter)
    sys.stdout.flush()
    time.sleep(st)
  print()

I usually put it at 0.04 because it prints it not too fast and not too slow. But you can change it. Just change the value after st

Each time you want to do this typewriter effect, just do:

sp(“Hello World”)

;)

OldWizard209 (1528)

I know I can make a function but after it was done i was too lazy to change it :) Thanks for the suggestion tho @Bookie0

OldWizard209 (1528)

OK @Bookie0 I was kinda itching by looking at my code being soo ugly so I will change it to a function.

SOON.......

OldWizard209 (1528)

Changed, Thanks a lot to you :) @Bookie0

PlazmaDolphin (0)

i tried for 2 and it said my number was 0.
what???

OldWizard209 (1528)

NGL, this program dosen't fail so u must have entered the wrong answers @PlazmaDolphin

PlazmaDolphin (0)

@abdullahrajput9
oh yeah i said y and n instead of yes and no that must have been it... sorry!

OldWizard209 (1528)

Yup unfortunately it dosent accept y and n so lemme change it @PlazmaDolphin

Jeydin21 (101)

Bruh. You should choose trickery as your major, legit

OldWizard209 (1528)

I call it MATH @Jeydin21
AND BTW I am only 12 so i cant pick a major :(

[deleted]

@abdullahrajput9 doesn't the repl.it TOS say 13+ (i am not a moderator so i can't do anything about this)

OldWizard209 (1528)

UMMM actually i am turning 13 in December @AJDevelopment

Jeydin21 (101)

@AJDevelopment Well, I'm pretty sure that there are some other very good coders on repl.it who posts regularly in Repl Talk that are under 13.

Jeydin21 (101)

@AJDevelopment Also I don't think Repl.it would limit their services to 13 and older because coding is supposed to be available to everyone regardless of their age.

ThisUserTaken (243)

here's how you did it. It's WAY EASIER to understand if I made the list shorter. The list and yes or no questions are part of the trick in this program. Let's say I asked you to have a number in this list [1, 2, 3, 4, 5, 6]. Let's say you chose 2. The first question he asks is even or prime by asking if the number is in this list [1, 3, 5]. this already halves the chance of our answer. We say no. He now knows that it is an even number. He mixes it a little by asking whether it is in this list [1, 4, 5] (changed some numbers). You say no. Ok, now he knows its an even number that is not 4. The final question: [1, 2, 4]. Is it in this? He already knows it isnt 4 and 1, so if you say yes, its 2 but if you say no, its 6! You say yes and the number is determined as 2! Tricky, yet simple!

adl212 (172)

@ThisUserTaken Time for me to make sure the program can't guess my number!

ThisUserTaken (243)

@adl212 oh. it will if you answer correctly. the math works that way.

ThisUserTaken (243)

trying to twist it up huh? but still good job using logical reasoning!

OldWizard209 (1528)

LOL I am not twisting it up, I am just analysing the data u provide and giving an answer based on that @ThisUserTaken

ThisUserTaken (243)

@abdullahrajput9 ik look at my other comment. i mean your kinda twisting with the list questions.

OldWizard209 (1528)

I know but thats what the program is made for ;) @ThisUserTaken

Stan085 (23)

Eh, its ok, i guess i'll upvote :)

JasonLiu19 (71)

how??? it guessed my number (think that's the point but whatever)

OldWizard209 (1528)

LOL @JasonLiu19
Its a simple math if you take it into consideration but the math is tricky, so you have to LOVE math to understand this

ThisUserTaken (243)

@JasonLiu19 look at my comment. Also, the Pokemon Battle game I made was by me. It was 1 month and 13 days older than that other person's. I have more evidence if you think I'm lying. -_-

OldWizard209 (1528)

Umm I dont get what u mean there @ThisUserTaken

ThisUserTaken (243)

@abdullahrajput9 its a long story. he accused me of copying someone else's program, but it was the other way around. That person forked my repl after 1 month and 13 days of I creating it. Sorry if you got a little confuzzled.

ThisUserTaken (243)

@abdullahrajput9 here's the post he said I "copied" https://repl.it/talk/share/Pokemon-Battle/59696. if you look at my repls and the other guys one. his is the exact same copy but created 1 month after I finished, so I was saying he forked mine instead of I copying him.

JasonLiu19 (71)

@ThisUserTaken never said you copied, was trying to find out who copied who(the guy is in one of my classes) and was suspicious because a.he was not doing well in that class and b.he is in 6th grade

ThisUserTaken (243)

@JasonLiu19 i am sorry for misunderstanding you lol. I thought you were on his side. Sorry for causing this trouble!

ThisUserTaken (243)

@JasonLiu19 ye. i really wish it said who forked who. I created that 6 months ago and started repl 3 months ago

MocaCDeveloper (651)

That is pretty cool not gonna lie!

MocaCDeveloper (651)

@abdullahrajput9

I honestly would've never had the brains to figure out how to do it. Good job!

NoNameByProgram (197)

did you just copy a post...that's trending...?

OldWizard209 (1528)

NOOOO This is a completely different program LMAO @NoNameByProgram
I made it

NoNameByProgram (197)

@abdullahrajput9 why did you steal some code for no reason?

NoNameByProgram (197)

@abdullahrajput9 i saw it again. why did you have to edit it

OldWizard209 (1528)

It was a mistake, This program and the trending one were side by side so I mistakenly clicked that one. I than had to edit it after seeing ur comment @NoNameByProgram