Skip to content
Sign upLog in
← Back to Community
EcoCode: Competitive Code Golfing Online
Profile icon
hacker
has Hacker Plan
eco27

Test your code golf skills

Inspired by the many code golf challenges on repl.it and elsewhere in the past, I created EcoCode, an online competitive code golfing website. Code golf is the programming challenge of solving problems in the shortest number of characters possible. EcoCode gives you an environment to attempt to solve a variety of programming challenges in the shortest number of characters using JavaScript.

Compete on the leaderboards

Every one of the 14 unique challenges ranging in difficulty from easy to very hard has its very own leaderboard. Your solutions are automatically processed then placed on the leaderboard by number of characters. Compete on the general leaderboard for the shortest solutions overall with your score being the sum of the scores of all your solutions. See who is the best code golfer!

Online coding environment

EcoCode has an embedded code editor using Ace and also allows you to test your code on the fly. No need for another IDE or the JavaScript console, write, test, and submit your code directly in EcoCode.

Mobile support

EcoCode was one of my first projects using responsive web design. No matter how wide your window is, EcoCode is still usable. With mobile support, attempt code golf challenges or check the leaderboards wherever you are.

repl auth

Log into EcoCode directly with your repl.it account, username, and pfp with the wonders of repl auth! Note that repl auth is still very much in beta and can be a bit buggy on some browsers and some platforms.

Can you be the champion code golfer? Find out on EcoCode today!

CODE GOLF TIPS: https://repl.it/talk/learn/Tips-and-Tricks-for-Code-Golfing-in-JavaScript/29876

Voters
Profile icon
pyelias
Profile icon
AmazingMech2418
Profile icon
ARJPEG
Profile icon
AgastyaSandhuja
Profile icon
leemlam
Profile icon
Awzri
Profile icon
LordPancake
Profile icon
templedees
Profile icon
ash15khng
Profile icon
JacksonHall
Comments
hotnewtop
Profile icon
amasad

wow dude this is insane how polished it is!

Profile icon
Navinor
Profile icon
NoelB33

is it just me or does this show up as a deceptive site for everyone?

Profile icon
IsaacLaFuria

@NoelBryan
, normal site for me

Profile icon
IsaacLaFuria

@Noelbryan
, deceptive for my friend though

Profile icon
TMishra

@NoelBryan

The deceptive site thing comes up for me too

Profile icon
NoelB33
Profile icon
NoelB33
Profile icon
NoelB33

It also says, “ An Error occured:
Failed to authenticate :(“


@MrEconomical

Profile icon
NoelB33
Profile icon
NoelB33

Thanks! It works now!

@MrEconomical

Profile icon
bgrubert

@NoelBryan
You can bypass the deceptive warning by clicking "view details," and then "visit this unsafe site"

Profile icon
bgrubert

@MrEconomical
I know, it was just a trick I used earlier.

Profile icon
staticvoidliam7

c# support
plz

Profile icon
Roar123

Very cool! I'm impressed with the degree of functionality EcoCode has with login, leaderboard, and an IDE. There's only one thing that's missing - Python support!

Profile icon
[deleted]

@MrEconomical
does it use the repl.it API, or its own evaluation thing? You could possibly set up an eval client thing...

Profile icon
[deleted]

@MrEconomical
ok, cool. does the eval server use an external API like repl.it's or your own?

Profile icon
[deleted]
Profile icon
ARJPEG

Really, an amazing job, but for the 'EEEEEEEEEE' challenge, it [the submit button] doesn't work as it doesn't let me submit it says, Status: ERROR Error: ReferenceError: prompt is not defined
My code:

e="2.718281828459045235360287471352662497757247093699959574966967627724" console.log(e.substring(0,prompt()))```
Profile icon
ARJPEG

@MrEconomical
Ohhh thanks

Profile icon
AmazingMech2418

@adityaru
For that one, you also need like 600 to 700 digits of e, and I also would recommend using slice instead of substring.

Profile icon
ARJPEG

@AmazingMech2418
oh ok thank you!

Profile icon
AmazingMech2418

@adityaru
You're welcome!

Profile icon
ARJPEG

@AmazingMech2418
fast reply!

Profile icon
AmazingMech2418

@adityaru
Yeah... I'm already on Repl.it, so I just had to see the notification and then reply.

Profile icon
ARJPEG

@AmazingMech2418
, wait how do you the input var? Sorry, I'm not very good at node

Profile icon
AmazingMech2418

@adityaru
It's just a precreated variable. Just put input.

Profile icon
AmazingMech2418

Please add more codegolf challenges. However, please not more like the one where you have to calculate e (I had to just copy and paste a bunch of digits and used the slice function) where attempting to do it in a shorter way would overload the memory in the browser. Also, another thing you could possibly do is make it so that other users can create codegolf challenges as well.

Profile icon
AmazingMech2418

@MrEconomical
I tried and it needs like 500 digits and JavaScript doesn't have that kind of precision...

Profile icon
AmazingMech2418

@MrEconomical
Won't the Node compiler timeout then? It would take a very long time, especially when dealing with the exponents.

Profile icon
AmazingMech2418

@MrEconomical
Tried that too. It won't work for decimals...

Profile icon
AmazingMech2418

For some reason, in leap years and character repetition, it is saying my solution is incorrect when it is actually correct. Any ideas on what is going on?

Profile icon
AmazingMech2418

@MrEconomical
No. For example for the leap year one, I just put console.log(input%4==0) which is correct, but was marked incorrect. Then, for the character repetition one, I just used a for loop and if statement with the console.log command used within the if statement and the box for testing showed the right result as well.

Profile icon
AmazingMech2418

@MrEconomical
I purposefully designed my script to display in order of first appearance with my script being this: for(i in a=input)if(i==a.search(a[i])&&i!=a.lastIndexOf(a[i]))console.log(a[i])

Profile icon
AmazingMech2418

@AmazingMech2418
Oh. It is supposed to be the first repetition, not the first occurrence.

Profile icon
AmazingMech2418

@AmazingMech2418
It worked when I updated it. I just misread the instructions.

Profile icon
avibeskrowni

now i really need help. after i log in it takes me to the screen that says "repl.it refused to connect".

Profile icon
bgrubert

Repl.it refused to connect

Profile icon
JORDANSISNEY

It's so cool!!! I wish I knew JavaScript lol I tried to do it in Python. :P

Profile icon
AgastyaSandhuja

I can't log in for some reason

Profile icon
mkhoi

Nice, sucks that i suck at JS

Profile icon
[deleted]

Dark mode! You need to add a dark mode! My poor eyes!

Profile icon
[deleted]

AIEEEE! Why don’t repls that use repl auth work on my iPad?! It looks fun :(

Profile icon
avibeskrowni

I can't log in for some reason

Profile icon
[deleted]

What device are you using? Mobile doesn’t work.

@avibeskrowni

Profile icon
avibeskrowni

@CodeABC123
macbook air

Profile icon
[deleted]

That’s your device’s problem.

@avibeskrowni

Profile icon
bgrubert

Why do I get the fail message every time?(This was the leap year challenge)
The code seems to work when I test it

Profile icon
bgrubert
Profile icon
[deleted]

does it use byte counts or char counts? if i typed a 2-byte unicode character, would my count go up by 1 or 2?

Profile icon
[deleted]

@MrEconomical
also, is there any way to see the expected input and output for a challenge? i want to know where my code is failing.

Profile icon
[deleted]
Profile icon
MatthewDoan1

@MrEconomical
Not true, my code on the E(uler) problem works on the sample but not for all of them.

ಠ益ಠ)

Profile icon
[deleted]

@MatthewDoan1
same for me with the character repitition - it works for the sample, but not for submitting. I tried looking through the source code to find the test cases, but I couldn't find them.

Profile icon
Mapaor4

I don't get it. How can I be stucked on the 1st level?
I enter the simplest code:

#include <iostream> using namespace std; int main(){ int input; cin >> input; for( int i = 0; i < input; i++){ cout << "Hello world!" << endl; } }

and I get this error:
SyntaxError: private fields are not currently supported

Help pls :'(

Profile icon
Highwayman

@MrEconomical
It would be cool if it had support for C++. hm maybe you could get support with google......compiler...........????? I know next to nothing about it, but yeah? No? Just a suggestion :P

Profile icon
Mapaor4

@MrEconomical
Oh sorry. My fault hehe

Profile icon
[deleted]

@Highwayman
it would have to compile and run the C++ in one step. This could be done, but you would have to probably port some tools for this, like Emscripten, to client side JS.

Profile icon
mattp123

JavaScript

Profile icon
Highwayman

@sugarfi
hmmm Idk bout that, that seems pretty hard. I was thinking more just getting a server that compiles and runs it for you and sends back the output, not doing it in the Client.

Profile icon
[deleted]

@Highwayman
the best way: just call os commands with unsanitized user input! What could go wrong?

Profile icon
Highwayman

@sugarfi
hey hey hey well what I was thinking was this:
...

** F wait your right **

Profile icon
Highwayman

@sugarfi
actually you could disallow some headers very easily for C++ actually, so couldn’t you just find any offensive/ dangerous headers and just spit the program back with an error if they’re there?

Profile icon
[deleted]

@Highwayman
what i'm saying is doing something like system(command + " test.whatever") but letting the user pick the command. Then they could do something like rm -rf /# and remove all your work

Profile icon
Highwayman

@sugarfi
buuut you can easily just say oh. Look this guy put #include <cstdlib> on line 273, f u random person I’m not compiling that! or make a regular expression to find the system command and deny that instead for more fine grained searching and sanitation.

Profile icon
Highwayman

@sugarfi
also they’d have to have the right permissions for that.

Profile icon
[deleted]

@Highwayman
but there are things other than system in <cstdlib> - what if the challenge needed them to use, say, malloc? As well, what if they made a function called system, but it was not malicious? Would you block, say, the following code?

#include <iostream> #include <string> void system(std::string cmd) { std::cout << "Not real!"; } void main(void) { system("rm -rf /#"); }
Profile icon
Highwayman

@sugarfi
that’s why you’d use a regex match instead of just looking for cstdlib instead.

Profile icon
[deleted]

@Highwayman
maybe to remove system files, but not to delete, say, the whole source of ecocode.

Profile icon
[deleted]