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

#10 instead of chr(10)
Source Link
AlexRacer
  • 1k
  • 1
  • 6
  • 11

Pascal (FPC) -Sew, 6 bytes per line, 348(削除) 348 (削除ここまで) 320 bytes

var
n,i://
word//
;begin
read//
(n);//
for
i:=1to
n do
if 0=i
mod
15then
write{
$}(//
'A',//
'p',//
'p',//
'l',//
'e',//
'P',//
'i',//
'e',//
chr(//
10)#10)//
else
if 0=i
mod
3then
write{
$}(//
'A',//
'p',//
'p',//
'l',//
'e',//
chr(//
10)#10)//
else
if 0=i
mod
5then
write{
$}(//
'P',//
'i',//
'e',//
chr(//
10)#10)//
else
write{
$}(i//
,chr//
(10)#10//
)end.

Try it online! Try it online!

Utilises FPC to get 6 bytes per line; without it, the result would be much worse. This is the smallest possible line width since after write must be either ; or ( (or unnecessary whitespace), so a special comment is inserted to avoid this. The features from FPC which influenced this answer are:

  1. // - starting one-line comments.
  2. Block comments in form {$<something>...} are compiler directives. If the directive does not exist, FPC will issue a warning (and on {$ ...} as well). In this program, { and $ are separated with a newline which will issue the warning when deleted.
  3. -Sew - Compiler also halts after warnings so that { and $ joined stop the compilation.

Pascal (FPC) -Sew, 6 bytes per line, 348 bytes

var
n,i://
word//
;begin
read//
(n);//
for
i:=1to
n do
if 0=i
mod
15then
write{
$}(//
'A',//
'p',//
'p',//
'l',//
'e',//
'P',//
'i',//
'e',//
chr(//
10))//
else
if 0=i
mod
3then
write{
$}(//
'A',//
'p',//
'p',//
'l',//
'e',//
chr(//
10))//
else
if 0=i
mod
5then
write{
$}(//
'P',//
'i',//
'e',//
chr(//
10))//
else
write{
$}(i//
,chr//
(10)//
)end.

Try it online!

Utilises FPC to get 6 bytes per line; without it, the result would be much worse. This is the smallest possible line width since after write must be either ; or ( (or unnecessary whitespace), so a special comment is inserted to avoid this. The features from FPC which influenced this answer are:

  1. // - starting one-line comments.
  2. Block comments in form {$<something>...} are compiler directives. If the directive does not exist, FPC will issue a warning (and on {$ ...} as well). In this program, { and $ are separated with a newline which will issue the warning when deleted.
  3. -Sew - Compiler also halts after warnings so that { and $ joined stop the compilation.

Pascal (FPC) -Sew, 6 bytes per line, (削除) 348 (削除ここまで) 320 bytes

var
n,i://
word//
;begin
read//
(n);//
for
i:=1to
n do
if 0=i
mod
15then
write{
$}(//
'A',//
'p',//
'p',//
'l',//
'e',//
'P',//
'i',//
'e',//
#10)//
else
if 0=i
mod
3then
write{
$}(//
'A',//
'p',//
'p',//
'l',//
'e',//
#10)//
else
if 0=i
mod
5then
write{
$}(//
'P',//
'i',//
'e',//
#10)//
else
write{
$}(i//
,#10//
)end.

Try it online!

Utilises FPC to get 6 bytes per line; without it, the result would be much worse. This is the smallest possible line width since after write must be either ; or ( (or unnecessary whitespace), so a special comment is inserted to avoid this. The features from FPC which influenced this answer are:

  1. // - starting one-line comments.
  2. Block comments in form {$<something>...} are compiler directives. If the directive does not exist, FPC will issue a warning (and on {$ ...} as well). In this program, { and $ are separated with a newline which will issue the warning when deleted.
  3. -Sew - Compiler also halts after warnings so that { and $ joined stop the compilation.
Source Link
AlexRacer
  • 1k
  • 1
  • 6
  • 11

Pascal (FPC) -Sew, 6 bytes per line, 348 bytes

var
n,i://
word//
;begin
read//
(n);//
for
i:=1to
n do
if 0=i
mod
15then
write{
$}(//
'A',//
'p',//
'p',//
'l',//
'e',//
'P',//
'i',//
'e',//
chr(//
10))//
else
if 0=i
mod
3then
write{
$}(//
'A',//
'p',//
'p',//
'l',//
'e',//
chr(//
10))//
else
if 0=i
mod
5then
write{
$}(//
'P',//
'i',//
'e',//
chr(//
10))//
else
write{
$}(i//
,chr//
(10)//
)end.

Try it online!

Utilises FPC to get 6 bytes per line; without it, the result would be much worse. This is the smallest possible line width since after write must be either ; or ( (or unnecessary whitespace), so a special comment is inserted to avoid this. The features from FPC which influenced this answer are:

  1. // - starting one-line comments.
  2. Block comments in form {$<something>...} are compiler directives. If the directive does not exist, FPC will issue a warning (and on {$ ...} as well). In this program, { and $ are separated with a newline which will issue the warning when deleted.
  3. -Sew - Compiler also halts after warnings so that { and $ joined stop the compilation.

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