88
\$\begingroup\$

Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.

Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+0061 or unicode U+0041. Other character encodings that aren't Unicode are allowed, but either way, the resulting output of your code must be the latin letter "A", and not any lookalikes or homoglyphs)

You must not use any of the below characters in your code, regardless of the character encoding that you pick:

  • "A", whether uppercase or lowercase.

  • "U", whether lowercase or uppercase.

  • X, whether uppercase or lowercase.

  • +

  • &

  • #

  • 0

  • 1

  • 4

  • 5

  • 6

  • 7

  • 9

Cheating, loopholes, etc, are not allowed.

Since this is , the shortest solution, in bytes, that follows all the rules, is the winner.


Validity Checker

This Stack Snippet checks to make sure your code doesn't use the restricted characters. It might not work properly for some character encodings.

var t = prompt("Input your code.");

if (/[AaUuXx+&#0145679]/.test(t)) {
  alert("Contains a disallowed character!");
} else {
  alert("No disallowed characters");
}

This Stack Snippet that makes sure you don't have a disallowed character is also available on JSFiddle.

Leaderboard

var QUESTION_ID=90349,OVERRIDE_USER=58717;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

\$\endgroup\$
10
  • 7
    \$\begingroup\$ @ColdGolf You seem to be saying "yes" to functions, but functions don't display, they usually return. \$\endgroup\$
    – xnor
    Commented Aug 19, 2016 at 23:06
  • 2
    \$\begingroup\$ Is ending up with a variable that contains just a also good enough ? \$\endgroup\$
    – Ton Hospel
    Commented Aug 19, 2016 at 23:17
  • 1
    \$\begingroup\$ That's not what I meant. The supposed code doing a variable assignment would not contain any of the forbidden characters. I'm just trying to understand what is covered by "display by means other than printing". If "return from a function" is OK, what about "assign to a variable" ? \$\endgroup\$
    – Ton Hospel
    Commented Aug 20, 2016 at 0:05
  • 1
    \$\begingroup\$ Why those particular characters? \$\endgroup\$ Commented Aug 22, 2016 at 1:32
  • 7
    \$\begingroup\$ @immibis A for obvious reasons. U for Unicode escape strings (\u0041 is A), X for hex escape strings (\x41), + for Unicode ordinals (U+0041), & for HTML entities, # for I actually don't know, 65 is the decimal ordinal of A, 41 is the hex ordinal of A, 97 is the decimal ordinal of a, and 0 for a few of the previous reasons. \$\endgroup\$
    – user45941
    Commented Aug 22, 2016 at 6:26

229 Answers 229

1 2 3
4
5
8
2
\$\begingroup\$

PHP, 15 14 bytes

(PHP7 only) Longer than others but a tricky approach :

<?=([].b)[.2];

[] instance an Array

.b cast to string = 'Array' and add any character (here b) at the end (thank you Business Cat)

[.2] : = [0] take first letter (A)

\$\endgroup\$
4
  • \$\begingroup\$ This is PHP 7 only, right? \$\endgroup\$
    – manatwork
    Commented Aug 22, 2016 at 7:32
  • \$\begingroup\$ You're right PHP7 only, I'll edit \$\endgroup\$
    – Crypto
    Commented Aug 22, 2016 at 9:37
  • 2
    \$\begingroup\$ I can't fully test it since I don't have PHP7, but I think you can replace '' with some letter that is legal to use like b. If you do [].b it will concatenate Array with the string b giving Arrayb. \$\endgroup\$ Commented Aug 22, 2016 at 12:45
  • \$\begingroup\$ Thank you ! You're right. You can test it with any PHP online interpreter. (Errors and Warning can be ignored) \$\endgroup\$
    – Crypto
    Commented Aug 23, 2016 at 5:36
2
\$\begingroup\$

Verbosy, 13 bytes

~` /3 ^3 \3 o

Verbosy is actually a language I wrote (see the link). Hopefully that's allowed...

Explanation:

~`: set Current to the ` character.

/3: put the ` character into slot 3

^3: increment the character in slot 3 by 1

\3: put the character in slot 3 into Current

o: prints Current

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

Kotlin, 22 bytes

{print("${3<2}"[3-2])}

This is a lambda that prints a to the console when invoked. Converts false (3<2) to string via string template and returns the 1-indexed character.

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

R, 12 bytes

I was losing it until I realized I can use 2 and 3.

 LETTERS[3-2]
\$\endgroup\$
2
\$\begingroup\$

QBasic, 17 bytes

PRINT CHR$(88-23)

Exploits the fact that the function which converts an integer to char is named CHR.

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

PowerShell, 89 59 32 Bytes:

[Convert]::ToString((8-3)*2,8*2)

$d=2-2;[char][byte]"".insert($d,(3*3)-(2*2)).insert($d,2*3) $b=[string]::Concat(2*3);$c=[string]::Concat((3*3)-(2*2));[char][byte]$b.insert(2*2-3,$c)

edit: use of a I see no way around this(not a golf language) It is possible...

\$\endgroup\$
1
  • \$\begingroup\$ This is now fixed \$\endgroup\$ Commented Oct 8, 2016 at 17:47
2
\$\begingroup\$

TI-Basic, 14 Bytes

:ClrHome
:Disp "Ans
:Output(1,2,"  

Note the two trialing spaces at the end of line 3.

  • TI-Basic has its own character encoding where many commands are 1 or 2-byte tokens. For example, ClrHome is a single byte. Ans is a single byte, so it does not violate the challenge rules.

Cheat version, 3 bytes

:"a

In this code, use the a from the statistic menu: VARS > 5 > Right Arrow > Right Arrow > 2.

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

Japt, 3 bytes

Any of these 3-byte programs work:

;Bg
;Cg
;Hd

Test it online!

How it works

;      Set B to the uppercase alphabet,
           C to the lowercase alphabet,
       and H to 65, among other things.
 Bg    Take the first char of B.
 Hd    Take the character with charcode H.
       Implicitly output.

Any of these 4-byte programs work as well:

;EgG
;EgI
;FgG
;FgH
°I d
IÄ d
\$\endgroup\$
2
\$\begingroup\$

C, 20 24

Surprisingly, you can cast negative integers to characters in C and you will get ASCII characters. I ran a loop up to -10,000 and found a few values that produce the character "A". One of which was -8383 which uses no invalid characters. Another being -2239 which breaks the rule of using '9', however you can use a bit operation of ~2238 which becomes -2239.

The generation function for negative integers producing 'A', at least in C-GCC4.9.2, is 65-256*i ... The first few are -191, -447, -703, -959 (Note: this is the same as 'A'-(256*n))


f(){printf("%c",-8383);}

f(){printf("%c",~2238);}

f(){printf("%c",-'¿');} //¿ (2 bytes) is x00BF in unicode (or 191 in base10), -191 = A

Bonus: printf("%c",-'₿'); //negative bitcoin produces A because bitcoin symbol is x20BF which is base_10 is 8383, -8383 cast to char is 'A', but the bitcoin symbol is 3 bytes putting my score to 25 so this is my popularity contest answer, not my codegolf answer


Edit: I can't use putchar since it contains a "U" and an "A". I've updated the answer above to use printf and thus increased my code by 4 bytes from a score of 20 to 24

\$\endgroup\$
1
  • \$\begingroup\$ Suggest L"𐁁" instead of "%c",-'¿' \$\endgroup\$
    – ceilingcat
    Commented Mar 11, 2019 at 3:48
2
\$\begingroup\$

Java 7, 73 69 bytes

Golfed:

void m(){System.err.println(new Object().toString().split("")[3-2]);}

Ungolfed:

void m()
{
    System.err.println(new Object().toString().split("")[3 - 2]);
}

Outputs a to the standard error.

\$\endgroup\$
3
  • \$\begingroup\$ I don't use Java but would 'C'-2 work and save you a byte? \$\endgroup\$ Commented Jan 26, 2017 at 4:40
  • \$\begingroup\$ no, but [3-2] would :P thanks. Why it wouldnt work? Because .split("") splits a string by character and stores it into a string. something like ["j", "a", "v", "a", ".", "l", "a", "n", "g", ...]. with [3 - 2] I get the second string in that array, which is a. \$\endgroup\$
    – peech
    Commented Jan 26, 2017 at 13:01
  • \$\begingroup\$ Interesting, thanks for the explanation! +1, clever solution \$\endgroup\$ Commented Jan 26, 2017 at 19:49
2
\$\begingroup\$

Chicken, 495 bytes

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken

You have to copy and paste the code but you can try it online.

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

Braingolf, 7 bytes

"C"2-@;

Try it online!

Screw you @totallyhuman :(

Explanation

It subtracts 2 from C and prints.

Braingolf, 12 bytes

Keeping this one because IMO it's the better answer, and took way more effort to do.

/..*3*<2*-@;

Try it online!

Man, this was hard.

Explanation

/..*3*<2*-@;
/             Niladic division, push 5 [5]
 ..           Duplicate twice          [5,5,5]
   *          Multiply last 2 items    [5,25]
    3         Push 3                   [5,25,3]
     *        Multiply by 3            [5,75]
      <       Left-shift stack         [75,5]
       2      Push 2                   [75,5,2]
        *     Multiply last 2 items    [75,10]
         -    Subtract last 2 items    [65]
          @   Print as character, 65 is the ASCII value of A
           ;  Suppress implicit output

Braingolf, 9 bytes

And here's a shorter one that still uses the "calculate 65" method

/82*3-*@;

Try it online!

Explanation

Uses niladic division for 5, calculates 13 from (8 * 2) - 3, then multiplies 5 and 13 to make 65

Braingolf, 11 bytes

And finally here's one that prints a lowercase a.

*v/2*c/3-@;

Try it online!

Explanation

*v/2*c/3-@;
*            Niladic multiply, push 1000 [1000]
 v           Switch to stack2            []
  /          Niladic division, push 5    [5]
   2*        Double                      [10]
     c       Collapse stack into stack1  [1000,10]
      /      Divide last 2 items         [100]
       3-    Subtract 3                  [97]
         @;  Print as ASCII and suppress implicit output
             97 is the ASCII value of a
\$\endgroup\$
1
  • \$\begingroup\$ :P - - - - - - - \$\endgroup\$ Commented Jul 18, 2017 at 16:19
2
\$\begingroup\$

Woefully, 335 bytes

|||||||| |
||||||| |
|||||| |
||||| |
|||| |
||| |
|| |
| | --push5; A[5], B[]
| |
| |
| |
| |
| | -- dupeA2B; A[5], B[5]
|| |
||| |
|||| |
||||| |
|||||| |
||||||| | -- swap dec/ascii (set to ascii)
|||||| |
||||| |
|||| |
||| |
|| | --push3; A[5,3], B[5]
|| |
|| | --popA2B; A[5], B[5, 3]
||| |
||| |
||| |
||| |
||| | --multiply; A[15], B[5]
|||| |
|||| |
||||| |
|||| |
||| |
|| |
| | --push2; A[15, 2], B[5]
| |
| | --popA2B; A[15], B[5, 2]
|| |
|| |
|| |
|| | --sub; A[13], b[5]
| |
| |
| |
| |
| | --multiply; a[65], b[]
|| |
||| |
|||| |
||||| |
|||||| | --print; OUTPUT; "A"
|||||| | --no op ends program

Try it online!

I've added the explanation of each step at the end of the step.

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

Pushy, 2 bytes

ZQ

Try it online!

Z          \ Push 0
 Q         \ Index into 0-indexed uppercase alphabet, print result
\$\endgroup\$
2
\$\begingroup\$

x86 MS-DOS, 10 bytes

b4 02 mov ah,0x2
b2 40 mov dl,0x40
fe c2 inc dl
cd 21 int 0x21
cd 20 int 0x20

Try yourself

echo "B402B240FEC2CD21CD20" | xxd -r -p > TEST.COM
\$\endgroup\$
2
\$\begingroup\$

Acc!!, 16 11 bytes

Write 32*2-(2-3)

  Write 88-23

Write tells it to output ASCII, 32*2=64, -(-1) gives 65

I realized 88-23 also gives 65

Try it online!

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

Pascal (FPC), 26 bytes

begin write(pred('B'))end.

Try it online!

At first, I wanted to use standard 88-23 approach, but luckily, there is the pred() which returns previous element of an ordinal type (integers, characters and enumerated types).

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

Kotlin, 7 bytes

{'C'-2}

This is a lambda that returns the Char A. Char overloads the minus operator. Since C is 2 characters after A in Unicode, 'C'-2 produces A.

Try it online!

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

Java 8, 9 bytes

()->'C'-2

-31 (!) bytes thanks to ASCII-only!
Try it online!

How?
I'm not sure. Best guess is the result of the subtraction is implicitly cast to char because of the return type of the function.

\$\endgroup\$
5
  • \$\begingroup\$ 34 \$\endgroup\$
    – ASCII-only
    Commented Mar 11, 2019 at 7:03
  • \$\begingroup\$ 9 \$\endgroup\$
    – ASCII-only
    Commented Mar 11, 2019 at 7:11
  • \$\begingroup\$ @ASCII-only I thought that returned an integer. I guess golfing at night is not the best idea ;) Thanks. \$\endgroup\$ Commented Mar 11, 2019 at 7:49
  • \$\begingroup\$ 9 bytes excluding the semicolon btw \$\endgroup\$
    – ASCII-only
    Commented Mar 11, 2019 at 8:19
  • \$\begingroup\$ @ASCII-only fixed, now time for sleep. \$\endgroup\$ Commented Mar 11, 2019 at 8:20
2
\$\begingroup\$

Python - 20 bytes

print(chr(-~(8<<3)))

IPython 7.11.1 - 19 bytes

print(__doc__[3^3])
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Submissions must be full programs or functions, snippets are not allowed. You would need to print this somehow. \$\endgroup\$
    – Stephen
    Commented Jan 24, 2020 at 15:06
2
\$\begingroup\$

Brainetry, 141 bytes

a b
a b c d
a b c d e f g h
a b c d
a b c d e f g h
a b c
a b c d e f g h i
a b
a b
a b c d
a b c
a b c d
a b c d e f g h i
a b
a b c d e f g

The code above is the golfed version of this program:

Hey, look,
I'm not even going
to try, ok? I will jvst write regvl@rly
@nd then svbstitvte the
letters yov do not w@nt me to vse.
Is this ok@y?
I re@lly hope yov do not mind. Other th@n
th@t, this
is @
f@irly st@nd@rd ch@llenge, I
jvst went online
@nd googled short w@ys
of gener@ting the const@nt 65 in br@infvck. Of covrse
I w@s
sent str@ight to the Esol@ngs web p@ge.
\$\endgroup\$
1
  • \$\begingroup\$ In the first section, you have a's. In the second section you have 5 and 6. \$\endgroup\$ Commented Nov 7, 2020 at 22:20
2
\$\begingroup\$

BRASCA, 1 byte

Uppercase: D

Lowercase: h

TRY IT | try it

Explanation

There's isnt really that much to explain. D pushes 65 to the stack, h pushes 97 to the stack, and implicit output does the rest.

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

TeX, 7 bytes

^^!\bye

An extra 12 bytes if you wanted to supress the page number:

^^!\def\folio{}\bye
\$\endgroup\$
2
  • \$\begingroup\$ I receive the error ! I can't find file 'a'. \$\endgroup\$ Commented Jan 27 at 23:26
  • \$\begingroup\$ @Kai You must write the code in a text file and then run tex on it, passing the code as an argument to tex won't work. \$\endgroup\$
    – plante
    Commented Jan 29 at 10:20
2
\$\begingroup\$

Vyxal, 2 bytes

«∧

Try it Online!

Pushes 'a' as a compressed string, which is printed automatically.

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

Factor, 12 bytes

[ "y""8"v- ]

Try it online!

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

KonamiCode, 17 bytes

v(^^^^^^>^^^^^)<<
\$\endgroup\$
2
\$\begingroup\$

k (ngn/k), 26 bytes

.""/("`";$8-8;":";`k@$@())

@() evaluates to the type of (), or `A. using `k@$ converts it to a string and then pretty prints it, giving us "A". we put this in an array, along with "`", "0", and ":", which once we join with ""/ gives us `0:"A". we evaluate this as k code with . which prints A to stdout.

try it on the ngn/k repl.

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

PostScript, 7 bytes

<~@/~>=

Prints "a", which is written using Ascii85 encoding as @/.

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

Risky, 1.5 bytes

[--

Try it online!

 -    The difference of...
[     64 and...
  -   -1
\$\endgroup\$
2
\$\begingroup\$

Straw, 6 bytes

Bæ}Æ>

Take the codepoint of B (), get the tail of the string (unary decrement) (}), take the character associated with the codepoint (Æ), and print it (>)

Try it online

\$\endgroup\$
0
1 2 3
4
5
8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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