In this challenge, you will be given a result, and your task is to find an arithmetic expression that uses only the numbers pi and e to yield that result. You can use addition, subtraction, multiplication, division, and exponentiation operations, and each number (pi and e) can appear at most two times. Parentheses are not allowed. If there are multiple solutions, return the one that requires fewer operations. If there are still multiple solutions, return the one that comes first alphabetically (without spaces). The calculated result must be equal with an error smaller than 1 x 10-10. If there is no solution for the input, return None. Non negative/positive symbol at the beginning is allowed.
Input: Floating point number (float).
Output: String (str).
assert checkio(5.85987448205) == "e+pi" assert checkio(18.2958548951) == "e**e+pi" assert checkio(47.6085189284) == "e**e*pi" assert checkio(-0.42331082513) == "e-pi"
How it is used: In challenges that require finding arithmetic expressions, we can intuit interesting mathematical relationships. For example, one such relationship is the fact that 1/12 + 1/22 + 1/32 + ... = 1.64493406685... = π2/6
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin --ff
checkio install-plugin --chromium