We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My solution might look more complicated than the others due to the fact that it contains more lines of code. However it is just code that others wrote in function:
Here is step-by-step explanation:
1. Read input
2. Call find_result function which performs all the neccesary calculations
2.1 Inside find_result function we call product method which creates iterable of cartesian_product, meaning [['a', 'b'], ['c', 'd']] would result into [['a', 'c'], ['a', 'd'], ['b', 'c'], ['b', 'd']] (in our case it is all possible combinations of parameters for math_function)
2.2 We use starmap to pass all possible combinations into math_function and find maximum from obtained results.
Maximize It!
You are viewing a single comment's thread. Return to all comments →
My solution might look more complicated than the others due to the fact that it contains more lines of code. However it is just code that others wrote in function:
Here is step-by-step explanation: 1. Read input 2. Call find_result function which performs all the neccesary calculations 2.1 Inside find_result function we call product method which creates iterable of cartesian_product, meaning [['a', 'b'], ['c', 'd']] would result into [['a', 'c'], ['a', 'd'], ['b', 'c'], ['b', 'd']] (in our case it is all possible combinations of parameters for math_function) 2.2 We use starmap to pass all possible combinations into math_function and find maximum from obtained results.
Starmap documentation: https://docs.python.org/3/library/itertools.html#itertools.starmap Product documentation: https://docs.python.org/3/library/itertools.html#itertools.product