Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Comments on Print the alphabet using alphabetic source

Post

Print the alphabet using alphabetic source

+2
−0

The task is to write a program that takes no input and prints the English alphabet in upper-case letters. It can be printed either as a single line ABCDEFGHIJKLMNOPQRSTUVWXYZ, or as letters separated by spaces, or as letters separated by new line.

This is code golf, so the shortest program in each programming language wins. However, there are special rules for this challenge:

  • The source code must be formatted in multiple lines, 26 in total.
  • The first letter symbol encountered on each line in the source must correspond to a letter in the alphabet, upper or lower case, and they must be placed in alphabetic order. So the first letter found on the first line must be A or a, the first letter on the next line must be B or b and so on.
  • Only the first letter encountered on that line counts as the letter for that line.
  • Other symbols that are not letters A to Z may occur anywhere.
  • The source may not contain comments.
  • Only complete stand-alone programs are accepted, not function solutions.

Example of an accepted program in standard C:

_Atomic int a=0x\
B\
C;
#define j int
extern char*
f=
"G"
"H";
#include <stdio.h>
j main (void){
k:;
long 
m,
n,
o;
puts("ABCDEFGHIJKLMNOP"
"Q"
"R"
"S"
"T"
"U"
"V"
"W"
"X"
"Y"
"Z");}

Try it online!

Output

ABCDEFGHIJKLMNOPQRSTUVWXYZ
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (12 comments)
General comments
Lundin‭ wrote almost 4 years ago · edited almost 4 years ago

Curious to know how if the 26 line requirement holds in plenty enough different languages or if too many languages enforces either stand-alone symbol-only lines, or non-alphabetic order (for example VB Private Sub... End wouldn't work since that language enforces line feed formatting with End on a line of its own).

Razetime‭ wrote almost 4 years ago

Where do unicode alphabet characters(ṙ,ṡ,ṫ) fit in this?

Lundin‭ wrote almost 4 years ago

@Razetime I think we should allow any source code format?

DJMcMayhem‭ wrote almost 4 years ago

"No comments allowed" Are languages where alphabetic characters ignored not allowed then? e.g. brainfuck?

Lundin‭ wrote almost 4 years ago

@DJMcMayhem‭ Yeah it won't be possible to solve this challenge in Brainfuck and similar languages.

Razetime‭ wrote almost 4 years ago

I mean, do unicode alphabets count as alphabetical characters or non alphabet chars?

Razetime‭ wrote almost 4 years ago

Also, if this is code-golf, there's no need for an alternative scoring tag.

Lundin‭ wrote almost 4 years ago

The only requirement is that the symbols must visually appear as "ABC..." etc and the underlying encoding symbol table doesn't matter.

Hakerh400‭ wrote almost 4 years ago · edited almost 4 years ago

"The source may not contain comments" - that is unobservable.

Lundin‭ wrote almost 4 years ago

@Hakerh400 How so? It's pretty clear what a comment consists of in most languages?

Hakerh400‭ wrote almost 4 years ago

"in most" does not mean "in all". Many esoteric languages do not have a clear notion of what a comment is.

Lundin‭ wrote almost 4 years ago

@Hakerh400 Ok. I have a feeling overall that these requirements would rule out a lot of languages, why I never posted it.