74
\$\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\$
  • 7
    \$\begingroup\$ @ColdGolf You seem to be saying "yes" to functions, but functions don't display, they usually return. \$\endgroup\$ – xnor Aug 19 '16 at 23:06
  • 2
    \$\begingroup\$ Is ending up with a variable that contains just a also good enough ? \$\endgroup\$ – Ton Hospel Aug 19 '16 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 Aug 20 '16 at 0:05
  • 1
    \$\begingroup\$ Why those particular characters? \$\endgroup\$ – user253751 Aug 22 '16 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\$ – Mego Aug 22 '16 at 6:26

183 Answers 183

1
3 4
5
6 7
1
\$\begingroup\$

F# Interactive, 17 bytes

string(3<2).[3-2]

This produces the following in the Output:

val it : char = 'a'

to print it to STDOUT, well, it becomes larger: 29 chars.

printf"%c"<|string(3<2).[3-2]
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Woefully, 400 bytes

| || |
|| |
||| |
|||| |
||||| |
|||||| |
||||||| |
|||||| |
||||| |
|||| |
||| |
|| |
| |
| |
| |
| |
| |
| |
|| |
|| |
|| |
|| |
|| |
|| |
||| |
||| |
||| |
||| |
||| |
|||| |
|||| |
|||| |
|||| |
|||| |
||| |
|| |
| |
|| |
|| |
|| |
||| |
|| |
| |
| |
| |
| |
|| |
|| |
|| |
||| |
||| |
||| |
||| |
|||| |
|||| |
||||| |
|||| |
||| |
|| |
| |
|| |
||| |
|| |
||| |
|||| |
||||| |
|||||| |
||||||| |

Can probably be golfed more

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This language is cool, I've made my own version for this at 335 bytes - but not sure if I should answer such an old question with this language already used. \$\endgroup\$ – Teal pelican Jul 18 '17 at 14:58
  • \$\begingroup\$ @Tealpelican go for it! we don't care about necros (except when it's like a hundred tag adding necros, but that's irrelevant), and we don't care that much about reusing langs \$\endgroup\$ – Destructible Lemon Jul 19 '17 at 1:20
1
\$\begingroup\$

JavaScript, Node console, 23

Shortest JavaScript I can do for a capital A.

This only works in the Node REPL console.

Object.keys(this)[2][3]

This only works in Firefox REPL (27)

Object.keys(this)[8*3][2*3]
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Elixir, 16 bytes

IO.write [88-23]

Try it online on ElixirPlayground !

Elixir outputs the character(s) with the ASCII code specified in the list.

Using IO.puts would make it 1 byte shorter, but u is not allowed.

As expected, the interactive mode removes the need of explicitly calling IO functions for on-screen output.


Elixir Interactive, 7 bytes

[88-23]
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Scala, 15 bytes

((2>3)+"")(3-2)

Explanation:

( 
  (2>3) //false
  +""   //toString
)(3-2)  //zero-indexed 1st char is 'a'
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

k, 14 bytes

*|$`byte$38-28

This returns "a"

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ What is this k language. Is it K? Where can I find out more about it? \$\endgroup\$ – Ad Hoc Garf Hunter Nov 11 '16 at 16:07
  • \$\begingroup\$ kparc.com/k.txt is the manual kx.com is the parent company's site - k in this case refers to k4, which is the c interpreter that underpins kdb+ and q. \$\endgroup\$ – Paul Kerrigan Nov 11 '16 at 17:03
1
\$\begingroup\$

GO, 22 20 bytes

print(string(88-23))

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\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

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Suggest L"𐁁" instead of "%c",-'¿' \$\endgroup\$ – ceilingcat Mar 11 '19 at 3:48
1
\$\begingroup\$

Insomnia, 2 bytes

Since any character is allowed, I used an unprintable character in the code (\u001a). Hex dump included below:

0000000: 641a                                     d.

StackExchange doesn't display control characters in the post, so click on edit to see the raw source code below and copy it to test on the online interpreter:

d
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

SmileBASIC, 10 bytes

?KEY(2)[2]

KEY accesses the function buttons used in the editor. They can be set to any string, but by default they are 1:FILES 2:LOAD" 3:SAVE" 4:LIST ERR\r 5:RUN

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ It's scored in bvtes, not characters. \$\endgroup\$ – Buffer Over Read Jan 24 '17 at 13:10
  • \$\begingroup\$ Relying on user defaults might not be a good idea, but this is clever. \$\endgroup\$ – snail_ Jan 24 '17 at 16:26
  • \$\begingroup\$ Luckily all the function keys are reset when restarting SB, so this will always print A if it's the first thing you run. \$\endgroup\$ – 12Me21 Jan 24 '17 at 16:32
1
\$\begingroup\$

,,,, 6 bytes

'Co2-c

Explanation

'Co2-c

'C      push "C"                    ["C"]
  o     convert to ASCII ordinal    [67]
   2-   subtract 2                  [65]
     c  convert to ASCII character  ["A"]
        implicit output             []
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

AutoHotkey, 19 bytes

Send % Chr(8-2 8-3)

This types a single character, A. It does so through AHK's surprising yet convenient implicit concatenation.

Send tries to write a string. %tells it to use the value of an expression (Rather than just plaintext) Chr() converts a number to a character. 8-2 8-3 evaluates to 6 5 which evaluates to 65, the ASCII code for A.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

K (oK), 8 bytes

Solution:

`c$88-23

Try it online!

Explanation:

Interpretted right-to-left:

   88-23 / 88 minus 23 is 65
`c$      / cast to character ("A")
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Pyth, 3 2 bytes

-1 from Dave reminding me to actually read the docs

hG

Explanation:

hG      The first entry in G (the alphabet)

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ hG is one byte shorter \$\endgroup\$ – Dave Aug 24 '17 at 13:10
  • \$\begingroup\$ longer but cuter is Ch^^2 2 3 \$\endgroup\$ – Dave Aug 24 '17 at 13:14
  • \$\begingroup\$ @Dave Really? Didn't know that's how that worked \$\endgroup\$ – Stan Strum Aug 24 '17 at 16:07
  • \$\begingroup\$ h of a sequence returns the first value \$\endgroup\$ – Dave Aug 24 '17 at 16:11
  • 1
    \$\begingroup\$ @Dave I should really head back to my desktop. This phone keyboard is so problematic. \$\endgroup\$ – Stan Strum Aug 24 '17 at 16:17
1
\$\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!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Python, 31 bytes

print(chr(-~(2**(8-2))),end='')

Explanation: 8-2 is 6, and 2**6 (2 to the power of 6) is 64. chr(65) is A, so I need to add 1 without using + (or 1). I then used -~ which adds 1, creating chr(65) which is A.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Ahead, 6 bytes

'C2-o@

'C      push 67 (C in unicode)
  2     push 2
   -    subtract
    o   print char
     @  end

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Scratch, 38 bytes

when gf clicked
think(letter(2)of<[]<[

Try it online!

think is used instead of say because say has an a.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

MathGolf, 3 2 bytes

-1 byte thanks to maxb

╩Z

Try it online!

Fetches the 90th word in the dictionary, which is a uppercase 'A'.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ You can shave a byte off using ♂¢ \$\endgroup\$ – maxb Dec 6 '18 at 8:03
  • \$\begingroup\$ For lowercase you have ╩♦ \$\endgroup\$ – maxb Dec 6 '18 at 8:07
  • \$\begingroup\$ There's also ╩Z for the uppercase. Check out the MathGolf chat, I have a great tool coming up for challenges like this one. \$\endgroup\$ – maxb Dec 6 '18 at 8:14
1
\$\begingroup\$

MathGolf, 2 bytes

♂¢

Try it online.

Explanation:

♂     # Push 10
 ¢    # Convert to hexadecimal (and output implicitly)
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Brian & Chuck, 7 bytes

B?
!<-.

Try it online!

code:

Brian:
B    constant B
?    switch to Chuck

Chuck:
<    go to B
-    decrement it
.    and print it
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Brain-Flak, 28 bytes

(((((()()()()){}){}){}){}())

Try it online!

code:

(((((()()()()){}){}){}){}()) push 65
                             implicitly print stack
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

W d, 2 bytes

∑Ƿ

Explanation

Pretty much boils down to this after decompression:

'A
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Pip, 4 bytes

/O@z

Try it online!

Explanation

   z  Lowercase alphabet
  @   First character
 O    Output without newline
/     Invert

That last (first?) instruction requires some more explanation:

By default, Pip prints the last expression in the program with a trailing newline. (This is why we couldn't do @z for 2 bytes, since the challenge states that newlines should be avoided if at all possible.) That's a problem because O@z, in addition to outputting a without a newline, is also an expression that evaluates to a. So O@z by itself would print aa plus a newline.

There are two ways to get rid of the extra output: First, we could output inside an if statement (5 bytes: IzO@z or other similar programs). Second, we could make the final expression in the program evaluate to nil. Nil produces no output when printed, not even the trailing newline. The usual way to suppress auto-printing is to end the program with u, a variable preset to nil. Unfortunately, u is banned. We could use the nil expression (), which would put us back at 5 bytes: O@z().

Enter the unary division operator /, which inverts its operand. In this case, if we invert O@z, the operand is the string a. Non-numeric strings evaluate to 0 in numeric contexts, which means we're dividing by 0. This gives nil, which suppresses the newline exactly as desired.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Wren, 41 bytes

System.write(String.fromCodePoint(88-23))

Try it online!

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ You're not allowed to use characters 6 and 5 :/ \$\endgroup\$ – daniero Dec 26 '19 at 22:00
  • \$\begingroup\$ 6 and 5 are disallowed because the asker knew someone would try this lol \$\endgroup\$ – Sagittarius Dec 27 '19 at 1:15
1
\$\begingroup\$

Python - 20 bytes

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

IPython 7.11.1 - 19 bytes

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

x86-16 machine code, IBM PC DOS, 6 bytes

Binary (CP437):

░@@═)├

Unassembled listing:

B0 40       MOV  AL, '@'    ; One below ASCII 'A' 
40          INC  AX         ; increment char 
CD 29       INT  29H        ; write AL to console 
C3          RET             ; return to DOS

enter image description here

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Brainfuck, 24 bytes

not as good as Dennis' anyones, but still posting it.

----[---->-<]>--[->-<]>.
| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Perl6, 20

(?0).comb[3>2].print
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Also (88-23).chr.print (17 bytes, from the Ruby answer), but that's arguably degenerate. \$\endgroup\$ – bb94 Aug 25 '16 at 3:15
0
\$\begingroup\$

Visual C++, 32 bytes

std::clog<<decltype('C')('C'-2);

or

std::clog<<decltype('C')(260>>2);

on the basis of @Karl Napf

dont know why it gets downvoted it clearly compiles on VisualC++2015 and outputs A on my Machine

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ 1. The downvote was cast automatically by the Community user when you edited your answer. I consider this a bug. 2. I'm not fluent in C++, but this looks like a snippet. Submissions have to be full programs or functions (named or lambdas) by default. \$\endgroup\$ – Dennis Aug 28 '16 at 19:52
1
3 4
5
6 7

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