supermegaexplosion 0.1.0__tar.gz → 0.2.0__tar.gz

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.
Files changed (24) hide show
  1. supermegaexplosion-0.2.0/PKG-INFO +60 -0
  2. supermegaexplosion-0.2.0/README.md +48 -0
  3. supermegaexplosion-0.2.0/libbs/ai_helper.py +46 -0
  4. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/libbs/catalog.py +1 -1
  5. supermegaexplosion-0.2.0/libbs/tools/__init__.py +0 -0
  6. supermegaexplosion-0.2.0/libbs/tools/add_func.py +145 -0
  7. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/pyproject.toml +2 -2
  8. supermegaexplosion-0.2.0/supermegaexplosion.egg-info/PKG-INFO +60 -0
  9. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/supermegaexplosion.egg-info/SOURCES.txt +2 -0
  10. supermegaexplosion-0.2.0/supermegaexplosion.egg-info/requires.txt +3 -0
  11. supermegaexplosion-0.1.0/PKG-INFO +0 -39
  12. supermegaexplosion-0.1.0/README.md +0 -26
  13. supermegaexplosion-0.1.0/libbs/ai_helper.py +0 -30
  14. supermegaexplosion-0.1.0/supermegaexplosion.egg-info/PKG-INFO +0 -39
  15. supermegaexplosion-0.1.0/supermegaexplosion.egg-info/requires.txt +0 -4
  16. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/libbs/__init__.py +0 -0
  17. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/libbs/arrays.py +0 -0
  18. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/libbs/ds.py +0 -0
  19. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/libbs/input_utils.py +0 -0
  20. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/libbs/math_utils.py +0 -0
  21. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/libbs/strings.py +0 -0
  22. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/setup.cfg +0 -0
  23. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/supermegaexplosion.egg-info/dependency_links.txt +0 -0
  24. {supermegaexplosion-0.1.0 → supermegaexplosion-0.2.0}/supermegaexplosion.egg-info/top_level.txt +0 -0
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: supermegaexplosion
3
+ Version: 0.2.0
4
+ Summary: DSA utility library — input helpers, algorithms, data structures, and AI assistant
5
+ Author-email: "Hadoopnb.ai" <hadoopnb@example.com>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Provides-Extra: ai
11
+ Requires-Dist: google-genai; extra == "ai"
12
+
13
+ # supermegaexplosion
14
+
15
+ DSA utility library — interactive input helpers, string/math/array algorithms, data structures, and an AI assistant powered by Google Gemini.
16
+
17
+ ```python
18
+ from libbs import *
19
+
20
+ show_commands() # list everything available
21
+ input_matrix() # interactively type a matrix
22
+ is_palindrome("racecar") # True
23
+ sieve(100) # primes up to 100
24
+ max_subarray_sum([-2,1,-3,4,-1,2,1,-5,4]) # 6
25
+ ListNode.from_list([1,2,3,4,5])
26
+
27
+ # AI assistant (requires API key + dependency)
28
+ respond_help("How to reverse a linked list?")
29
+ ```
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ pip install supermegaexplosion # core (zero deps)
35
+ pip install supermegaexplosion[ai] # with AI assistant (google-genai)
36
+ ```
37
+
38
+ ## AI Setup
39
+
40
+ Get a free API key from https://aistudio.google.com/ and set it:
41
+
42
+ ```bash
43
+ set GEMINI_API_KEY=your_api_key_here
44
+ ```
45
+
46
+ Then use `respond_help("your question")` — free tier gives 60 requests/min, 1500/day.
47
+
48
+ ## Adding New Functions
49
+
50
+ Run the interactive helper:
51
+
52
+ ```bash
53
+ python -m libbs.tools.add_func
54
+ ```
55
+
56
+ It appends the function to the right module, updates the catalog, bumps the version, and optionally rebuilds + uploads to PyPI.
57
+
58
+ ## License
59
+
60
+ MIT
@@ -0,0 +1,48 @@
1
+ # supermegaexplosion
2
+
3
+ DSA utility library — interactive input helpers, string/math/array algorithms, data structures, and an AI assistant powered by Google Gemini.
4
+
5
+ ```python
6
+ from libbs import *
7
+
8
+ show_commands() # list everything available
9
+ input_matrix() # interactively type a matrix
10
+ is_palindrome("racecar") # True
11
+ sieve(100) # primes up to 100
12
+ max_subarray_sum([-2,1,-3,4,-1,2,1,-5,4]) # 6
13
+ ListNode.from_list([1,2,3,4,5])
14
+
15
+ # AI assistant (requires API key + dependency)
16
+ respond_help("How to reverse a linked list?")
17
+ ```
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pip install supermegaexplosion # core (zero deps)
23
+ pip install supermegaexplosion[ai] # with AI assistant (google-genai)
24
+ ```
25
+
26
+ ## AI Setup
27
+
28
+ Get a free API key from https://aistudio.google.com/ and set it:
29
+
30
+ ```bash
31
+ set GEMINI_API_KEY=your_api_key_here
32
+ ```
33
+
34
+ Then use `respond_help("your question")` — free tier gives 60 requests/min, 1500/day.
35
+
36
+ ## Adding New Functions
37
+
38
+ Run the interactive helper:
39
+
40
+ ```bash
41
+ python -m libbs.tools.add_func
42
+ ```
43
+
44
+ It appends the function to the right module, updates the catalog, bumps the version, and optionally rebuilds + uploads to PyPI.
45
+
46
+ ## License
47
+
48
+ MIT
@@ -0,0 +1,46 @@
1
+ import os
2
+
3
+
4
+ def respond_help(query=None, api_key=None, model="gemini-2.0-flash-lite"):
5
+ if query is None:
6
+ query = input("Ask a DSA/Python question: ").strip()
7
+ if not query:
8
+ return
9
+
10
+ if api_key is None:
11
+ api_key = os.environ.get("GEMINI_API_KEY")
12
+ if not api_key:
13
+ print(
14
+ "Gemini API key not found.\n"
15
+ "Set the GEMINI_API_KEY environment variable:\n"
16
+ " set GEMINI_API_KEY=your_key_here\n"
17
+ "Or pass api_key='your_key' to respond_help()."
18
+ )
19
+ return
20
+
21
+ try:
22
+ from google import genai
23
+ except ImportError:
24
+ print(
25
+ "Missing dependency. Install with:\n"
26
+ " pip install supermegaexplosion[ai]"
27
+ )
28
+ return
29
+
30
+ try:
31
+ client = genai.Client(api_key=api_key)
32
+ resp = client.models.generate_content(
33
+ model=model,
34
+ contents=(
35
+ "You are a DSA and Python coding assistant. "
36
+ "Answer concisely with code examples.\n\n"
37
+ f"Question: {query}"
38
+ ),
39
+ config={
40
+ "max_output_tokens": 512,
41
+ "temperature": 0.3,
42
+ },
43
+ )
44
+ print(resp.text)
45
+ except Exception as e:
46
+ print(f"Error: {e}")
@@ -55,7 +55,7 @@ COMMANDS = {
55
55
  "has_path_sum": "Check if root-to-leaf path sums to target.",
56
56
  },
57
57
  "AI Assistant": {
58
- "respond_help": "Ask a coding/DSA question and get an answer from a free local AI model.",
58
+ "respond_help": "Ask a coding/DSA question via Google Gemini (free, needs GEMINI_API_KEY env var).",
59
59
  },
60
60
  }
61
61
 
File without changes
@@ -0,0 +1,145 @@
1
+ import os
2
+ import re
3
+ import subprocess
4
+ import sys
5
+
6
+
7
+ MODULE_MAP = {
8
+ "1": ("arrays.py", "Arrays", "arrays"),
9
+ "2": ("strings.py", "Strings", "strings"),
10
+ "3": ("math_utils.py", "Math", "math_utils"),
11
+ "4": ("ds.py", "Data Structures", "ds"),
12
+ "5": ("input_utils.py", "Input", "input_utils"),
13
+ }
14
+
15
+ MODULE_CHOICES = "\n".join(
16
+ f" {k}. {v[1]}" for k, v in MODULE_MAP.items()
17
+ )
18
+
19
+
20
+ def main():
21
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
22
+
23
+ root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
24
+
25
+ print("=== Add Function to libbs ===\n")
26
+
27
+ name = input("Function name: ").strip()
28
+ if not name:
29
+ print("Aborted.")
30
+ return
31
+
32
+ print(f"\nSelect module:\n{MODULE_CHOICES}")
33
+ mod_key = input("Module number: ").strip()
34
+ if mod_key not in MODULE_MAP:
35
+ print("Invalid choice.")
36
+ return
37
+
38
+ filename, category, module_name = MODULE_MAP[mod_key]
39
+
40
+ desc = input("Description: ").strip()
41
+
42
+ print("\nPaste function body (empty line to finish):")
43
+ lines = []
44
+ while True:
45
+ line = input()
46
+ if not line.strip():
47
+ break
48
+ lines.append(line)
49
+ body = "\n".join(lines)
50
+
51
+ if not body:
52
+ print("No body provided. Aborted.")
53
+ return
54
+
55
+ # 1. Append to module file
56
+ mod_path = os.path.join(root, filename)
57
+ with open(mod_path, "a", encoding="utf-8") as f:
58
+ f.write("\n\n" + body)
59
+
60
+ # 2. Update __all__ in module
61
+ with open(mod_path, "r", encoding="utf-8") as f:
62
+ content = f.read()
63
+
64
+ all_match = re.search(r"__all__\s*=\s*\[(.*?)\]", content, re.DOTALL)
65
+ if all_match:
66
+ existing = all_match.group(1)
67
+ new_all = f'__all__ = [{existing} "{name}",\n]'
68
+ content = content.replace(all_match.group(0), new_all)
69
+ with open(mod_path, "w", encoding="utf-8") as f:
70
+ f.write(content)
71
+
72
+ # 3. Update catalog
73
+ catalog_path = os.path.join(root, "catalog.py")
74
+ with open(catalog_path, "r", encoding="utf-8") as f:
75
+ content = f.read()
76
+
77
+ section_pattern = rf'("{category}": \{{\n)(.*?)(\n \}},)'
78
+
79
+ def add_to_section(m):
80
+ pre = m.group(1)
81
+ mid = m.group(2)
82
+ suf = m.group(3)
83
+ entry = f'\n "{name}": "{desc}",'
84
+ return pre + mid + entry + suf
85
+
86
+ new_content = re.sub(section_pattern, add_to_section, content, count=1, flags=re.DOTALL)
87
+ if new_content != content:
88
+ with open(catalog_path, "w", encoding="utf-8") as f:
89
+ f.write(new_content)
90
+ print(" catalog.py: updated")
91
+ else:
92
+ print(" Warning: catalog section not found, update manually.")
93
+
94
+ # 4. Bump patch version
95
+ pyproject_path = os.path.join(root, "..", "pyproject.toml")
96
+ with open(pyproject_path, "r", encoding="utf-8") as f:
97
+ content = f.read()
98
+
99
+ ver_match = re.search(r'version = "(\d+)\.(\d+)\.(\d+)"', content)
100
+ if ver_match:
101
+ major, minor, patch = map(int, ver_match.groups())
102
+ new_ver = f"{major}.{minor}.{patch + 1}"
103
+ content = content.replace(ver_match.group(0), f'version = "{new_ver}"')
104
+ with open(pyproject_path, "w", encoding="utf-8") as f:
105
+ f.write(content)
106
+ print(f" pyproject.toml: version {new_ver}")
107
+ else:
108
+ print(" Warning: could not bump version.")
109
+
110
+ print(f"\nDone. Function '{name}' added.\n")
111
+
112
+ ans = input("Build and upload to PyPI now? (y/n): ").strip().lower()
113
+ if ans == "y":
114
+ _build_and_upload(root)
115
+
116
+
117
+ def _build_and_upload(root):
118
+ os.chdir(os.path.join(root, ".."))
119
+ print("\nBuilding...")
120
+ r = subprocess.run([sys.executable, "-m", "build"], capture_output=True, text=True)
121
+ if r.returncode != 0:
122
+ print("Build failed:", r.stderr)
123
+ return
124
+ print("Build OK.")
125
+
126
+ token = os.environ.get("TWINE_PASSWORD")
127
+ if not token:
128
+ token = input("PyPI API token: ").strip()
129
+
130
+ env = os.environ.copy()
131
+ env["TWINE_USERNAME"] = "__token__"
132
+ env["TWINE_PASSWORD"] = token
133
+ print("Uploading...")
134
+ r = subprocess.run(
135
+ [sys.executable, "-m", "twine", "upload", "dist/*"],
136
+ env=env, capture_output=True, text=True,
137
+ )
138
+ if r.returncode == 0:
139
+ print("Uploaded to PyPI!")
140
+ else:
141
+ print("Upload failed:", r.stderr)
142
+
143
+
144
+ if __name__ == "__main__":
145
+ main()
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "supermegaexplosion"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "DSA utility library — input helpers, algorithms, data structures, and AI assistant"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Hadoopnb.ai", email = "hadoopnb@example.com" }]
@@ -15,4 +15,4 @@ classifiers = [
15
15
  requires-python = ">=3.8"
16
16
 
17
17
  [project.optional-dependencies]
18
- ai = ["transformers>=4.30.0", "torch>=2.0.0"]
18
+ ai = ["google-genai"]
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: supermegaexplosion
3
+ Version: 0.2.0
4
+ Summary: DSA utility library — input helpers, algorithms, data structures, and AI assistant
5
+ Author-email: "Hadoopnb.ai" <hadoopnb@example.com>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Provides-Extra: ai
11
+ Requires-Dist: google-genai; extra == "ai"
12
+
13
+ # supermegaexplosion
14
+
15
+ DSA utility library — interactive input helpers, string/math/array algorithms, data structures, and an AI assistant powered by Google Gemini.
16
+
17
+ ```python
18
+ from libbs import *
19
+
20
+ show_commands() # list everything available
21
+ input_matrix() # interactively type a matrix
22
+ is_palindrome("racecar") # True
23
+ sieve(100) # primes up to 100
24
+ max_subarray_sum([-2,1,-3,4,-1,2,1,-5,4]) # 6
25
+ ListNode.from_list([1,2,3,4,5])
26
+
27
+ # AI assistant (requires API key + dependency)
28
+ respond_help("How to reverse a linked list?")
29
+ ```
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ pip install supermegaexplosion # core (zero deps)
35
+ pip install supermegaexplosion[ai] # with AI assistant (google-genai)
36
+ ```
37
+
38
+ ## AI Setup
39
+
40
+ Get a free API key from https://aistudio.google.com/ and set it:
41
+
42
+ ```bash
43
+ set GEMINI_API_KEY=your_api_key_here
44
+ ```
45
+
46
+ Then use `respond_help("your question")` — free tier gives 60 requests/min, 1500/day.
47
+
48
+ ## Adding New Functions
49
+
50
+ Run the interactive helper:
51
+
52
+ ```bash
53
+ python -m libbs.tools.add_func
54
+ ```
55
+
56
+ It appends the function to the right module, updates the catalog, bumps the version, and optionally rebuilds + uploads to PyPI.
57
+
58
+ ## License
59
+
60
+ MIT
@@ -8,6 +8,8 @@ libbs/ds.py
8
8
  libbs/input_utils.py
9
9
  libbs/math_utils.py
10
10
  libbs/strings.py
11
+ libbs/tools/__init__.py
12
+ libbs/tools/add_func.py
11
13
  supermegaexplosion.egg-info/PKG-INFO
12
14
  supermegaexplosion.egg-info/SOURCES.txt
13
15
  supermegaexplosion.egg-info/dependency_links.txt
@@ -0,0 +1,3 @@
1
+
2
+ [ai]
3
+ google-genai
@@ -1,39 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: supermegaexplosion
3
- Version: 0.1.0
4
- Summary: DSA utility library — input helpers, algorithms, data structures, and AI assistant
5
- Author-email: "Hadoopnb.ai" <hadoopnb@example.com>
6
- License-Expression: MIT
7
- Classifier: Programming Language :: Python :: 3
8
- Requires-Python: >=3.8
9
- Description-Content-Type: text/markdown
10
- Provides-Extra: ai
11
- Requires-Dist: transformers>=4.30.0; extra == "ai"
12
- Requires-Dist: torch>=2.0.0; extra == "ai"
13
-
14
- # libbs
15
-
16
- DSA utility library — interactive input helpers, string/math/array algorithms, data structures, and an optional AI coding assistant.
17
-
18
- ```python
19
- from libbs import *
20
-
21
- show_commands() # list everything available
22
- input_matrix() # interactively type a matrix
23
- is_palindrome("racecar") # True
24
- sieve(100) # primes up to 100
25
- max_subarray_sum([-2,1,-3,4,-1,2,1,-5,4]) # 6
26
- ListNode.from_list([1,2,3,4,5])
27
- respond_help("How to reverse a linked list?") # requires: pip install libbs[ai]
28
- ```
29
-
30
- ## Install
31
-
32
- ```bash
33
- pip install libbs # core
34
- pip install libbs[ai] # with AI assistant (transformers + torch)
35
- ```
36
-
37
- ## License
38
-
39
- MIT
@@ -1,26 +0,0 @@
1
- # libbs
2
-
3
- DSA utility library — interactive input helpers, string/math/array algorithms, data structures, and an optional AI coding assistant.
4
-
5
- ```python
6
- from libbs import *
7
-
8
- show_commands() # list everything available
9
- input_matrix() # interactively type a matrix
10
- is_palindrome("racecar") # True
11
- sieve(100) # primes up to 100
12
- max_subarray_sum([-2,1,-3,4,-1,2,1,-5,4]) # 6
13
- ListNode.from_list([1,2,3,4,5])
14
- respond_help("How to reverse a linked list?") # requires: pip install libbs[ai]
15
- ```
16
-
17
- ## Install
18
-
19
- ```bash
20
- pip install libbs # core
21
- pip install libbs[ai] # with AI assistant (transformers + torch)
22
- ```
23
-
24
- ## License
25
-
26
- MIT
@@ -1,30 +0,0 @@
1
- def respond_help(query, model_name="TinyLlama/TinyLlama-1.1B-Chat-v1.0"):
2
- try:
3
- from transformers import pipeline
4
- except ImportError:
5
- print(
6
- "The AI helper requires extra dependencies.\n"
7
- "Install them with: pip install libbs[ai]\n"
8
- "Or: pip install transformers torch"
9
- )
10
- return
11
-
12
- print(f"Loading AI model ({model_name})... This may take a while on first run.")
13
- pipe = pipeline(
14
- "text-generation",
15
- model=model_name,
16
- trust_remote_code=True,
17
- )
18
- prompt = (
19
- "You are a helpful DSA and Python coding assistant. "
20
- "Answer the following question concisely with code examples.\n\n"
21
- f"Question: {query}\n\nAnswer:"
22
- )
23
- result = pipe(
24
- prompt,
25
- max_new_tokens=512,
26
- temperature=0.3,
27
- do_sample=True,
28
- pad_token_id=pipe.tokenizer.eos_token_id,
29
- )
30
- print(result[0]["generated_text"].split("Answer:")[-1].strip())
@@ -1,39 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: supermegaexplosion
3
- Version: 0.1.0
4
- Summary: DSA utility library — input helpers, algorithms, data structures, and AI assistant
5
- Author-email: "Hadoopnb.ai" <hadoopnb@example.com>
6
- License-Expression: MIT
7
- Classifier: Programming Language :: Python :: 3
8
- Requires-Python: >=3.8
9
- Description-Content-Type: text/markdown
10
- Provides-Extra: ai
11
- Requires-Dist: transformers>=4.30.0; extra == "ai"
12
- Requires-Dist: torch>=2.0.0; extra == "ai"
13
-
14
- # libbs
15
-
16
- DSA utility library — interactive input helpers, string/math/array algorithms, data structures, and an optional AI coding assistant.
17
-
18
- ```python
19
- from libbs import *
20
-
21
- show_commands() # list everything available
22
- input_matrix() # interactively type a matrix
23
- is_palindrome("racecar") # True
24
- sieve(100) # primes up to 100
25
- max_subarray_sum([-2,1,-3,4,-1,2,1,-5,4]) # 6
26
- ListNode.from_list([1,2,3,4,5])
27
- respond_help("How to reverse a linked list?") # requires: pip install libbs[ai]
28
- ```
29
-
30
- ## Install
31
-
32
- ```bash
33
- pip install libbs # core
34
- pip install libbs[ai] # with AI assistant (transformers + torch)
35
- ```
36
-
37
- ## License
38
-
39
- MIT
@@ -1,4 +0,0 @@
1
-
2
- [ai]
3
- transformers>=4.30.0
4
- torch>=2.0.0