Skip to content

Scrapes problem links from the most popular LeetCode problem sets as well as one's own lists and adds them to an Anki deck.

Notifications You must be signed in to change notification settings

roblieblang/leetcode-anki-script

Repository files navigation

About

Inspired by this Reddit post, I made a Python program to scrape LeetCode problem links from some of the most popular problem sets and add them to an Anki deck. Anki serves as a scheduler for this study strategy, deciding for the user when to revisit problems based on their perceived difficulty.

There are thousands of LeetCode problems available to solve, but these curated lists are commonly considered to cover the most fundamental techniques, strategies, patterns, data structures and algorithms.

The purpose of this tool is not to memorize exact LeetCode solutions, but instead to devote most of one's study time to weak areas, while also tracking your progress through Anki's native capabilities.

Requirements

  • Python
  • Web driver for your browser (I use Chrome)
    • Add it to your PATH, or paste the path to the web driver in between the parentheses of webdriver.Chrome() in config.py
  • Anki
  • Anki Connect

Getting Started

  • Clone the repo to your machine
  • Create a new Python virtual environment and activate it
  • Create a .env following the .env.example in the root directory of the project
  • Start Anki (it must be running in order for the script to work)
  • Create Python virtual environment with python -m venv venv
  • Activate Python virtual environment with .\venv\Scripts\activate
  • Install dependencies with pip install -r .\requirements.txt
  • Run the program using command python main.py from a CLI in the root directory of the project

Last Tested

This script was last tested on 4/13/24 with the following configurations:

  • Anki Version: 23.12.1 (1a1d4d54)⁩
  • AnkiConnect Version: 6
  • Python Version: 3.11.5
  • Operating System: Windows 11, Version 22H2, OS Build 22621.3007
  • Google Chrome Version: 120.0.6099.217 (Official Build) (64-bit)

Please note that while the code has been tested with these versions, newer versions of Anki or other dependencies may affect its functionality.

Example Ouput

example output example output

Troubleshooting

  • Duplicate Anki Cards Error
    • Delete the deck containing the duplicates and try again
  • OSError upon finishing program execution
    • Comment out time.sleep(0.1) on line 798 of venv\Lib\site-packages\undetected_chromedriver\__init__.py

Disclaimer

I am not responsible for any misuse of this code. Please respect the websites and their terms.

About

Scrapes problem links from the most popular LeetCode problem sets as well as one's own lists and adds them to an Anki deck.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages