-1
\$\begingroup\$

You need to print A-Z like this:

1. A
2. B
3. C
4. D
5. E
6. F
7. G
8. H
9. I
10. J
11. K
12. L
13. M
14. N
15. O
16. P
17. Q
18. R
19. S
20. T
21. U
22. V
23. W
24. X
25. Y
26. Z

But your source code cannot use 1,2,4,6.

Trailing newlines in output allowed,, but leading ones not allowed.

Standard loopholes apply, shortest code wins.

\$\endgroup\$
2
  • 12
    \$\begingroup\$ This is pretty much a duplicate of many existing restricted-source kolmogorov-complexity "print X without Y" challenges, and the ban on 1 2 4 and 6 is arbitrary and unchallenging, \$\endgroup\$ – pxeger Feb 28 at 11:09
  • 10
    \$\begingroup\$ In future, please use the Sandbox to get feedback on your question before posting. \$\endgroup\$ – pxeger Feb 28 at 11:09

31 Answers 31

6
\$\begingroup\$

APL (Dyalog Extended), 19 bytes (SBCS)

↑(⍳∘≢,⍥⍕¨'. '∘,¨)⎕A

Try it online!

⎕A the uppercase Alphabet

() apply the following tacit function:

'. '∘,¨ prepend ". " to each letter.

,⍥⍕¨ concatenate the string representation of each to the string representation of:

  ⍳∘≢ the ɩndices of the length of the alphabet

 "mix" the list of strings into a character matrix

\$\endgroup\$
6
\$\begingroup\$

JavaScript (Node.js), 48 bytes

f=(n=033)=>--n?f(n)+n+`. ${Buffer([8*8|n])}
`:''

Try it online!

\$\endgroup\$
6
\$\begingroup\$

Python 2, 44 bytes

i=8*8
while i<90:i=-~i;print`i-8*8`+'. %c'%i

Try it online!

46 bytes

i=0
while i<33-7:i=-~i;print'%d. %c'%(i,i+8*8)

Try it online!

The loop condition can also be while-~i/9-3: or while~-i/5-5 or while-i/5-~5: or while~-i-5*5: or while~-033>i.

46 bytes

i=0
exec 78/3*"i=-~i;print'%d. %c'%(i,i+8*8);"

Try it online!

46 bytes

i=8*8
while i<90:i=-~i;print'%d. %c'%(i-8*8,i)

Try it online!

46 bytes

i=0
while~i-5*5:i=~-i;print'%d. %c'%(-i,8*8-i)

Try it online!

46 bytes

i=8*8
while i<90:i=-~i;print'%d. %c'%(i&799,i)

Try it online!

47 bytes

for i in range(33-7):print"%d. %c"%(-~i,8*8-~i)

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ @ovs The issue is that 1's are banned \$\endgroup\$ – xnor Feb 28 at 11:26
  • \$\begingroup\$ Does this work for 44 bytes? \$\endgroup\$ – dingledooper Feb 28 at 11:55
  • \$\begingroup\$ @dingledooper Yes, I had just gotten exactly that too \$\endgroup\$ – xnor Feb 28 at 11:57
6
\$\begingroup\$

PHP, 45 40 39 38 bytes

for($c=A;$c<>AA;$c++)echo++$i,". $c
";

Try it online!

-1 thanks to Kaddath

\$\endgroup\$
2
  • 1
    \$\begingroup\$ The new line can be a "literal" new line in the string like this to save 1 byte \$\endgroup\$ – Kaddath Mar 1 at 10:30
  • \$\begingroup\$ Didn't know about that, thanks! \$\endgroup\$ – Cray Mar 1 at 17:43
4
\$\begingroup\$

05AB1E, 9 bytes

Auā'.«sø»

Try it online!

A          # push the lowercase alphabet
 u         # convert to uppercase
  ā        # push the range [1 .. len(alphabet)]
   '.«    '# append '.' to each number
      s    # swap to the alphabet
       ø   # zip both lists => [['1.', 'A'], ..., ['26.', 'Z']]
        »  # join each inner list by spaces and the outer list by newlines
\$\endgroup\$
4
\$\begingroup\$

Charcoal, 9 bytes

Eα⁺⁺⊕κ. ι

Try it online! Link is to verbose version of code. Explanation:

 α          Predefined variable uppercase alphabet
E           Map over characters
     κ      Current index (0-indexed)
    ⊕       Incremented
      .     Literal string `. `
        ι   Current character
  ⁺⁺        All concatenated
            Implicitly print on separate lines
\$\endgroup\$
4
\$\begingroup\$

Zsh, 27 bytes

eval ';echo $[++i]. '{A..Z}

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Perl 5.10, 22 bytes

say++$..". $_"for A..Z

Try it online!

\$\endgroup\$
3
\$\begingroup\$

R, 33 bytes

write.table(LETTERS,,,F,". ",c=F)

Try it online!

\$\endgroup\$
2
\$\begingroup\$

PowerShell, 41 bytes

(8-7)..(33-7)|%{"$($_). "+[char]($_+8*8)}

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Python 3, 52 50 bytes

for x in range(8-7,33-6):print(f"{x}.",chr(x+8*8))

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ 50 bytes \$\endgroup\$ – ovs Feb 28 at 10:55
  • \$\begingroup\$ @ovs thanks for that! \$\endgroup\$ – Wasif Feb 28 at 10:56
  • \$\begingroup\$ 46 bytes \$\endgroup\$ – Jiří Mar 1 at 16:23
2
\$\begingroup\$

Retina 0.8.2, 49 bytes


ABCDEFGHIJKLMNOPQRSTUVWXYZ
.
$`$&¶
.*(.)
$.&. $+

Try it online! Explanation:


ABCDEFGHIJKLMNOPQRSTUVWXYZ

Insert the alphabet. (This is the shortest way of doing it without using the digits 2 or 6.)

.
$`$&¶

Generate all the prefixes.

.*(.)
$.&. $+

Replace each prefix with its length, . , and its last character ($+ actually means the last captured group in Retina 0.8.2).

\$\endgroup\$
2
  • \$\begingroup\$ You have a 1 that snuck in \$\endgroup\$ – xnor Feb 28 at 11:25
  • \$\begingroup\$ @xnor Luckily Retina 0.8.2 gives me an alternate way of referring to that capture group! \$\endgroup\$ – Neil Feb 28 at 11:28
2
\$\begingroup\$

Canvas, 8 bytes

Z{²O. oo

Try it here!, alternate version

The only reason this is shorter than charcoal is because it's got a 1-indexed iteration count.

Explanation

Z{²O. oo
Z{       loop over the alphabet
  ²O     output the iteration number
    . o  output ". "
       o output the current letter     
\$\endgroup\$
2
\$\begingroup\$

PowerShell, 25 bytes

'A'..'Z'|%{++$i;"$i. $_"}

Try it online!

\$\endgroup\$
2
\$\begingroup\$

BASIC, 41 bytes

for i=!0 to 33-7:?i,". ",chr$(8*8+i):next

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Javascript (Browser console), 58 bytes

for(i=0;i<35-9;)alert(++i+". "+String.fromCharCode(i+8*8))

-2 bytes thanks to @expressjs123 -3 bytes thanks to @tsh

\$\endgroup\$
4
  • \$\begingroup\$ 67 bytes: for(i=8-7;i<35-8;i++)console.log(i+". "+String.fromCharCode(i+8*8)) \$\endgroup\$ – ophact Feb 28 at 11:17
  • \$\begingroup\$ 64 bytes: for(i=0;i<35-9;)console.log(++i+". "+String.fromCharCode(i+8*8)) \$\endgroup\$ – tsh Mar 1 at 8:40
  • \$\begingroup\$ @tsh thanks for it \$\endgroup\$ – Wasif Mar 1 at 8:42
  • \$\begingroup\$ @expressjs123 thanks for it \$\endgroup\$ – Wasif Mar 1 at 8:43
1
\$\begingroup\$

Retina, 27 bytes


3*9*@
Y`@`L_
L$`.
$.>`. $&

Try it online! Explanation:


3*9*@

Insert 27 @s. (Best I can do since I can't use 2 or 6.)

Y`@`L_

Replace each @ with subsequent uppercase letters, but delete the last one.

L$`.

Match each letter.

$.>`. $&

For each letter, output its 1-indexed index, . , then the letter.

\$\endgroup\$
1
\$\begingroup\$

Japt, 12 bytes

;B£[YÄLSXR]q

Try it online!

Straightforward, though I feel like there's still room for improvement.

Explanation:

;B£[YÄLSXR]q    #
;               # Store the uppercase alphabet in B
 B£             # Replace each character in B with the following:
   [      ]     #  Make an array containing:
    YÄ          #   The 0-based index of the character + 1 (i.e. 1-based index)
      L         #   Period
       S        #   Space
        X       #   The original character
         R      #   A newline
           q    #  Join the array into a string with no separator
                # Implicitly output the resulting string
\$\endgroup\$
1
\$\begingroup\$

Rust, 56 bytes

||for(i,x)in(9..).zip('A'..'['){print!("{}. {}
",i-8,x)}
\$\endgroup\$
1
\$\begingroup\$

Jelly, 10 9 bytes

ØAĖj€⁾. Y

Try it online!

How it works

ØAĖj€⁾. Y - Main link. Takes no arguments
ØA        - Yield the uppercase alphabet and set as the left and right arguments
  Ė       - Enumerate
   j€⁾.   - Join each pair with ". "
        Y - Join with newlines and output
\$\endgroup\$
2
  • \$\begingroup\$ Ė saves 1 over . \$\endgroup\$ – Jonathan Allan Feb 28 at 22:15
  • \$\begingroup\$ @JonathanAllan Very nice! \$\endgroup\$ – caird coinheringaahing Feb 28 at 22:17
1
\$\begingroup\$

Java, 62 bytes

$->{for(char c='@';++c<'[';)System.out.println(c-'@'+". "+c);}

Try it online!

Java, 95 bytes

$->java.util.stream.IntStream.range('A','[').forEach(i->System.out.println(i-'@'+". "+(char)i))

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Lua (55 bytes)

for i=7%3,33-7 do print(i..". "..(8*8+i..""):char())end
\$\endgroup\$
1
\$\begingroup\$

Bash, 41 bytes

echo {A..Z}|tr ' ' '
'|nl -s". " -w$[8-7]

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Julia, 37 bytes

print.("$(i-'@'). $i
" for i='A':'Z')

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Vyxal, j, 10 bytes

αɾkAZƛı. j

Try it Online!

\$\endgroup\$
0
\$\begingroup\$

C

main() { for(int i='A',j=0;i<='Z';j++,printf("%d. %c\n",j,i),i++);}

If for some, this wouldn't work:

#include <stdio.h>
void main() { for(int i='A',j=0;i<='Z';j++,printf("%d. %c\n",j,i),i++);}
\$\endgroup\$
9
  • 1
    \$\begingroup\$ using void main will give a warning, but allow you to omit return 0. \$\endgroup\$ – Razetime Feb 28 at 11:23
  • 1
    \$\begingroup\$ You're not allowed to use 1, but you can use j=0 and ++j instead. \$\endgroup\$ – Neil Feb 28 at 11:26
  • 1
    \$\begingroup\$ Why not remove the spaces? Also you can change i<='Z' to i<'[' and put the j++ and i++ inside the printf call, and remove the =0 because j will be initialised to 0 implicitly \$\endgroup\$ – pxeger Feb 28 at 17:20
  • 1
    \$\begingroup\$ @pxeger I know it will as a global, but not as a local surely? \$\endgroup\$ – Neil Mar 2 at 0:59
  • 1
    \$\begingroup\$ @Neil I'm not a C expert so I'm not sure, but it seems to work on GCC - Try it online! \$\endgroup\$ – pxeger Mar 2 at 10:00
0
\$\begingroup\$

C (gcc), 50 bytes

main(i){for(;i<3*9;printf("%d. %c\n",i++,i+8*8));}

Try it online!

f(i){for(i=0;++i<3*9;printf("%d. %c\n",i,i+8*8));}

Try it online!

\$\endgroup\$
0
0
\$\begingroup\$

C (gcc), 50 bytes

f(i){for(i=0;++i<033;)printf("%d. %c\n",i,i+'@');}

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ You are missing the space after the dot and you can save 1 byte with f(i) \$\endgroup\$ – Sheik Yerbouti Feb 28 at 11:38
  • 1
    \$\begingroup\$ @SheikYerbouti Fixed, thanks! :) \$\endgroup\$ – Noodle9 Feb 28 at 11:41
0
\$\begingroup\$

Stax, 9 8 bytes

τ┌Z*µ╝╘Q

Run and debug it

\$\endgroup\$
0
\$\begingroup\$

Pyth, 15 bytes

j.e+++hk\.dbrG1

Try it online!


Python 3 translation:

G = "abcdefghijklmnopqrstuvwzyz"

print("\n".join(map(lambda(k,b):str(k+1)+"."+" "+b,enumerate(G.upper()))))
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.