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

Literate.jl #1

Closed
miguelraz opened this issue Nov 16, 2020 · 6 comments
Closed

Literate.jl #1

miguelraz opened this issue Nov 16, 2020 · 6 comments

Comments

@miguelraz
Copy link

This repo is great!
Thank you so much for making it.
Sorry to bother, but is there anyway to upload the notebooks as Literate.jl files?
The mutable state of the notebooks is a real drag for git work, and the Conda dependency can be a bit heavy.
I understand if it doesn't get made but appreciate it anyways.
Thanks for your time!

@heetbeet
Copy link
Owner

heetbeet commented Nov 18, 2020

Hi, I remember generating these as Python notebooks from a hacked-together web scraper and notebook injector, but I can't seem to find the original code. I only recently mutated these notebooks to work with Julia. I might be adventurous one day and see if I can port this more cleanly (like dropping the Python dependency 100%), then it might be worth while to migrate to Pluto. As I understand it Pluto source files are text files that works well with version control. I don't know Literate.jl, what would the workflow look like? Are there any benefit to Pluto?

@miguelraz
Copy link
Author

Thanks for responding.
Yes, pluto are plain text that work well with version control.
There is an automatic converter from .ipynb -> pluto files here
The advantage of Literate.jl is that you can keep files as .jl and then target different output formats: .ipynb, pluto, markdown, pdf, etc.
This should be at most some weeks/days away if you don't want to do it manually with the previous link though.

@heetbeet
Copy link
Owner

heetbeet commented Nov 19, 2020

Okay cool, I see the point of Literate.jl. So it's basically an annotate julia file that can be used either standalone, or be converted to notebooks. That does sound useful. So what I'll probably do is, write a new scraper (I lost the old one), and target a Literate.jl type julia file.

So my main idea with this repo was for me to learn Julia. I already had the .ipynb notebooks in Python form from years prior, so I just quickly hacked together something that can work with Julia, and then I started learning Julia through project Euler. But since my Julia is a bit more mature now, it might be good idea to properly port this for others. Since we are back to the drawing board, how do you think such a port should look like?

  • Should the answer checker return a pass/ fail icon like currently, or should we rather try to make it work with a proper test suite, so that the puzzles can be done through a test-driven approach.
  • How many puzzles should be on a single page/ in a single file? With the .ipynb files, too many puzzles quickly cluttered the workspace, but a single puzzle per file felt a bit claustrophobic. I went with 25 per file as a good trade-off. It this still applicable for the current system?

@miguelraz
Copy link
Author

miguelraz commented Nov 19, 2020

  1. Interface: There's actually a neat Pluto function that changes the display if you answer properly: see this line here. https://github.com/fonsp/Pluto.jl/blob/a97a49f31817abb18b0d5072b910ea4739924775/sample/Basic%20mathematics.jl#L266

I guess if your interface is something like

if solution_21() == 456 # for problem 23, the solution should be 456
    correct(md"Correct! :partying_face: ")
else
   warn()
end

...
export solution_20, solution 21, solution_22...

You can then include the test files like

@testset "1-25" begin 
    @test solution_1() == 42
    @test solutiion_2() == 69
    ....
end

That seems friendly to the script/test/edit workflow.

  1. Sticking with 25 per file seems fine. It would only be a problem if some exercises are too computationally expensive. Don't think that's the case though.

@heetbeet
Copy link
Owner

Okay, I added a Project Euler scraper so that this project can somewhat stay up to date with new Project Euler puzzles. I have also added the output of the scraper in the repository:

  • Puzzles in Literate.jl format
  • Puzzles in Jupyter format
  • Puzzles in Pluto.jl format

@miguelraz
Copy link
Author

Awesome! Thanks a lot!

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

2 participants