Extract the Electrons
Description:
Lithium_3
has the electron configuration: 2)1)
, meaning it has 2 electrons in the first shell, 1 in the second shell.
Electrons are always torn from the last shell when an ionization occurs. In the Li
atom above, if we tear one electron apart from it, it becomes 2)
.
This ionization as a cost in energy, which depends on the radius of the atom/ion and the number of protons its nucleus holds:
Energy = nProtons / radius^2
(no units, in the current context)
Task
In this kata you are expected to compute the total_energy of the ionization of a certain number of electrons from an atom, according to the following rules:
- Number of protons of a nucleus is equal to its initial number of electrons (see
inputs
) - Cost in energy to remove one single electron is computed accordingly to the formula above
- Electrons are always removed from the outer shell still containing electrons.
- When a shell is emptied, the radius of the atom/ion decreases. To keep things simple, we will considere that radii of the shells, counting from the nucleus, are increasing with a regular step. For example if the most inner shell has a radius
r
, second shell is2r
, then3r
, ...
Inputs
You will be given:
- A list
electrons
, with the initial partition of the electrons in the shells (inner->outer). We do not follow the real chemistry here, therefore any shell of the atom can contain between 1 and 8 electrons. - The number of electrons to ionize,
remove_count
. It will not be negative, however it can be more than the number of electrons of the atom. In this case you should just remove all the electrons. - The
total_radius
, which will be the initial radius of the atom, from core to last shell.
Output
The total energy needed to remove the required number of electrons.
Example
electron_ionization([2,3,4], 5, 2.4) == 9.765625
Last 4 electrons with 9 protons and the distance 2.4 require an energy of 6.25
.
We need to remove one more from the remaining electrons, [2,3]
, with now the distance 1.6 and so a cost of 3.515625
.
Hence: total = 9.765625
Similar Kata:
Stats:
Created | Jun 13, 2019 |
Published | Jun 13, 2019 |
Warriors Trained | 244 |
Total Skips | 11 |
Total Code Submissions | 309 |
Total Times Completed | 89 |
Python Completions | 89 |
Total Stars | 4 |
% of votes with a positive feedback rating | 88% of 30 |
Total "Very Satisfied" Votes | 24 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |