math-magic-tricks 0.1.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.
@@ -0,0 +1,6 @@
1
+ {
2
+ "cSpell.words": [
3
+ "Manzoor",
4
+ "Musaib"
5
+ ]
6
+ }
@@ -0,0 +1,18 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2026 Musaib Manzoor Shah
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.5
2
+ Name: math-magic-tricks
3
+ Version: 0.1.0
4
+ Summary: A Python package for mathematical tricks and puzzles
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+
10
+
11
+ # Math Magic Tricks
12
+
13
+ A Python package containing simple mathematical tricks and puzzles.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install math-magic-tricks
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```python
24
+ from math_magic_tricks import birth_year_trick
25
+
26
+ result = birth_year_trick(14, 1998)
27
+ print(result)
28
+ ```
29
+
30
+ Output:
31
+
32
+ ```text
33
+ 1428
34
+ ```
35
+
36
+ ## How it works
37
+
38
+ The trick calculates:
39
+
40
+ (number × 2 + 5) × 50 + (target year − 250) − birth year
41
+
42
+ With the default target year of 2026, this simplifies to:
43
+
44
+ 100 × number + 2026 − birth year
45
+
46
+ ## License
47
+
48
+ MIT
@@ -0,0 +1,39 @@
1
+
2
+ # Math Magic Tricks
3
+
4
+ A Python package containing simple mathematical tricks and puzzles.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ pip install math-magic-tricks
10
+ ```
11
+
12
+ ## Example
13
+
14
+ ```python
15
+ from math_magic_tricks import birth_year_trick
16
+
17
+ result = birth_year_trick(14, 1998)
18
+ print(result)
19
+ ```
20
+
21
+ Output:
22
+
23
+ ```text
24
+ 1428
25
+ ```
26
+
27
+ ## How it works
28
+
29
+ The trick calculates:
30
+
31
+ (number × 2 + 5) × 50 + (target year − 250) − birth year
32
+
33
+ With the default target year of 2026, this simplifies to:
34
+
35
+ 100 × number + 2026 − birth year
36
+
37
+ ## License
38
+
39
+ MIT
@@ -0,0 +1,12 @@
1
+
2
+ [build-system]
3
+ requires = ["hatchling"]
4
+ build-backend = "hatchling.build"
5
+
6
+ [project]
7
+ name = "math-magic-tricks"
8
+ version = "0.1.0"
9
+ description = "A Python package for mathematical tricks and puzzles"
10
+ readme = "README.md"
11
+ requires-python = ">=3.9"
12
+ license = "MIT"
@@ -0,0 +1,4 @@
1
+
2
+ from .tricks import birth_year_trick
3
+
4
+ __all__ = ["birth_year_trick"]
@@ -0,0 +1,25 @@
1
+
2
+ def birth_year_trick(
3
+ number: int,
4
+ birth_year: int,
5
+ target_year: int = 2026,
6
+ ) -> int:
7
+ """
8
+ Perform a mathematical number trick.
9
+
10
+ Example:
11
+ Choose 14, use birth year 1998, and target year 2026.
12
+ The result is 1428.
13
+ """
14
+ if not isinstance(number, int) or isinstance(number, bool):
15
+ raise TypeError("number must be an integer")
16
+
17
+ if not isinstance(birth_year, int) or isinstance(birth_year, bool):
18
+ raise TypeError("birth_year must be an integer")
19
+
20
+ if not isinstance(target_year, int) or isinstance(target_year, bool):
21
+ raise TypeError("target_year must be an integer")
22
+
23
+ result = (number * 2 + 5) * 50 + (target_year - 250) - birth_year
24
+
25
+ return result
@@ -0,0 +1,27 @@
1
+
2
+ from math_magic_tricks import birth_year_trick
3
+
4
+
5
+ def test_original_example():
6
+ assert birth_year_trick(14, 1998) == 1428
7
+
8
+
9
+ def test_different_number():
10
+ assert birth_year_trick(37, 1998) == 3728
11
+
12
+
13
+ def test_different_target_year():
14
+ assert birth_year_trick(14, 1998, target_year=2030) == 1432
15
+
16
+
17
+ def test_negative_number():
18
+ assert birth_year_trick(-2, 1998) == -172
19
+
20
+
21
+ def test_rejects_float():
22
+ try:
23
+ birth_year_trick(14.5, 1998)
24
+ except TypeError:
25
+ pass
26
+ else:
27
+ raise AssertionError("Expected TypeError")