AtCoderStudyBooster 0.2__py3-none-any.whl → 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.3
2
+ Name: AtCoderStudyBooster
3
+ Version: 0.3.1
4
+ Summary: A tool to download and manage AtCoder problems.
5
+ Project-URL: Homepage, https://github.com/yuta6/AtCoderStudyBooster
6
+ Author-email: yuta6 <46110512+yuta6@users.noreply.github.com>
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Requires-Dist: beautifulsoup4
10
+ Requires-Dist: fire
11
+ Requires-Dist: markdownify>=0.13.1
12
+ Requires-Dist: pywebview>=5.4
13
+ Requires-Dist: questionary>=2.0.1
14
+ Requires-Dist: requests
15
+ Requires-Dist: rich>=13.7.1
16
+ Requires-Dist: tiktoken
17
+ Requires-Dist: types-beautifulsoup4>=4.12.0.20240511
18
+ Requires-Dist: types-requests>=2.32.0.20240712
19
+ Description-Content-Type: text/markdown
20
+
21
+ # AtCoderStudyBooster
22
+
23
+ ## 概要
24
+
25
+ AtCoderStudyBoosterはAtCoderの学習を加速させるためのCLIツールです。問題をローカルにダウンロードし、テスト、提出、解答の作成をサポートするツールです。Pythonが入っていることが必須です。Pythonが入っている環境なら、`pip install AtCoderStudyBooster`でインストールできます。
26
+
27
+ このツールは以下のプロジェクトに強く影響を受けています。
28
+ [online-judge-tools](https://github.com/online-judge-tools)
29
+ [atcoder-cli](https://github.com/Tatamo/atcoder-cli)
30
+
31
+ ## 利用ケース
32
+
33
+ ### B問題の練習したい場合
34
+
35
+ ABCコンテストの223から226のB問題だけを集中的に練習したい場合、次のコマンドを実行します。
36
+
37
+ ```sh
38
+ ❯ atcdr download B 223..226
39
+ ```
40
+
41
+ コマンドを実行すると,次のようなフォルダーを作成して、各々のフォルダーに問題をダウンロードします。
42
+
43
+ ```css
44
+ B
45
+ ├── 223
46
+ │ ├── StringShifting.html
47
+ │ └── StringShifting.md
48
+ ├── 224
49
+ │ ├── Mongeness.html
50
+ │ └── Mongeness.md
51
+ ├── 225
52
+ │ ├── StarorNot.html
53
+ │ └── StarorNot.md
54
+ └── 226
55
+ ├── CountingArrays.html
56
+ └── CountingArrays.md
57
+ ```
58
+
59
+ ### 特定のコンテストの問題に取り組みたい場合
60
+
61
+ ```sh
62
+ ❯ atcdr download 223..225 A..C
63
+ ```
64
+ のように実行すると以下のようなフォルダーを生成します.
65
+
66
+ ```css
67
+ .
68
+ ├── 223
69
+ │ ├── A
70
+ │ │ ├── ExactPrice.html
71
+ │ │ └── ExactPrice.md
72
+ │ ├── B
73
+ │ │ ├── StringShifting.html
74
+ │ │ └── StringShifting.md
75
+ │ └── C
76
+ │ ├── Doukasen.html
77
+ │ └── Doukasen.md
78
+ ├── 224
79
+ │ ├── A
80
+ │ │ ├── Tires.html
81
+ │ │ └── Tires.md
82
+ │ ├── B
83
+ │ │ ├── Mongeness.html
84
+ │ │ └── Mongeness.md
85
+ │ └── C
86
+ │ ├── Triangle.html
87
+ │ └── Triangle.md
88
+ └── 225
89
+ ├── A
90
+ │ ├── DistinctStrings.html
91
+ │ └── DistinctStrings.md
92
+ ├── B
93
+ │ ├── StarorNot.html
94
+ │ └── StarorNot.md
95
+ └── C
96
+ ├── CalendarValidator.html
97
+ └── CalendarValidator.md
98
+ ```
99
+
100
+ ### 問題を解く
101
+
102
+ MarkdownファイルあるいはHTMLファイルをVS CodeのHTML Preview, Markdown Previewで開くと問題を確認できます。VS Codeで開くと左側にテキストエディターを表示して、右側で問題をみながら問題に取り組めます。
103
+
104
+ ![demo画像](./.images/demo1.png)
105
+
106
+ ### サンプルをローカルでテストする
107
+
108
+ 問題をダウンロードしたフォルダーに移動します。
109
+
110
+ ```sh
111
+ ❯ cd 224/B
112
+ ```
113
+
114
+ 移動したフォルダーで解答ファイルを作成後をtestコマンドを実行すると, サンプルケースをテストします。
115
+
116
+ ```sh
117
+ ~/.../224/B
118
+ ❯ atcdr t
119
+ ```
120
+
121
+ ![demo画像](./.images/demo2.png)
122
+
123
+ WAの場合は以下のような表示になります。
124
+
125
+ ![demo画像](./.images/demo3.png)
126
+
127
+
128
+ ### 提出する
129
+
130
+ ```sh
131
+ ~/.../224/B
132
+ ❯ atcdr s
133
+ ```
134
+ を実行すると, 提出することができます。提出にはAtCoderのサイトへのログインが必要です。
135
+
136
+ ### 解答をGPTで生成する
137
+
138
+ ```sh
139
+ ~/.../224/B
140
+ ❯ atcdr g
141
+ ```
142
+ で解答をGPTで生成します。Chat GPTのAPIキーが必要です。さらに、生成されたファイルはサンプルケースが自動でテストされ、**テストをパスしなかった場合、テスト結果がGPTにフィードバックされ解答が再生成**されます。
143
+
144
+ GPTとプログラムとのやり取りのログはJSONファイルで保存されます。
145
+
146
+ ## 解答生成機能generateコマンドに関する注意点
147
+
148
+ [AtCoder生成AI対策ルール](https://info.atcoder.jp/entry/llm-rules-ja)によるとAtCoder Beginner Contest(以下、ABCとする)および AtCoder Regular Contest (Div. 2) においてに問題文を生成AIに直接与えることは禁止されています。ただし、このルールは過去問を練習している際には適用されません。 該当のコンテスト中にこの機能を使用しないでください。
149
+
150
+ ## その他の機能
151
+
152
+ ### markdownコマンド
153
+
154
+ 完全なCLI環境方向けのコマンドです。
155
+ ```sh
156
+ ~/.../224/B
157
+ ❯ atcdr md
158
+ ```
159
+ を実行すると, 問題をプリントします。
160
+
161
+ ![demo画像](./.images/demo4.png)
162
+
163
+ ### 複数のファイルを一度にテスト
164
+
165
+ ```sh
166
+ ~/.../224/B
167
+ ❯ atcdr t *.py
168
+ ```
169
+ でフォルダー内にあるすべてのPythonファイルを一度にテストします。
170
+ ```sh
171
+ ~/.../224/B
172
+ ❯ atcdr t mon.py mon.c mon.cpp
173
+ ```
174
+
175
+ フォルダー内に複数ファイルある場合は、インタラクティブに選択できます。
176
+ ```sh
177
+ ~/.../224/B
178
+ ❯ atcdr t
179
+ ```
180
+
181
+ ```sh
182
+ ~/.../224/B
183
+ ❯ atcdr t
184
+ 複数のファイルが見つかりました.ファイルを選択してください:
185
+ 十字キーで移動, [enter]で実行
186
+ ❯❯❯ mon.py
187
+ mon.c
188
+ mon.cpp
189
+ ```
190
+
191
+ ### プログラミング言語を指定してコードを生成
192
+
193
+ `--lang`オプションを使うと、生成したいプログラミング言語を指定できます。
194
+ ```sh
195
+ ~/.../224/B
196
+ ❯ atcdr generate --lang rust
197
+ ```
198
+ ### テストをせずにコードのみ生成
199
+
200
+ デフォルトで`atcdr generate`コマンドは生成されたコードをテストしますが、テストせずにコードのみ生成できます。
201
+
202
+ ```sh
203
+ ~/.../224/B
204
+ ❯ atcdr generate --lang rust --without_test
205
+ ```
@@ -0,0 +1,21 @@
1
+ atcdr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ atcdr/download.py,sha256=roscCz_6bq4Ab6XNc1KpYywMc37XTfmH7ciEhEPYu5M,11056
3
+ atcdr/generate.py,sha256=ckjI7CuPO5_1DDrMch8EFtQK5F0102ZDJFAzpjlxqqg,8024
4
+ atcdr/login.py,sha256=kNs2vUSuYqSn5oOJGVbQOluJXKi3zr5ZQBXfai3VU08,4575
5
+ atcdr/logout.py,sha256=uBFt3idW4Ik2TypBFuQjXJpYWWDNWZM42--B5Xlcbtc,622
6
+ atcdr/main.py,sha256=tcNUcmOFh5hSKmFMgsD6g9k467x6rOI5rSMb8aPfL78,953
7
+ atcdr/markdown.py,sha256=v3Sh5vl20V6dTkspwzf5SxLKJLw6J2Xj1HX3F185X2I,1227
8
+ atcdr/open.py,sha256=l5QbrefXuZxn8LoqjfAE5p5EwRBJeg5VqopbjMXdG3Y,1121
9
+ atcdr/submit.py,sha256=IxVz2QyotDjQqvfqFgyNWuDBDeI-CmVKYqaIMIInDIY,9694
10
+ atcdr/test.py,sha256=Q7HHggbAix6iqClzm01YCs7Db9v01D5NNzmSztY8dbc,13521
11
+ atcdr/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ atcdr/util/execute.py,sha256=r4rYmbNQH5kIzdqAeo9SGvqJZyFX4yBIdmg9cTKeiYE,2221
13
+ atcdr/util/filetype.py,sha256=pceB08trkwNkdzKJx4fFfOWpz9jYMBRDwXLW4un0sRM,2254
14
+ atcdr/util/gpt.py,sha256=vH10Waa7KXlz6-5pEUBuIbxTbDH3Hys7k9Tt7prvFX4,3772
15
+ atcdr/util/parse.py,sha256=SJ4khlH5iWaSwyORmQLi84npMwh5u2omCeg0q7ScEAE,6974
16
+ atcdr/util/problem.py,sha256=wEoMC5KVQu5l-i4V-ZCR30Z30Zov0VCNtLVIbL-0iI0,2594
17
+ atcdr/util/session.py,sha256=LwlSN86sfnkE9a-opL4qvKYHsCgiMy7eFCdcXdo79eg,4889
18
+ atcoderstudybooster-0.3.1.dist-info/METADATA,sha256=FElAss6sLM-k7pAmZJteKHgrl8uPsZCV95jiyJAHaac,6243
19
+ atcoderstudybooster-0.3.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
20
+ atcoderstudybooster-0.3.1.dist-info/entry_points.txt,sha256=_bhz0R7vp2VubKl_eIokDO8Wz9TdqvYA7Q59uWfy6Sk,42
21
+ atcoderstudybooster-0.3.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
atcdr/util/cost.py DELETED
@@ -1,120 +0,0 @@
1
- from enum import Enum
2
- from typing import Optional
3
-
4
- import tiktoken
5
- import yfinance as yf # type: ignore
6
-
7
-
8
- class Model(Enum):
9
- GPT4O = 'gpt-4o'
10
- GPT4O_MINI = 'gpt-4o-mini'
11
-
12
-
13
- class CostType(Enum):
14
- INPUT = 'input'
15
- OUTPUT = 'output'
16
-
17
-
18
- class Currency:
19
- def __init__(
20
- self, usd: Optional[float] = None, jpy: Optional[float] = None
21
- ) -> None:
22
- self._exchange_rate = self.get_exchange_rate()
23
- self._usd = usd if usd is not None else 0.0
24
- self._jpy = jpy if jpy is not None else self.convert_usd_to_jpy(self._usd)
25
-
26
- @staticmethod
27
- def get_exchange_rate() -> float:
28
- ticker = yf.Ticker('USDJPY=X')
29
- todays_data = ticker.history(period='1d')
30
- return todays_data['Close'].iloc[0]
31
-
32
- def convert_usd_to_jpy(self, usd: float) -> float:
33
- return usd * self._exchange_rate
34
-
35
- def convert_jpy_to_usd(self, jpy: float) -> float:
36
- return jpy / self._exchange_rate
37
-
38
- @property
39
- def usd(self) -> float:
40
- return self._usd
41
-
42
- @usd.setter
43
- def usd(self, value: float) -> None:
44
- self._usd = value
45
- self._jpy = self.convert_usd_to_jpy(value)
46
-
47
- @property
48
- def jpy(self) -> float:
49
- return self._jpy
50
-
51
- @jpy.setter
52
- def jpy(self, value: float) -> None:
53
- self._jpy = value
54
- self._usd = self.convert_jpy_to_usd(value)
55
-
56
- def __add__(self, other: 'Currency') -> 'Currency':
57
- return Currency(usd=self.usd + other.usd)
58
-
59
- def __sub__(self, other: 'Currency') -> 'Currency':
60
- return Currency(usd=self.usd - other.usd)
61
-
62
- def __mul__(self, factor: float) -> 'Currency':
63
- return Currency(usd=self.usd * factor)
64
-
65
- def __truediv__(self, factor: float) -> 'Currency':
66
- return Currency(usd=self.usd / factor)
67
-
68
- def __eq__(self, other: object) -> bool:
69
- if not isinstance(other, Currency):
70
- return NotImplemented
71
- epsilon = 1e-9 # 許容範囲
72
- return abs(self.usd - other.usd) < epsilon
73
-
74
- def __lt__(self, other: 'Currency') -> bool:
75
- return self.usd < other.usd
76
-
77
- def __repr__(self) -> str:
78
- return f'Currency(usd={self.usd:.2f}, jpy={self.jpy:.2f})'
79
-
80
- def __str__(self) -> str:
81
- return f'USD: {self.usd:.2f}, JPY: {self.jpy:.2f}'
82
-
83
-
84
- class Rate:
85
- _COST_RATES = {
86
- Model.GPT4O: {CostType.INPUT: 5 / 1000**2, CostType.OUTPUT: 15 / 1000**2},
87
- Model.GPT4O_MINI: {
88
- CostType.INPUT: 0.15 / 1000**2,
89
- CostType.OUTPUT: 0.60 / 1000**2,
90
- },
91
- }
92
-
93
- @staticmethod
94
- def calc_cost(model: Model, cost_type: CostType, token_count: int) -> Currency:
95
- cost_in_usd = Rate._COST_RATES[model][cost_type] * token_count
96
- return Currency(usd=cost_in_usd)
97
-
98
-
99
- class ApiCostCalculator:
100
- def __init__(self, text: str, cost_type: CostType, model: Model) -> None:
101
- self.text = text
102
- self.cost_type = cost_type
103
- self.model = model
104
-
105
- # トークンモデルを取得
106
- self.token_model = tiktoken.encoding_for_model(model.value)
107
-
108
- @property
109
- def token_count(self) -> int:
110
- return len(self.token_model.encode(self.text))
111
-
112
- @property
113
- def cost(self) -> Currency:
114
- return Rate.calc_cost(self.model, self.cost_type, self.token_count)
115
-
116
- def __str__(self) -> str:
117
- return f'Token count: {self.token_count}\nCost ({self.cost_type.value}): ${self.cost.usd:.2f} / ¥{self.cost.jpy:.2f}'
118
-
119
- def __repr__(self) -> str:
120
- return f'ApiCostCalculator(text={self.text}, cost_type={self.cost_type}, model={self.model})'
@@ -1,96 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: AtCoderStudyBooster
3
- Version: 0.2
4
- Summary: A tool to download and manage AtCoder problems.
5
- Project-URL: Homepage, https://github.com/yuta6/AtCoderStudyBooster
6
- Author-email: yuta6 <46110512+yuta6@users.noreply.github.com>
7
- License: MIT
8
- Requires-Python: >=3.8
9
- Requires-Dist: beautifulsoup4
10
- Requires-Dist: fire
11
- Requires-Dist: markdownify>=0.13.1
12
- Requires-Dist: questionary>=2.0.1
13
- Requires-Dist: requests
14
- Requires-Dist: rich>=13.7.1
15
- Requires-Dist: tiktoken
16
- Requires-Dist: types-beautifulsoup4>=4.12.0.20240511
17
- Requires-Dist: types-requests>=2.32.0.20240712
18
- Requires-Dist: yfinance
19
- Description-Content-Type: text/markdown
20
-
21
- # AtCoderStudyBooster
22
-
23
- ## 概要
24
-
25
- AtCoderStudyBoosterはAtCoderの学習を加速させるためのツールです。問題をローカルにダウンロードし、テスト、解答の作成をサポートするツールです。Pythonが入っていることが必須です。Pythonが入っている環境なら、`pip install AtCoderStudyBooster`でインストールできます。
26
-
27
- このツールは以下のプロジェクトに強く影響を受けています。
28
- [online-judge-tools](https://github.com/online-judge-tools)
29
- [atcoder-cli](https://github.com/Tatamo/atcoder-cli)
30
- これらとの違いですが、本ツールはAtCoderでのコンテストでの利用は想定しておらず、初心者の学習のサポートのみを意識しています。そのため、現時点で提出機能は備えていません。また, Chat GPT APIによる解答の作成サポート機能を備えています。
31
-
32
- ## 利用ケース
33
-
34
- ### B問題の練習したい場合
35
-
36
- ABCコンテストの223から226のB問題だけを集中的に練習したい場合、次のコマンドを実行します。
37
-
38
- ```sh
39
- atcdr download B 223..226
40
- ```
41
-
42
- コマンドを実行すると,次のようなフォルダーを作成して、各々のフォルダーに問題をダウンロードします。
43
-
44
- ```css
45
- B
46
- ├── 223
47
- │ ├── StringShifting.html
48
- │ └── StringShifting.md
49
- ├── 224
50
- │ ├── Mongeness.html
51
- │ └── Mongeness.md
52
- ├── 225
53
- │ ├── StarorNot.html
54
- │ └── StarorNot.md
55
- └── 226
56
- ├── CountingArrays.html
57
- └── CountingArrays.md
58
- ```
59
-
60
- MarkdownファイルあるいはHTMLファイルをVS CodeのHTML Preview, Markdown Previewで開くと問題を確認できます。VS Codeで開くと左側にテキストエディターを表示して、右側で問題をみながら問題に取り組めます。
61
-
62
- ![demo画像](./.images/demo1.png)
63
-
64
- ### サンプルをローカルでテストする
65
-
66
- 問題をダウンロードしたフォルダーに移動します。
67
-
68
- ```sh
69
- cd B/224
70
- ```
71
-
72
- 移動したフォルダーで解答ファイルを作成後を実行すると, 自動的にテストします。
73
-
74
- ```sh
75
- ▷ ~/.../B/224
76
- atcdr t
77
- ```
78
-
79
- ```sh
80
- solution.pyをテストします。
81
- --------------------
82
-
83
- Sample 1 of Test:
84
- ✓ Accepted !! Time: 24 ms
85
-
86
- Sample 2 of Test:
87
- ✓ Accepted !! Time: 15 ms
88
- ```
89
-
90
- と実行すると作成したソースコードをテストして、HTMLに書かれているテストケースを読み込んで実行し, Passするかを判定します。
91
-
92
- ## 解答生成機能generateコマンドに関する注意点
93
-
94
- 本ツールにはChatGPT APIを利用したコード生成機能があります。[AtCoder生成AI対策ルール](https://info.atcoder.jp/entry/llm-abc-rules-ja?_gl=1*1axgs02*_ga*ODc0NDAyNjA4LjE3MTk1ODEyNDA.*_ga_RC512FD18N*MTcyMzMxNDA1Ni43NC4xLjE3MjMzMTY1NjUuMC4wLjA.)によるとAtCoder Beginner Contestにおいてに問題文を生成AIに直接与えることは禁止されています。ただし、このルールは過去問を練習している際には適用されません。
95
-
96
- 現時点で本ツールにはログイン機能がないため、コンテスト中の問題に対して`download`コマンドは利用して問題をダウンロードすることはできません。`generate`コマンドは`download`コマンドに依存しており、ダウンロードした問題のHTMLファイルをパースしてGPTに解釈しやすいmarkdownを与えることで実現しています。したがって、このコマンドがAtCoder Beginner Contest中に[AtCoder生成AI対策ルール](https://info.atcoder.jp/entry/llm-abc-rules-ja?_gl=1*1axgs02*_ga*ODc0NDAyNjA4LjE3MTk1ODEyNDA.*_ga_RC512FD18N*MTcyMzMxNDA1Ni43NC4xLjE3MjMzMTY1NjUuMC4wLjA.)に抵触することはありません。
@@ -1,17 +0,0 @@
1
- atcdr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- atcdr/download.py,sha256=aqJEmrLop_Mj8GNJjoWRcSzWU0z9iNc9vtZOjhWXx3U,8945
3
- atcdr/generate.py,sha256=0yWX-5PS-FR6LTaP3muHq6a7rFB2a1Oek48mF45exoA,6972
4
- atcdr/main.py,sha256=y2IkXwcAyKZ_1y5PgU93GpXzo5lKak9oxo0XV_9d5Fo,727
5
- atcdr/markdown.py,sha256=jEktnYgrDYcgIuhxRpJImAzNpFmfSPkRikAesfMxAVk,1125
6
- atcdr/open.py,sha256=2UlmNWdieoMrPu1xSUWf-8sBB9Y19r0t6V9zDRBSPes,924
7
- atcdr/test.py,sha256=hAhttwVJiDJX8IAWcnpKj04yTTs4cmr8GQ-NsldBAGc,8468
8
- atcdr/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- atcdr/util/cost.py,sha256=0c9H8zLley7xZDLuYU4zJmB8m71qcO1WEIQOoEavD_4,3168
10
- atcdr/util/execute.py,sha256=tcYflnVo_38LdaOGDUAuqfSfcA54bTrCaTRShH7kwUw,1750
11
- atcdr/util/filetype.py,sha256=NyTkBbL44VbPwGXps381odbC_JEx_eYxRYPaYwRHfZ0,1647
12
- atcdr/util/gpt.py,sha256=Lto6SJHZGer8cC_Nq8lJVnaET2R7apFQteo6ZEFpjdM,3304
13
- atcdr/util/problem.py,sha256=WprmpOZm6xpyvksIS3ou1uHqFnBO1FUZWadsLziG1bY,2484
14
- atcoderstudybooster-0.2.dist-info/METADATA,sha256=Yyj9AArb6NwZNk6YwjS8W_NVwwdZBlFd2a__T6OsfM4,4467
15
- atcoderstudybooster-0.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
16
- atcoderstudybooster-0.2.dist-info/entry_points.txt,sha256=_bhz0R7vp2VubKl_eIokDO8Wz9TdqvYA7Q59uWfy6Sk,42
17
- atcoderstudybooster-0.2.dist-info/RECORD,,