Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 286 characters in body
Source Link
es1024
  • 9.2k
  • 1
  • 29
  • 67
0000000: 61404061 753d3d75 706e6e70 63616163 276b6b27 2a43432a 2c27272c 10272710 @a=unpack'C*','.
0000010: 42414142 52131352 14333314 34535334 73151573 35545435 74161674 36555536 AB.R3.S4.sT5.tU6
0000020: 3b27273b 66696966 2828 2d24242d 3c3d3d3c 293e3e29 7e7e 755b5b75 ';if(($-=<>)~~[u
0000030: 706e6e70 63616163 276b6b27 2a43432a 2c27272c 18272718 291d1d29 2c2a2a2c npack'C*','..)*,
0000040: 2e2d2d2e 392f2f39 403a3a40 4f4e4e4f 5a59595a 5c5b5b5c 605d5d60 27676727 -./9:@NOYZ[\]`g'
0000050: 295d5d29 247b7b24 2b2e2e2b 283d3d28 2d24242d 7e7e 345b5b34 2c36362c ]){$.+=($-~~[46,
0000060: 30393930 295d5d29 243b3b24 3d70703d 2b32322b 2d24242d 332f2f33 3b33333b 90]);$p=2+$-/33;
0000070: 2d24242d 383e3e38 7c37377c 2d24242d 7e7e 355b5b35 2e37372e 362e2e36 $->87|$-~~[57..6
0000080: 5d34345d 2626 24282824 2a2e2e2a 2d3d3d2d 29313129 243b3b24 5b6f6f5b 4]&&($.*=-1);$o[
0000090: 70242470 2b5d5d2b 243d3d24 2c2e2e2c 6f24246f 245b5b24 2b70702b 5d31315d $p]+=$.,$o[$p+1]
00000a0: 3d2d2d3d 2e24242e 247d7d24 3d25253d 24282824 3d25253d 61242461 245b5b24 -=$.}$%=($%=$a[$
00000b0: 5d71715d 382f2f38 3e29293e 2d24242d 243f3f24 3a2d2d3a 25242425 242c2c24 q]/8)>$-?$-:$%,$
00000c0: 5b6f6f5b 61242461 245b5b24 2b71712b 2b5d 2637 5d2b 37263d24 2b5d 243do[$a[$q++]&7]+=$
00000d0: 77252577 69686869 656c6c65 24282824 2d2d 243d3d24 29252529 243b3b24 %while($--=$%);$
00000e0: 3d2c2c3d 22242422 733b3b73 79616179 6f40
00000ea406f ,=$";say@o
0000000 6140 753d 706e 6361 276b 2a43 2c27 1027
0000010 4241 5213 1433 3453 7315 3554 7416 3655
0000020 3b27 6669 2828 2d24 3c3d 293e 7e7e 755b
0000030 706e 6361 276b 2a43 2c27 1827 291d 2c2a
0000040 2e2d 392f 403a 4f4e 5a59 5c5b 605d 2767
0000050 295d 247b 2b2e 283d 2d24 7e7e 345b 2c36
0000060 3039 295d 243b 3d70 2b32 2d24 332f 3b33
0000070 2d24 383e 7c37 2d24 7e7e 355b 2e37 362e
0000080 5d34 2626 2428 2a2e 2d3d 2931 243b 5b6f
0000090 7024 2b5d 243d 2c2e 6f24 245b 2b70 5d31
00000a0 3d2d 2e24 247d 3d25 2428 3d25 6124 245b
00000b0 5d71 382f 3e29 2d24 243f 3a2d 2524 242c
00000c0 5b6f 6124 245b 2b71 5d2b 3726 2b5d 243d
00000d0 7725 6968 656c 2428 2d2d 243d 2925 243b
00000e0 3d2c 2224 733b 7961 6f40
00000ea
0000000: 4061 3d75 6e70 6163 6b27 432a 272c 2710 @a=unpack'C*','.
0000010: 4142 1352 3314 5334 1573 5435 1674 5536 AB.R3.S4.sT5.tU6
0000020: 273b 6966 2828 242d 3d3c 3e29 7e7e 5b75 ';if(($-=<>)~~[u
0000030: 6e70 6163 6b27 432a 272c 2718 1d29 2a2c npack'C*','..)*,
0000040: 2d2e 2f39 3a40 4e4f 595a 5b5c 5d60 6727 -./9:@NOYZ[\]`g'
0000050: 5d29 7b24 2e2b 3d28 242d 7e7e 5b34 362c ]){$.+=($-~~[46,
0000060: 3930 5d29 3b24 703d 322b 242d 2f33 333b 90]);$p=2+$-/33;
0000070: 242d 3e38 377c 242d 7e7e 5b35 372e 2e36 $->87|$-~~[57..6
0000080: 345d 2626 2824 2e2a 3d2d 3129 3b24 6f5b 4]&&($.*=-1);$o[
0000090: 2470 5d2b 3d24 2e2c 246f 5b24 702b 315d $p]+=$.,$o[$p+1]
00000a0: 2d3d 242e 7d24 253d 2824 253d 2461 5b24 -=$.}$%=($%=$a[$
00000b0: 715d 2f38 293e 242d 3f24 2d3a 2425 2c24 q]/8)>$-?$-:$%,$
00000c0: 6f5b 2461 5b24 712b 2b5d 2637 5d2b 3d24 o[$a[$q++]&7]+=$
00000d0: 2577 6869 6c65 2824 2d2d 3d24 2529 3b24 %while($--=$%);$
00000e0: 2c3d 2422 3b73 6179 406f ,=$";say@o
added 35 characters in body
Source Link
es1024
  • 9.2k
  • 1
  • 29
  • 67

Perl 5, 243235 (242234 + 1 for -E)

@a=unpack'C*','ABR3S4sT5tU6';if(($-=<>;@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';@b=unpack'C*'=<>)~~[unpack'C*',')*,-./9:@NOYZ[\]`g';if($-~~@b@NOYZ[\]`g']){$y=1+$.+=($-~~[46,90]);$p=2+$-/33;$->87|$-~~[57..64]&&($y*=$.*=-1);$o[$p]+=$y;$o[$p]+=$.,$o[$p+1]-=$y=$.}$e=$%=($e=$a[$q]>>4$%=$a[$q]/8)>$-?$-:$e$%,$o[$a[$q++]&7]+=$e while$o[$a[$q++]&7]+=$%while($--=$e=$%);,ドル=$";say@o

Note: a hex dump is provided at the bottom of this post, as some of the string literals contain control characters (which waswere entered through a hex editor).

$_=<>;
# For each byte, the first nibble5 isbits are the number of spaces to fill at a time, the secondnext nibble3 isbits represent the shell number, minus 1.
# Values: 2010 8141 8242 2313 a252 6333 2414 a353 6434 2515 e373 a454 6535 2616 e474 a555 6636
# The 1st shell takes 2 electrons
# Then the 2nd shell take 8, then the third takes 8...
@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';'ABR3S4sT5tU6';
# Contains the atomic numbers of abnormal elements
# Values: 18 1d 29 2a 2c 2d 2e 2f 39 3a 40 4e 4f 59 5a 5b 5c 5d 60 67
@b=unpack'C*',')*,-./9:@NOYZ[\]`g';
# if abnormal
if($_~~@b){
 # All abnormals, except element 46 and 90, only displace 1 electron
 $y=1+($_~~[46,90]);
 # Abnormals with atomic number less than 33 involve switches between shells 3 and 4
 # 33-65: 4 and 5
 # 66-98: 5 and 6
 # 99+ : 6 and 7
 $p = (3 + ~~($_/33)) - 1;
 # abnormals in these ranges move electrons from lower to higher
 # abnormals elsewhere do higher to lower
 if($_ >= 88 || $_ ~~ [57..64]){
 $y *= -1;
 }
 # move electrons
 $o[$p] += $y;
 $o[$p+1] -= $y;
}
 # extract max number of electrons to fill shell with
 $e# >> 3 is equivalent to /8 for integers; $% is always an integer.
 $% = $a[$q] >>/ 48,
 # do not overfill
 $e$% = $e$% > $_ ? $_ : $e$%,
 # add electrons to shell
 $o[ $a[$q++] & 7 ] += $e$%
# reduce number of electrons left to fill shells with
while($_ -= $e$%);
# set list separator to space
,ドル = $";
# print list representing shells
say @o 
0000000 2d24 3c3d 3b3e 6140 753d 706e 6361 276b
0000010 2a43 2c27 20271027
0000010 82814241 a2235213 24631433 64a33453 e3257315 3554 7416 3655
0000020 65a43b27 e4266669 66a52828 3b272d24 62403c3d 753d293e 706e7e7e 6361755b
0000030 706e 6361 276b 2a43 2c27 1827 291d 2c2a
0000040 2e2d 392f
0000040 403a 4f4e 5a59 5c5b 605d 2767 693b 2866
0000050 2d24 7e7e 6240 7b29295d 7924247b 313d2b2e 282b283d 2d24
0000060 7e7e 345b 2c36
0000060 3039 295d 243b 3d70 2b32
0000070 2d24 332f 3b33
0000070 2d24 383e 7c37 2d24 7e7e
0000080 355b 2e37 362e
0000080 5d34 2626 2428 2a792a2e 2d3d
0000090 2931 243b 5b6f
0000090 7024 2b5d 243d 2c792c2e 6f24
00000a0 245b 2b70 5d31
00000a0 3d2d 79242e24 247d 3d653d25 2428
00000b0 3d653d25 6124 245b
00000b0 5d71 3e3e382f 29343e29 243e2d24 3f2d243f 3a2d 2524 242c
00000c0 2d245b6f 243a6124 2c65245b 6f242b71 245b5d2b 5b613726 71242b5d 2b2b243d
00000d0 265d 5d37 3d2b 6524 77207725 6968 656c 2428
00000e0 2d2d 243d 29652925 243b
00000e0 3d2c 2224 733b 7961
00000f0 6f40
00000f200000ea

Perl 5, 243 (242 + 1 for -E)

$-=<>;@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';@b=unpack'C*',')*,-./9:@NOYZ[\]`g';if($-~~@b){$y=1+($-~~[46,90]);$p=2+$-/33;$->87|$-~~[57..64]&&($y*=-1);$o[$p]+=$y,$o[$p+1]-=$y}$e=($e=$a[$q]>>4)>$-?$-:$e,$o[$a[$q++]&7]+=$e while($--=$e);,ドル=$";say@o

Note: a hex dump is provided at the bottom of this post, as some of the string literals contain control characters (which was entered through a hex editor).

$_=<>;
# For each byte, the first nibble is the number of spaces to fill at a time, the second nibble is the shell number, minus 1.
# Values: 20 81 82 23 a2 63 24 a3 64 25 e3 a4 65 26 e4 a5 66
# The 1st shell takes 2 electrons
# Then the 2nd shell take 8, then the third takes 8...
@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';
# Contains the atomic numbers of abnormal elements
# Values: 18 1d 29 2a 2c 2d 2e 2f 39 3a 40 4e 4f 59 5a 5b 5c 5d 60 67
@b=unpack'C*',')*,-./9:@NOYZ[\]`g';
# if abnormal
if($_~~@b){
 # All abnormals, except element 46 and 90, only displace 1 electron
 $y=1+($_~~[46,90]);
 # Abnormals with atomic number less than 33 involve switches between shells 3 and 4
 # 33-65: 4 and 5
 # 66-98: 5 and 6
 # 99+ : 6 and 7
 $p = (3 + ~~($_/33)) - 1;
 # abnormals in these ranges move electrons from lower to higher
 # abnormals elsewhere do higher to lower
 if($_ >= 88 || $_ ~~ [57..64]){
 $y *= -1;
 }
 # move electrons
 $o[$p] += $y;
 $o[$p+1] -= $y;
}
 # extract max number of electrons to fill shell with
 $e = $a[$q] >> 4,
 # do not overfill
 $e = $e > $_ ? $_ : $e,
 # add electrons to shell
 $o[ $a[$q++] & 7 ] += $e
# reduce number of electrons left to fill shells with
while($_ -= $e);
# set list separator to space
,ドル = $";
# print list representing shells
say @o 
0000000 2d24 3c3d 3b3e 6140 753d 706e 6361 276b
0000010 2a43 2c27 2027 8281 a223 2463 64a3 e325
0000020 65a4 e426 66a5 3b27 6240 753d 706e 6361
0000030 276b 2a43 2c27 1827 291d 2c2a 2e2d 392f
0000040 403a 4f4e 5a59 5c5b 605d 2767 693b 2866
0000050 2d24 7e7e 6240 7b29 7924 313d 282b 2d24
0000060 7e7e 345b 2c36 3039 295d 243b 3d70 2b32
0000070 2d24 332f 3b33 2d24 383e 7c37 2d24 7e7e
0000080 355b 2e37 362e 5d34 2626 2428 2a79 2d3d
0000090 2931 243b 5b6f 7024 2b5d 243d 2c79 6f24
00000a0 245b 2b70 5d31 3d2d 7924 247d 3d65 2428
00000b0 3d65 6124 245b 5d71 3e3e 2934 243e 3f2d
00000c0 2d24 243a 2c65 6f24 245b 5b61 7124 2b2b
00000d0 265d 5d37 3d2b 6524 7720 6968 656c 2428
00000e0 2d2d 243d 2965 243b 3d2c 2224 733b 7961
00000f0 6f40
00000f2

Perl 5, 235 (234 + 1 for -E)

@a=unpack'C*','ABR3S4sT5tU6';if(($-=<>)~~[unpack'C*',')*,-./9:@NOYZ[\]`g']){$.+=($-~~[46,90]);$p=2+$-/33;$->87|$-~~[57..64]&&($.*=-1);$o[$p]+=$.,$o[$p+1]-=$.}$%=($%=$a[$q]/8)>$-?$-:$%,$o[$a[$q++]&7]+=$%while($--=$%);,ドル=$";say@o

Note: a hex dump is provided at the bottom of this post, as some of the string literals contain control characters (which were entered through a hex editor).

$_=<>;
# For each byte, the first 5 bits are the number of spaces to fill at a time, the next 3 bits represent the shell number, minus 1.
# Values: 10 41 42 13 52 33 14 53 34 15 73 54 35 16 74 55 36
# The 1st shell takes 2 electrons
# Then the 2nd shell take 8, then the third takes 8...
@a=unpack'C*','ABR3S4sT5tU6';
# Contains the atomic numbers of abnormal elements
# Values: 18 1d 29 2a 2c 2d 2e 2f 39 3a 40 4e 4f 59 5a 5b 5c 5d 60 67
@b=unpack'C*',')*,-./9:@NOYZ[\]`g';
# if abnormal
if($_~~@b){
 # All abnormals, except element 46 and 90, only displace 1 electron
 $y=1+($_~~[46,90]);
 # Abnormals with atomic number less than 33 involve switches between shells 3 and 4
 # 33-65: 4 and 5
 # 66-98: 5 and 6
 # 99+ : 6 and 7
 $p = (3 + ~~($_/33)) - 1;
 # abnormals in these ranges move electrons from lower to higher
 # abnormals elsewhere do higher to lower
 if($_ >= 88 || $_ ~~ [57..64]){
 $y *= -1;
 }
 # move electrons
 $o[$p] += $y;
 $o[$p+1] -= $y;
}
 # extract max number of electrons to fill shell with
 # >> 3 is equivalent to /8 for integers; $% is always an integer.
 $% = $a[$q] / 8,
 # do not overfill
 $% = $% > $_ ? $_ : $%,
 # add electrons to shell
 $o[ $a[$q++] & 7 ] += $%
# reduce number of electrons left to fill shells with
while($_ -= $%);
# set list separator to space
,ドル = $";
# print list representing shells
say @o 
0000000 6140 753d 706e 6361 276b 2a43 2c27 1027
0000010 4241 5213 1433 3453 7315 3554 7416 3655
0000020 3b27 6669 2828 2d24 3c3d 293e 7e7e 755b
0000030 706e 6361 276b 2a43 2c27 1827 291d 2c2a
0000040 2e2d 392f 403a 4f4e 5a59 5c5b 605d 2767
0000050 295d 247b 2b2e 283d 2d24 7e7e 345b 2c36
0000060 3039 295d 243b 3d70 2b32 2d24 332f 3b33
0000070 2d24 383e 7c37 2d24 7e7e 355b 2e37 362e
0000080 5d34 2626 2428 2a2e 2d3d 2931 243b 5b6f
0000090 7024 2b5d 243d 2c2e 6f24 245b 2b70 5d31
00000a0 3d2d 2e24 247d 3d25 2428 3d25 6124 245b
00000b0 5d71 382f 3e29 2d24 243f 3a2d 2524 242c
00000c0 5b6f 6124 245b 2b71 5d2b 3726 2b5d 243d
00000d0 7725 6968 656c 2428 2d2d 243d 2925 243b
00000e0 3d2c 2224 733b 7961 6f40
00000ea
deleted 21 characters in body
Source Link
es1024
  • 9.2k
  • 1
  • 29
  • 67

Perl 5, 247243 (246242 + 1 for -E)

$-=<>;@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';@b=unpack'C*',')*,-./9:@NOYZ[\]`g';if($-~~@b){$y=1+($-==46|$-==90~~[46,90]);$p=2+$-/33;($33;$->87|$-~~[57..64])&&64]&&($y*=-1);$o[$p]+=$y,$o[$p+1]-=$y}$e=($e=$a[$q]>>4)>$-?$-:$e,$o[$a[$q++]&7]+=$e while($--=$e);,ドル=$";say@o
using 5.10.1;
$_=<>;
# For each byte, the first nibble is the number of spaces to fill at a time, the second nibble is the shell number, minus 1.
# Values: 20 81 82 23 a2 63 24 a3 64 25 e3 a4 65 26 e4 a5 66
# The 1st shell takes 2 electrons
# Then the 2nd shell take 8, then the third takes 8...
@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';
# Contains the atomic numbers of abnormal elements
# Values: 18 1d 29 2a 2c 2d 2e 2f 39 3a 40 4e 4f 59 5a 5b 5c 5d 60 67
@b=unpack'C*',')*,-./9:@NOYZ[\]`g';
# if abnormal
if($_~~@b){
 # All abnormals, except element 46 and 90, only displace 1 electron
 $y=1+($_==46||$_==90$_~~[46,90]);
 # Abnormals with atomic number less than 33 involve switches between shells 3 and 4
 # 33-65: 4 and 5
 # 66-98: 5 and 6
 # 99+ : 6 and 7
 $p = (3 + ~~($_/33)) - 1;
 # abnormals in these ranges move electrons from lower to higher
 # abnormals elsewhere do higher to lower
 if($_ >= 88 || $_ ~~ [57..64]){
 $y *= -1;
 }
 # move electrons
 $o[$p] += $y;
 $o[$p+1] -= $y;
}
 # extract max number of electrons to fill shell with
 $e = $a[$q] >> 4,
 # do not overfill
 $e = $e > $_ ? $_ : $e,
 # add electrons to shell
 $o[ $a[$q++] & 7 ] += $e
# reduce number of electrons left to fill shells with
while($_ -= $e);
# set list separator to space
,ドル = $";
# print list representing shells
say @o 
0000000 2d24 3c3d 3b3e 6140 753d 706e 6361 276b
0000010 2a43 2c27 2027 8281 a223 2463 64a3 e325
0000020 65a4 e426 66a5 3b27 6240 753d 706e 6361
0000030 276b 2a43 2c27 1827 291d 2c2a 2e2d 392f
0000040 403a 4f4e 5a59 5c5b 605d 2767 693b 2866
0000050 2d24 7e7e 6240 7b29 7924 313d 282b 2d24
0000060 3d3d 36347e7e 247c345b 3d2d2c36 393d3039 2930295d 243b 3d70
0000070 2b32
0000070 2d24 332f 3b33 24282d24 3e2d383e 37387c37 247c2d24 7e7e
0000080 7e2d 5b7e 3735355b 2e2e2e37 3436362e 295d5d34 2626 2428
0000090 2a79 2d3d
0000090 2931 243b 5b6f 7024 2b5d 243d
00000a0 2c79 6f24
00000a0 245b 2b70 5d31 3d2d 7924 247d
00000b0 3d65 2428
00000b0 3d65 6124 245b 5d71 3e3e 2934
00000c0 243e 3f2d
00000c0 2d24 243a 2c65 6f24 245b 5b61
00000d0 7124 2b2b
00000d0 265d 5d37 3d2b 6524 7720 6968
00000e0 656c 2428
00000e0 2d2d 243d 2965 243b 3d2c 2224
00000f0 733b 7961
00000f0 6f40
00000f600000f2

Perl 5, 247 (246 + 1 for -E)

$-=<>;@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';@b=unpack'C*',')*,-./9:@NOYZ[\]`g';if($-~~@b){$y=1+($-==46|$-==90);$p=2+$-/33;($->87|$-~~[57..64])&&($y*=-1);$o[$p]+=$y,$o[$p+1]-=$y}$e=($e=$a[$q]>>4)>$-?$-:$e,$o[$a[$q++]&7]+=$e while($--=$e);,ドル=$";say@o
using 5.10.1;
$_=<>;
# For each byte, the first nibble is the number of spaces to fill at a time, the second nibble is the shell number, minus 1.
# Values: 20 81 82 23 a2 63 24 a3 64 25 e3 a4 65 26 e4 a5 66
# The 1st shell takes 2 electrons
# Then the 2nd shell take 8, then the third takes 8...
@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';
# Contains the atomic numbers of abnormal elements
# Values: 18 1d 29 2a 2c 2d 2e 2f 39 3a 40 4e 4f 59 5a 5b 5c 5d 60 67
@b=unpack'C*',')*,-./9:@NOYZ[\]`g';
# if abnormal
if($_~~@b){
 # All abnormals, except element 46 and 90, only displace 1 electron
 $y=1+($_==46||$_==90);
 # Abnormals with atomic number less than 33 involve switches between shells 3 and 4
 # 33-65: 4 and 5
 # 66-98: 5 and 6
 # 99+ : 6 and 7
 $p = (3 + ~~($_/33)) - 1;
 # abnormals in these ranges move electrons from lower to higher
 # abnormals elsewhere do higher to lower
 if($_ >= 88 || $_ ~~ [57..64]){
 $y *= -1;
 }
 # move electrons
 $o[$p] += $y;
 $o[$p+1] -= $y;
}
 # extract max number of electrons to fill shell with
 $e = $a[$q] >> 4,
 # do not overfill
 $e = $e > $_ ? $_ : $e,
 # add electrons to shell
 $o[ $a[$q++] & 7 ] += $e
# reduce number of electrons left to fill shells with
while($_ -= $e);
# set list separator to space
,ドル = $";
# print list representing shells
say @o 
0000000 2d24 3c3d 3b3e 6140 753d 706e 6361 276b
0000010 2a43 2c27 2027 8281 a223 2463 64a3 e325
0000020 65a4 e426 66a5 3b27 6240 753d 706e 6361
0000030 276b 2a43 2c27 1827 291d 2c2a 2e2d 392f
0000040 403a 4f4e 5a59 5c5b 605d 2767 693b 2866
0000050 2d24 7e7e 6240 7b29 7924 313d 282b 2d24
0000060 3d3d 3634 247c 3d2d 393d 2930 243b 3d70
0000070 2b32 2d24 332f 3b33 2428 3e2d 3738 247c
0000080 7e2d 5b7e 3735 2e2e 3436 295d 2626 2428
0000090 2a79 2d3d 2931 243b 5b6f 7024 2b5d 243d
00000a0 2c79 6f24 245b 2b70 5d31 3d2d 7924 247d
00000b0 3d65 2428 3d65 6124 245b 5d71 3e3e 2934
00000c0 243e 3f2d 2d24 243a 2c65 6f24 245b 5b61
00000d0 7124 2b2b 265d 5d37 3d2b 6524 7720 6968
00000e0 656c 2428 2d2d 243d 2965 243b 3d2c 2224
00000f0 733b 7961 6f40
00000f6

Perl 5, 243 (242 + 1 for -E)

$-=<>;@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';@b=unpack'C*',')*,-./9:@NOYZ[\]`g';if($-~~@b){$y=1+($-~~[46,90]);$p=2+$-/33;$->87|$-~~[57..64]&&($y*=-1);$o[$p]+=$y,$o[$p+1]-=$y}$e=($e=$a[$q]>>4)>$-?$-:$e,$o[$a[$q++]&7]+=$e while($--=$e);,ドル=$";say@o
$_=<>;
# For each byte, the first nibble is the number of spaces to fill at a time, the second nibble is the shell number, minus 1.
# Values: 20 81 82 23 a2 63 24 a3 64 25 e3 a4 65 26 e4 a5 66
# The 1st shell takes 2 electrons
# Then the 2nd shell take 8, then the third takes 8...
@a=unpack'C*',' ‚#¢c$£d%ã¤e&ä\f';
# Contains the atomic numbers of abnormal elements
# Values: 18 1d 29 2a 2c 2d 2e 2f 39 3a 40 4e 4f 59 5a 5b 5c 5d 60 67
@b=unpack'C*',')*,-./9:@NOYZ[\]`g';
# if abnormal
if($_~~@b){
 # All abnormals, except element 46 and 90, only displace 1 electron
 $y=1+($_~~[46,90]);
 # Abnormals with atomic number less than 33 involve switches between shells 3 and 4
 # 33-65: 4 and 5
 # 66-98: 5 and 6
 # 99+ : 6 and 7
 $p = (3 + ~~($_/33)) - 1;
 # abnormals in these ranges move electrons from lower to higher
 # abnormals elsewhere do higher to lower
 if($_ >= 88 || $_ ~~ [57..64]){
 $y *= -1;
 }
 # move electrons
 $o[$p] += $y;
 $o[$p+1] -= $y;
}
 # extract max number of electrons to fill shell with
 $e = $a[$q] >> 4,
 # do not overfill
 $e = $e > $_ ? $_ : $e,
 # add electrons to shell
 $o[ $a[$q++] & 7 ] += $e
# reduce number of electrons left to fill shells with
while($_ -= $e);
# set list separator to space
,ドル = $";
# print list representing shells
say @o 
0000000 2d24 3c3d 3b3e 6140 753d 706e 6361 276b
0000010 2a43 2c27 2027 8281 a223 2463 64a3 e325
0000020 65a4 e426 66a5 3b27 6240 753d 706e 6361
0000030 276b 2a43 2c27 1827 291d 2c2a 2e2d 392f
0000040 403a 4f4e 5a59 5c5b 605d 2767 693b 2866
0000050 2d24 7e7e 6240 7b29 7924 313d 282b 2d24
0000060 7e7e 345b 2c36 3039 295d 243b 3d70 2b32
0000070 2d24 332f 3b33 2d24 383e 7c37 2d24 7e7e
0000080 355b 2e37 362e 5d34 2626 2428 2a79 2d3d
0000090 2931 243b 5b6f 7024 2b5d 243d 2c79 6f24
00000a0 245b 2b70 5d31 3d2d 7924 247d 3d65 2428
00000b0 3d65 6124 245b 5d71 3e3e 2934 243e 3f2d
00000c0 2d24 243a 2c65 6f24 245b 5b61 7124 2b2b
00000d0 265d 5d37 3d2b 6524 7720 6968 656c 2428
00000e0 2d2d 243d 2965 243b 3d2c 2224 733b 7961
00000f0 6f40
00000f2
deleted 16 characters in body
Source Link
es1024
  • 9.2k
  • 1
  • 29
  • 67
Loading
Source Link
es1024
  • 9.2k
  • 1
  • 29
  • 67
Loading

AltStyle によって変換されたページ (->オリジナル) /