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

deleted 48 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
0"hTH^Løìð^R1⁄4Ä^X¿håêÛ3⁄4aÔ^G^Æ^Y^Æ1⁄4^Q"256b6b5a0"hTHøìð1⁄4Ä¿håêÛ3⁄4aÔ1⁄4"256b6b5a/4a8**li<{[33:B_B*65_B*1]=\_B%8=B\#*+}/Bb0-`

The above code uses caret notation for the control characters in the string. It is equivalent to the following code, which uses an array of character codes instead:

0[104 84 72C248 236 240I188 196 24 191 104 229 234 219 190 170 212 7 134 25 134 188H]
256b6b5a/4a8**li<{[33:B_B*65_B*1]=\_B%8=B\#*+}/Bb0-`

The above code contains unprintable characters.

You can try the second versionTry it online in the CJam interpreter CJam interpreter . If the link doesn't work for you, copy from this paste.

" Push 0, the initial value of R; convert the following array into an integer by
 considering it a base 256 number, then back to the array of its digits in base 6. ";
0[104 84 72C248 236 240I188 196 24 191 104 229 234 219 190 170 212 7 134 25 134 188H]
256b6b0"hTHøìð1⁄4Ä¿håêÛ3⁄4aÔ1⁄4"256b6b
" Replace each 5 in the resulting array by [4 4 4 4 4 4 4 4]. This yields the array T
 from the above section. ";
5a/4a8**
" Read an integer N from STDIN and discard all but the first N elements of T. ";
li<
" For each element Y of the remainder of T, do the following: ";
{
 [33:B_B*65_B*1]=\ " Define B := 33, push L, retrieve L[Y] and swap it with R. ";
 _B%8=B\#* " Execute R *= 33 ** (R % 33 == 8). ";
 + " Execute R += L[Y]. ";
}/
" Convert R into the array of its digits in base 33, remove eventual zeros (Palladium)
 and replace the resulting array with its string representation. ";
Bb0-`
0"hTH^Løìð^R1⁄4Ä^X¿håêÛ3⁄4aÔ^G^Æ^Y^Æ1⁄4^Q"256b6b5a/4a8**li<{[33:B_B*65_B*1]=\_B%8=B\#*+}/Bb0-`

The above code uses caret notation for the control characters in the string. It is equivalent to the following code, which uses an array of character codes instead:

0[104 84 72C248 236 240I188 196 24 191 104 229 234 219 190 170 212 7 134 25 134 188H]
256b6b5a/4a8**li<{[33:B_B*65_B*1]=\_B%8=B\#*+}/Bb0-`

You can try the second version in the CJam interpreter.

" Push 0, the initial value of R; convert the following array into an integer by
 considering it a base 256 number, then back to the array of its digits in base 6. ";
0[104 84 72C248 236 240I188 196 24 191 104 229 234 219 190 170 212 7 134 25 134 188H]
256b6b
" Replace each 5 in the resulting array by [4 4 4 4 4 4 4 4]. This yields the array T
 from the above section. ";
5a/4a8**
" Read an integer N from STDIN and discard all but the first N elements of T. ";
li<
" For each element Y of the remainder of T, do the following: ";
{
 [33:B_B*65_B*1]=\ " Define B := 33, push L, retrieve L[Y] and swap it with R. ";
 _B%8=B\#* " Execute R *= 33 ** (R % 33 == 8). ";
 + " Execute R += L[Y]. ";
}/
" Convert R into the array of its digits in base 33, remove eventual zeros (Palladium)
 and replace the resulting array with its string representation. ";
Bb0-`
0"hTHøìð1⁄4Ä¿håêÛ3⁄4aÔ1⁄4"256b6b5a/4a8**li<{[33:B_B*65_B*1]=\_B%8=B\#*+}/Bb0-`

The above code contains unprintable characters.

Try it online in the CJam interpreter . If the link doesn't work for you, copy from this paste.

" Push 0, the initial value of R; convert the following array into an integer by
 considering it a base 256 number, then back to the array of its digits in base 6. ";
0"hTHøìð1⁄4Ä¿håêÛ3⁄4aÔ1⁄4"256b6b
" Replace each 5 in the resulting array by [4 4 4 4 4 4 4 4]. This yields the array T
 from the above section. ";
5a/4a8**
" Read an integer N from STDIN and discard all but the first N elements of T. ";
li<
" For each element Y of the remainder of T, do the following: ";
{
 [33:B_B*65_B*1]=\ " Define B := 33, push L, retrieve L[Y] and swap it with R. ";
 _B%8=B\#* " Execute R *= 33 ** (R % 33 == 8). ";
 + " Execute R += L[Y]. ";
}/
" Convert R into the array of its digits in base 33, remove eventual zeros (Palladium)
 and replace the resulting array with its string representation. ";
Bb0-`
added 11 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

The above code uses caret notation for the control characters in the string. It is equivalent to the following code, which uses an array of character codes instead:

To reduce the byte count of the implementation, we represent the electron configuration of an atom as an integer. Each digit of thethat integer in base 33 corresponds to the number of electrons in a shell;certain shells; the least significant digit corresponds torepresents the outer shell.

" Push 0, the initial value of R; convert the following array into an integer by
 considering it a base 256 number, then back to the array of its digits in base 6. ";
0[104 84 72C248 236 240I188 196 24 191 104 229 234 219 190 170 212 7 134 25 134 188H]
256b6b
" Replace each 5 in the resulting array by [4 4 4 4 4 4 4 4]. This yields the array T
 from the above section. ";
5a/4a8**
" Read an integer N from STDIN and discard all but the first N elements of T. ";
li<
" For each element Y of the remainder of T, do the following: ";
{
 [33:B_B*65_B*1]=\ " Define B := 33, push L, retrieve L[Y] and swap it with R. ";
 _B%8=B\#* " Execute R *= 33 ** (R % 33 == 8). ";
 + " Execute R += L[Y]. ";
}/
" Convert R into the array of its digits in base 33, remove eventual zeros (Palladium)
 and replace the resulting array bywith its string representation. ";
Bb0-`

The above code uses caret notation for the control characters in the string. It is equivalent to the following code, which an array of character codes instead:

To reduce the byte count of the implementation, we represent the electron configuration of an atom as an integer. Each digit of the integer in base 33 corresponds to the number of electrons in a shell; the least significant digit corresponds to the outer shell.

" Push 0, the initial value of R; convert the following array into an integer by
 considering it a base 256 number, then back to the array of its digits in base 6. ";
0[104 84 72C248 236 240I188 196 24 191 104 229 234 219 190 170 212 7 134 25 134 188H]
256b6b
" Replace each 5 in the resulting array by [4 4 4 4 4 4 4 4]. This yields the array T
 from the above section. ";
5a/4a8**
" Read an integer N from STDIN and discard all but the first N elements of T. ";
li<
" For each element Y of the remainder of T, do the following: ";
{
 [33:B_B*65_B*1]=\ " Define B := 33, push L, retrieve L[Y] and swap it with R. ";
 _B%8=B\#* " Execute R *= 33 ** (R % 33 == 8). ";
 + " Execute R += L[Y]. ";
}/
" Convert R into the array of its digits in base 33, remove eventual zeros (Palladium)
 and replace the resulting array by its string representation. ";
Bb0-`

The above code uses caret notation for the control characters in the string. It is equivalent to the following code, which uses an array of character codes instead:

To reduce the byte count of the implementation, we represent the electron configuration of an atom as an integer. Each digit of that integer in base 33 corresponds to the number of electrons in a certain shells; the least significant digit represents the outer shell.

" Push 0, the initial value of R; convert the following array into an integer by
 considering it a base 256 number, then back to the array of its digits in base 6. ";
0[104 84 72C248 236 240I188 196 24 191 104 229 234 219 190 170 212 7 134 25 134 188H]
256b6b
" Replace each 5 in the resulting array by [4 4 4 4 4 4 4 4]. This yields the array T
 from the above section. ";
5a/4a8**
" Read an integer N from STDIN and discard all but the first N elements of T. ";
li<
" For each element Y of the remainder of T, do the following: ";
{
 [33:B_B*65_B*1]=\ " Define B := 33, push L, retrieve L[Y] and swap it with R. ";
 _B%8=B\#* " Execute R *= 33 ** (R % 33 == 8). ";
 + " Execute R += L[Y]. ";
}/
" Convert R into the array of its digits in base 33, remove eventual zeros (Palladium)
 and replace the resulting array with its string representation. ";
Bb0-`
added 89 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

The above code uses caret notation for the control characters in the string. It is equivalent to the following code, which an array of character codecodes instead:

To reduce the byte count of the implementation, we represent the electron configurationsconfiguration of an atom as an integer. Each digit of the integer in base 33 corresponds to the number of electrons in a shell; the least significant digit corresponds to the outer shell.

  • R += 1 (add an electron to the outer shell)
  • R += 33 (add an electron to the second outer shell)
  • R += 65 (add two electrons to the second outer shell; remove one from the first)
  • R += 1089 (add an electron to the third outer shell)
  • R += 2145 (add two electrons to the third outer shell; remove one from the second)
  • R *= 33, +R += 1 (add a new shell containing a single electron)

All that's left tois to encode somehow encode which transformation has to be applied to pass from onea particular atom to the next. The differences of the integer representations of two consecutive atomatoms are the followingas follows:

The unique differences in this arrasarray are the following:

Since we have to add a new shell if and only if the current atom has exactly eight electrons in its outer shell (with the exception of He (2) ↦ Li (3), which can be encoded as add 65), we can encode those transformations as add 1 and determine the need for multiplication on the fly.

The above code uses caret notation for the control characters in the string. It is equivalent to the following code, which an array of character code instead:

To reduce the byte count of the implementation, we represent the electron configurations of an atom as an integer. Each digit of the integer in base 33 corresponds to the number of electrons in a shell; the least significant digit corresponds to the outer shell.

  • R += 1 (add an electron to the outer shell)
  • R += 33 (add an electron to the second outer shell)
  • R += 65 (add two electrons to the second outer shell; remove one from the first)
  • R += 1089 (add an electron to the third outer shell)
  • R += 2145 (add two electrons to the third outer shell; remove one from the second)
  • R *= 33 + 1 (add a new shell containing a single electron)

All that's left to to encode somehow which transformation has to be applied to pass from one atom to the next. The differences of the integer representations of two consecutive atom are the following:

The unique differences in this arras are the following:

Since we have to add a new shell if and only if the current atom has exactly eight electrons in its outer shell, we can encode those transformations as add 1 and determine the need for multiplication on the fly.

The above code uses caret notation for the control characters in the string. It is equivalent to the following code, which an array of character codes instead:

To reduce the byte count of the implementation, we represent the electron configuration of an atom as an integer. Each digit of the integer in base 33 corresponds to the number of electrons in a shell; the least significant digit corresponds to the outer shell.

  • R += 1 (add an electron to the outer shell)
  • R += 33 (add an electron to the second outer shell)
  • R += 65 (add two electrons to the second outer shell; remove one from the first)
  • R += 1089 (add an electron to the third outer shell)
  • R += 2145 (add two electrons to the third outer shell; remove one from the second)
  • R *= 33, R += 1 (add a new shell containing a single electron)

All that's left is to somehow encode which transformation has to be applied to pass from a particular atom to the next. The differences of the integer representations of two consecutive atoms are as follows:

The unique differences in this array are the following:

Since we have to add a new shell if and only if the current atom has exactly eight electrons in its outer shell (with the exception of He (2) ↦ Li (3), which can be encoded as add 65), we can encode those transformations as add 1 and determine the need for multiplication on the fly.

added 5 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading
added 3464 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading
deleted 13 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading
added 6 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading
added 2299 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading

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