How the heck do I use Anki to remember my Codewars solutions?
Published: 2023-11-27 19:36:41

Maybe you’ve been grinding Codewars to work on some fundamental coding skills. Maybe you’ve even progressed into the more advanced questions on Codewars or started doing some LeetCode too. But there’s a problem!

When you go back and look at some of the more basic Codewars challenges, you can’t remember anything about them! Ack!! Codewars has marked them as completed, so you did really solve them, but in the months that have passed, these problems have faded entirely from your memory!!! 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qsy5tluiak9eg85xvuye.png)



I don’t know about you, but I find this situation alarming. What is the point of doing all of these coding exercises if I’m going to forget everything after a few months?

- Note - if you are new to Codewars, check out this excellent [guide](https://dev.to/barbaralaw/i-want-to-do-codewars-uh-how-do-i-do-that-1pf0) to getting started.

## Anki to the rescue

Luckily, there is a simple solution to this memory problem by using a technique called "spaced repetition." Even better, there is a free app that you can use to do spaced repetition called [Anki](https://apps.ankiweb.net/).


Let’s say you have just solved the Reversed Strings challenge using the solution below. (Yes, there are many other ways to reverse a string, but let’s stick to the basics for now.) The question now is how to use Anki so that you never forget this solution.




![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06donk9gsaln06bflg1w.png)



## Adding a Codewars challenge to a flashcard

Just like there are many ways to reverse a string, there are many ways to use the flashcards that you get with Anki. I will show you the way that works best for me, but of course, feel free to experiment with the options that Anki provides.

If you’re new to Anki, there are lots of [tutorials](https://www.youtube.com/watch?v=AjdUxCnAXJw&ab_channel=TheAnKing) to get you started overall. I will focus on the specifics of adding a Codewars solution here. 

I like to use the “Basic (type in the answer)” option for my Codewars cards. It works just like the Basic one, but you have the **option** of typing in the answer, which I find keeps me honest.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhfkmklrp5338m7ltgsn.png)


Now I go back to the Codewars window and copy the name, the description, and the examples for the challenge. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vwpi5q0az5fe8eg6nro3.png)

Paste these items into the “Front” section of the flashcard.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5uywr1g1pczxajqu01w.png)


Now go to the **Solutions** tab in Codewars and copy the full text of the function you want to remember - along with the function name, the curly braces, the return statement, and everything else.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s0cq5zr5plst18xbyvg2.png)


Go back to Anki and paste the function ALSO IN THE FRONT SECTION!! Yes, the Front!! Why, you ask? Read on!



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nn26uw3zew96j8npmek2.png)


## Curating the back of the card

The reason to start on the front of the card is that we want to curate the back of the flashcard very carefully. It may look like a simple step, but selecting what to put on the back of the card is a crucial decision.

As the solutions get a bit longer, the choice of what to put on the back gets even more important. If you put too much on the back, you can slow down your entire daily Anki sessions (and maybe abandon your Codewars cards as a result - horror!). If you put too little on the back, you may not memorize the essential logic of the solution. 

## How do you pick what goes on the back?

I find that there is no general rule for how many characters or methods to place on the back of my cards, but overall, shorter is better.

If I was learning this function for the first time, there would be two main options for what to put on the back of the card. 


## Option #1 - Short and sweet

If I was comfortable using split() and join(), and the reverse() method was the thing that I was learning, I would do it like this.

- NOTE - There are some fancier ways to handle the "code here" part of it, but I like to keep it super simple.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cg6mv7sjfhlcm3yhhqcf.png)

 

## Option #2 - All three methods on the back

If the whole string of methods was new to me, I would put all of them on the back like this.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y59qwnd502rv6w6d3k88.png)


 The selection is more of an art than a science - it’s about finding what piece of the solution I need to remember better so that I can recall the entire solution better. My understanding and memory of a solution may evolve over time, and if it does, I edit what goes on the back of the card to correspond. 

 





## Conclusion
	
That’s it! The process looks deceptively simple when you look at it like this. It might even seem too simple as you start adding solutions like this one for reversing a string. 

But wait until you start adding a new solution every day (or so) and then start drilling these solutions every day (or so). Do this for a month or two, and I think you'll find that this practice starts to expand your memory/knowledge in a surprising and even mind-bending way.  

Imagine how much you will memorize in the next year if you do a new Codewars challenge every day and use Anki to remember every one of them!