Skip to content

qphong/repeat

Repository files navigation

A HACKABLE STUDY MANAGEMENT FOR LEETCODERS

Table of Contents

Vy Leetcodes with Spaced-Repetition

Vy has recently familiarized herself with the computer keyboard and is now tackling some Leetcode problems. However, she frequently struggles to recall the problems she has solved before. Consequently, she requires assistance from a management system.

This approach involves keeping track of several parameters related the learning and an experimental basic version of the Leitner system, enhanced by incorporating time-awareness (classic Leitner system). In other words, it utilizes distinct Leitner systems tailored for various time intervals. To reduce it the classic Leitner system, set the constant (in constants.py) TRACKER_DEFAULT_INTERVAL to a large value such as SECS_DAY(1000000).

images/time-leitner.png

The project is implemented in Python which is easily hackable by Leetcode users. It can be used for studying other subjects than solving Leetcode problems.

Requirements

The Python implementation does not require any additional packages. However, to use the leetcode-scripts, it requires neovim (a text editor, you can change it to your favorite editor in leetcode-scripts/vy-config) to edit the code and =fzf= (a fuzzy search) to quickly browser problems.

Usage

All commands can be skipped with ESC.

Relevant directories:

  • Study results are stored in subjects/sbj-leetcode/study/
  • Added problems are stored in subject/sbj-leetcode/item/item.json
  • Parameters related to the learning are stored in subject/sbj-leetcode/tracker/tracker.json
  • problem-lists.txt contains problem titles and some tags. It is to simplify the process of adding a new problem.

I downloaded that file from some github repo long time ago that, unfortunately, I cannot remember where it comes from. You can change the problem-lists.txt to your own problem lists.

Initialization

Remove everything in the directory subjects/ to start the study anew. In the leetcode-scripts direction, run

CommandDescription
vy-learn-leetcodeinitializing the leetcode project by generating necessary directories
vy-addadd a problem to solve from problem-lists.txt
vy-add -i {problem_id} -n {name} -t {tags_separated_by_comma}add a problem to solve by specifying name (required), id (optional), and tags (optional) (this problem is not required to be in problem-lists.txt
vy-removeremove a problem (search from the list of added problems)
vy-remove -i {problem_id}remove a problem by problem_id

e.g., below is the following screenshot of vy-add images/add-problem.png

Solving a problem

A study item (a Leetcode problem) has 3 states: (1) new (haven’t attempted), (2) studying (currently solving), and (3) studied (was attempted before, regardless we solved it, i.e., pass or fail). The transitions between these states are as follows.

  • vy-add —[new]—> vy-start —[studying]—> vy-complete (regardless pass, i.e., we solved it by ourself like in an interview, or fail, i.e., we looked at the solution, asked someone)—[studied]
  • vy-add —[new]—> vy-start —[studying]—> vy-cancel —[new]
  • [studied]—> vy-start —[studying]—> vy-complete / vy-cancel —[studied]
  • [studied]—> vy-review-xxx —[studying]—> vy-complete / vy-cancel —[studied]
CommandDescription
vy-startselect a problem to start coding with nvim (change to another editor in leetcode-scripts/vy-config). The program automatically creates a python script with a unique name (based on the problem id) in subjects/sbj-leetcode/study, and opens it with a text editor (default is nvim). If we start the same problem with vy-start, the same file is opened, so the program helps us manage the python scripts of all solved problems.
vy-start -i {problem_id}same as vy-start but with provided problem_id
vy-endcomplete a problem with result: pass (we solved it by ourself, like in an interview), fail (we looked at the solution, or we asked someone)
vy-cancelcancel solving a problem
vy-noteselect a problem to add a note (or retrieve previous note). It is similar to vy-start. A markdown file with a unique name (based on the problem id) is created in subjects/sbj-leetcode/study.
vy-note -i {problem_id}same as vy-note, but with a provided problem_id
vy-viewview a previously solved solution without starting the problem
vy-view -i {problem_id}same as vy-view, but with a provided problem_id

Below are screenshots of vy-start. It first lists all tags with the number of problems in each tag (and in a state). images/start-problem-tag.png Then, we can choose a tag to list problems in that tag. We can list problems in all tags by pressing ESC. images/start-problem.png Then, we can search for a problem in this list to start. The program will open a python script with a unique name for that problem. If the state of a problem is _studying_, it means we continue the problem we started before. Note that if the state of a problem is _studied_, we do not show its state. Starting a _studied_ problem will open the script containing the solution that we coded before.

List problems

CommandDescription
vy-listlist added problems
vy-list-newlist added, but not attempted, problems
vy-list-passlist solved problems by the percentage of successfully solving the problem
vy-list-studyinglist pending problems
vy-list-durationlist solved problems by time spent solving
vy-list-recentlist solved problems by the most recent attempt
vy-list-competencylist solved problems by based on how compentent the learner is

e.g., below are screenshots of

  • vy-list

images/list.png 17/19 indicates that the problem was successfully solved 17 times out of 19 attempts.

  • vy-list-recent

images/list-recent.png

Tag

Tag can be used to mark a problem as interesting, tricky, or note a specific trick/approach to the problem.

CommandDescription
vy-add-tag -t {tags_separated_by_comma}add tags to a problem
vy-add-tag -t {tags_separated_by_comma} -i {problem_id}add tags to a problem with problem_id
vy-remove-tagremove a tag from a problem
vy-remove-tag -i {problem_id}remove a tag from a problem with problem_id

Review a problem

CommandDescription
vy-suggest-competencysuggest a solved problem for reviews (based on the Leitner system). If the user decides to review the problem, the program runs vy-start.
vy-suggest-durationsuggest a solved problem for reviews (based on the amount of time spent on the problem
vy-suggest-passsuggest a solved problem for reviews (based on the percentage of successfully solving the problem
vy-suggest-recentsuggest a solved problem for reviews (based on how recent the problem is solved)

Below are screenshots of vy-suggest-competency. Like vy-start, it first lists all tags. images/start-problem-tag.png

Then, we can choose a tag to have a suggestion in that tag. We can consider all tags by pressing ESC. A random problem is suggested based on the criterion: competency, duration, pass, or recent. images/suggest.png

There are 3 cases:

  1. If the suggested problem is too easy for us, we can choose to skip the suggestion, and request another suggestion
  2. If the suggested problem is interesting to us, we can choose to start the suggested problem. Its effect is the same as running vy-start on that problem.
  3. We can quit the command. We can also do this by pressing ESC.

A note on the experimental commands: vy-list-competency and vy-suggest-competency

vy-list-competency lists problems based on how competent the learner is about solving it. This competency is measured by the BOX property, shown as B:x. The large the BOX is, the higher the competency is, following the Leitner system. Note that the competency takes into the time since the last seeing the problem. Thus, it seems to be incorrect at first (as the model has not interacted with the learner a lot). For the model to correctly learn the level of competency, run vy-suggest-competency and start solving problem that you are not confident; or skip the problem that you are confident. This is a way that the model interacts with the learner to learn about the level of competency.

Demo

A screen recording to demo the above functions

About

A simple hackable commandline tool to help managing Leetcode problems

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published