Skip to content
← Back to Community
Weekly Challenge #1
Profile icon
h
has Hacker Plan
TheDrone7

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

  1. 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.
  2. 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!

Comments
hotnewtop
Profile icon
Bookie0

where's the frontend part

Profile icon
Lord_Poseidon

ew frontend

Profile icon
MrVoo

@Lord_Poseidon What's wrong with frontend? .-.

Profile icon
Lord_Poseidon

@MrVoo nah I just suck at it

Profile icon
Bookie0

@Lord_Poseidon 😭

Profile icon
FlaminHotValdez

@Bookie0 frontend requires knowledge of several specific languages/libraries, this requires nothing but your brain

Profile icon
IMayBeMe
Profile icon
Bookie0

@FlaminHotValdez idk, frontend seems easier for me but ¯\_(ツ)_/¯

Profile icon
FlaminHotValdez

@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).

Profile icon
Bookie0

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

Profile icon
CodingElf66
num ** 1/2

Is this allowed? It has the "*" in it, but it is not that individual.

Profile icon
MrVoo

@JeffreyChen13 Exponents aren't allowed

Profile icon
kannibalistic

@MrVoo but whhyyyy

Profile icon
MrVoo

@kannibalistic Beeeeecause it's a challenge

Profile icon
MattDESTROYER

@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
Profile icon
CodingElf66

@MattDESTROYER I am a Python coder, I have no idea what this is LOL

Profile icon
MattDESTROYER

@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
Profile icon
CodingElf66

@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 : )

Profile icon
MattDESTROYER

@JeffreyChen13 Yep, you got it. Nice :)
You can even do long division manually, I used these tricks in my project.

Profile icon
CodingElf66
Profile icon
CodingElf66

@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
Profile icon
CodingElf66

@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
Profile icon
MattDESTROYER

@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.

Profile icon
CodingElf66
Profile icon
FlaminHotValdez

@MattDESTROYER Lol you need to multiply?

Profile icon
MattDESTROYER

@FlaminHotValdez It is quite a useful ability.

Profile icon
FlaminHotValdez

@MattDESTROYER Indeed, but it is not necessary for this challenge. ;)

Profile icon
GhostKing007

@FlaminHotValdez You're really enjoying low-key flexing on everyone that you found such a unique solution, aren't you :P

Profile icon
CodingElf66
Profile icon
RayhanADev

@FlaminHotValdez what are you doing the Babylonian method?

Profile icon
FlaminHotValdez

@RayhanADev I don't know names lmao

Profile icon
GhostKing007

@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.

Profile icon
ruiwenge2

for some reason I can't put a hyphen for the tag, so can I just submit it without the hyphen?

Profile icon
CyberPy

@ruiwenge2 yea, that's what I did. The only tag is #Weekly1

Profile icon
DynamicSquid

@ruiwenge2 Oh yeah, sorry about that! Just submit it without the hypen please :)

Profile icon
ruiwenge2
Profile icon
CyberPy
Profile icon
ruiwenge2

when are the monthly highlights for June going to be announced? @DynamicSquid

Profile icon
DynamicSquid
Profile icon
CyberPy

am i allowed to use log() from the math in python?

Profile icon
DynamicSquid

@CodingEssence No, because log is related to exponents.

Profile icon
CyberPy
Profile icon
CyberPy

@DynamicSquid How about abs()?

Profile icon
DynamicSquid

@CodingEssence abs() is perfectly fine :)

Profile icon
CyberPy
Profile icon
kannibalistic

what about infinite?

Profile icon
kannibalistic

@kannibalistic ill just F A I L

Profile icon
DynamicSquid

@kannibalistic Input's will be reasonable, so don't worry about large numbers :)

Profile icon
kannibalistic
Profile icon
ruiwenge2

When are the monthly highlights going to be announced?

Profile icon
IMayBeMe

Finally weekly challenges are back

Profile icon
DynamicSquid
Profile icon
firefish

@IMayBeMe well they've been reincarnated once before by yours truly

Profile icon
JDOG787

they are back!?!

Profile icon
DynamicSquid
Profile icon
kannibalistic

Do we just turn it in publicly to let everyone see our work? btw i'm accusing no one

Profile icon
kannibalistic

@kannibalistic and do we get our scores in or email or something?

Profile icon
DynamicSquid

@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

Profile icon
kannibalistic

@DynamicSquid thanksx =D

Profile icon
SilentFoxy78

@TheDrone7 or @DynamicSquid , when is the due date?

Profile icon
CodingElf66

@LavernieChen It is a week after this post has been created, I suppose

Profile icon
SilentFoxy78

@JeffreyChen13 Did it start at July 3? I'm not a daily checker

Profile icon
SilentFoxy78

So i suppose it is july 10?

Profile icon
CodingElf66

@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.

Profile icon
SilentFoxy78

@JeffreyChen13 Haha, Yes only in america not sure if time zone in america matters, should be same day

Profile icon
CodingElf66
Profile icon
DynamicSquid

@LavernieChen Friday morning when I wake up

Profile icon
cuber1515

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.

Profile icon
DynamicSquid

@cuber1515 Do you have discord? Just DM Drone the submission. Or reply to my comment with your submission

Profile icon
cuber1515

ok, thanks @DynamicSquid

Profile icon
Whippingdot

Hey, for C++ am I allowed to include 'iostream' or that other library that imports the printf statement?

Also, when is the submission date.

Profile icon
MrVoo

@Whippingdot Yes you can use that library, and the due date is anytime between when you publish to apps and the next challenge

Profile icon
FlaminHotValdez

@Whippingdot Yeah. Fuzzy and I already asked lol

Profile icon
Whippingdot

good cause i deleted my python one when i learned that you could only submit it in one language :( @FlaminHotValdez

Profile icon
Whippingdot

Thanks! @MrVoo

Profile icon
FlaminHotValdez

when will these be scored

Profile icon
DynamicSquid

@FlaminHotValdez Whenever Drone looks at them :)

Profile icon
kannibalistic

=( this is soo hard im a beginner

Profile icon
GLXY-LGNDS-4

i keep thinking of new ways, but im tryin out how to work them out

Profile icon
GLXY-LGNDS-4

is it ok to use / or * in this situation

num[len(num)/2]

?

Profile icon
DynamicSquid
Profile icon
GLXY-LGNDS-4

@DynamicSquid
:o, ok, good to know

Profile icon
GLXY-LGNDS-4

@DynamicSquid
so you can't use it in any way where it will be dividing or multiplying something, string or integer?

Profile icon
DynamicSquid

@DEANKASOZI Nope. There can't be * or / in your code

Profile icon
GLXY-LGNDS-4

@DynamicSquid
ik ._., like 5 different people told me that XD

Profile icon
EducatedStrikeC

Is hard-coding the solutions allowed? e.g a single massive object with key-value pairs of perfect squares and their square roots xD

Profile icon
Nayoar

@EducatedStrikeC well, you'd need an infinite object, as the set of perfect squares is infinite...

Profile icon
TheDrone7

@Nayoar do be speaking fax here.

Profile icon
Nayoar

@TheDrone7 @EducatedStrikeC the other option would be to use psychic powers and predict exactly which numbers will be tested, and hard-code those only.

Profile icon
fuzzyastrocat

@Nayoar I mean, if you use a lazy language like Haskell technically that's possible :)

Profile icon
EducatedStrikeC

@Nayoar Yes the set of perfect squares is infinite, but patience of people to test them all is finite :)

Profile icon
Nayoar

Is the modulus operator (% in python and JS) allowed?

Profile icon
TheDrone7

@Nayoar Yes it is

Profile icon
Nayoar

@TheDrone7 great, thanks, I wasn't sure if it might be banned because idk if it uses / behind the scenes

Profile icon
MrVoo

Can we make small edits once we publish if you haven't scored yet?

Profile icon
DynamicSquid

@MrVoo Yes

Profile icon
Th3Coder

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!

Profile icon
DynamicSquid

@Th3Coder Yeah, it's allowed

Profile icon
Th3Coder

@DynamicSquid thanks! Well, I can just replace it with loops and minuses anyway

Profile icon
GLXY-LGNDS-4

finally finished -_-

My Entry

p.s.(if you think root is a module, it's not, check my files, it is one of the files I made)

Profile icon
XCode101

@DEANKASOZI
what are the extra enters for?

Profile icon
SilentFoxy78

I made a version in python, not sure if it fits requirements though, still working on it

Profile icon
SilentFoxy78

I'm confused @TheDrone7 , So you can't add multiplication or division to put in your code?

Profile icon
DynamicSquid
Profile icon
SilentFoxy78
Profile icon
JarodL
Profile icon
FlaminHotValdez

@JarodL

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

Profile icon
GLXY-LGNDS-4

@JarodL
you know, i actually did the exact same thing and they said we can't use exponents

Profile icon
GLXY-LGNDS-4

@JarodL
actually, this a literal imitation of the code i did earlier, i guess were both looking at it that way

Profile icon
GLXY-LGNDS-4

Im a newbie in python rn, plus, the "not using * or /" part makes things harder

Profile icon
FlaminHotValdez

@DEANKASOZI This doesn't require advanced programming knowledge-just your brain! Basic knowledge should be all that's necessary

Profile icon
GLXY-LGNDS-4

@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)"?

Profile icon
MrVoo

@DEANKASOZI You can't use exponents

Profile icon
FlaminHotValdez
Profile icon
GLXY-LGNDS-4

@FlaminHotValdez
yea, just found that out, im restarting

Profile icon
JBloves27

Eyyyy, weekly challenges are back :D

Profile icon
zplusfour

done ez

Profile icon
DynamicSquid

@zplusfour You can't use the division operator :)

btw js is not the future js sucks

Profile icon
zplusfour

@DynamicSquid WTF ok
wait what I didn't use js

Profile icon
zplusfour

@DynamicSquid I unpublished it

Profile icon
DynamicSquid

@zplusfour Your profile description says JS is the future

Profile icon
zplusfour

@DynamicSquid yeah yeah but the repl is not written in js :)
yknow what, ima change it

Profile icon
FlaminHotValdez

@zplusfour you used exponent operator lmao

Profile icon
aar2dee2

Can we make multiple submissions in different languages?

Profile icon
TheDrone7
Profile icon
VulcanWM

So I’m allowed to publish today, then add someone else and publish the update because scoring is going to be next week?

Profile icon
DynamicSquid

@VulcanWM I wouldn't risk it. Drone could score anytime. I would recommend publishing once you're certain it's done

Profile icon
VulcanWM

okay thanks @DynamicSquid

Profile icon
Lord_Poseidon

so uh exponentiation is allowed

Profile icon
TheDrone7

@Lord_Poseidon no