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

Commonmark migration
Source Link

#PHP, (削除) 1217 (削除ここまで) 1081

PHP, (削除) 1217 (削除ここまで) 1081

The code:

for(;$T!=T;$T=($T+52)%95)echo chr(32+$T);

Because the variables are not initialized, it needs to suppress the notices on running (PHP complains but continues execution and uses a default value that is appropriate in the context; 0 in this case):

$ php -d error_reporting=0 remapping-ascii.php

Its output:

 T)]2f;oDxM"V+_4h=qFzO$X-a6j?sH|Q&Z/c8lAuJ~S(1円e:nCwL!U*^3g<pEyN#W,`5i>rG{P%Y.b7k@tI}R'[0d9mBvK

Remarks:

  • the output starts with a white space (chr(32));
  • the code prints the white space then each 52th character, wrapping around the range;
  • the magic number 52 was "discovered" by searching the entire range (1..94) of possible offsets; 1 produces the list of printable chars in the ascending order of their ASCII codes, 94 produces the list in the reverse order, both are bad; the multiples of 5 and 19 (the divisors of 95) produce short cycles and don't cover the entire range of values (also bad);
  • 52 seems to be magic; it is the best offset for this code; but it is also the best for some variations of the code (that produce slightly bigger scores); the variations I tried: use while() instead of for(), use $f++, $f-- or --$f instead of ++$f, swap the operands around the < and + operators; squeeze the modification of $T into 32+$T;
  • the names of the variables ($T and $f) are the first letters from the output;
  • I tried to initialize $T with 4 or 11 but the scores were worse; starting with 4 makes $ the first character in the output; it is the most used character in a PHP source code; 11 brings + in front; $ and + are the most used characters in this code.

The code, tests, incremental changes I tried until I reached this solution and the script that tested all possible step values (the authoritative provider for 52 as the best step) can be found on github.

#PHP, (削除) 1217 (削除ここまで) 1081

The code:

for(;$T!=T;$T=($T+52)%95)echo chr(32+$T);

Because the variables are not initialized, it needs to suppress the notices on running (PHP complains but continues execution and uses a default value that is appropriate in the context; 0 in this case):

$ php -d error_reporting=0 remapping-ascii.php

Its output:

 T)]2f;oDxM"V+_4h=qFzO$X-a6j?sH|Q&Z/c8lAuJ~S(1円e:nCwL!U*^3g<pEyN#W,`5i>rG{P%Y.b7k@tI}R'[0d9mBvK

Remarks:

  • the output starts with a white space (chr(32));
  • the code prints the white space then each 52th character, wrapping around the range;
  • the magic number 52 was "discovered" by searching the entire range (1..94) of possible offsets; 1 produces the list of printable chars in the ascending order of their ASCII codes, 94 produces the list in the reverse order, both are bad; the multiples of 5 and 19 (the divisors of 95) produce short cycles and don't cover the entire range of values (also bad);
  • 52 seems to be magic; it is the best offset for this code; but it is also the best for some variations of the code (that produce slightly bigger scores); the variations I tried: use while() instead of for(), use $f++, $f-- or --$f instead of ++$f, swap the operands around the < and + operators; squeeze the modification of $T into 32+$T;
  • the names of the variables ($T and $f) are the first letters from the output;
  • I tried to initialize $T with 4 or 11 but the scores were worse; starting with 4 makes $ the first character in the output; it is the most used character in a PHP source code; 11 brings + in front; $ and + are the most used characters in this code.

The code, tests, incremental changes I tried until I reached this solution and the script that tested all possible step values (the authoritative provider for 52 as the best step) can be found on github.

PHP, (削除) 1217 (削除ここまで) 1081

The code:

for(;$T!=T;$T=($T+52)%95)echo chr(32+$T);

Because the variables are not initialized, it needs to suppress the notices on running (PHP complains but continues execution and uses a default value that is appropriate in the context; 0 in this case):

$ php -d error_reporting=0 remapping-ascii.php

Its output:

 T)]2f;oDxM"V+_4h=qFzO$X-a6j?sH|Q&Z/c8lAuJ~S(1円e:nCwL!U*^3g<pEyN#W,`5i>rG{P%Y.b7k@tI}R'[0d9mBvK

Remarks:

  • the output starts with a white space (chr(32));
  • the code prints the white space then each 52th character, wrapping around the range;
  • the magic number 52 was "discovered" by searching the entire range (1..94) of possible offsets; 1 produces the list of printable chars in the ascending order of their ASCII codes, 94 produces the list in the reverse order, both are bad; the multiples of 5 and 19 (the divisors of 95) produce short cycles and don't cover the entire range of values (also bad);
  • 52 seems to be magic; it is the best offset for this code; but it is also the best for some variations of the code (that produce slightly bigger scores); the variations I tried: use while() instead of for(), use $f++, $f-- or --$f instead of ++$f, swap the operands around the < and + operators; squeeze the modification of $T into 32+$T;
  • the names of the variables ($T and $f) are the first letters from the output;
  • I tried to initialize $T with 4 or 11 but the scores were worse; starting with 4 makes $ the first character in the output; it is the most used character in a PHP source code; 11 brings + in front; $ and + are the most used characters in this code.

The code, tests, incremental changes I tried until I reached this solution and the script that tested all possible step values (the authoritative provider for 52 as the best step) can be found on github.

Shortened the code (it produces the same output), reduced the score.
Source Link
axiac
  • 769
  • 6
  • 13

#PHP, 1217(削除) 1217 (削除ここまで) 1081

The code:

for(;++$f<96;$T=;$T!=T;$T=($T+52)%95)echo chr(32+$T);

Because the variables are not initialized, it needs to suppress the notices on running (PHP complains but continues execution and uses a default value that is appropriate in the context; 0 in this case):

$ php -d error_reporting=0 remapping-ascii.php

Its output:

 T)]2f;oDxM"V+_4h=qFzO$X-a6j?sH|Q&Z/c8lAuJ~S(1円e:nCwL!U*^3g<pEyN#W,`5i>rG{P%Y.b7k@tI}R'[0d9mBvK

Remarks:

  • the output starts with a white space (chr(32));
  • the code prints the white space then each 52th character, wrapping around the range;
  • the magic number 52 was "discovered" by searching the entire range (1..94) of possible offsets; 1 produces the list of printable chars in the ascending order of their ASCII codes, 94 produces the list in the reverse order, both are bad; the multiples of 5 and 19 (the divisors of 95) produce short cycles and don't cover the entire range of values (also bad);
  • 52 seems to be magic; it is the best offset for this code; but it is also the best for some variations of the code (that produce slightly bigger scores); the variations I tried: use while() instead of for(), use $f++, $f-- or --$f instead of ++$f, swap the operands around the < and + operators; squeeze the modification of $T into 32+$T;
  • the names of the variables ($T and $f) are the first letters from the output;
  • I tried to initialize $T with 4 or 11 but the scores were worse; starting with 4 makes $ the first character in the output; it is the most used character in a PHP source code; 11 brings + in front; $ and + are the most used characters in this code.

The code, tests, incremental changes I tried until I reached this solution and the script that tested all possible step values (the authoritative provider for 52 as the best step) can be found on github .

#PHP, 1217

The code:

for(;++$f<96;$T=($T+52)%95)echo chr(32+$T);

Because the variables are not initialized, it needs to suppress the notices on running (PHP complains but continues execution and uses a default value that is appropriate in the context; 0 in this case):

$ php -d error_reporting=0 remapping-ascii.php

Its output:

 T)]2f;oDxM"V+_4h=qFzO$X-a6j?sH|Q&Z/c8lAuJ~S(1円e:nCwL!U*^3g<pEyN#W,`5i>rG{P%Y.b7k@tI}R'[0d9mBvK

Remarks:

  • the output starts with a white space (chr(32));
  • the code prints the white space then each 52th character, wrapping around the range;
  • the magic number 52 was "discovered" by searching the entire range (1..94) of possible offsets; 1 produces the list of printable chars in the ascending order of their ASCII codes, 94 produces the list in the reverse order, both are bad; the multiples of 5 and 19 (the divisors of 95) produce short cycles and don't cover the entire range of values (also bad);
  • 52 seems to be magic; it is the best offset for this code; but it is also the best for some variations of the code (that produce slightly bigger scores); the variations I tried: use while() instead of for(), use $f++, $f-- or --$f instead of ++$f, swap the operands around the < and + operators; squeeze the modification of $T into 32+$T;
  • the names of the variables ($T and $f) are the first letters from the output;
  • I tried to initialize $T with 4 or 11 but the scores were worse; starting with 4 makes $ the first character in the output; it is the most used character in a PHP source code; 11 brings + in front; $ and + are the most used characters in this code.

#PHP, (削除) 1217 (削除ここまで) 1081

The code:

for(;$T!=T;$T=($T+52)%95)echo chr(32+$T);

Because the variables are not initialized, it needs to suppress the notices on running (PHP complains but continues execution and uses a default value that is appropriate in the context; 0 in this case):

$ php -d error_reporting=0 remapping-ascii.php

Its output:

 T)]2f;oDxM"V+_4h=qFzO$X-a6j?sH|Q&Z/c8lAuJ~S(1円e:nCwL!U*^3g<pEyN#W,`5i>rG{P%Y.b7k@tI}R'[0d9mBvK

Remarks:

  • the output starts with a white space (chr(32));
  • the code prints the white space then each 52th character, wrapping around the range;
  • the magic number 52 was "discovered" by searching the entire range (1..94) of possible offsets; 1 produces the list of printable chars in the ascending order of their ASCII codes, 94 produces the list in the reverse order, both are bad; the multiples of 5 and 19 (the divisors of 95) produce short cycles and don't cover the entire range of values (also bad);
  • 52 seems to be magic; it is the best offset for this code; but it is also the best for some variations of the code (that produce slightly bigger scores); the variations I tried: use while() instead of for(), use $f++, $f-- or --$f instead of ++$f, swap the operands around the < and + operators; squeeze the modification of $T into 32+$T;
  • the names of the variables ($T and $f) are the first letters from the output;
  • I tried to initialize $T with 4 or 11 but the scores were worse; starting with 4 makes $ the first character in the output; it is the most used character in a PHP source code; 11 brings + in front; $ and + are the most used characters in this code.

The code, tests, incremental changes I tried until I reached this solution and the script that tested all possible step values (the authoritative provider for 52 as the best step) can be found on github .

Source Link
axiac
  • 769
  • 6
  • 13

#PHP, 1217

The code:

for(;++$f<96;$T=($T+52)%95)echo chr(32+$T);

Because the variables are not initialized, it needs to suppress the notices on running (PHP complains but continues execution and uses a default value that is appropriate in the context; 0 in this case):

$ php -d error_reporting=0 remapping-ascii.php

Its output:

 T)]2f;oDxM"V+_4h=qFzO$X-a6j?sH|Q&Z/c8lAuJ~S(1円e:nCwL!U*^3g<pEyN#W,`5i>rG{P%Y.b7k@tI}R'[0d9mBvK

Remarks:

  • the output starts with a white space (chr(32));
  • the code prints the white space then each 52th character, wrapping around the range;
  • the magic number 52 was "discovered" by searching the entire range (1..94) of possible offsets; 1 produces the list of printable chars in the ascending order of their ASCII codes, 94 produces the list in the reverse order, both are bad; the multiples of 5 and 19 (the divisors of 95) produce short cycles and don't cover the entire range of values (also bad);
  • 52 seems to be magic; it is the best offset for this code; but it is also the best for some variations of the code (that produce slightly bigger scores); the variations I tried: use while() instead of for(), use $f++, $f-- or --$f instead of ++$f, swap the operands around the < and + operators; squeeze the modification of $T into 32+$T;
  • the names of the variables ($T and $f) are the first letters from the output;
  • I tried to initialize $T with 4 or 11 but the scores were worse; starting with 4 makes $ the first character in the output; it is the most used character in a PHP source code; 11 brings + in front; $ and + are the most used characters in this code.

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