commit 7efac2bbfadecbfcd339e902049e8eac504274c2 Author: Michael Zhang Date: Sat Aug 28 00:53:25 2021 -0500 gm diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..20e1d3a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,10 @@ +This project comes in two parts: + +- Lesson material, which lives in `material`, licensed with [CC BY-SA 4.0][2]. +- Source code, which is everything else in this repository, licensed with [GPL 3.0][1]. + +The full legal text of the license can be found in a file called LICENSE within +the respective directories. + +[1]: https://www.gnu.org/licenses/quick-guide-gplv3.html +[2]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..d1bdf4c --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +eduproj diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..444495a --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1630125726, + "narHash": "sha256-STeKWv2RQCTwA9FEAiGCcO9l+CiXhVuaTl1bz3mJRxw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "45131df1671d5886821908b5294f5fba5fb23fc7", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a25cc8b --- /dev/null +++ b/flake.nix @@ -0,0 +1,14 @@ +{ + inputs.flake-utils.url = "github:numtide/flake-utils"; + outputs = { self, flake-utils, nixpkgs }: + flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + flakePkgs = rec { + sm2 = pkgs.python39Packages.callPackage ./sm2 {}; + }; + in rec { + defaultPackage = packages.sm2; + packages = flake-utils.lib.flattenTree flakePkgs; + }); +} diff --git a/ideas.txt b/ideas.txt new file mode 100644 index 0000000..e73982d --- /dev/null +++ b/ideas.txt @@ -0,0 +1,17 @@ +concepts: +- learning targets +- can relate to other concepts in the following ways: + - concept A "depends" on concept B; explaining concept A requires some information from concept B + - concept A "optdepends" on concept B + - concept A "satisfies" concept B; mastery of concept A implies mastery of concept B + +topics: +- groups of concepts +- can nest infinitely + +"reviews" are randomly constructed sets of activities + +each user has a mastery level for each concept + +references: +- super memo algorithm used by anki: https://en.wikipedia.org/wiki/SuperMemo#Description_of_SM-2_algorithm diff --git a/material/proof.rst b/material/proof.rst new file mode 100644 index 0000000..d819453 --- /dev/null +++ b/material/proof.rst @@ -0,0 +1,10 @@ +.. TODO: split out into math proofs and formal proofs + +:title: Proof + +:subtopics: + - induction + +:summary: + Proofs are arguments that present evidence that constructs an argument. + diff --git a/result b/result new file mode 120000 index 0000000..3cfdad6 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/gqxdrhrrpjadp664vj934mj5nhzk7y9f-sm2 \ No newline at end of file diff --git a/sm2/default.nix b/sm2/default.nix new file mode 100644 index 0000000..b7ed0ad --- /dev/null +++ b/sm2/default.nix @@ -0,0 +1,19 @@ +{ buildPythonApplication, nix-gitignore, python, mypy }: + +let + pythonBuildInputs = [ ]; + pythonWithBuildInputs = python.withPackages (_: pythonBuildInputs); +in +buildPythonApplication { + name = "sm2"; + src = nix-gitignore.gitignoreSourcePure [ ../.gitignore ] ./.; + + doCheck = true; + checkInputs = [ mypy ]; + checkPhase = '' + ${mypy}/bin/mypy --no-color-output \ + --package sm2 \ + --python-executable ${pythonWithBuildInputs}/bin/python \ + --strict + ''; +} diff --git a/sm2/pyproject.toml b/sm2/pyproject.toml new file mode 100644 index 0000000..8af5fde --- /dev/null +++ b/sm2/pyproject.toml @@ -0,0 +1 @@ +[build-system] diff --git a/sm2/setup.py b/sm2/setup.py new file mode 100644 index 0000000..0240fde --- /dev/null +++ b/sm2/setup.py @@ -0,0 +1,6 @@ +from setuptools import setup + +setup( + name = "sm2", + packages = ["sm2"], +) diff --git a/sm2/sm2/__init__.py b/sm2/sm2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sm2/sm2/sm2.py b/sm2/sm2/sm2.py new file mode 100644 index 0000000..f68e9ab --- /dev/null +++ b/sm2/sm2/sm2.py @@ -0,0 +1,43 @@ +from typing import Tuple + +def sm2_algo( + user_grade: int, + n: int, + ef: float, + i: int, +) -> Tuple[int, float, int]: + """ + From https://en.wikipedia.org/wiki/SuperMemo#Description_of_SM-2_algorithm + + n: repetition number, how many times a number was repeated + ef: easiness-factor, how quickly the interval grows + i: interval (in days) + + returns the updated version of these values + """ + + # grade >= 3 means the response was correct + if user_grade >= 3: + # update the number of days until the next review + # increases exponentially starting with 1 day and 6 days + if n == 0: + i = 1 + elif n == 1: + i = 6 + else: + i = round(i * ef) + + # increment the number of days + n += 1 + + # incorrect + else: + n = 0 + i = 1 + + inv_grade = 5 - user_grade + ef = ef + (0.1 - inv_grade * (0.08 + inv_grade * 0.02)) + if ef < 1.3: + ef = 1.3 + + return (n, ef, i)