Weekly Challenge #1
Good Morning/Afternoon/Evening/Night to all beautiful replers! Today we are starting something very requested set of events. That's right!
TODAY WE START WEEKLY CHALLENGES ONCE AGAIN!
For the new users who were not around the last time, we were hosting these. These are short coding challenges that you are required to finish within 1 week. A new challenge is posted every weekend and you have until the next challenge is posted, to finish that challenge.
At the end of every month, the total score of the 4 challenges held within that month is your score. The one with the highest score at the end of every month will be awarded free replit hacker plan!
To post your submission, just publish your repl onto apps and make sure to include the tag #weekly{n}
and replace {n}
with the number of the weekly challenge in the title. For example, for the submission to this weekly challenge, publish the repl that contains your submission on apps and include the tag weekly1
.
More guidelines
- You are allowed to make only 1 submission. Only submit after you're completely sure about submitting your submission. Your score won't be updated once your submission is scored.
- If there is any sort of condition in which your submission does not satisfy the challenge's requirement, its score will be
0
.
And that's it! Now, let's get back to this week's weekly challenge.
SQUARE ROOT!
Inspired by the last year's first challenge, you have to write a program that finds a number's square root. BUT, as usual, with a twist! You are not allowed to use the arithmetic operators *
and /
(some languages use these for operations other than multiplication and division so they're fine there). You can also not use any external libraries, or the square root functions of any internal libraries of any language you might be using, or any special square root or square operators specific to your language. Same goes for exponentiation operators/pre-defined functions - not allowed.
It is also fine if your program cannot find the square root in case the number is not a perfect square, the minimum requirement is for the program to be able to detect at least the square roots of perfect squares.
Note that first your output is judged and only if it can be figured out without having to look at the code, will the code be judged. Basically, you just have to add prompts that tell the user what to enter and what each value is. For example:
This is wrong
> 25 5
This is right
Please enter a number: 25 The square root of 25 is 5.
If you have any further questions, you can ask them via the comments section, and if you don't, I would still recommend going through the comments section as they may contain some extra information.
The criteria for scoring is subjective but there are points for creativity, uniqueness, clean code, etc.
Also, you may find @DynamicSquid hosting these alongside me so just know that those are official too and you will be getting scores for those.
Good luck to all the replers, have fun and hack away!
num ** 1/2
Is this allowed? It has the "*" in it, but it is not that individual.
@JeffreyChen13 Exponents aren't allowed
@MrVoo but whhyyyy
@kannibalistic Beeeeecause it's a challenge
@JeffreyChen13 You can do multiplication and exponents using addition. eg:
function mult(a, b) { let result = 0; for (let i = 0; i < a; i++) result += b; return result; } console.log(mult(0, 6)); // -> 0 console.log(mult(6, 5)); // -> 30 console.log(mult(9, 9)); // -> 81
@MattDESTROYER I am a Python coder, I have no idea what this is LOL
@JeffreyChen13 In python:
def mult(a, b): result = 0 for i in range(a): result += b return result print(mult(0, 6)); # -> 0 print(mult(6, 5)); # -> 30 print(mult(9, 9)); # -> 81
@MattDESTROYER Haha yes! I thought of that. It is multiplying but in the way of repeated addition. I thought of that too, just working on the Pygame parts in my code : )
@JeffreyChen13 Yep, you got it. Nice :)
You can even do long division manually, I used these tricks in my project.
@JeffreyChen13 Just repeated addition in a for loop, I did it like this:
def square(root): sum = 0 for i in range(root): sum += root return root
@MattDESTROYER And to say, you really don't need that extra parameter b, because a and b are the same thing, you can just substitute b with a! Clean code there, yay!
def mult(a): result = 0 for i in range(a): result += b return result
@JeffreyChen13 The parameter b
was to enable you to do multiplication as well as squares. To be honest I think I recreated all the operators in my project manually lol. I also took a different approach to getting square roots to everyone else as far as I can tell.
@MattDESTROYER Lol you need to multiply?
@FlaminHotValdez It is quite a useful ability.
@MattDESTROYER Indeed, but it is not necessary for this challenge. ;)
@FlaminHotValdez You're really enjoying low-key flexing on everyone that you found such a unique solution, aren't you :P
@FlaminHotValdez what are you doing the Babylonian method?
@RayhanADev I don't know names lmao
@RayhanADev Not Babylonian. I don't think the method has a name, it's just based on logic. You can easily derive the result from simple algebra. (Ik this coz we used the same method) I gave an explanation on my spotlight page if you want to see it.
for some reason I can't put a hyphen for the tag, so can I just submit it without the hyphen?
@ruiwenge2 yea, that's what I did. The only tag is #Weekly1
@ruiwenge2 Oh yeah, sorry about that! Just submit it without the hypen please :)
ok thanks @DynamicSquid @CodingEssence
when are the monthly highlights for June going to be announced? @DynamicSquid
am i allowed to use log()
from the math
in python?
@CodingEssence No, because log is related to exponents.
@DynamicSquid ok :(
@DynamicSquid How about abs()
?
@CodingEssence abs() is perfectly fine :)
@DynamicSquid yay! :)
what about infinite?
@kannibalistic ill just F A I L
@kannibalistic Input's will be reasonable, so don't worry about large numbers :)
@DynamicSquid thanks!
When are the monthly highlights going to be announced?
Finally weekly challenges are back
they are back!?!
@JDOG787 yes!
Do we just turn it in publicly to let everyone see our work? btw i'm accusing no one
@kannibalistic and do we get our scores in or email or something?
@kannibalistic Yeah. Don't worry, it's rare for plagiarism to happen. And if it does, just let me know :)
Also for your scores, you'll get a comment on your repl once it has been marked
@DynamicSquid thanksx =D
@TheDrone7 or @DynamicSquid , when is the due date?
@LavernieChen It is a week after this post has been created, I suppose
@JeffreyChen13 Did it start at July 3? I'm not a daily checker
So i suppose it is july 10?
@LavernieChen No, if you move top to the post, today it will say "Posted 4 days ago" only if you live right now in America PST haha, if you are in another time zone, please convert, which means it would have started at July 1 (in my time zone), so it must be due at July 8.
@JeffreyChen13 Haha, Yes only in america not sure if time zone in america matters, should be same day
@LavernieChen Friday morning when I wake up
what if for some reason your account is stuck in education mode (I can't leave it but I'm not in any teams for ed.), not that I'm got anything yet.
@cuber1515 Do you have discord? Just DM Drone the submission. Or reply to my comment with your submission
ok, thanks @DynamicSquid
Hey, for C++ am I allowed to include 'iostream' or that other library that imports the printf statement?
Also, when is the submission date.
@Whippingdot Yes you can use that library, and the due date is anytime between when you publish to apps and the next challenge
@Whippingdot Yeah. Fuzzy and I already asked lol
good cause i deleted my python one when i learned that you could only submit it in one language :( @FlaminHotValdez
Thanks! @MrVoo
when will these be scored
@FlaminHotValdez Whenever Drone looks at them :)
=( this is soo hard im a beginner
i keep thinking of new ways, but im tryin out how to work them out
is it ok to use /
or *
in this situation
num[len(num)/2]
?
@DEANKASOZI No :)
@DynamicSquid
:o, ok, good to know
@DynamicSquid
so you can't use it in any way where it will be dividing or multiplying something, string or integer?
@DEANKASOZI Nope. There can't be *
or /
in your code
@DynamicSquid
ik ._., like 5 different people told me that XD
Is hard-coding the solutions allowed? e.g a single massive object with key-value pairs of perfect squares and their square roots xD
@EducatedStrikeC well, you'd need an infinite object, as the set of perfect squares is infinite...
@TheDrone7 @EducatedStrikeC the other option would be to use psychic powers and predict exactly which numbers will be tested, and hard-code those only.
@Nayoar I mean, if you use a lazy language like Haskell technically that's possible :)
@Nayoar Yes the set of perfect squares is infinite, but patience of people to test them all is finite :)
Is the modulus operator (%
in python and JS) allowed?
@TheDrone7 great, thanks, I wasn't sure if it might be banned because idk if it uses /
behind the scenes
Can we make small edits once we publish if you haven't scored yet?
Great challenge! This is actually fun!
Also I would to ask a question (just for confirmation). Is the modulo operator allowed? I think it is, but once again just confirming! Thanks!
@Th3Coder Yeah, it's allowed
@DynamicSquid thanks! Well, I can just replace it with loops and minuses anyway
finally finished -_-
p.s.(if you think root is a module, it's not, check my files, it is one of the files I made)
@DEANKASOZI
what are the extra enters for?
I made a version in python, not sure if it fits requirements though, still working on it
I'm confused @TheDrone7 , So you can't add multiplication or division to put in your code?
Thanks! @DynamicSquid
I think I did a good job: https://replit.com/@JarodL/WeeklyChallenge1#main.py
You can also not use any external libraries, or the square root functions of any internal libraries of any language you might be using, or any special square root or square operators specific to your language. Same goes for exponentiation operators/pre-defined functions - not allowed.
lol
@JarodL
you know, i actually did the exact same thing and they said we can't use exponents
@JarodL
actually, this a literal imitation of the code i did earlier, i guess were both looking at it that way
Im a newbie in python rn, plus, the "not using * or /" part makes things harder
@DEANKASOZI This doesn't require advanced programming knowledge-just your brain! Basic knowledge should be all that's necessary
@FlaminHotValdez
ik, im trying to figure it out with my brain. i mean, im pretty sure im on the right track, though it depends on the answer for this question: for python, can we use the "pow(x, y)"?
@DEANKASOZI You can't use exponents
@FlaminHotValdez
yea, just found that out, im restarting
Eyyyy, weekly challenges are back :D
done ez
@zplusfour You can't use the division operator :)
btw js is not the future js sucks
@DynamicSquid WTF ok
wait what I didn't use js
@DynamicSquid I unpublished it
@zplusfour Your profile description says JS is the future
@DynamicSquid yeah yeah but the repl is not written in js :)
yknow what, ima change it
@zplusfour you used exponent operator lmao
So I’m allowed to publish today, then add someone else and publish the update because scoring is going to be next week?
@VulcanWM I wouldn't risk it. Drone could score anytime. I would recommend publishing once you're certain it's done
okay thanks @DynamicSquid
so uh exponentiation is allowed
@Lord_Poseidon no
where's the frontend partew frontend
@Lord_Poseidon What's wrong with frontend? .-.
@MrVoo
nah I just suck at it@Lord_Poseidon 😭
@Bookie0 frontend requires knowledge of several specific languages/libraries, this requires nothing but your brain
@FlaminHotValdez precisely
@FlaminHotValdez idk, frontend seems easier for me but
¯\_(ツ)_/¯
@Bookie0 yeah but it requires knowledge of specific things. This challenge requires your brain and only the most basic programming knowledge(variables, loops, if, input/output).
Hmm.. I do know those basics, but I just can't think of something lol (most likely because this week I've been rahter distracted and away). Oh well! :D @FlaminHotValdez