Updates from the Repl.it team about the product

← Back to all posts
Weekly Challenge #1
h
TheDrone7 (1932)

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
Bookie0 (6359)

where's the frontend part

MrVoo (78)

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

FlaminHotValdez (712)

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

Bookie0 (6359)

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

FlaminHotValdez (712)

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

Bookie0 (6359)

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

JeffreyChen13 (58)
num ** 1/2

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

MrVoo (78)

@JeffreyChen13 Exponents aren't allowed

MrVoo (78)

@kannibalistic Beeeeecause it's a challenge

MattDESTROYER (16)

@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
JeffreyChen13 (58)

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

MattDESTROYER (16)

@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
JeffreyChen13 (58)

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

MattDESTROYER (16)

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

JeffreyChen13 (58)

@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
JeffreyChen13 (58)

@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
MattDESTROYER (16)

@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 (16)

@FlaminHotValdez It is quite a useful ability.

FlaminHotValdez (712)

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

GhostKing007 (142)

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

RayhanADev (2594)

@FlaminHotValdez what are you doing the Babylonian method?

GhostKing007 (142)

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

ruiwenge2 (1101)

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

CodingEssence (125)

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

kannibalistic (103)

what about infinite?

DynamicSquid (5016)

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

ruiwenge2 (1101)

When are the monthly highlights going to be announced?

IMayBeMe (527)

Finally weekly challenges are back

firefish (953)

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

kannibalistic (103)

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

kannibalistic (103)

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

DynamicSquid (5016)

@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

JeffreyChen13 (58)

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

LavernieChen (10)

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

LavernieChen (10)

So i suppose it is july 10?

JeffreyChen13 (58)

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

LavernieChen (10)

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

DynamicSquid (5016)

@LavernieChen Friday morning when I wake up

cuber1515 (90)

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.

DynamicSquid (5016)

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

Whippingdot (678)

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

Also, when is the submission date.

MrVoo (78)

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

FlaminHotValdez (712)

@Whippingdot Yeah. Fuzzy and I already asked lol

Whippingdot (678)

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

FlaminHotValdez (712)

when will these be scored

DynamicSquid (5016)

@FlaminHotValdez Whenever Drone looks at them :)

kannibalistic (103)

=( this is soo hard im a beginner

DEANKASOZI (12)

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

spiceagent11 (1)

Is hard-coding the solutions allowed? e.g a single massive object with key-value pairs of perfect squares and their square roots xD
https://vidmateapp.win https://tataindicombroadband.in

DynamicSquid (5016)

@spiceagent11 Uhhhhh... I mean... I guess? But you probably won't be giving a lot of point for that xD

DEANKASOZI (12)

is it ok to use / or * in this situation

num[len(num)/2]

?

DEANKASOZI (12)

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

DynamicSquid (5016)

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

DEANKASOZI (12)

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

EducatedStrikeC (3)

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

Nayoar (581)

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

TheDrone7 (1932)

@Nayoar do be speaking fax here.

Nayoar (581)

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

fuzzyastrocat (1867)

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

EducatedStrikeC (3)

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

Nayoar (581)

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

Nayoar (581)

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

MrVoo (78)

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

Th3Coder (135)

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 (135)

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

DEANKASOZI (12)

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)

XCode101 (41)

@DEANKASOZI
what are the extra enters for?

LavernieChen (10)

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

LavernieChen (10)

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

FlaminHotValdez (712)

@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

DEANKASOZI (12)

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

DEANKASOZI (12)

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

DEANKASOZI (12)

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

FlaminHotValdez (712)

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

DEANKASOZI (12)

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

MrVoo (78)

@DEANKASOZI You can't use exponents

DEANKASOZI (12)

@FlaminHotValdez
yea, just found that out, im restarting

JBloves27 (1903)

Eyyyy, weekly challenges are back :D

DynamicSquid (5016)

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

btw js is not the future js sucks

zplusfour (914)

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

DynamicSquid (5016)

@zplusfour Your profile description says JS is the future

zplusfour (914)

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

FlaminHotValdez (712)

@zplusfour you used exponent operator lmao

aa2dee2 (11)

Can we make multiple submissions in different languages?

VulcanWM (2874)

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

DynamicSquid (5016)

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