Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Codes for the editorials #2

Open
raghavrambo007 opened this issue Aug 27, 2023 · 14 comments
Open

Add Codes for the editorials #2

raghavrambo007 opened this issue Aug 27, 2023 · 14 comments

Comments

@raghavrambo007
Copy link
Contributor

Some editorials doesn't show the code, since they are hidden inside scrolling. Without editorial code, solutions doesn't help that much.
maybe you can hit the copy button using selenium, and copy those codes, and provide along with the screenshot for each problem to refer to.

@raghavrambo007
Copy link
Contributor Author

@akhilkammila if you still have the leetcode premium account, can you run this python script ?
This I created by reverse engineering the API calls made in the editorial page to get the editorial solution codes, this gets those codes, and puts them in separate files, for all the approaches, and for all the languages..
Let me know if you face any issues, since some file paths and other things might needs to be changed.

@akhilkammila
Copy link
Owner

@raghavrambo007

Nice script, it seems to work decently well. Appreciate it.
For some problems it doesn't work. Problem 3, for example, throws an exception because response1.text is just {"data":{"question":{"solution":{"content":null}}}}.

I'll run the script for now though and push the files. Thx man

@raghavrambo007
Copy link
Contributor Author

Hey @akhilkammila , thanks a lot!

Maybe some problems use some other json response structure.
if we can write those problems which doesnt work in the except section to some csv, could look into them.

Also, looking forward to integrate this with your project, with all those docker, and proper foldering out the output and stuff.
I am not much familiar with docker, let me know how we can go about that.

@akhilkammila
Copy link
Owner

Hm yeah. The foldering isn't that hard, I just made a quick change to the script and it should put it into folders. The main point of the folders is just because github doesn't display more than 1000 subitems per folder.

I think the main thing to do for integration is create something that formats the files into the ReadMe (like whats under the readme-formatter folder). So people can just go to the ReadMe and click links and it'll open the link to the problem. It'd be great if you could help with that, if not its aight

Also don't worry about Docker. It runs fine locally, Docker is just for containerization (so you can run it on AWS EC2 or something). I don't really use the docker container most of the time.

I'll push the editorial code once the script finishes running. Lmk if u need anything, I'm a bit too busy for like big stuff right now cuz of school and recruiting, but I can help. Thx!

@unable8759
Copy link

unable8759 commented Aug 29, 2023

@akhilkammila Speaking on this, the editorials sometimes have video solutions. Is it possible to scrap those videos?

Edit: Since I've never seen the videos, I don't know if they cover the same things the editorials do or if they have additional content. If they're the same, it's not worth the effort but if the videos are useful, it might be worth it.

@raghavrambo007
Copy link
Contributor Author

@akhilkammila , sure would do the readme formatter thing, thats just simple string concatenation it seems.
Once you push the codes data, would create that based on the forder structure.
Thanks

@akhilkammila
Copy link
Owner

@raghavrambo007 Pushed it, thx. Unfortunately it looks like a good amount failed, but it got a lot of the editorial code.

@unable8759 Its probably not feasible. Even if we could get them, would have to store it somewhere. Tbh the videos aren't that useful though, its the same content plus some examples and stuff. I don't watch them I just use the editorials.

@raghavrambo007
Copy link
Contributor Author

raghavrambo007 commented Aug 30, 2023

@akhilkammila , there was a bug in the script. Basically there was no default return statement for the getExt method in the previous one. so if there is some code language which I didnt mentioned, it would fail with exception.
I fixed it, can you merge this PR ( #3 )?
Also when you get time can you rerun this to check if there is any reduction in number of errors this time? This time it should run faster than last time, since I removed the unnecessary time.sleep also.

@unable8759
Copy link

unable8759 commented Aug 30, 2023

@raghavrambo007 does this also fix the editorials that didn't work? Or is it too hard to debug why some fail? There's a few that didn't make it in which would be great to see.

@akhilkammila
Copy link
Owner

@raghavrambo007 Hey! I just ran the new script. It seems to have fixed the issue for a few editorials, but a lot of them still don't work (like #3 for example). I pushed the new changes tho, thx. Appreciate ur help

@unable8759 Nah this is unrelated to the screenshots. To get screenshots for the missing problems I need to rescrape the problems and rerun my screenshotter. I'll do that in a few weeks when I have more time, sry.

@unable8759
Copy link

oh I was referring to the editorial code snippets that @raghavrambo007 created the script for. Doesn't look like it was able to get all of them unfortunately but still got a lot

@unable8759
Copy link

unable8759 commented Sep 13, 2023

@akhilkammila do you have neetcode by any chance? There are courses in there which have articles similar to this leetcode editorials.

@47-Carnage
Copy link

Hi @akhilkammila @raghavrambo007 , please can you add remaining Editorial Codes please. Like i am solving interview 150 questions for those i don't think codes are there..i didn't find many..

like house robber etc..

@NDR0216
Copy link

NDR0216 commented Apr 15, 2024

I think the API in the script is correct, but the login session header is missing
However, I don't have a premium account. so it's hard to fix the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants