diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index d66144a..49d0e4c 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -4,31 +4,29 @@ on: [push, pull_request]
jobs:
build:
-
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v2
- - name: Set up Python
- uses: actions/setup-python@v2
- with:
- python-version: '3.x'
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.x"
- - uses: actions/cache@v1
- with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/dev-requirements.txt') }}
- restore-keys: |
- ${{ runner.os }}-pip-
+ - uses: actions/cache@v1
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/dev-requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
- - name: Install Dependencies
- if: steps.cache.outputs.cache-hit != 'true'
- run: |
- pip install -r dev-requirements.txt
+ - name: Install Dependencies
+ if: steps.cache.outputs.cache-hit != 'true'
+ run: make deps
- - name: Linter
- run: make lint
+ - name: Linter
+ run: make lint
- - name: Test
- run: make test
+ - name: Test
+ run: make test
diff --git a/Makefile b/Makefile
index e5dca74..eb91e5e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,15 @@
IGNORE_ERRORS = E501,F401,F403,F405
PKG = mathgenerator
+PYTHON ?= python3
+
+deps:
+ $(PYTHON) -m pip install --user -r dev-requirements.txt
format:
- python -m autopep8 --ignore=$(IGNORE_ERRORS) -ir $(PKG)/*
+ $(PYTHON) -m autopep8 --ignore=$(IGNORE_ERRORS) -ir $(PKG)/*
lint:
- python -m flake8 --ignore=$(IGNORE_ERRORS) $(PKG)
+ $(PYTHON) -m flake8 --ignore=$(IGNORE_ERRORS) $(PKG)
test:
- python -m pytest --verbose -s tests
+ $(PYTHON) -m pytest --verbose -s tests
diff --git a/README.md b/README.md
index bae0d1f..4fe1e18 100644
--- a/README.md
+++ b/README.md
@@ -31,99 +31,104 @@ problem, solution = mathgen.genById(0)
| Id | Skill | Example problem | Example Solution | Function Name |
|------|-----------------------------------|--------------------|-----------------------|--------------------------|
[//]: # list start
-| 0 | Addition | 48+19= | 67 | addition |
-| 1 | Subtraction | 31-0= | 31 | subtraction |
-| 2 | Multiplication | 44*1= | 44 | multiplication |
-| 3 | Division | 19/73= | 0.2602739726027397 | division |
-| 4 | Binary Complement 1s | 001110110= | 110001001 | binary_complement_1s |
-| 5 | Modulo Division | 99%80= | 19 | modulo_division |
-| 6 | Square Root | sqrt(144)= | 12 | square_root |
-| 7 | Power Rule Differentiation | 7x^8 + 9x^3 | 56x^7 + 27x^2 | power_rule_differentiation |
-| 8 | Square | 15^2= | 225 | square |
-| 9 | LCM (Least Common Multiple) | LCM of 18 and 10 = | 90 | lcm |
-| 10 | GCD (Greatest Common Denominator) | GCD of 9 and 8 = | 1 | gcd |
-| 11 | Basic Algebra | 9x + 10 = 10 | 0 | basic_algebra |
-| 12 | Logarithm | log2(32) | 5 | log |
-| 13 | Easy Division | 475/19 = | 25 | int_division |
-| 14 | Decimal to Binary | Binary of 97= | 1100001 | decimal_to_binary |
-| 15 | Binary to Decimal | 0110 | 6 | binary_to_decimal |
-| 16 | Fraction Division | (3/6)/(7/1) | 1/14 | divide_fractions |
-| 17 | Integer Multiplication with 2x2 Matrix | 12 * [[2, 6], [3, 3]] = | [[24,72],[36,36]] | multiply_int_to_22_matrix |
-| 18 | Area of Triangle | Area of triangle with side lengths: 12 2 2 = | (2.0782945349651837e-15+33.94112549695428j) | area_of_triangle |
-| 19 | Triangle exists check | Does triangle with sides 40, 5 and 39 exist? | Yes | valid_triangle |
-| 20 | Midpoint of the two point | (-14,11),(-2,9)= | (-8.0,10.0) | midpoint_of_two_points |
-| 21 | Factoring Quadratic | x^2-5x-14 | (x+2)(x-7) | factoring |
-| 22 | Third Angle of Triangle | Third angle of triangle with angles 27 and 88 = | 65 | third_angle_of_triangle |
-| 23 | Solve a System of Equations in R^2 | -7x - 7y = -14, -7x - 8y = -18 | x = -2, y = 4 | system_of_equations |
-| 24 | Distance between 2 points | Find the distance between (5, 9) and (5, 8) | sqrt(1) | distance_two_points |
-| 25 | Pythagorean Theorem | The hypotenuse of a right triangle given the other two lengths 13 and 17 = | 21.40 | pythagorean_theorem |
-| 26 | Linear Equations | 2x + -1y = -19, -14x + -9y = 149 | x = -10, y = -1 | linear_equations |
-| 27 | Prime Factorisation | Find prime factors of 8 | [2, 2, 2] | prime_factors |
-| 28 | Fraction Multiplication | (3/1)*(2/10) | 3/5 | fraction_multiplication |
-| 29 | Angle of a Regular Polygon | Find the angle of a regular polygon with 20 sides | 162.0 | angle_regular_polygon |
-| 30 | Combinations of Objects | Number of combinations from 16 objects picked 5 at a time | 4368 | combinations |
-| 31 | Factorial | 0! = | 1 | factorial |
-| 32 | Surface Area of Cube | Surface area of cube with side = 4m is | 96 m^2 | surface_area_cube |
-| 33 | Surface Area of Cuboid | Surface area of cuboid with sides = 19m, 10m, 16m is | 1308 m^2 | surface_area_cuboid |
-| 34 | Surface Area of Cylinder | Surface area of cylinder with height = 32m and radius = 5m is | 1162 m^2 | surface_area_cylinder |
-| 35 | Volum of Cube | Volume of cube with side = 20m is | 8000 m^3 | volume_cube |
-| 36 | Volume of Cuboid | Volume of cuboid with sides = 11m, 17m, 1m is | 187 m^3 | volume_cuboid |
-| 37 | Volume of cylinder | Volume of cylinder with height = 16m and radius = 17m is | 14526 m^3 | volume_cylinder |
-| 38 | Surface Area of cone | Surface area of cone with height = 36m and radius = 1m is | 116 m^2 | surface_area_cone |
-| 39 | Volume of cone | Volume of cone with height = 17m and radius = 17m is | 5144 m^3 | volume_cone |
-| 40 | Common Factors | Common Factors of 80 and 59 = | [1] | common_factors |
-| 41 | Intersection of Two Lines | Find the point of intersection of the two lines: y = 10/6x + 6 and y = 5x + 7 | (-3/10, 11/2) | intersection_of_two_lines |
-| 42 | Permutations | Number of Permutations from 15 objects picked 1 at a time = | 15 | permutation |
-| 43 | Cross Product of 2 Vectors | [16, -8, 0] X [11, -6, -13] = | [104, 208, -8] | vector_cross |
-| 44 | Compare Fractions | Which symbol represents the comparison between 4/6 and 7/9? | < | compare_fractions |
-| 45 | Simple Interest | Simple interest for a principle amount of 1857 dollars, 8% rate of interest and for a time period of 7 years is = | 1039.92 | simple_interest |
-| 46 | Multiplication of two matrices | Multiply
and| -10 | -10 | -2 | 10 |
| -6 | -9 | -5 | -9 |
| 2 | 7 | -8 | -8 |
| -2 | 6 | 10 | 0 |
| | -38 | -5 | 35 | 77 |
| 62 | 99 | 194 | 66 |
| 40 | -10 | 62 | 42 |
| matrix_multiplication |
-| 47 | Cube Root | cuberoot of 616 upto 2 decimal places is: | 8.51 | cube_root |
-| 48 | Power Rule Integration | 4x^1 | (4/1)x^2 + c | power_rule_integration |
-| 49 | Fourth Angle of Quadrilateral | Fourth angle of quadrilateral with angles 72 , 42, 103 = | 143 | fourth_angle_of_quadrilateral |
-| 50 | Quadratic Equation | Zeros of the Quadratic Equation 88x^2+181x+68=0 | [-0.49, -1.56] | quadratic_equation |
-| 51 | HCF (Highest Common Factor) | HCF of 2 and 1 = | 1 | hcf |
-| 52 | Probability of a certain sum appearing on faces of dice | If 3 dice are rolled at the same time, the probability of getting a sum of 16 = | 6/216 | dice_sum_probability |
-| 53 | Exponentiation | 17^10 = | 2015993900449 | exponentiation |
-| 54 | Confidence interval For sample S | The confidence interval for sample [289, 211, 294, 290, 264, 258, 229, 265, 272, 228, 257, 262, 210, 259, 246, 224, 266, 283, 273, 222, 250, 241, 225, 237] with 99% confidence is | (265.1917573633045, 239.39157597002884) | confidence_interval |
-| 55 | Comparing surds | Fill in the blanks 81^(1/7) _ 54^(1/9) | > | surds_comparison |
-| 56 | Fibonacci Series | The Fibonacci Series of the first 20 numbers is ? | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181] | fibonacci_series |
-| 57 | Trigonometric Values | What is cos(90)? | 0 | basic_trigonometry |
-| 58 | Sum of Angles of Polygon | Sum of angles of polygon with 9 sides = | 1260 | sum_of_polygon_angles |
-| 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[43, 23, 43, 13, 16, 40, 36, 19, 17, 39, 45, 26, 12, 17, 12] | The Mean is 26.733333333333334 , Standard Deviation is 151.79555555555555, Variance is 12.3205338989654 | data_summary |
-| 60 | Surface Area of Sphere | Surface area of Sphere with radius = 10m is | 1256.6370614359173 m^2 | surface_area_sphere |
-| 61 | Volume of Sphere | Volume of sphere with radius 93 m = | 3369282.722751367 m^3 | volume_sphere |
-| 62 | nth Fibonacci number | What is the 52th Fibonacci number? | 32951280099 | nth_fibonacci_number |
-| 63 | Profit or Loss Percent | Loss percent when CP = 798 and SP = 713 is: | 10.651629072681704 | profit_loss_percent |
-| 64 | Binary to Hexidecimal | 0000 | 0x0 | binary_to_hex |
-| 65 | Multiplication of 2 complex numbers | (14-1j) * (-15+4j) = | (-206+71j) | multiply_complex_numbers |
-| 66 | Geometric Progression | For the given GP [8, 24, 72, 216, 648, 1944] ,Find the value of a,common ratio,11th term value, sum upto 8th term | The value of a is 8, common ratio is 3 , 11th term is 472392 , sum upto 8th term is 26240.0 | geometric_progression |
-| 67 | Geometric Mean of N Numbers | Geometric mean of 4 numbers 65 , 75 , 65 , 23 = | (65*75*65*23)^(1/4) = 51.95818275737109 | geometric_mean |
-| 68 | Harmonic Mean of N Numbers | Harmonic mean of 2 numbers 2 and 12 = | 2/((1/2) + (1/12)) = 3.4285714285714284 | harmonic_mean |
-| 69 | Euclidian norm or L2 norm of a vector | Euclidian norm or L2 norm of the vector[488.10260237588165, 438.9926997215375, 481.4248776631771, 480.58824363943177, 509.73053046857785, 268.09288505668803, 410.3732502610836, 318.6216647891933, 296.4238196042428, 808.0996438115192, 121.7211186065138, 615.1986904309553, 380.29841107431093, 195.23491823519456, 81.69943837555405, 155.69629311805645, 97.46954246782546, 634.0953876946306, 199.72352388042535, 568.2278203619796] is: | 1901.9741243296269 | euclidian_norm |
-| 70 | Angle between 2 vectors | angle between the vectors [955.8351549798066, 177.1594811522551, 900.6055058476991, 712.0208070601419, 601.3956854892953, 628.8267644026017, 893.2727217464875, 492.4340309181726] and [668.7008663033757, 138.7169080640255, 515.5875138676224, 230.03917249114247, 51.099523634880015, 894.1460097286858, 313.47733623460283, 837.2412043583688] is: | NaN | angle_btw_vectors |
-| 71 | Absolute difference between two numbers | Absolute difference between numbers -63 and 84 = | 147 | absolute_difference |
-| 72 | Dot Product of 2 Vectors | [7, -9, 12] . [6, 12, 14] = | 102 | vector_dot |
-| 73 | Binary 2's Complement | 2's complement of 11101 = | 11 | binary_2s_complement |
-| 74 | Inverse of a Matrix | Inverse of Matrix Matrix([[61, 90, 56], [2, 74, 38], [29, 91, 7]]) is: | Matrix([[735/47851, -2233/95702, 181/47851], [-272/47851, 1197/191404, 1103/95702], [491/47851, 2941/191404, -2167/95702]]) | invert_matrix |
-| 75 | Area of a Sector | Given radius, 17 and angle, 98. Find the area of the sector. | Area of sector = 247.15608 | sector_area |
-| 76 | Mean and Median | Given the series of numbers [13, 89, 68, 53, 61, 3, 17, 66, 63, 48]. find the arithmatic mean and mdian of the series | Arithmetic mean of the series is 48.1 and Arithmetic median of this series is 57.0 | mean_median |
-| 77 | Determinant to 2x2 Matrix | Det([[49, 6], [62, 19]]) = | 559 | int_matrix_22_determinant |
-| 78 | Compound Interest | Compound interest for a principle amount of 7750 dollars, 9% rate of interest and for a time period of 7 year is = | 14167.3 | compound_interest |
-| 79 | Decimal to Hexadecimal | Binary of 972= | 0x3cc | decimal_to_hexadeci |
-| 80 | Percentage of a number | What is 38% of 82? | Required percentage = 31.16% | percentage |
-| 81 | Celsius To Fahrenheit | Convert -49 degrees Celsius to degrees Fahrenheit = | -56.2 | celsius_to_fahrenheit |
-| 82 | AP Term Calculation | Find the term number 83 of the AP series: -41, -110, -179 ... | -5699 | arithmetic_progression_term |
-| 83 | AP Sum Calculation | Find the sum of first 99 terms of the AP series: 20, -59, -138 ... | -381249.0 | arithmetic_progression_sum |
-| 84 | Converts decimal to octal | The decimal number 1424 in Octal is: | 0o2620 | decimal_to_octal |
-| 85 | Converts decimal to Roman Numerals | The number 3563 in Roman Numerals is: | MMMDLXIII | decimal_to_roman_numerals |
-| 86 | Degrees to Radians | Angle 286 in radians is = | 4.99 | degree_to_rad |
-| 87 | Radians to Degrees | Angle 2 in degrees is = | 114.59 | radian_to_deg |
-| 88 | Differentiation | differentiate w.r.t x : d(exp(x)+6*x^(-3))/dx | exp(x) - 18/x^4 | differentiation |
-| 89 | Definite Integral of Quadratic Equation | The definite integral within limits 0 to 1 of the equation 94x^2 + 86x + 97 is = | 171.3333 | definite_integral |
-| 90 | isprime | 28 | False | is_prime |
-| 91 | Binary Coded Decimal to Integer | Integer of Binary Coded Decimal 9 is = | 37408 | bcd_to_decimal |
-| 92 | Complex To Polar Form | rexp(itheta) = | 15.65exp(i-2.68) | complex_to_polar |
-| 93 | Union,Intersection,Difference of Two Sets | Given the two sets a={2, 3, 5} ,b={2, 3, 6, 7}.Find the Union,intersection,a-b,b-a and symmetric difference | Union is {2, 3, 5, 6, 7},Intersection is {2, 3}, a-b is {5},b-a is {6, 7}, Symmetric difference is {5, 6, 7} | set_operation |
-| 94 | Base Conversion | Convert E656 from base 16 to base 12. | 2A15A | base_conversion |
-| 95 | Curved surface area of a cylinder | What is the curved surface area of a cylinder of radius, 43 and height, 85? | CSA of cylinder = 22965.04 | curved_surface_area_cylinder |
+| 0 | Addition | 20+9= | 29 | addition |
+| 1 | Subtraction | 52-50= | 2 | subtraction |
+| 2 | Multiplication | 53*1= | 53 | multiplication |
+| 3 | Division | 35/79= | 0.4430379746835443 | division |
+| 4 | Binary Complement 1s | 011011= | 100100 | binary_complement_1s |
+| 5 | Modulo Division | 27%39= | 27 | modulo_division |
+| 6 | Square Root | sqrt(16)= | 4 | square_root |
+| 7 | Power Rule Differentiation | 7x^5 | 35x^4 | power_rule_differentiation |
+| 8 | Square | 10^2= | 100 | square |
+| 9 | LCM (Least Common Multiple) | LCM of 14 and 14 = | 14 | lcm |
+| 10 | GCD (Greatest Common Denominator) | GCD of 17 and 7 = | 1 | gcd |
+| 11 | Basic Algebra | 6x + 5 = 5 | 0 | basic_algebra |
+| 12 | Logarithm | log2(64) | 6 | log |
+| 13 | Easy Division | 252/12 = | 21 | int_division |
+| 14 | Decimal to Binary | Binary of 19= | 10011 | decimal_to_binary |
+| 15 | Binary to Decimal | 1000010100 | 532 | binary_to_decimal |
+| 16 | Fraction Division | (10/9)/(10/8) | 8/9 | divide_fractions |
+| 17 | Integer Multiplication with 2x2 Matrix | 15 * [[5, 3], [3, 2]] = | [[75,45],[45,30]] | multiply_int_to_22_matrix |
+| 18 | Area of Triangle | Area of triangle with side lengths: 3 17 2 = | (4.221036154550547e-15+68.93475175845634j) | area_of_triangle |
+| 19 | Triangle exists check | Does triangle with sides 24, 20 and 17 exist? | Yes | valid_triangle |
+| 20 | Midpoint of the two point | (4,-10),(2,4)= | (3.0,-3.0) | midpoint_of_two_points |
+| 21 | Factoring Quadratic | x^2-3x-54 | (x+6)(x-9) | factoring |
+| 22 | Third Angle of Triangle | Third angle of triangle with angles 6 and 29 = | 145 | third_angle_of_triangle |
+| 23 | Solve a System of Equations in R^2 | - 5y = -20, 3x + 9y = 9 | x = -9, y = 4 | system_of_equations |
+| 24 | Distance between 2 points | Find the distance between (-2, -4) and (21, -13) | sqrt(610) | distance_two_points |
+| 25 | Pythagorean Theorem | The hypotenuse of a right triangle given the other two lengths 16 and 11 = | 19.42 | pythagorean_theorem |
+| 26 | Linear Equations | 11x + 4y = -72, 17x + -18y = -208 | x = -8, y = 4 | linear_equations |
+| 27 | Prime Factorisation | Find prime factors of 88 | [2, 2, 2, 11] | prime_factors |
+| 28 | Fraction Multiplication | (7/3)*(2/10) | 7/15 | fraction_multiplication |
+| 29 | Angle of a Regular Polygon | Find the angle of a regular polygon with 9 sides | 140.0 | angle_regular_polygon |
+| 30 | Combinations of Objects | Number of combinations from 16 objects picked 6 at a time | 8008 | combinations |
+| 31 | Factorial | 2! = | 2 | factorial |
+| 32 | Surface Area of Cube | Surface area of cube with side = 3m is | 54 m^2 | surface_area_cube |
+| 33 | Surface Area of Cuboid | Surface area of cuboid with sides = 9m, 1m, 14m is | 298 m^2 | surface_area_cuboid |
+| 34 | Surface Area of Cylinder | Surface area of cylinder with height = 30m and radius = 3m is | 622 m^2 | surface_area_cylinder |
+| 35 | Volum of Cube | Volume of cube with side = 16m is | 4096 m^3 | volume_cube |
+| 36 | Volume of Cuboid | Volume of cuboid with sides = 4m, 12m, 11m is | 528 m^3 | volume_cuboid |
+| 37 | Volume of cylinder | Volume of cylinder with height = 32m and radius = 17m is | 29053 m^3 | volume_cylinder |
+| 38 | Surface Area of cone | Surface area of cone with height = 18m and radius = 16m is | 2014 m^2 | surface_area_cone |
+| 39 | Volume of cone | Volume of cone with height = 24m and radius = 6m is | 904 m^3 | volume_cone |
+| 40 | Common Factors | Common Factors of 73 and 75 = | [1] | common_factors |
+| 41 | Intersection of Two Lines | Find the point of intersection of the two lines: y = -10/4x - 6 and y = -2/5x + 2 | (-80/21, 74/21) | intersection_of_two_lines |
+| 42 | Permutations | Number of Permutations from 18 objects picked 5 at a time = | 1028160 | permutation |
+| 43 | Cross Product of 2 Vectors | [-19, -17, 16] X [-3, -10, 19] = | [-163, 313, 139] | vector_cross |
+| 44 | Compare Fractions | Which symbol represents the comparison between 10/8 and 4/7? | > | compare_fractions |
+| 45 | Simple Interest | Simple interest for a principle amount of 8277 dollars, 8% rate of interest and for a time period of 8 years is = | 5297.28 | simple_interest |
+| 46 | Multiplication of two matrices | Multiplyand | | matrix_multiplication |
+| 47 | Cube Root | cuberoot of 725 upto 2 decimal places is: | 8.98 | cube_root |
+| 48 | Power Rule Integration | 6x^8 + 10x^3 + 2x^8 + 8x^8 + 6x^9 | (6/8)x^9 + (10/3)x^4 + (2/8)x^9 + (8/8)x^9 + (6/9)x^10 + c | power_rule_integration |
+| 49 | Fourth Angle of Quadrilateral | Fourth angle of quadrilateral with angles 34 , 200, 57 = | 69 | fourth_angle_of_quadrilateral |
+| 50 | Quadratic Equation | Zeros of the Quadratic Equation 28x^2+105x+65=0 | [-0.78, -2.97] | quadratic_equation |
+| 51 | HCF (Highest Common Factor) | HCF of 14 and 7 = | 7 | hcf |
+| 52 | Probability of a certain sum appearing on faces of dice | If 1 dice are rolled at the same time, the probability of getting a sum of 3 = | 1/6 | dice_sum_probability |
+| 53 | Exponentiation | 2^2 = | 4 | exponentiation |
+| 54 | Confidence interval For sample S | The confidence interval for sample [271, 209, 205, 219, 291, 221, 226, 217, 230, 272, 276, 293, 237, 252, 283, 253, 266, 240, 234, 207, 279] with 80% confidence is | (254.68568495447266, 238.74288647409878) | confidence_interval |
+| 55 | Comparing surds | Fill in the blanks 8^(1/2) _ 55^(1/6) | > | surds_comparison |
+| 56 | Fibonacci Series | The Fibonacci Series of the first 19 numbers is ? | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584] | fibonacci_series |
+| 57 | Trigonometric Values | What is cos(45)? | 1/√2 | basic_trigonometry |
+| 58 | Sum of Angles of Polygon | Sum of angles of polygon with 6 sides = | 720 | sum_of_polygon_angles |
+| 59 | Mean,Standard Deviation,Variance | Find the mean,standard deviation and variance for the data[25, 45, 11, 49, 43, 21, 18, 22, 46, 41, 48, 45, 47, 46, 22] | The Mean is 35.266666666666666 , Standard Deviation is 169.9288888888889, Variance is 13.035677538543553 | data_summary |
+| 60 | Surface Area of Sphere | Surface area of Sphere with radius = 20m is | 5026.548245743669 m^2 | surface_area_sphere |
+| 61 | Volume of Sphere | Volume of sphere with radius 6 m = | 904.7786842338604 m^3 | volume_sphere |
+| 62 | nth Fibonacci number | What is the 98th Fibonacci number? | 135301852344707186688 | nth_fibonacci_number |
+| 63 | Profit or Loss Percent | Profit percent when CP = 88 and SP = 155 is: | 76.13636363636364 | profit_loss_percent |
+| 64 | Binary to Hexidecimal | 0111100 | 0x3c | binary_to_hex |
+| 65 | Multiplication of 2 complex numbers | (6+15j) * (-11+14j) = | (-276-81j) | multiply_complex_numbers |
+| 66 | Geometric Progression | For the given GP [4, 8, 16, 32, 64, 128] ,Find the value of a,common ratio,10th term value, sum upto 7th term | The value of a is 4, common ratio is 2 , 10th term is 2048 , sum upto 7th term is 508.0 | geometric_progression |
+| 67 | Geometric Mean of N Numbers | Geometric mean of 2 numbers 15 and 89 = | (15*89)^(1/2) = 36.53765181289022 | geometric_mean |
+| 68 | Harmonic Mean of N Numbers | Harmonic mean of 4 numbers 57 , 38 , 60 , 25 = | 4/((1/57) + (1/38) + (1/60) + (1/25)) = 39.79057591623037 | harmonic_mean |
+| 69 | Euclidian norm or L2 norm of a vector | Euclidian norm or L2 norm of the vector[987.2988424731678, 717.1306649026507, 239.90848831697863, 979.8627407501484, 102.29066104606976, 458.7906478877879, 275.5546983244834, 225.6916602424589, 26.12527792643693, 366.7028959774343, 752.5264100654856] is: | 1885.7336411802055 | euclidian_norm |
+| 70 | Angle between 2 vectors | angle between the vectors [204.34, 989.9, 769.23, 587.22, 313.6, 598.75, 907.67, 221.31, 7.76, 716.11, 697.58, 26.04, 416.61, 562.5, 818.67, 197.06, 492.85, 507.85, 609.86, 475.4] and [877.86, 605.89, 409.16, 650.41, 32.59, 244.04, 903.77, 499.35, 438.81, 709.82, 656.49, 745.17, 497.04, 832.24, 195.85, 37.89, 851.83, 608.87, 119.84, 17.96] is: | 0.66 radians | angle_btw_vectors |
+| 71 | Absolute difference between two numbers | Absolute difference between numbers -40 and -6 = | 34 | absolute_difference |
+| 72 | Dot Product of 2 Vectors | [-17, 12, 6] . [-2, -9, 9] = | -20 | vector_dot |
+| 73 | Binary 2's Complement | 2's complement of 10100110 = | 1011010 | binary_2s_complement |
+| 74 | Inverse of a Matrix | Inverse of Matrix Matrix([[54, 47, 44], [59, 41, 7], [86, 33, 5]]) is: | Matrix([[26/56451, -1217/56451, 1475/56451], [-307/56451, 3514/56451, -2218/56451], [1579/56451, -2260/56451, 559/56451]]) | invert_matrix |
+| 75 | Area of a Sector | Given radius, 23 and angle, 4. Find the area of the sector. | Area of sector = 18.46558 | sector_area |
+| 76 | Mean and Median | Given the series of numbers [19, 93, 45, 37, 39, 8, 48, 44, 12, 10]. find the arithmatic mean and mdian of the series | Arithmetic mean of the series is 35.5 and Arithmetic median of this series is 38.0 | mean_median |
+| 77 | Determinant to 2x2 Matrix | Det([[73, 67], [64, 58]]) = | -54 | int_matrix_22_determinant |
+| 78 | Compound Interest | Compound interest for a principle amount of 2095 dollars, 6% rate of interest and for a time period of 3 year is = | 2495.18 | compound_interest |
+| 79 | Decimal to Hexadecimal | Binary of 494= | 0x1ee | decimal_to_hexadeci |
+| 80 | Percentage of a number | What is 14% of 51? | Required percentage = 7.14% | percentage |
+| 81 | Celsius To Fahrenheit | Convert -22 degrees Celsius to degrees Fahrenheit = | -7.600000000000001 | celsius_to_fahrenheit |
+| 82 | AP Term Calculation | Find the term number 39 of the AP series: -42, -102, -162 ... | -2322 | arithmetic_progression_term |
+| 83 | AP Sum Calculation | Find the sum of first 49 terms of the AP series: 18, -50, -118 ... | -79086.0 | arithmetic_progression_sum |
+| 84 | Converts decimal to octal | The decimal number 3746 in Octal is: | 0o7242 | decimal_to_octal |
+| 85 | Converts decimal to Roman Numerals | The number 2967 in Roman Numerals is: | MMCMLXVII | decimal_to_roman_numerals |
+| 86 | Degrees to Radians | Angle 109 in radians is = | 1.9 | degree_to_rad |
+| 87 | Radians to Degrees | Angle 3 in degrees is = | 171.89 | radian_to_deg |
+| 88 | Differentiation | differentiate w.r.t x : d(sin(x)+9*x^3)/dx | 27*x^2 + cos(x) | differentiation |
+| 89 | Definite Integral of Quadratic Equation | The definite integral within limits 0 to 1 of the equation 50x^2 + 38x + 41 is = | 76.6667 | definite_integral |
+| 90 | isprime | 11 | True | is_prime |
+| 91 | Binary Coded Decimal to Integer | Integer of Binary Coded Decimal 7 is = | 29331 | bcd_to_decimal |
+| 92 | Complex To Polar Form | rexp(itheta) = | 14.42exp(i-2.55) | complex_to_polar |
+| 93 | Union,Intersection,Difference of Two Sets | Given the two sets a={2, 3, 4, 5, 6, 8, 10} ,b={4, 5, 6, 7}.Find the Union,intersection,a-b,b-a and symmetric difference | Union is {2, 3, 4, 5, 6, 7, 8, 10},Intersection is {4, 5, 6}, a-b is {8, 10, 2, 3},b-a is {7}, Symmetric difference is {2, 3, 7, 8, 10} | set_operation |
+| 94 | Base Conversion | Convert 33210 from base 10 to base 11. | 22A51 | base_conversion |
+| 95 | Curved surface area of a cylinder | What is the curved surface area of a cylinder of radius, 3 and height, 21? | CSA of cylinder = 395.84 | curved_surface_area_cylinder |
+| 96 | Perimeter of Polygons | The perimeter of a 10 sided polygon with lengths of [11, 117, 72, 120, 46, 96, 40, 76, 15, 19]cm is: | 612 | perimeter_of_polygons |
+| 97 | Power of Powers | The 41^3^4 = 41^(3*4) = 41^12 | 22563490300366186081 | power_of_powers |
+| 98 | Quotient of Powers with Same Base | The Quotient of 19^2 and 19^2 = 19^(2-2) = 19^0 | 1 | quotient_of_power_same_base |
+| 99 | Quotient of Powers with Same Power | The Quotient of 29^3 and 22^3 = (29/22)^3 = 1.3181818181818181^3 | 2.2904770848985723 | quotient_of_power_same_power |
+| 100 | complex Quadratic Equation | Find the roots of given Quadratic Equation 9x^2 + 9x + 2 = 0 | simplified solution : ((-0.333, -0.667)), generalized solution : ((-9 + 3)/2*9, (-9 - 3)/2*9) | complex_quadratic |
diff --git a/mathgenerator/funcs/__init__.py b/mathgenerator/funcs/__init__.py
index 19b52cc..2b8fe33 100644
--- a/mathgenerator/funcs/__init__.py
+++ b/mathgenerator/funcs/__init__.py
@@ -100,4 +100,10 @@ from .complex_to_polar import *
from .set_operation import *
from .base_conversion import *
from .curved_surface_area_cylinder import *
-from .minutesToHours import *
+from .perimeter_of_polygons import *
+from .power_of_powers import *
+from .quotient_of_power_same_base import *
+from .quotient_of_power_same_power import *
+from .complex_quadratic import *
+from .is_leap_year import *
+from .minutesToHours import *
\ No newline at end of file
diff --git a/mathgenerator/funcs/angle_btw_vectors.py b/mathgenerator/funcs/angle_btw_vectors.py
index 1553435..054c44b 100644
--- a/mathgenerator/funcs/angle_btw_vectors.py
+++ b/mathgenerator/funcs/angle_btw_vectors.py
@@ -4,18 +4,20 @@ import math
def angleBtwVectorsFunc(maxEltAmt=20):
s = 0
- v1 = [random.uniform(0, 1000) for i in range(random.randint(2, maxEltAmt))]
- v2 = [random.uniform(0, 1000) for i in v1]
- for i in v1:
- for j in v2:
- s += i * j
+ v1 = [
+ round(random.uniform(0, 1000), 2)
+ for i in range(random.randint(2, maxEltAmt))
+ ]
+ v2 = [round(random.uniform(0, 1000), 2) for i in v1]
+ for i in range(len(v1)):
+ s += v1[i] * v2[i]
mags = math.sqrt(sum([i**2
for i in v1])) * math.sqrt(sum([i**2 for i in v2]))
problem = f"angle between the vectors {v1} and {v2} is:"
solution = ''
try:
- solution = str(math.acos(s / mags))
+ solution = str(round(math.acos(s / mags), 2)) + " radians"
except ValueError:
print('angleBtwVectorsFunc has some issues with math module, line 16')
solution = 'NaN'
diff --git a/mathgenerator/funcs/complex_quadratic.py b/mathgenerator/funcs/complex_quadratic.py
new file mode 100644
index 0000000..7cbf0b0
--- /dev/null
+++ b/mathgenerator/funcs/complex_quadratic.py
@@ -0,0 +1,75 @@
+from .__init__ import *
+
+
+def complexQuadraticFunc(prob_type=0, max_range=10):
+ if prob_type < 0 or prob_type > 1:
+ print("prob_type not supported")
+ print("prob_type = 0 for real roots problems ")
+ print("prob_tpye = 1 for imaginary roots problems")
+ return None
+ if prob_type == 0:
+ d = -1
+ while d < 0:
+ a = random.randrange(1, max_range)
+ b = random.randrange(1, max_range)
+ c = random.randrange(1, max_range)
+
+ d = (b**2 - 4 * a * c)
+ else:
+ d = 0
+ while d >= 0:
+ a = random.randrange(1, max_range)
+ b = random.randrange(1, max_range)
+ c = random.randrange(1, max_range)
+
+ d = (b**2 - 4 * a * c)
+
+ eq = ''
+
+ if a == 1:
+ eq += 'x^2 + '
+ else:
+ eq += str(a) + 'x^2 + '
+
+ if b == 1:
+ eq += 'x + '
+ else:
+ eq += str(b) + 'x + '
+
+ eq += str(c) + ' = 0'
+
+ problem = 'Find the roots of given Quadratic Equation ' + eq
+
+ if d < 0:
+ sqrt_d = (-d)**0.5
+
+ if sqrt_d - int(sqrt_d) == 0:
+ sqrt_d = int(sqrt_d)
+ solution = f'(({-b} + {sqrt_d}i)/2*{a}, ({-b} - {sqrt_d}i)/2*{a})'
+ else:
+ solution = f'(({-b} + sqrt({-d})i)/2*{a}, ({-b} - sqrt({-d})i)/2*{a})'
+
+ return problem, solution
+
+ else:
+ s_root1 = round((-b + (d)**0.5) / (2 * a), 3)
+ s_root2 = round((-b - (d)**0.5) / (2 * a), 3)
+
+ sqrt_d = (d)**0.5
+
+ if sqrt_d - int(sqrt_d) == 0:
+ sqrt_d = int(sqrt_d)
+ g_sol = f'(({-b} + {sqrt_d})/2*{a}, ({-b} - {sqrt_d})/2*{a})'
+ else:
+ g_sol = f'(({-b} + sqrt({d}))/2*{a}, ({-b} - sqrt({d}))/2*{a})'
+
+ solution = f'simplified solution : ({s_root1, s_root2}), generalized solution : ' + g_sol
+
+ return problem, solution
+
+
+complex_quadratic = Generator(
+ "complex Quadratic Equation", 100,
+ "Find the roots of given Quadratic Equation ",
+ "simplified solution : (x1, x2), generalized solution : ((-b + sqrt(d))/2a, (-b - sqrt(d))/2a) or ((-b + sqrt(d)i)/2a, (-b - sqrt(d)i)/2a)",
+ complexQuadraticFunc)
diff --git a/mathgenerator/funcs/is_leap_year.py b/mathgenerator/funcs/is_leap_year.py
new file mode 100644
index 0000000..3f9c351
--- /dev/null
+++ b/mathgenerator/funcs/is_leap_year.py
@@ -0,0 +1,25 @@
+from .__init__ import *
+
+
+def IsLeapYear(minNumber=1900, maxNumber=2099):
+ year = random.randint(minNumber, maxNumber)
+ problem = "Year " + str(year) + " "
+ solution = ""
+ if (year % 4) == 0:
+ if (year % 100) == 0:
+ if (year % 400) == 0:
+ solution = "is a leap year"
+ else:
+ solution = "is not a leap year"
+ else:
+ solution = "is a leap year"
+ else:
+ solution = "is not a leap year"
+
+ return problem, solution
+
+
+is_leap_year = Generator("Leap Year or Not", 101,
+ "Year y ", "is/not a leap year",
+ IsLeapYear)
+# for readme ## | 102 | Leap Year or Not | Year 1964 | is a leap year | is_leap_year |
diff --git a/mathgenerator/funcs/perimeter_of_polygons.py b/mathgenerator/funcs/perimeter_of_polygons.py
new file mode 100644
index 0000000..5b61688
--- /dev/null
+++ b/mathgenerator/funcs/perimeter_of_polygons.py
@@ -0,0 +1,20 @@
+from .__init__ import *
+
+
+def perimeterOfPolygons(maxSides=12, maxLength=120):
+ size_of_sides = random.randint(3, maxSides)
+ sides = []
+ for x in range(size_of_sides):
+ sides.append(random.randint(1, maxLength))
+ problem = "The perimeter of a " + str(size_of_sides) + \
+ " sided polygon with lengths of " + str(sides) + "cm is: "
+ solution = 0
+ for y in range(len(sides)):
+ solution += sides[y]
+ return problem, solution
+
+
+perimeter_of_polygons = Generator(
+ "Perimeter of Polygons", 96,
+ "The perimeter of a x sided polygon with lengths of y cm is: ", "z",
+ perimeterOfPolygons)
diff --git a/mathgenerator/funcs/power_of_powers.py b/mathgenerator/funcs/power_of_powers.py
new file mode 100644
index 0000000..9381327
--- /dev/null
+++ b/mathgenerator/funcs/power_of_powers.py
@@ -0,0 +1,20 @@
+from .__init__ import *
+
+
+def powerOfPowersFunc(maxBase=50, maxPower=10):
+ base = random.randint(1, maxBase)
+ power1 = random.randint(1, maxPower)
+ power2 = random.randint(1, maxPower)
+ step = power1 * power2
+
+ problem = "The {base}^{power1}^{power2} = " \
+ "{base}^({power1}*{power2}) = {base}^{step}".format(base=base,
+ power1=power1,
+ power2=power2,
+ step=step)
+ solution = str(base**step)
+ return problem, solution
+
+
+power_of_powers = Generator("Power of Powers", 97, "6^4^2 = 6^(4*2) = 6^6",
+ "46656", powerOfPowersFunc)
diff --git a/mathgenerator/funcs/quotient_of_power_same_base.py b/mathgenerator/funcs/quotient_of_power_same_base.py
new file mode 100644
index 0000000..cf38296
--- /dev/null
+++ b/mathgenerator/funcs/quotient_of_power_same_base.py
@@ -0,0 +1,21 @@
+from .__init__ import *
+
+
+def quotientOfPowerSameBaseFunc(maxBase=50, maxPower=10):
+ base = random.randint(1, maxBase)
+ power1 = random.randint(1, maxPower)
+ power2 = random.randint(1, maxPower)
+ step = power1 - power2
+
+ problem = "The Quotient of {base}^{power1} and {base}^{power2} = " \
+ "{base}^({power1}-{power2}) = {base}^{step}".format(base=base,
+ power1=power1,
+ power2=power2,
+ step=step)
+ solution = str(base**step)
+ return problem, solution
+
+
+quotient_of_power_same_base = Generator("Quotient of Powers with Same Base",
+ 98, "6^4 / 6^2 = 6^(4-2) = 6^2", "36",
+ quotientOfPowerSameBaseFunc)
diff --git a/mathgenerator/funcs/quotient_of_power_same_power.py b/mathgenerator/funcs/quotient_of_power_same_power.py
new file mode 100644
index 0000000..1c668a8
--- /dev/null
+++ b/mathgenerator/funcs/quotient_of_power_same_power.py
@@ -0,0 +1,21 @@
+from .__init__ import *
+
+
+def quotientOfPowerSamePowerFunc(maxBase=50, maxPower=10):
+ base1 = random.randint(1, maxBase)
+ base2 = random.randint(1, maxBase)
+ power = random.randint(1, maxPower)
+ step = base1 / base2
+
+ problem = "The Quotient of {base1}^{power} and {base2}^{power} = " \
+ "({base1}/{base2})^{power} = {step}^{power}".format(base1=base1,
+ base2=base2,
+ power=power,
+ step=step)
+ solution = str(step**power)
+ return problem, solution
+
+
+quotient_of_power_same_power = Generator("Quotient of Powers with Same Power",
+ 99, "6^4 / 3^4 = (6/3)^4 = 2^4", "16",
+ quotientOfPowerSamePowerFunc)
diff --git a/test.py b/test.py
index 126c9d8..0b24009 100644
--- a/test.py
+++ b/test.py
@@ -10,4 +10,5 @@ for item in list:
print(item[2])
# print(mathgen.getGenList())
-print(mathgen.genById(95))
+print(mathgen.decimal_to_roman_numerals())
+print(mathgen.genById(101))