Problem 480. Aufbau principle
Given the order e=[1s, 2s, 2p, 3s, 3p, 4s, 3d, 4p, 5s, 4d, 5p, 6s, 4f, 5d, 6p, 7s, 5f, 6d, 7p], find a vector x with these conditions:
- sum(x)==sumofx
- length of x is the shortest possible
- x has positive integers only
- if e(k) contains s,p,d,f,g, then x(k) must be less than 3,7,11,15,19, respectively
- if x(k+1)>0 then x(k) must be maximum possible.
For example, if sumofx=3 then x=[2 1]. Return x embedded in e in the following style: electrons='1s2,2s1'. Please see more info: Aufbau Principle, Electron Shell.
Solution Stats
Problem Comments
-
3 Comments
Alfonso Nieto-Castanon
on 12 Mar 2012
should not sumofx be 6 for test 2?
AMITAVA BISWAS
on 12 Mar 2012
yes, corrected, thanks
Christian Schröder
on 2 Dec 2025
The element in the last test case is calcium, not chlorine.
Solution Comments
Show commentsProblem Recent Solvers26
Suggested Problems
-
Find the "ordinary" or Euclidean distance between A and Z
176 Solvers
-
"Low : High - Low : High - Turn around " -- Create a subindices vector
580 Solvers
-
Calculate the area of a triangle between three points
3405 Solvers
-
Test if two numbers have the same digits
262 Solvers
-
I've got the power! (Inspired by Project Euler problem 29)
141 Solvers
More from this Author99
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!