How to master writing code fast with spaced repetition and Anki?

Spaced repetition and Anki can help you to learn any programming language quickly and permanently. If you put in 10 minutes each day, you can become the fastest programmer around, easing your work and shine at coding job interviews.

If you don’t know spaced repetition and Anki yet, have a look at this great article: Level Up Your Learning with Anki and Spaced Repetition.

Just to clarify the terms, spaced repetition is a learning technique that is often used with flashcards and Anki is an open-source flashcards application for desktop and mobile.

There are many guides on spaced repetition and Anki, and therefore, this article will focus specifically on how to create flashcards with written code answers. For an example see the three screenshots below.

Question
Type answer and confirm with “Enter” key
Rate answer

Setup

The steps to setup Anki for written code answers are as following:

  • Create your first card
  • Setup card format

Front Template:

{{Front}}
<br>
<br>
{{type:Back}}

Back Template:

{{Front}}
<hr id=answer>
{{type:Back}}

Styling:

.card {
font-family: monospace;
font-size: 12px;
text-align: left;
color: black;
background-color: white;
}
input[type=text] {
background-color: #262626;
color: white
}

How to Learn Cards

On the main screen select the deck you want to practice.

Type your answer and confirm with the “Enter” key:

Rate you answer with the key “1” if the answer was wrong and “Enter” if the answer was correct.

Tips

Each card should be as simple as possible

An overly complex card would be:

This card practices two problems at the same time: first, how to subset the column ‘weight’ and second, how to get the ‘minimum’ and ‘median’. A better solution would be to split the card in two cards.

Do not mix typed and not typed answers in one deck

Create separate decks with typed answers, for instance, to practice python data manipulation create a deck specifically for that. To practice, for instance coding theory and edge cases, create another deck with a ‘basic’ card format or even use another app.

The benefit is that this will help you focus on practicing a specific skill. Switching too much between concepts (e.g. programming languages, type of answers, …) will drain you more quickly and will slow down your learning process.

How to have multi line answers?

Download and install the extension “Multi-Line Type Answer Box”.

Confirm answers with the hotkey “Ctrl” + “Enter” instead of “Enter”.

Front Template

{{Front}}
<br>
<br>
[[typebox:Back]]

Back Template

{{FrontSide}}

Styling

.card {
font-family: monospace;
font-size: 12px;
text-align: left;
color: black;
background-color: white;
}

textarea {
font-family: monospace !important;
font-size: 12px;
height: 10em;
background-color: #262522;
color: white;
}

How to display tables?

Download and install the extension “Add Table”.

To create dummy tables, for instance in python, you can create a data frame and print it as markdown table. The “Add Table” extension in Anki can convert the markdown tables to display them on the card.

Data Scientist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store