85
\$\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
    Aug 19, 2016 at 23:06
  • 2
    \$\begingroup\$ Is ending up with a variable that contains just a also good enough ? \$\endgroup\$
    – Ton Hospel
    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
    Aug 20, 2016 at 0:05
  • 1
    \$\begingroup\$ Why those particular characters? \$\endgroup\$
    – user253751
    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
    Aug 22, 2016 at 6:26

218 Answers 218

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

reticular, 9 bytes

"C"c2-co;

Try it online!

This is basically C converted from a char to a char code, subtracting two, converting back to a char, printing it with o, then finally terminating it with ;.

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

Fission, 5 bytes

R'B_O

Try it online!

How it works

R      Spawn an atom that moves to the right.
 'B    Set the atom's mass to 'B'.
   _   Decrement the atom's mass.
    O  Print the character that corresponds to the atoms mass and destroy the atom.
\$\endgroup\$
3
\$\begingroup\$

PHP, 12 bytes

<?=chr(833);

Due to an overflow the above produces an 'A' (see example 2 of the PHP doc).

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

Python 3, 18 17 bytes

print(chr(88-23))

Prints the Unicode value 0x41 = 65 - credit SnoringFrog

Previous answers

print(str(int)[3])

Prints index 3 (the fourth character) of the string "<class 'int'>":

print(chr(33*3-2))

Prints the Unicode value 0x61 = 97

\$\endgroup\$
2
  • 1
    \$\begingroup\$ 88-23 saves one byte over 33*3-2 in the second example \$\endgroup\$ Aug 23, 2016 at 14:29
  • 1
    \$\begingroup\$ @SnoringFrog - how did I miss it?! Thanks! \$\endgroup\$ Aug 24, 2016 at 8:52
3
\$\begingroup\$

DC, 6 bytes

3BFFvP

...spits out an A and nothing else.

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

JavaScript ES6 ES5, 23 17 12

12 bytes

`${!3}`[3-2]

17 bytes: (typeof!3)[2- -3]

23 bytes: _=()=>(typeof!3)[2- -3]

Edit 05/10/2016: Took advantage of templating strings, as well as boolean coercion and string/array indexing... Also realized my previous code used +, I could always salvage 2+3 as 2- -3 at a cost of 2 bytes for each previous example... (Updated code and scores for previous submissions)

Edit 30/08/2016:

I took a different approach, exploiting the fat arrow functions as well as the typeof return type, which is a string. So converting a number to a boolean was easier then, had to encase it in parentheses before pulling the 5th element of the resulting string...

Seems that there was no mention of my answer requiring to be in the form of a function, so I've just stripped the fat arrow function declaration.

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

Piet, 30 codels

I'm sure that this can be improved, but I'm a bit of a Piet newbie.

piet

Side note: I have titled it Icy Toll Gate to a Nether Portal. It's artistic, but not abstract, so it kind of follows the main design principle!

\$\endgroup\$
1
  • \$\begingroup\$ Following community consensus on the meta, piet is now scored by the byte count of the image. You can try to compress it as much as possible provided there is a piet interpreter which accepts it. \$\endgroup\$
    – Pavel
    Jan 1, 2017 at 22:39
3
\$\begingroup\$

C++14, 30 bytes

As unnamed lambda (allowed in Python):

[](decltype('B')*c){*c='C'-2;} //'c'-2 for lowercase

//Usage:
#include <iostream>
main(){
  char c;
  [](decltype('B')*c){*c='C'-2;}(&c);
  std::cout << c << std::endl;
}

33 bytes

Function that assigns to its parameter:

int f(decltype('B')*c){*c='C'-2;}

//Usage:

#include <iostream>
main(){
 char c;
 f(&c);
 std::cout << c << std::endl;
}

Pretty hard to do it otherwise since no #include, return or auto because of U. Modifying parameters for return values seems ok Meta

\$\endgroup\$
2
  • \$\begingroup\$ You could just use the same printf code as in your C solution inside the lambda and get rid of the argument to make it shorter. \$\endgroup\$ Aug 20, 2016 at 21:20
  • \$\begingroup\$ suggest passing c by reference and taking advantage of implicit conversions to make this 27 bytes \$\endgroup\$
    – c--
    Apr 12, 2023 at 18:32
3
\$\begingroup\$

SMBF, 4 bytes

<-.B

Try it Online!

Explanation:

<-    Wrap pointer around to the "B" and decrement it, giving "A"
  .   Print
   B  Data storage
\$\endgroup\$
3
\$\begingroup\$

JavaScript, 21

Capital A because there seems to be no other solution to find a capital A

_=>`${[].keys()}`[8]

`${[].keys}` => "[object Array Iterator]" 8th index is A

_=>`${keys}`[38]

Also works in browser for similar reasons.

Edited to add function

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

Powershell, 11 bytes

" $(!2)"[2]

Every non-0 integer evaluates to True when casted to [bool].
!2 implicitly converts 2 to [bool] and negates it, so it becomes False.
$() blocks inside a string allow expressions to be evaluated before being converted to string.
When accessing a string with an index the string is treated as a char-array.
Since we're not allowed to use 1 i had to use a space to shift the a in False one to the right. Another option would be a negative index: "$(!2)"[-4].

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

!@#$%^&*()_+, 3 bytes

`^@

Try it online! Outputs lowercase.

Shortest for A seems to be 5 bytes: >^^^@ or B_^_@.

Explanation

`^@
`     push the character "`"
 ^    increment (to `a`)
  @   output as character
\$\endgroup\$
3
\$\begingroup\$

Keg, 3 2 bytes

B;

This pushes the ASCII character B onto the stack, and then decrements the value by 1. The value will automatically be printed.

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

Lenguage, 62,544,587,333,324 bytes

Unary, 134,032,404,790,876 bytes

I couldn't resist ;)

Programs consists of 62544587333324 and 134032404790876 times the character B (or any allowed character you choose to). (Actually pretty short for Lenguage/Unary..)

Port of @Dennis♦' Brainfuck answer.

Byte-counts generated by this program I wrote in 05AB1E.

\$\endgroup\$
2
  • \$\begingroup\$ Do your brainfuck include +? \$\endgroup\$
    – l4m2
    Mar 19, 2021 at 11:57
  • \$\begingroup\$ @l4m2 What do you mean? \$\endgroup\$ Mar 19, 2021 at 13:03
3
\$\begingroup\$

International Phonetic Esoteric Language, 8 bytes

My original answer used the old instruction set and interpreter, which have since been completely rewritten. Still abusing Unicode, and somehow the same length heh.

"C"ʁ2zχo

Explanation:

"C"ʁ     (push "C", convert str to num 67) ( -- 67)
    2    (push 2) ( -- 67 2)
     z   (subtract) ( -- 65)
      χ  (convert num to str) ( -- "A")
       o (print) ( -- )

International Phonetic Esoteric Language, 8 bytes (WIP language) (OLD)

2<C>ʀdχo

The wonders of abusing Unicode as your instruction set.

No TIO interpreter yet, but is runnable by cloning the repository above, and calling python main.py "code here".

2<C>ʀdχo
2        ; push 2
 <C>     ; push "C"
    ʀ    ; pop, push ord("C")
     d   ; pop, push 67 - 2
      χ  ; pop, push chr(65)
       o ; pop, print string
\$\endgroup\$
3
\$\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

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

Python 3, 24 bytes

print(chr(88-23),end='')

Prints an uppercase A without a newline.

Python 2, 16 bytes (with newline)

print chr(88-23)
\$\endgroup\$
1
  • \$\begingroup\$ you can do print(end=chr(88-23)) for 21 bytes \$\endgroup\$ Dec 13, 2022 at 7:53
3
\$\begingroup\$

Excel, 15 bytes

=MID(2=3,2,3-2)

Show the second character in FALSE

VBA (immediate window), 14 12 bytes

Lower case (12): ?chr(33*3-2)
Upper case (14): ?chr(8*8--3-2) or ?chr(23*3-2-2)
\$\endgroup\$
3
\$\begingroup\$

Mathematica, 27 25 24 bytes

Writes 10 in base 24. Half the length is one function name :(

IntegerString[2(8-3),33]

Thanks to Xavier for pointing out that the base doesn't have to be 16 (as in my original hexadecimal solution), and thanks to c-- for saving another byte!

\$\endgroup\$
8
  • \$\begingroup\$ What about First@WordList[]? \$\endgroup\$
    – user48818
    Aug 22, 2016 at 16:21
  • \$\begingroup\$ @Xavier: Make that an answer and I'll upvote it! \$\endgroup\$ Aug 22, 2016 at 17:52
  • \$\begingroup\$ Done! A small gain for your approach: IntegerString[8 + 2, 3*3 + 2] :-) \$\endgroup\$
    – user48818
    Aug 22, 2016 at 20:09
  • \$\begingroup\$ Unfortunately the mean OP doesn't let us use + in this challenge :) I upvoted your answer though! \$\endgroup\$ Aug 23, 2016 at 4:44
  • \$\begingroup\$ Ah yes, I have missed the + in the constraints. +1 as well! \$\endgroup\$
    – user48818
    Aug 23, 2016 at 12:47
3
\$\begingroup\$

Piet + ascii-piet, 14 bytes (10×2=20 codels)

sSsSKNMTFVrFff

Try Piet online!

(Previous record: 30 codels / ascii-piet bytes)

In ascii-piet, a represents a dark blue cell, and u is a light magenta cell. (x and symbols and digits do not exist.) This program has only one dark color but four different light colors, so I had to rotate the hue so that the resulting ascii-piet representation contains neither a nor u.

The program itself is pretty simple:

4 dup dup * * 1 + outC
\$\endgroup\$
4
  • \$\begingroup\$ Could you save a few bytes by expanding the 4 into an 8 through the black region, and removing a dup and a *? \$\endgroup\$
    – emanresu A
    Jul 12, 2022 at 20:47
  • \$\begingroup\$ @emanresuA It would have to be 16 rather than 8 (64 is 4*4*4), which would increase the size. \$\endgroup\$
    – DLosc
    Jul 12, 2022 at 21:03
  • \$\begingroup\$ @DLosc What I meant was 8 dup * \$\endgroup\$
    – emanresu A
    Jul 12, 2022 at 21:08
  • 1
    \$\begingroup\$ @emanresuA Ah, I see. That still wouldn't save bytes, though? It would be the same dimensions, and with ASCII-Piet it would actually increase the bytecount (since black codels at the ends of lines can be left implicit in ASCII-Piet). \$\endgroup\$
    – DLosc
    Jul 12, 2022 at 21:12
2
\$\begingroup\$

MATL, 5 Bytes

'b'qc

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ It's annoying that this requires the c, but unfortunately that behavior is a MATLAB/Octave thing. \$\endgroup\$
    – Suever
    Aug 19, 2016 at 22:20
2
\$\begingroup\$

SQF, 30 15

Using the function-as-a-file format:

toString[88-23]

Call as: call FUNCTION

Finally a challenge where SQF can compete. Not win, but actually competing is nice.

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

Pyth - 3 bytes

Alternate longer answer.

.HT

Try it online here.

\$\endgroup\$
2
  • \$\begingroup\$ @ColdGolf accept the first one. \$\endgroup\$
    – Maltysen
    Aug 20, 2016 at 21:17
  • \$\begingroup\$ also mine is 3 bytes so it can't win. \$\endgroup\$
    – Maltysen
    Aug 20, 2016 at 21:18
2
\$\begingroup\$

Jellyfish, 5 bytes

P;>'@

Try it online!

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

Befunge-98, 6 bytes

'Lb-,q

Very basic: 'Lb- pushes (76-11 aka 65), , prints, q quits because using @ is too boring.

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

Caker, 24 bytes

ωΩθΩθθθθθΩθΘ

Body must be at least 30 characters; you entered 29.

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

Perl 6, 14 bytes

print 'B'.pred

pred is short for "predecessor"

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

WolframAlpha, 10 bytes

chr(88-23)
\$\endgroup\$
4
  • \$\begingroup\$ Do you mean "Wolfram Language"? \$\endgroup\$ Aug 21, 2016 at 3:30
  • \$\begingroup\$ @ColdGolf WA is a program using Wolfram language. It can also be called from Mathematica by typing equality sign twice (==). Check the link. \$\endgroup\$ Aug 21, 2016 at 3:35
  • \$\begingroup\$ Are you implying I can't use WA? \$\endgroup\$ Aug 21, 2016 at 3:38
  • \$\begingroup\$ Nope, it was just an interesting thing. \$\endgroup\$ Aug 21, 2016 at 3:42
2
\$\begingroup\$

3var, 14 11 8 bytes

iii       # set A to 3
   s      # square A to 9
    d     # decrease A to 8
     s    # square A to 64
      i   # increment A to 65
       P  # print A as ascii

Try it online

Saved 3 bytes thanks to Joffan.

\$\endgroup\$
2
  • \$\begingroup\$ Is there a reason to involve R and B - why not iiisdsiP? \$\endgroup\$
    – Joffan
    Aug 21, 2016 at 3:21
  • \$\begingroup\$ @Joffan: You are of course correct. There's no reason at all to use R. Thanks! \$\endgroup\$
    – Emigna
    Aug 21, 2016 at 9:21
2
\$\begingroup\$

Oracle SQL 11.2, 56 50 bytes

Shorter way to compute 65, thanks to the previous answers using it.

SELECT NVL(MIN('.'),CHR(88-23))FROM col WHERE 2=3;

Old version :

SELECT NVL(MIN('.'),CHR(3*3*8-2-2-3))FROM col WHERE 2=3;

Ugly, but I had to find a way around DUAL

\$\endgroup\$
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.