Coder Social home page Coder Social logo

leetcode-anki's Introduction

Nothing here yet

leetcode-anki's People

Contributors

fspv avatar klaudioz avatar klintan avatar xnorpx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

leetcode-anki's Issues

Add frequency

Hey @prius would it be possible to get the frequency of a problem as a tag in anki? This would make it a lot easier to prioritise canonical problems.

Thanks I really love this tool!

Cards are generated with "No content" for some leetcode problems

For a small subset of questions, the generated cards don't capture the question content but instead, have the Content field being No content.

For instance, problem 2340 has such an issue deterministically, while problem 2341 always shows up fine.

Some Leetcode questions with Content field being no content:

  • 2339
  • 2340
  • 2345
  • 2346
  • 2355
  • 2356
  • 2361
  • 2362
  • ...

Generation problem

Hi @prius, tried to generate and got this error:

test ! "x/Users/user/Downloads/leetcode-anki/leetcode-anki" = "x" || (echo "Need to run inside venv" && exit 1)
pip install -r requirements.txt
Requirement already satisfied: python-leetcode in ./leetcode-anki/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (1.0.6)
Requirement already satisfied: diskcache in ./leetcode-anki/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (5.2.1)
Requirement already satisfied: genanki in ./leetcode-anki/lib/python3.9/site-packages (from -r requirements.txt (line 3)) (0.11.0)
Requirement already satisfied: tqdm in ./leetcode-anki/lib/python3.9/site-packages (from -r requirements.txt (line 4)) (4.62.3)
Requirement already satisfied: certifi in ./leetcode-anki/lib/python3.9/site-packages (from python-leetcode->-r requirements.txt (line 1)) (2021.10.8)
Requirement already satisfied: urllib3>=1.15 in ./leetcode-anki/lib/python3.9/site-packages (from python-leetcode->-r requirements.txt (line 1)) (1.26.7)
Requirement already satisfied: python-dateutil in ./leetcode-anki/lib/python3.9/site-packages (from python-leetcode->-r requirements.txt (line 1)) (2.8.2)
Requirement already satisfied: six>=1.10 in ./leetcode-anki/lib/python3.9/site-packages (from python-leetcode->-r requirements.txt (line 1)) (1.16.0)
Requirement already satisfied: cached-property in ./leetcode-anki/lib/python3.9/site-packages (from genanki->-r requirements.txt (line 3)) (1.5.2)
Requirement already satisfied: pyyaml in ./leetcode-anki/lib/python3.9/site-packages (from genanki->-r requirements.txt (line 3)) (6.0)
Requirement already satisfied: frozendict in ./leetcode-anki/lib/python3.9/site-packages (from genanki->-r requirements.txt (line 3)) (2.0.6)
Requirement already satisfied: pystache in ./leetcode-anki/lib/python3.9/site-packages (from genanki->-r requirements.txt (line 3)) (0.5.0)
python3 generate.py
Traceback (most recent call last):
File "/Users/user/Downloads/leetcode-anki/generate.py", line 14, in
import genanki # type: ignore
File "/Users/user/Downloads/leetcode-anki/leetcode-anki/lib/python3.9/site-packages/genanki/init.py", line 6, in
from .model import Model
File "/Users/user/Downloads/leetcode-anki/leetcode-anki/lib/python3.9/site-packages/genanki/model.py", line 3, in
import pystache
File "/Users/user/Downloads/leetcode-anki/leetcode-anki/lib/python3.9/site-packages/pystache/init.py", line 2, in
from init import *
ModuleNotFoundError: No module named 'init'
make: *** [generate] Error 1

Split the script into files

Now when it works, it's time to make it look nice as well.

So we need to split the script into files and make a nice CLI for that.

Create cards with Solution/s on Back (in chosen langs)?

I love this, but I expected it to fetch solution information/strategies and actual solution code in various languages.

Is there an easy way to edit this to get a deck with cards with the problems on the front and tons of solution info on the back? (Maybe with fields for solution/s and strategy/ies descriptions and solution lang fields like python, java, typescript, etc,. and maybe even including a field about which lang is fastest)

I am looking for a way to use Anki to memorize all the problems AND their solution/s, not just what the problems are. I feel this would be a quicker way to learn. Any ideas? Could you point me in the right direction?

Release is missing the leetcode.apkg file content

When a new release is created via GitHub actions, the leetcode.apkg file is visible in the assets and has a size, but its content is missing (GitHub returns 404 when you try to download it).

An example: https://github.com/prius/leetcode-anki/releases/tag/refs%2Fheads%2Fmaster-1635295155

I tried to fork the repo and create a new release myself but ended up with the same issue: https://github.com/dropsonic/leetcode-anki/releases/tag/refs%2Fheads%2Fmaster-1676754546

The Build Anki deck workflow doesn't show any errors. The "Upload release asset" step succeeded without any errors.

1 card is missing during deck generation

Leetcode return tehre are 2052 cards, but we get 2051 in the end. It is either a bug with the way we calculate pages and offsets, or leetcode really returns incorrect number of problems. Have to investigate

spv@laptop [venv:leetcode-anki] leetcode-anki $ time ipython3 --pdb -- generate.py                            
INFO:root:Fetching 2052 problems 50 per page                                                                          
100%|████████████████████████████████████████████████████████████████████████| 2100/2100 [04:37<00:00,  7.58problem/s]
INFO:root:Generating flashcards                            
100%|███████████████████████████████████████████████████████████████████| 2051/2051 [00:00<00:00, 28815.78flashcard/s]
                                                                                                                      
real    4m41.243s                                                                                                     
user    0m3.262s                                           
sys     0m0.440s                                                                                                      

Any way to order the problems?

I've found the most helpful thing for me so far is using curated/organized lists, like this one.

I started manually making cards and it is a pain, so your tool seems great! But I am concerned if Anki is just going to randomly throw all 25XX problems at me, it won't be as effective.

Is there any way (via this or in Anki) to encourage/constrain the cards or their ordering?

Sort field doesn't work

I set the sort field to 3 digits string at the moment: https://github.com/prius/leetcode-anki/blob/master/generate.py#L298

But the sorting is still incorrect.

For example, there are 15 cards for which sorting by the sort field gives the following order:

012
010
025
011
023
006
002
035
008
033
036
037
037
011
048

So effective there is no sorting.

I guess I need to look at Anki's source code to understand how it uses this field.

Error when trying to run `make generate`

Hello, I'm on a Mac running Python 3.11.1 and receiving an error when running the make generate build script.

Below is an output from CLI

python3 generate.py /private/tmp/test/leetcode-anki/generate.py:215: DeprecationWarning: There is no current event loop loop: asyncio.events.AbstractEventLoop = asyncio.get_event_loop() Traceback (most recent call last): File "/private/tmp/test/leetcode-anki/generate.py", line 216, in <module> loop.run_until_complete(main()) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/generate.py", line 211, in main await generate(start, stop, page_size, list_id, output_file) File "/private/tmp/test/leetcode-anki/generate.py", line 184, in generate task_handles = await leetcode_data.all_problems_handles() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode_anki/helpers/leetcode.py", line 274, in all_problems_handles return list(self._cache.keys()) ^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/functools.py", line 1001, in __get__ val = self.func(instance) ^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode_anki/helpers/leetcode.py", line 143, in _cache problems = self._get_problems_data() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode_anki/helpers/leetcode.py", line 240, in _get_problems_data problem_count = self._get_problems_count() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode_anki/helpers/leetcode.py", line 76, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode_anki/helpers/leetcode.py", line 148, in _get_problems_count api_instance = self._api_instance ^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/functools.py", line 1001, in __get__ val = self.func(instance) ^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode_anki/helpers/leetcode.py", line 134, in _api_instance return _get_leetcode_api_client() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode_anki/helpers/leetcode.py", line 38, in _get_leetcode_api_client csrf_token = leetcode.auth.get_csrf_cookie(session_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode-anki/lib/python3.11/site-packages/leetcode/auth.py", line 12, in get_csrf_cookie return response.cookies["csrftoken"] ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode-anki/lib/python3.11/site-packages/requests/cookies.py", line 334, in __getitem__ return self._find_no_duplicates(name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/tmp/test/leetcode-anki/leetcode-anki/lib/python3.11/site-packages/requests/cookies.py", line 413, in _find_no_duplicates raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}") KeyError: "name='csrftoken', domain=None, path=None" make: *** [generate] Error 1

Any suggestions on how to fix this? I have followed the README steps to a T.

How to add solutions?

This repo is really awesome and just what I was doing for myself.
I just have a question about adding my own solutions to the "back" card. I managed to add the field but it's not the back. And I don't see the discuss and solutions card.. could you help me with this?

Tests are failing

    @pytest.mark.asyncio
    @mock.patch(
        "leetcode_anki.helpers.leetcode.LeetcodeData._get_problems_data",
        mock.Mock(return_value=[QUESTION_DETAIL]),
    )
    async def test_tags(self) -> None:
        self._leetcode_data._cache["test"] = QUESTION_DETAIL
    
>       assert (await self._leetcode_data.tags("test")) == ["test-tag"]
E       AssertionError: assert ['test-tag', 'Hard'] == ['test-tag']
E         Left contains one more item: 'Hard'
E         Use -v to get more diff

test/helpers/test_leetcode.py:248: AssertionError

This is due to logic change

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.