nexora-vg 2.0.0__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.
nexora_vg/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Nexora VG: printable Python learning templates."""
2
+ from .templates import SECTION_NAMES, TEMPLATES, template, variants
3
+
4
+ __version__ = "2.0.0"
5
+ __all__ = ["template", "variants", "TEMPLATES", "SECTION_NAMES"]
nexora_vg/cli.py ADDED
@@ -0,0 +1,69 @@
1
+ """CLI that prints readable Python templates without computing the answer."""
2
+ import sys
3
+ from .templates import SECTION_NAMES, TEMPLATES, template
4
+
5
+
6
+ def list_sections():
7
+ print("Nexora — Python-шаблоны для задач")
8
+ for number, name in SECTION_NAMES.items():
9
+ print(f" {number}. {name} ({len(TEMPLATES[number])} вариантов)")
10
+
11
+
12
+ def list_variants(section):
13
+ print(f"{section}. {SECTION_NAMES[section]}")
14
+ for number, item in TEMPLATES[section].items():
15
+ print(f" {number}. {item.title}")
16
+ print(f" {item.formula}")
17
+
18
+
19
+ def main():
20
+ argv = sys.argv[1:]
21
+ if argv and argv[0] in ("--help", "-h", "help"):
22
+ print("Использование: nexora [раздел [вариант]]")
23
+ print(" nexora интерактивный выбор")
24
+ print(" nexora 1 первый шаблон раздела 1")
25
+ print(" nexora 2 7 седьмой шаблон раздела 2")
26
+ print(" nexora list список разделов")
27
+ print(" nexora list 1 варианты раздела 1")
28
+ print(" nexora 5 1 > code.py сохранить код в файл")
29
+ return
30
+ if argv and argv[0] in ("list", "--list"):
31
+ if len(argv) > 1 and argv[1] in TEMPLATES:
32
+ list_variants(argv[1])
33
+ else:
34
+ list_sections()
35
+ return
36
+ if argv:
37
+ section = argv[0]
38
+ variant = argv[1] if len(argv) > 1 else "1"
39
+ try:
40
+ sys.stdout.write(template(section, variant))
41
+ except ValueError as exc:
42
+ print(f"Ошибка: {exc}", file=sys.stderr)
43
+ sys.exit(2)
44
+ return
45
+
46
+ while True:
47
+ print()
48
+ list_sections()
49
+ section = input("Раздел (0 — выход): ").strip()
50
+ if section == "0" or not section:
51
+ return
52
+ if section not in TEMPLATES:
53
+ print("Нет такого раздела")
54
+ continue
55
+ list_variants(section)
56
+ variant = input("Вариант [1]: ").strip() or "1"
57
+ if variant not in TEMPLATES[section]:
58
+ print("Нет такого варианта")
59
+ continue
60
+ item = TEMPLATES[section][variant]
61
+ print("\n--- СКОПИРУЙ КОД НИЖЕ ---")
62
+ print(item.code, end="")
63
+ print("--- КОНЕЦ КОДА ---")
64
+ if item.note:
65
+ print("Пояснение:", item.note)
66
+
67
+
68
+ if __name__ == "__main__":
69
+ main()
nexora_vg/templates.py ADDED
@@ -0,0 +1,324 @@
1
+ """Small, self-contained Python examples; each is a runnable template, not an answer service."""
2
+ from dataclasses import dataclass
3
+ from textwrap import dedent
4
+ from typing import Dict, List
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class Snippet:
9
+ title: str
10
+ formula: str
11
+ code: str
12
+ note: str
13
+
14
+
15
+ def snippet(title: str, formula: str, code: str, note: str = "") -> Snippet:
16
+ return Snippet(title, formula, dedent(code).strip() + "\n", note)
17
+
18
+
19
+ TEMPLATES: Dict[str, Dict[str, Snippet]] = {
20
+ "1": {
21
+ "1": snippet("Делимость: вложенные следования (макс A)",
22
+ "ДЕЛ(x,B) -> (!ДЕЛ(x,A) -> !ДЕЛ(x,C))",
23
+ '''\
24
+ from math import lcm
25
+
26
+ # Измени B и C. x — натуральное число.
27
+ B, C = 21, 77
28
+ # (ДЕЛ(x,B) и ДЕЛ(x,C)) -> ДЕЛ(x,A)
29
+ print(lcm(B, C))
30
+ ''', "Максимальный A равен НОК(B,C); структура и отрицания обязательны."),
31
+ "2": snippet("Делимость: И (макс A)",
32
+ "(ДЕЛ(x,B) и ДЕЛ(x,C)) -> ДЕЛ(x,A)",
33
+ '''\
34
+ from math import lcm
35
+ B, C = 21, 77
36
+ print(lcm(B, C))
37
+ '''),
38
+ "3": snippet("Делимость: ИЛИ (макс A)",
39
+ "(ДЕЛ(x,B) или ДЕЛ(x,C)) -> ДЕЛ(x,A)",
40
+ '''\
41
+ from math import gcd
42
+ B, C = 21, 77
43
+ print(gcd(B, C))
44
+ '''),
45
+ "4": snippet("Делимость: A слева, И (мин A)",
46
+ "ДЕЛ(x,A) -> (ДЕЛ(x,B) и ДЕЛ(x,C))",
47
+ '''\
48
+ from math import lcm
49
+ B, C = 21, 77
50
+ print(lcm(B, C))
51
+ '''),
52
+ "5": snippet("Делимость: A слева, ИЛИ (мин A)",
53
+ "ДЕЛ(x,A) -> (ДЕЛ(x,B) или ДЕЛ(x,C))",
54
+ '''\
55
+ B, C = 21, 77
56
+ print(min(B, C))
57
+ '''),
58
+ "6": snippet("Делимость: B слева (макс A)",
59
+ "ДЕЛ(x,B) -> ДЕЛ(x,A)",
60
+ '''\
61
+ B = 21
62
+ print(B)
63
+ '''),
64
+ "7": snippet("Делимость: A слева (мин A)",
65
+ "ДЕЛ(x,A) -> ДЕЛ(x,B)",
66
+ '''\
67
+ B = 21
68
+ print(B)
69
+ '''),
70
+ "8": snippet("Делимость: другое отрицание (макс A)",
71
+ "ДЕЛ(x,B) -> (!ДЕЛ(x,A) -> ДЕЛ(x,C))",
72
+ '''\
73
+ B, C = 21, 77
74
+ if B % C == 0:
75
+ print("Максимума A нет: подходят все натуральные A")
76
+ else:
77
+ print(B)
78
+ '''),
79
+ "9": snippet("Делимость: проверка произвольной формулы (граница A)",
80
+ "Впиши свою формулу в переменную f; проверка всех x через НОК",
81
+ '''\
82
+ from math import lcm
83
+ B, C = 21, 77
84
+ MAX_A = 300 # граница поиска, не математический максимум
85
+
86
+ def good(A):
87
+ # Все условия ДЕЛ периодичны с периодом НОК(A,B,C).
88
+ for x in range(1, lcm(A, B, C) + 1):
89
+ db = x % B == 0
90
+ da = x % A == 0
91
+ dc = x % C == 0
92
+ # Перепиши формулу из условия здесь:
93
+ f = (not db) or (da or (not dc))
94
+ if not f:
95
+ return False
96
+ return True
97
+
98
+ answers = [A for A in range(1, MAX_A + 1) if good(A)]
99
+ print("В пределах 1..", MAX_A, ":", answers[-1] if answers else None)
100
+ ''', "Для других формул нужно изменить f; поиск A ограничен MAX_A; медленнее быстрых формул."),
101
+ },
102
+ "2": {
103
+ "1": snippet("Биты: НЕ(x&A=0), мин A",
104
+ "((x&B!=0) и (x&C=0)) -> НЕ(x&A=0)",
105
+ '''\
106
+ B, C = 117, 91
107
+ # НЕ(x&A=0) означает (x&A != 0)
108
+ print(B & ~C)
109
+ '''),
110
+ "2": snippet("Биты: x&A=0, мин A",
111
+ "((x&B!=0) и (x&C=0)) -> (x&A=0)",
112
+ '''\
113
+ B, C = 117, 91
114
+ print(0) # A=0 всегда делает x&A равным 0
115
+ '''),
116
+ "3": snippet("Биты: x&A=0, макс A",
117
+ "((x&B!=0) и (x&C=0)) -> (x&A=0)",
118
+ '''\
119
+ B, C = 117, 91
120
+ if B & ~C == 0:
121
+ print("Максимума A нет: посылка всегда ложна")
122
+ else:
123
+ print(C)
124
+ '''),
125
+ "4": snippet("Биты: A в посылке, макс A",
126
+ "(x&A!=0) -> ((x&B=0) -> (x&C!=0))",
127
+ '''\
128
+ B, C = 117, 91
129
+ print(B | C)
130
+ '''),
131
+ "5": snippet("Биты: вложенное следование, мин A",
132
+ "(x&B!=0) -> ((x&C=0) -> (x&A!=0))",
133
+ '''\
134
+ B, C = 117, 91
135
+ print(B & ~C)
136
+ '''),
137
+ "6": snippet("Биты: невозможность тройного И, мин A",
138
+ "(x&A=0) и (x&B!=0) и (x&C=0) всегда ложно",
139
+ '''\
140
+ B, C = 117, 91
141
+ print(B & ~C)
142
+ '''),
143
+ "7": snippet("Биты: универсальная проверка (граница A)",
144
+ "Проверка заданной формулы для всех x по маске, поиск A до LIMIT",
145
+ '''\
146
+ B, C = 117, 91
147
+ LIMIT = 127 # ищем 0 <= A <= LIMIT
148
+ width = max(1, B.bit_length(), C.bit_length(), LIMIT.bit_length())
149
+
150
+ def good(A):
151
+ # Достаточно перебрать все комбинации используемых битов.
152
+ for x in range(1 << width):
153
+ left = (x & B != 0) and (x & C == 0)
154
+ right = (x & A != 0)
155
+ # Измени left/right, если формула из условия другая.
156
+ if left and not right:
157
+ return False
158
+ return True
159
+
160
+ answers = [A for A in range(LIMIT + 1) if good(A)]
161
+ print("Минимум в диапазоне:", min(answers) if answers else None)
162
+ print("Максимум в диапазоне:", max(answers) if answers else None)
163
+ ''', "Полная проверка x для масок указанной битности; перебор A ограничен LIMIT."),
164
+ },
165
+ "3": {
166
+ "1": snippet("Неравенства с x,y: формула",
167
+ "((x<A) и (y<kA)) или (p*x+q*y>C); x,y>=1",
168
+ '''\
169
+ # Измени p,q,k,C по условию.
170
+ p, q, k, C = 2, 1, 3, 128
171
+ if min(p, q, k) <= 0:
172
+ raise ValueError("p, q, k должны быть положительными")
173
+ if C < p + q:
174
+ A = 1 # x,y>=1 не могут нарушить вторую часть
175
+ else:
176
+ xmax = (C - q) // p
177
+ ymax = (C - p) // q
178
+ A = max(1, xmax + 1, ymax // k + 1)
179
+ print(A)
180
+ ''', "Для строго указанных знаков <, <, > и натуральных x,y; при других знаках нужен другой вывод."),
181
+ "2": snippet("Неравенства: проверка на небольшой области",
182
+ "Произвольная формула F(x,y,A) на ограниченном диапазоне (не доказательство)",
183
+ '''\
184
+ MAX_A = 100
185
+ MAX_XY = 150 # проверяются только x,y в 1..MAX_XY
186
+
187
+ def good(A):
188
+ for x in range(1, MAX_XY + 1):
189
+ for y in range(1, MAX_XY + 1):
190
+ f = ((x < A) and (y < 3*A)) or (2*x + y > 128)
191
+ # Измени только f для своей формулы.
192
+ if not f:
193
+ return False
194
+ return True
195
+
196
+ print(next((A for A in range(1, MAX_A + 1) if good(A)), None))
197
+ ''', "Ограниченный перебор не доказывает условие 'для всех натуральных x,y'."),
198
+ },
199
+ "4": {
200
+ "1": snippet("Отрезки: минимальная длина A",
201
+ "(x не в A) -> ((x в P) или (x не в Q) или (x не в T))",
202
+ '''\
203
+ # Замкнутые отрезки P,Q,T; A — один отрезок.
204
+ P = (66, 67)
205
+ Q = (32, 125)
206
+ T = (30, 49)
207
+
208
+ if any(a > b for a, b in (P, Q, T)):
209
+ raise ValueError("Начало отрезка не может быть больше конца")
210
+ left = max(Q[0], T[0])
211
+ right = min(Q[1], T[1])
212
+ if left >= right or (P[0] <= left and right <= P[1]):
213
+ length = 0
214
+ elif P[0] <= left <= P[1] < right:
215
+ length = right - P[1]
216
+ elif left < P[0] <= right <= P[1]:
217
+ length = P[0] - left
218
+ else:
219
+ length = right - left
220
+ print(length)
221
+ ''', "Только эта логическая структура; если P отсекает середину, A охватывает обе части."),
222
+ },
223
+ "5": {
224
+ "1": snippet("Система счисления: сколько цифр C",
225
+ "Количество заданной цифры в записи числа в основании base",
226
+ '''\
227
+ n = 14**1402 + 28**501 - 14**51 - 1400
228
+ base = 14
229
+ wanted = 12 # A=10, B=11, C=12, D=13
230
+ if n < 0 or base < 2 or not 0 <= wanted < base:
231
+ raise ValueError("Проверь число, основание и цифру")
232
+ count = 0
233
+ while True:
234
+ count += (n % base == wanted)
235
+ n //= base
236
+ if n == 0:
237
+ break
238
+ print(count)
239
+ ''', "Заменяй выражение, base и wanted. В Python степень — **, не ^."),
240
+ "2": snippet("Система счисления: сумма цифр",
241
+ "Сумма всех цифр в основании base",
242
+ '''\
243
+ n = 14**1402 + 28**501 - 14**51 - 1400
244
+ base = 14
245
+ if n < 0 or base < 2:
246
+ raise ValueError("Нужны n>=0 и base>=2")
247
+ total = 0
248
+ while n:
249
+ total += n % base
250
+ n //= base
251
+ print(total)
252
+ '''),
253
+ "3": snippet("Система счисления: нечётные цифры",
254
+ "Количество нечётных цифр в основании base",
255
+ '''\
256
+ n = 14**1402 + 28**501 - 14**51 - 1400
257
+ base = 14
258
+ if n < 0 or base < 2:
259
+ raise ValueError("Нужны n>=0 и base>=2")
260
+ count = 0
261
+ while n:
262
+ count += ((n % base) % 2 == 1)
263
+ n //= base
264
+ print(count)
265
+ '''),
266
+ "4": snippet("Система счисления: цифры больше порога",
267
+ "Количество цифр, строго больших threshold",
268
+ '''\
269
+ n = 14**1402 + 28**501 - 14**51 - 1400
270
+ base = 14
271
+ threshold = 10
272
+ if n < 0 or base < 2:
273
+ raise ValueError("Нужны n>=0 и base>=2")
274
+ count = 0
275
+ while True:
276
+ count += (n % base > threshold)
277
+ n //= base
278
+ if n == 0:
279
+ break
280
+ print(count)
281
+ '''),
282
+ "5": snippet("Система счисления: перевести число в другую базу",
283
+ "Получить строку с записью числа в основании 2..36",
284
+ '''\
285
+ n = 14**1402 + 28**501 - 14**51 - 1400
286
+ base = 14
287
+ alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
288
+ if n < 0 or not 2 <= base <= len(alphabet):
289
+ raise ValueError("Основание от 2 до 36, n>=0")
290
+ digits = []
291
+ while True:
292
+ digits.append(alphabet[n % base])
293
+ n //= base
294
+ if n == 0:
295
+ break
296
+ print("".join(reversed(digits)))
297
+ '''),
298
+ },
299
+ }
300
+
301
+ SECTION_NAMES = {
302
+ "1": "Делимость",
303
+ "2": "Побитовая логика",
304
+ "3": "Неравенства",
305
+ "4": "Отрезки",
306
+ "5": "Системы счисления",
307
+ }
308
+
309
+
310
+ def template(section, variant="1") -> str:
311
+ """Get a runnable Python template as plain text."""
312
+ sec, var = str(section), str(variant)
313
+ try:
314
+ return TEMPLATES[sec][var].code
315
+ except KeyError:
316
+ raise ValueError("Нет такого номера или варианта шаблона") from None
317
+
318
+
319
+ def variants(section) -> List[Snippet]:
320
+ """Return template options in order."""
321
+ sec = str(section)
322
+ if sec not in TEMPLATES:
323
+ raise ValueError("Нет такого раздела")
324
+ return list(TEMPLATES[sec].values())
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: nexora-vg
3
+ Version: 2.0.0
4
+ Summary: Offline Python learning templates for numeric, logic and bitwise tasks
5
+ Author: Nexora VG contributors
6
+ License-Expression: MIT
7
+ Keywords: python,learning,templates,mathematics,logic,bitwise
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Topic :: Education
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # Nexora VG — Python template reference
17
+
18
+ Nexora VG 2.0 prints self-contained Python code examples for arithmetic, divisibility,
19
+ bitwise logic, inequalities, intervals and numeral-system tasks. It never needs an online
20
+ service after installation and uses only the standard Python library.
21
+
22
+ It is a code-template reference, not a universal automatic solver. Each example includes
23
+ specific assumptions; match the formula exactly before using the template.
24
+
25
+ ## Installation (after publishing to PyPI)
26
+
27
+ ```bash
28
+ python3 -m pip install --user --upgrade nexora-vg
29
+ ```
30
+
31
+ On managed Linux distributions, prefer a virtual environment if system Python blocks pip.
32
+
33
+ ## Commands
34
+
35
+ ```bash
36
+ nexora # interactive list of topics and formula variants
37
+ nexora list # list topics
38
+ nexora list 2 # list variants in category 2
39
+ nexora 1 # print code for the first divisibility structure
40
+ nexora 2 1 # print code for the first bitwise structure
41
+ nexora 5 1 # print code for the base-digit counting template
42
+ nexora 5 1 > example.py # optional: save printed code
43
+ ```
44
+
45
+ ## Python import
46
+
47
+ ```python
48
+ from nexora_vg import template
49
+ print(template(2, 1))
50
+ ```
51
+
52
+ ## Formula scopes
53
+
54
+ - Divisibility templates assume **positive integer** divisors and `x` natural.
55
+ - Bit-mask templates assume **nonnegative** integers, not the same as logical AND.
56
+ - The inequality formula assumes positive integer `x,y` and positive `p,q,k`.
57
+ - Interval formula assumes one continuous interval `A` and closed intervals `P,Q,T`.
58
+ - Positional numeral templates assume a nonnegative integer and radix 2 through 36.
59
+ - Universal-check variants limit the candidate `A` interval; the bound is not a proof of an absolute maximum.
60
+
61
+ Use these examples for studying, practice, and situations where code references are permitted.
@@ -0,0 +1,9 @@
1
+ nexora_vg/__init__.py,sha256=L72OCt882bm-k79HKB9Wn11urx7jQNOxPpdccwcaJcs,210
2
+ nexora_vg/cli.py,sha256=y4fzDwo-tKHzLXfZ1S3XcDQ37wAaNYd2pU97AW3ueGM,2516
3
+ nexora_vg/templates.py,sha256=24cIR2ElydDDGXoDFmkVCttmdD13iJElQGSCHOsbpDY,13762
4
+ nexora_vg-2.0.0.dist-info/licenses/LICENSE,sha256=0uB20T3gWQkcAK93iYFpDqqglzGrblHOLb2iUiYogHA,1079
5
+ nexora_vg-2.0.0.dist-info/METADATA,sha256=LxJb78XovoLmZiuff-e97vDqSZSBWq-7LvCwG-QIN-c,2280
6
+ nexora_vg-2.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ nexora_vg-2.0.0.dist-info/entry_points.txt,sha256=F8HUrzFfwI9FgK6iE0_IiodYPxt-MP_iq3cYL103bBI,77
8
+ nexora_vg-2.0.0.dist-info/top_level.txt,sha256=3f78jgKehwRJFFQC8WlKikDg0SNRbWWQyg0L_LcSkmw,10
9
+ nexora_vg-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ nexora = nexora_vg.cli:main
3
+ nexora-vg = nexora_vg.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nexora VG contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ nexora_vg