Challenges!


#1

Hello all! I just wanted to rekindle the who wants a challenge? topic without bumping it after seven months. I think it's really cool to pass on challenges to other users, even if they're newer and just want to participate. I really like codewars, but the katas can really kick your butt, and I like the community aspect of this forum. :slight_smile: Anyways, challenge away. I don't know exactly how to go about this, but anybody who wants a challenge can ask for the difficulty level and language like: "Gimme a easy/mediumish challenge for Ruby, m8."
Hopefully this picks up. :slight_smile: @stetim94 gave me a good challenge I'll be working more on when I have time.


Welcome to our forums! Please Introduce Yourself
#2

Ok well lets get this started. I think I want a medium Javascript challenge. Not sure what that challenge will encompass but if possible I like games :stuck_out_tongue:


#3

Can you write a function, that when passed a string of words, you can print the length of the SHORTEST word?
Does this make sense?


#4

Yeah, Basically, if I type a string like this "brad ate pizza tonight" I want ate to return because it is the shortest word


#5

You want to return 3, because

:slight_smile:


#6

Sigh yeah yeah just testing ya :stuck_out_tongue: ok sounds interesting enough :smiley: thank you! let the fun begin


#7

i already provided a good challenge for kyleaw:

build a program which build a pyramid, first prompt the user for how high the pyramid should be, lets say the user enters 5, the pyramid should be printed like this:

#
##
###
####
#####

if you want to make it yourself more difficult:

    #
   ##
  ###
 ####
#####

or even more difficult:

    # 
   # # 
  # # # 
 # # # #
# # # # #

you can pick the programming language, good luck!


#8

does someone have a good challenge for me?


#9

what you want a challenge in oh master of coding? :stuck_out_tongue:


#10

of course, even for me there can be challenges. I am still struggling on codewars on a regular basis :stuck_out_tongue:


#11

me too, I just started yesterday and those katas kill me


#12

I've got one!
Can you write a program that generates a guessing game? Make it end when the user guesses the correct answer. If the user guess is too low, tell them, also tell them if it's too high. I've done this in Java using scanner.
Bonus points: ask the user to determine what the range should be!

This sounds hard but it's really more time consuming than difficult.


#13

is this you? https://www.codewars.com/users/kyleaw

the challenges in codewar get more difficult if you progress through the ranks


#14

That is in fact me! :slight_smile:


#15

Haha so @kyleaw where did you get that challenge? :stuck_out_tongue: not from codewars :open_mouth: hehe


#16

No, the guessing game is something I wrote in Java a couple months ago. :slight_smile:


#17

No I meant mine xD you give me link to your profile and the first challenge I see is "Shortest Word" and I be like this girl is trying to get me to cheat haha


#18

I did mine in python haha, I've already seen the solutions for JavaScript, it was just something I did yesterday and I was trying to think of something pretty easy.

Mine in python.

def find_short(s):
    # your code here
    l = 100
    words = s.split(" ")
    for word in words:
        if len(word) < l:
            l = len(word)
    return l

#19

hm.. i build the number guesses 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!"
        print("not the right number")
        print("guesses remaining:", guesses - i - 1 )
    return "You lost"
print(guess())

still has some sharp edges, but how did i do? (this is python3 code)


#20

function find_shortest_word(str)  
{  
  var array1 = str.match(/\w[a-z]{0,}/gi);  
  var result = array1[0];  
  
  for(var x = 1 ; x < array1.length ; x++)  
  {  
    if(result.length > array1[x].length)  
    {  
    result = array1[x];  
    }   
  }  
  return result;  
}  
console.log(find_shortest_word('brad ate pizza tonight'));

Ok, I will admit, I did cheat slightly with var array1 = str.match(/\w[a-z]{0,}/gi); found it on another forum post xD However, fondly enough, other javascript lessons pretty much provided everything else :smiley: