Okay I went through this and the logic and readability of it is very high. it’s really good. the only thing that would make it easier, (for the user, rather than your programming), I would say that instead of just telling the user that their guess was wrong, actually tell them if it was too low or too high. you did it so fast! really impressive.
oh yes, i forgot that part of the assignment, let me fix that
This is awesome! Really good job. It was easy for me in python, but JavaScript was a lot harder for me because I forgot methods and stuff.
You did really awesome.
Yeah funnily enough I can get longest word shortest word and first word out of a string from that one code xD Just change the < and > around and you can get all three from the one code
Yeah, and that’s really awesome. I think the point of challenges is to improve thinking and how to get better. Do you have a pretty easy challenge for me? I’ll do Java or python, not sure yet.
updated version of the game:
from random import randint
print("welcome to the number guess game")
invalid = True
while invalid:
try:
print("enter the range of guess game")
minimum = int(input("enter minimum value: "))
maximum = int(input("enter maximum value: "))
guesses = int(input("nuber of guesses: "))
if minimum + 5 > maximum:
raise ValueError
except ValueError:
print("invalid input or to small range")
else:
invalid = False
number = randint(minimum,maximum)
def guess():
for i in range(0,guesses):
try:
temp = int(input("guess the number: "))
except ValueError:
print("invalid input, you wasted a guess")
else:
if temp == number:
return "you won!"
elif temp > number:
print("number is to high")
else:
print("number is to low")
print("not the right number")
print("guesses remaining:", guesses - i - 1 )
return "You lost"
print(guess())
simply adding a if/else solves the problem
@bibleman13 impressive js solution to the problem
perfect! do you prefer to program in python 3?
well, certain things are certainly better in python3. And python3 is default on my arch linux installation, besides, the world is slowly moving away from python2, new projects are better to coded in python3
Ok well you have heard of PigLatin now we are doing CowLatin. in Python create a function that when a string is imputed you get the reverse of that string or you get the string backwards whichever you prefer. Bonus: do both! Not sure how hard that is…but it is something xD
In Java, I found this challenge on codingbit.com under Easy Java challenges 2nd Tier,
Medium boolean logic puzzles – if else && || !
We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.
makeBricks(3, 1, 8) → true
makeBricks(3, 1, 9) → false
makeBricks(3, 2, 10) → true
what is the challenge here? you could simply do:
def example(input):
return input[::-1]
Well I made that one up so ruin my dreams if you must i was just thinking of something off the top of my head xD
oh man
what if you have:
makeBricks(2, 6, 25)
should true be returned? Or are this cases not given?
such a case is given, and this is possible without loops?
that sounds like a challenge, i will try it
I believe for the sake of the challenge it wants you stick with the cases given. [quote=“stetim94, post:33, topic:65935”]
Return true if it is possible to make the goal by choosing from the given bricks.
[/quote]
http://codingbat.com/doc/practice/makebricks-introduction.html
I believe if it works true should be returned however if it fails false
and sense it says possible without loops I would assume it is possible without loops. The link above takes you directly to the challenge and if necessary you could complete the first challenge of makeBricks just to get a feel for it. Also, solutions and help is on the website as well.
I haven’t started it, I’ve thought about it, and it probably won’t take me too long, but I’ll do it after school in a few hours. I’ll keep you posted.
see if you can build all pyramids, the first one is super easy.
Alright, I got something, did it in python. (I originally wrote everything in java but then couldn’t find an alternative to multiplying a string like you can do in python.)
First one:
rows = raw_input("how many rows of pyramids? ")
counter = 1
for i in range(0, int(rows)):
content = "#" * counter
counter += 1
print content
Second one:
rows = raw_input("how many rows of pyramids? ")
counter = 1
spaces = int(rows)
for i in range(0, int(rows)):
spacesPrinted = " " * spaces
content = "#" * counter
counter += 1
spaces -= 1
print spacesPrinted + content
Third one:
rows = raw_input("how many rows of pyramids? ")
counter = 1
spaces = int(rows)
for i in range(0, int(rows)):
spacesPrinted = " " * spaces
content = "#" * counter
counter += 2
spaces -= 1
print spacesPrinted + content
Tell me how I did… it’s not the best, but I tried.
i was really mean. wasn’t i? You did good, but there is one challenge remaining:
#
# #
# # #
# # # #
# # # # #
the final and most difficult one.
yours:
#
###
#####
#######
#########
they are not the same, mean, isn’t it?
the final one is really difficult
hmmm… you are mean
I’ll see what I can do.