Author: The CodeFights Team

Can Learning Be Addictive?

Can Learning Be Addictive?

CodeFights CEO Tigran Sloyan gave a TEDx talk in October, and we’re so excited to be able to share it with the world!

Watch the video to discover how advances in neuroscience, psychology, and game theory have paved the way for the creation of addictive learning systems like CodeFights.

Tigran outlines the basics of an unconventional – but proven – method of creating geniuses. If you start teaching a young child one skill very early on, and keep them focused on that single skill for years, they will excel at it. He discusses how following a similar practice in his childhood led to him becoming an international math champion.

His experiences led him to discover the core idea of CodeFights: that practicing a skill needs to be fun in order to be effective! He talks about why the challenge-achievement-dopamine loop (a core component of CodeFights gameplay) is critical to keeping people engaged in any process.

Challenge Achievement Dopamine Loop

Tell us…

Have you ever experienced the challenge-achievement-dopamine loop that Tigran talks about? If so, has it helped you to learn a new skill – coding or otherwise? Let us know on the Forum over on CodeFights!

The CodeFights Polyglot Marathon

The CodeFights Polyglot Marathon

Polyglot (noun):

A person who has mastered multiple languages.

Are you a programming polyglot? Here’s your chance to prove it!

If you pride yourself on knowing multiple programming languages, then you’re going to love our next worldwide coding tournament. On November 11, CodeFights is hosting the Polyglot Marathon.

This marathon is composed of twelve coding tasks. You get to choose which language you want to solve each question in, and each one must be solved in a different coding language. If that sounds tricky, that’s because it is! You have to know 12 different programming languages well enough to solve a coding task in them. (That’s why it’s really helpful to have our new Syntax Tips feature displayed in each challenge. 😁)

Consider this your chance to practice programming in all of those different languages that you love but don’t get a chance to use very often. Keep in mind that while CodeFights does support 38 different programming languages, Python 2 and Python 3 will count as the same language for the purposes of this marathon, as will C and C++.

The Polyglot Marathon will start Saturday, November 11 at 9:00 AM PST. Remember to adjust this to your own time zone when you’re planning out your day! Since this is going to be a difficult marathon, you’ll have two hours to solve all of the tasks.

The top 10 participants will all receive a $50 Amazon gift card and 500,000 CodeFights coins. Will you be one of them?

Sign up on CodeFights!

Polyglot Marathon Rules:

  • You must solve each task in this Marathon using a different programming language.
  • You can run your code as much as you want before submitting, which will run it against sample test cases only. When you actually submit your solution, we run all the tests on it.
  • Your score depends on how many tests your program passes. If you pass all the tests, you get the maximum possible score for that task. Passing sample tests does not give you points, so you need to pass some of the non-sample tests to get a positive score.
  • In the case of a tied score for a task, the participant with the lowest time penalty is ranked highest.
Hello World! Introducing Language Syntax Tips

Hello World! Introducing Language Syntax Tips

Ever wondered how to say Hello world in 38 different programming languages? CodeFights has you covered!

We just launched Syntax Tips, a brand-new feature in all of our coding tasks and challenges that gives you important information about how to format code in every programming language that our platform supports.

It can be hard to remember how to format a function, write a comment, print to the console, or return output in a specific language. This is especially true if you’re just learning the language, or if it’s one that you don’t use very frequently. So this is going to come in very handy!

Hello world

Gif of all supported programming languages on CodeFights
Hello world in 38 languages!

Think of Syntax Tips as your own personal Rosetta Stone for programming languages. To see tips for a particular language, just choose that language from the dropdown menu at the top right side of the code editor. (This is also how you change the language that you’re writing in to solve a task.)

Hello world in JavaScript

You do not need to do anything different to access Syntax Tips. This section is now at the bottom of every coding task’s description section, no matter which CodeFights mode you’re using.

Just as a reminder, CodeFights now supports 38 different programming languages: ClojureCoffeeScript, Common Lisp, C, C++, C#, D, Dart, Elixir, Erlang, Free Pascal, Fortran, F#GoGroovyHaskellJavaJavaScript / ES6JuliaKotlinLuaNimObjective-COCamlGNU OctavePerlPHPPython 2Python 3RRubyRustScalaSmalltalkSwift 3TclTypeScript, and Visual Basic.

If your favorite language isn’t on this list yet, don’t worry. Because we know how important it is for you to be able to practice programming in the language of your choice, we add new language support to CodeFights all the time. (Seems like just yesterday that we only had 14 languages, and look at us now!)

Tell us…

What you you think of Syntax Tips? Let us know over on the CodeFights user forum!

Interview Basics: Multidimensional Arrays

Interview Basics: Multidimensional Arrays

Did you read last week’s article on static vs dynamic arrays? If not, catch up now! This week we’re continuing the arrays theme and discussing multidimensional arrays. This is another data structure that you absolutely have to know to succeed in technical interviews, which is why several of our array questions in Interview Practice feature them.

Multidimensional Array Basics

What makes a multidimensional array different from a plain old array? And just what is a multidimensional array, anyway? 

Basically, a multidimensional array is also a random-access data structure, but in this case the data is accessed by more than one index.

Some languages like C# have built-in support for multidimensional arrays. But other languages support multiple indices by creating an “array of arrays”. A multidimensional array in which you need N numbers to reference a particular piece of data is an N-dimensional array. In other words, N is the number of indices needed to locate a single element in the array.

How do you access elements in a multidimensional array? In the “array of arrays” model, the elements at arr[i] are arrays themselves. And element arr[i][j] is the jth element in the array arr[i]. These arrays can be dynamic or static.

The good: The item lookup by index for multidimensional arrays is O(1), and it’s easy to iterate over every element stored in a multidimensional array. You can use multiple indices that make sense for the problem you’re solving (consider using rows and columns for a problem about a chess board, for example), which makes it easier for you to read and maintain your code.

The bad: It’s not easy or quick to rearrange the elements in a multidimensional array, and it requires a long time to change its size.

Meet the 2D Array

Technically, it’s possible to have a multidimensional array of any size. But for technical interviews, it’s most important for you to be familiar with 2D arrays. 2D arrays are often used to implement:

  • Matrices, where matrix[i][j] represents the element at row i and column j;
  • Game boards like chess or checkers boards, where board[row][col] represents the state of the board at the location (row, col);
  • Maps, in which the map is divided into cells to represent different locations.

Jagged vs Regular Arrays

As we mentioned earlier, different languages have different ways of representing this kind of array. When implementing a 2D array as an “array of arrays” (i.e. arr[i] is itself an array), there is no technical reason why len(array[i]) == len(array[j]). If the subarrays have different lengths, we call this a jagged array.

jagged multidimensional array
A jagged multidimensional array

But when we talk about multidimensional arrays, we often mean regular (or rectangular) arrays, in which each dimension has a fixed length.

regular multidimensional array
A regular multidimensional array

TL;DR? Watch this video instead!

More of a visual learner? We get it. Watch this video to get up to speed on the basics of multidimensional arrays!

Up to speed on this handy data structure? Head on over to the arrays section of Interview Practice to solve some real multidimensional array-based technical interview questions!

Interview Basics: Static vs. Dynamic Arrays

Interview Basics: Static vs. Dynamic Arrays

Arrays are one of the most basic data structures in computer science. But they form the basis of some difficult technical interview questions! So no matter where you are in your programming career, you need to be very familiar with arrays and how to use them. Read on to review the basics of static and dynamic arrays, then watch our video to get clear on the differences between them. And once you’re ready to solve some array-based technical interview questions on your own, head to Interview Practice. You’ll be able to practice solving array interview questions that have been asked at Google, LinkedIn, Apple, Uber, and Palantir. 

First Things First

Whatever programming language you choose use in an interview, make sure you know its array methods very well. Like, forwards and backwards well. Interviewers will definitely be judging you on this! If you don’t know something basic like this in the language you’ve chosen to interview with, they’ll question how well you know that language at all… Not to mention how well you can program, period. So spend some time with your language’s documentation to make sure that you’ve got a handle on its basic and advanced array methods.


The simplest definition of an array is that it’s a data structure that contains a group of elements. In interviews, you’ll get a lot of questions about static arrays, which are the most basic implementation of this data structure. You’ll also get questions about dynamic arrays. We’re going to focus on static and dynamic arrays in this article. (You’ll also get questions about multidimensional arrays in technical interviews, which we’re going to cover in an upcoming article.)

Static Arrays

The most basic implementation of an array is a static array. A static array is a random-access data structure with a fixed size. You have to declare its size when you first initialize it. To add or remove elements from a static array, you have to create a new appropriately-sized contiguous chunk of memory. Then you have to copy the elements that you want to keep into this new array.

The good: The item lookup by index for static arrays is really quick (O(1)), and they have a very low memory footprint.

The bad: Adding elements to or deleting elements from the array is an O(n) operation, where n is the number of elements in the array. Searching the array for a particular element is also O(n). Arrays don’t allow for the quick rearrangement of their elements.

Dynamic Arrays

A dynamic array is a random-access, variable-sized list data structure that elements can be added to or removed from. They’re basically like static arrays, but with the addition of space that’s reserved for adding more elements. When dealing with a dynamic array, there are two important factors to consider. There’s the logical size of the array (the number of elements being used by the array’s contents) and its physical size (the size of the underlying array). The physical size is counted in either the number of elements the array has room for, or the number of bytes used. In a technical interview, you should use a dynamic array if you know you’ll need to add or delete information.

The good: On average, it’s quick to insert elements to the end of the dynamic array. And item lookup by index is O(1).

The bad: They don’t allow for the quick rearrangement of their elements. And they have inconsistent runtimes for adding elements to the array, so they’re not good for real-time systems.

Diving Deeper

Now that you’re clear on the basics of static and dynamic arrays, watch this video for a deeper dive on the differences between the two.

Bonus Array Joke

  1. Why did the programmer leave his job?
  2. Because he didn’t get arrays.

(Get it? Arrays, “a raise”! Stop groaning. It’s a great joke.)

Beautiful JavaScript Winner Code Walkthrough

Beautiful JavaScript Winner Code Walkthrough

“It’s rewarding. It feels good to come up with a solution, and just to in general practice how you approach solving problems.”

– Beautiful JavaScript winner boomx on CodeFights

The CodeFights Beautiful JavaScript contest wrapped up a few weeks ago, and the winners were CodeFighters boomx, arnav_a2, and marcusekeenan. Each of them won a trip to San Francisco and three nights at a hotel downtown. We recently had the first of our winners visit us!

boomx is a software developer in North Carolina. Earlier this year, he went to a conference where a presenter talked about how important it is for programmers to stay sharp by practicing outside of work. One of boomx’s coworkers mentioned that CodeFights is his favorite site for practicing programming, so he signed up to try it too. boomx solved a few challenges here and there, but really got into the site once he saw the Beautiful JavaScript challenge. Now he tries to solve the daily Challenge as often as he can to keep his skills sharp!

We had a great time hosting him at CodeFights HQ. Our Engineering team really enjoyed getting to talk with him about his solution, coding in general, and of course JavaScript!

Beautiful JavaScript Winner boomx
Oh, you know, just casually pointing at a contest winner.

During his visit, he was kind enough to give us a great walkthrough of his solution. He started by talking about his original naive solution, and then about how he optimized it. It’s really interesting to see the code’s evolution from its (still great!) beginnings to the expressive, readable, and concise solution that you can see at solution #191. Watch his explanation below!

Thanks, boomx!

We’ll post the next two solutions when our other winners visit us later this year, so stay tuned!

Beautiful JavaScript Contest Winners

Beautiful JavaScript Contest Winners

The Beautiful JavaScript contest was an amazing event. We got over 500 solutions from our awesome CodeFighter community! It ended up being really hard to narrow our list of favorites down to just three. But after a lot of thought, our judges have chosen the three that they think are the most expressive, readable, and concise – in other words, the most beautiful – as our winners.

The winners

Congratulations to the winners of the Beautiful JavaScript contest! Each of these CodeFighters has won a three-day trip to San Francisco, and will get to come nerd out with us about JavaScript at CodeFights HQ.

See the winner’s solutions section of this post for their full solutions to the challenge secretArchivesLock! We’re going to be posting an in-depth explanation of each winner’s solution, in the winner’s own words, so stay tuned for that in the next few weeks.

Honorable mentions

We also want to acknowledge the following CodeFighters with an honorable mention and a CodeFights gift box!

  • ben_s24: This CodeFighter’s solution was a crowd favorite – commenters on the challenge really liked his solution!
  • hydralisk: Not only did this CodeFighter have a great solution to the challenge, he also reviewed all of the solutions to compile his own list of favorites.
  • jeff_b36: This CodeFighter created an awesome website to help visualize the challenge.

The winner’s solutions

And now the moment you’ve all been waiting for – the winner’s solutions!

arnav_a2’s solution

arnav_a2's Beautiful Javascript Solution

boomx’s solution

boomx's Beautiful JavaScript Solution

marcusekeenan’s solution

marcusekeenan's Beautiful JavaScript Solution

Congratulations to our winners! And everyone who submitted a solution, great work! We really enjoyed reading through all of the creative solutions that you all came up with.

Tell us…

Did you have a favorite solution that didn’t end up being a winner or an honorable mention? Let us know over on the CodeFights Forum!

Introducing the CodeFights Arcade Database World

Introducing the CodeFights Arcade Database World

The ability to access, understand, and manipulate data is extremely important in the current engineering job market. Employers are increasingly listing SQL as a “required skill” in job listings, whether the job is a back-end engineering job or not.

Data scientists, data analysts, researchers, and many others also need to be able to access information that’s stored in relational databases. No matter what your job title is, the ability to dive deep into an organized collection of data to answer questions, uncover patterns, and discover information is incredibly useful!

But unless you already work with a relational database, whether at a job or at school, how do you practice writing efficient and accurate queries?

Database World

At CodeFights, we wanted to give people a fun, easy way to practice writing queries and manipulating data. That’s why we created Database World, our latest addition to the CodeFights Arcade!

Database World has over 80+ tasks spread out over 16 levels. The questions start out easy… But they ramp up in difficulty as you progress. This means you’ll never get bored as you practice!

Database World is a unique way of learning database skills that’s both educational and entertaining. While you write more and more queries, you’ll start to know what to look for and how to pinpoint the information you need. You’ll get faster and have less hesitation. In other words, writing amazing SQL queries will become second nature for you. You’re going to be able to leverage this into being highly competitive in the job market!

Back up – what’s the Arcade?

There are five different worlds in the CodeFights Arcade. Each world has tons of levels and tasks to complete that help you master a particular concept.

  • Start tackling tasks and get familiar with Arcade in the The Intro.
  • Get up to speed on programming fundamentals in The Core.
  • Python World focuses on helping you master programming in Python.
  • Solve graph theory questions in Graphs World.
  • And now, practice your SQL and database skills with Database World!

Get started!

Are you ready to become a database guru? If so, get started on Database World with projectList, the first task in the introductory level!


Interview Practice: Graphs, Advanced Trees & RegEx

Interview Practice: Graphs, Advanced Trees & RegEx

We’ve just added three-brand new computer science topics to Interview Practice! Get ready to dive deep on Graphs, Trees: Advanced, and RegEx. We’ve added these topics to our Extra Credit learning plan, which covers all of the topics in Interview Practice. 

Why are these topics so important to know for technical interviews? Read on for a brief introduction to each concept!


Graphs Interview Practice TopicA graph is an abstract data structure composed of nodes and the edges between nodes. Graphs are a useful way of demonstrating the relationship between different objects. For instance, did you know that you can represent social networks as graphs? Or that the 6 Degrees of Kevin Bacon game can be modeled as a graph problem? Graph questions are really common in technical interviews. In some cases, the question will be explicitly about graphs, but in other cases the connection is more subtle. Read our tutorial to get up to speed on this topic and to learn how to identify this kind of question. Then practice your skills on graph questions from real technical interviews!

Trees: Advanced

Trees: Advanced Interview Practice TopicA tree is a data structure composed of parent and child nodes. Each node contains a value and a list of references to its child nodes. Tree traversal and tree implementation problems come up a lot in technical interviews. Common use-cases for an interview are: needing to store and do searches on data that is sorted in some way; needing to manage objects that are grouped by an attribute (think computer file systems); or implementing a search strategy like backtracking. You need to be very familiar with how to deal with these kinds of questions! (The tasks in Trees: Advanced ramp up in difficulty from the ones you get in the Trees: Basic category, so make sure you finish those questions before moving on to these ones!)


RegEx Interview Practice TopicA regex is a string that encodes a pattern to be searched for (and perhaps replaced). They let you find patterns of text, validate data inputs, and do text replacement operations. A well-written regex can make it easier to solve really tricky interview questions like “Find all of the 10-digit phone numbers in a block of text, where the area code might or might not be surrounded by parentheses and there might or might not be either a space or a dash between the first and second number groupings”. While the specifics of how to implement a regex can vary between languages, the basics are pretty much the same. In the topic tutorial, we cover regex character classes, quantifiers, anchors, and modifiers and how to use them to write a good regex.    

Start now

These topics might not get asked in every interview, but they’re important to know! Read the tutorials about each concept, then solve the real interview tasks to practice your skills and solidify your understanding of the topic. (Learn more about how we’ve updated the Interview Practice experience to make it an even better practice and preparation tool.)

If you’re signed up for the Extra Credit learning plan, these topics have been added to your Interview Practice page already. If you’re signed up for a different learning plan, you can switch over to Extra Credit. Or you can sign up for a customizable Freestyle plan and add these topics!

New supported languages: C, Erlang, Rust, and more!

New supported languages: C, Erlang, Rust, and more!

You asked, and we listened! Over the past few weeks, we’ve added support for 14 more programming languages to the CodeFights platform.

The new languages on CodeFights are:

  • C
  • Clojure
  • CoffeeScript
  • Common Lisp
  • D
  • Elixir
  • Erlang
  • Julia
  • Kotlin
  • Lua
  • Nim
  • Objective-C
  • OCaml
  • Rust

With these additions, we now support 32 coding languages that you can use to solve CodeFights tasks! Being able to select your language of choice means that you can master your primary coding language, practice a language that you’re in the process of learning, or just try one on for size.

See the postscript to this blog post for the entire list of languages that you can use on the platform. Keep in mind that you can’t use some languages to solve some tasks, so if that’s the case you may need to choose a backup language. (For instance, you can’t use Lua to solve a database task, so you’ll need to switch to MySQL.)

We hope that you’ve found a few languages that you’re excited about using! If your preferred language isn’t on our list, you can start a post on the CodeFights Forum to request it. We try to add new supported languages a few times a year based on user requests and language popularity.

Programming Languages Supported on CodeFights

CodeFights Supported Languages

The languages that our platform currently supports are:

Bash, Clojure, CoffeeScript, Common Lisp, C, C++, C#, D, Elixir, Erlang, F#, Go, Haskell, Java, JavaScript (ES6), Julia, Kotlin, Lua, MySQL, Nim, Objective-C, OCaml, Perl, PHP, Python2, Python3, R, Ruby, Rust, Scala, Swift3, and Visual Basic.