Got this question on an online SE assessment for Electronic Arts (EA). Applied through their career website. Seems easy-medium difficulty but wasn't able to solve it completely. Can anyone give me the correct solution?
Move an atom on a grid using predefined actions.
You have discovered ancient alchemical processes for transmuting matter. You can add or remove protons and neutrons from an atom.
Your atom is placed in the game area. The x-axis represents the number of protons and the y-axis the number of neutrons.
You need to list the actions to be taken so that the atom reaches the expected number of protons and neutrons.
The following 3 predefined actions are available:
You must return a list of strings corresponding to the actions to be performed.
For example, if you return a list containing the words ALPHA, PROTON, PROTON, PROTON, the atom will lose two protons and two neutrons, then regain 3 protons. In the end, it will move two squares up and one square to the right.
The order of the actions is not important. There's no need to minimize the number of actions. You are allowed to move your atom out of the grid, even through the upper and left borders.
Implement the function solve(protons_start, neutrons_start, protons_target, neutrons_target). This function must return a list of strings: the successive actions to be performed to go from the supplied atom to the target atom.
The function takes 4 input parameters:
protons_start and neutrons_start represent the number of protons and neutrons in the initial atom.protons_target and neutrons_target represent the number of protons and neutrons in the desired atom.


