Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dero
- import "strconv"
- func ElectronicConfiguration(atomic_number int) string {
- solution := ""
- for level := 0 ; level < 7 ; level++ {
- //s orbital
- if atomic_number > 0 && level != 0 {
- if atomic_number >= 2 {
- solution += strconv.Itoa(level+1)
- solution += "p2 "
- atomic_number -= 2
- } else {
- atomic_number -= 2
- solution += strconv.Itoa(level+1)
- solution += "s"
- solution += strconv.Itoa(2 + atomic_number)
- solution += " "
- break
- }
- }
- //p orbital
- if atomic_number > 0 && level != 0 {
- if atomic_number >= 6 {
- solution += strconv.Itoa(level+1)
- solution += "p6 "
- atomic_number -= 6
- } else {
- atomic_number -= 6
- solution += strconv.Itoa(level+1)
- solution += "p"
- solution += strconv.Itoa(6 + atomic_number)
- solution += " "
- break
- }
- }
- //d orbital
- if level >= 2 && level <= 5 {
- if atomic_number >= 10 {
- solution += strconv.Itoa(level+1)
- solution += "d10 "
- atomic_number -= 10
- } else {
- atomic_number -= 10
- solution += strconv.Itoa(level+1)
- solution += "d"
- solution += strconv.Itoa(10 + atomic_number)
- solution += " "
- break
- }
- }
- //f orbital
- if level == 3 && level == 4 {
- if atomic_number >= 14 {
- solution += strconv.Itoa(level+1)
- solution += "f14 "
- atomic_number -= 10
- } else {
- atomic_number -= 14
- solution += strconv.Itoa(level+1)
- solution += "f"
- solution += strconv.Itoa(14 + atomic_number)
- solution += " "
- break
- }
- }
- }
- return solution
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement