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

215 Answers 215

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

Brainfuck, 24 bytes

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

----[---->-<]>--[->-<]>.
\$\endgroup\$
1
\$\begingroup\$

Befunge 93, 7 bytes

"C"2-,@

Pretty simple.

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

ECMAScript 6, 41 59 55 bytes

Golfed

This is the golfed version, which doesn't support the use strict pragma. If you want to allow this to be compatible with it, simply replace s=(2-2>(3-2) with var s=(2-2)>(3-2).

Version 3 of this replaced the old substring (that uses the disallowed character u) with slice, a byte-efficient version that fits these rules.

You can try this on JSFiddle or use the below Stack Snippet.

s=(2-2)>(3-2);console.log(s.toString().slice((3-2),2));

Ungolfed

This version of golfed code (version 3) supports the use strict pragma and is 79 bytes.

You can try this on JSFiddle or use the below Stack Snippet.

"use strict";
var s = (2-2) > (3-2);
console.log(s.toString().slice((3-2), 2));

Technically, this doesn't follow the rules as it uses u and a (in use and var respectively), but it was needed to support use strict.

\$\endgroup\$
3
  • \$\begingroup\$ console.log((3<2).toString().slice(3-2,2)) works too. \$\endgroup\$
    – BartekChom
    Aug 20, 2016 at 18:30
  • \$\begingroup\$ @BartekChom, thanks. Will update main post. \$\endgroup\$ Aug 20, 2016 at 19:51
  • \$\begingroup\$ Why not console.log(String(!2)[~-2]) \$\endgroup\$
    – Cyoce
    Aug 21, 2016 at 6:59
1
\$\begingroup\$

Ruby, 20 Bytes

print ("c".ord-2).chr

Subtracts 2 from the unicode-code from "c".

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

C# Interactive (REPL), 21 bytes

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

I really wonder how much smaller it can become in C# in a REPL environment.

\$\endgroup\$
3
  • \$\begingroup\$ I don't think this is valid, since it's just a snippet. It has to be wrapped in a function, which would almost definitely need to have an A or a U in it somewhere. \$\endgroup\$
    – DJMcMayhem
    Aug 21, 2016 at 4:15
  • \$\begingroup\$ @DJMcMayhem I can't seem to see anything specifying that it must be wrapped in a function. I also noticed a few answers aren't even necessarily printing the result explicitly either. It's also worth mentioning that by using something like C# Interactive (built into Visual Studio 2015, it's possible to just add the snippet I have above and it will output the correct value ('a'). Meaning if PowerShell can get away without a explicit print equivalent, C# could too? \$\endgroup\$ Aug 21, 2016 at 7:00
  • \$\begingroup\$ I've asked about this here and have as such now specified that the solution is for C# Interactive (or any other REPL C# environment that might exist). \$\endgroup\$ Aug 21, 2016 at 7:48
1
\$\begingroup\$

Python 2, 16 bytes

print chr(88-23)

Simpler but longer (21 bytes):

print chr(ord('c')-2)
\$\endgroup\$
1
\$\begingroup\$

Senva, 9 bytes 4 bytes

There is two ways to write this program, let's begin by the longest :

82.8--8-~

This stores 82 in the memory, substract 8, 8 again, 1, then display the memory as an ASCII char (65 is the ASCII code of A). The cell's value is 82 - 8 - 8 - 1 = 65.

The second way is a little bit pernicious :

B_-~

This converts the 'B' character to its ASCII char code, substract 1, and then display it as an ASCII char.

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

C# Interactive (REPL), 12 bytes

Lower case:

$"_{3<2}"[2]

This works by getting the third character from the string _False.

Upper case:

$"{new{}.GetType()}"[8-3]

This creates an anonymous object and gets its type, which is always of the form <>f__AnonymousType0#9. It then turns this into a string and gets the 6th character.

Answers are given as C# Interactive to compete with the other C# answer, though they can easily be converted to a printing anonymous lambda by wrapping them with:

()=>System.Console.Write(...);

This adds 27 characters to each solution.

\$\endgroup\$
4
  • \$\begingroup\$ Note the method to wrap the call could be an Action and be displayed as: ()=>System.Console.Write(...);, Note the System. and ending ;. \$\endgroup\$ Aug 22, 2016 at 10:06
  • \$\begingroup\$ The problem with that is that you can't declare an Action without an explicit cast. Which you can't do, because the 'A' in 'Action' is disallowed. \$\endgroup\$
    – Scepheo
    Aug 22, 2016 at 10:29
  • \$\begingroup\$ You don't need to declare the Action as the action by itself is fine i.e ()=>... \$\endgroup\$ Aug 22, 2016 at 10:33
  • \$\begingroup\$ Had a look and it does seem like anonymous lambdas are allowed. I've changed the answer accordingly. \$\endgroup\$
    – Scepheo
    Aug 22, 2016 at 10:59
1
\$\begingroup\$

3d, 7 bytes

Don't know if competing, but still, here it is.
Program:

>'b.-!;

Output:

a

Explanation:

>        Set direction of the IP
 'b      Push Unicode ordinal of character 'b'
   .     Push digit 1
    -    Push difference
     !   Print as Unicode character
      ;  End of program
\$\endgroup\$
1
\$\begingroup\$

Javascript, 32 bytes

Uppercase A:

String.fromCodePoint(33*2-(3-2))
\$\endgroup\$
1
  • \$\begingroup\$ “Your task is to print/display” – Your code is just a snippet generating the value. \$\endgroup\$
    – manatwork
    Aug 24, 2016 at 7:01
1
\$\begingroup\$

MSX-BASIC, 25 bytes

?CHR$(3*3*3*2-(-3-3-3-2))
\$\endgroup\$
1
\$\begingroup\$

MIXAL - 101 bytes including tabs

Run on your MIX machine. Or assemble and run using the GNU MIX Development Kit (http://www.gnu.org/software/mdk/).

S       ENT2    2/2
        ST2     8
        ENT3    22*2-3-2-2
        ST3     P(8-3:8-3)
        ENT2    22-3
        ST2     P(8-2-2:8-2-2)
P       IN      8
        HLT
        END     S

The biggest challenge is not being able to use OUT, the only output command, or 19, the number of the teletype output device. I get around the source restrictions by creating forbidden numbers using MIX assembler arithmetic, and by using MIX's self-modifying code features.

  1. Enter the number 1 into index register 2 (assembler turns 2/2 into 1)
  2. Store the contents of index register 2 at memory address 8, later to be sent to the output device
  3. Enter the number 37 into index register 3 using assembler arithmetic. 37 is the operation code OUT, which we need but can't use because it has a U.
  4. Store the contents of index register 3 (=37) in the opcode field (5:5) of the instruction already stored at address 'P' as part of the program (in other words, change IN to OUT)
  5. Enter the number 19 into index register 2. The teletype output device is no. 19.
  6. Store the contents of index register 2 (=19) in the field-specification field (4:4) of the instruction at address 'P' (change 0 to 19 to specify the teletype device as output).
  7. Instruction 'P': We have now rewritten this line as P OUT 8(19). So, send the contents stored at address 8 (= 1 = character code for 'A') to the teletype device for output.
  8. Stop the machine.
\$\endgroup\$
1
\$\begingroup\$

JavaScript (ES6), Uppercase, 34 30 bytes

1. I started from the answers of Conor O'Brien to get this:

_=>this[`${` ${-$}`[2]}tob`]("QQ")

Since btoa("A") gives "QQ==", it's doing atob("QQ") wich gives "A".

2. Completing the answer of chronixlol :

_=>String.fromCodePoint(88-23)
\$\endgroup\$
1
\$\begingroup\$

Game Maker Language, 26 bytes

So lucky that the command is chr() instead of char()...

get_string('',chr(33*3-2))

Basically, we have to get chr(65) or chr(97) to get A or a. Also, I had to use get_string to show the output since return, show_message, show_question, etc. all contained restricted characters.

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

Microscript II, 6 bytes

2s'C-K

Basically subtracts 2 from the char code of C, then converts back to a character before printing implicitly.

In the original Microscript, it becomes this 7-byte program:

2s'C-Ph
\$\endgroup\$
1
\$\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\$
1
\$\begingroup\$

Ruby REPL, 11 bytes

(88-23).chr

88 - 23 = 65. 65 is the decimal representation of ASCII A. The chr function changes the decimal representation to the character. The REPL displays the result.

\$\endgroup\$
1
  • \$\begingroup\$ does this display that character though? \$\endgroup\$ Aug 29, 2016 at 1:19
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]
\$\endgroup\$
1
\$\begingroup\$

Woefully, 400 bytes

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

Can probably be golfed more

\$\endgroup\$
2
  • \$\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\$ Jul 18, 2017 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\$ Jul 19, 2017 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]
\$\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]
\$\endgroup\$
1
\$\begingroup\$

Scala, 15 bytes

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

Explanation:

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

k, 14 bytes

*|$`byte$38-28

This returns "a"

\$\endgroup\$
2
  • \$\begingroup\$ What is this k language. Is it K? Where can I find out more about it? \$\endgroup\$
    – Wheat Wizard
    Nov 11, 2016 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\$ Nov 11, 2016 at 17:03
1
\$\begingroup\$

GO, 22 20 bytes

print(string(88-23))

Try it online!

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

\$\endgroup\$
3
  • \$\begingroup\$ It's scored in bvtes, not characters. \$\endgroup\$ Jan 24, 2017 at 13:10
  • \$\begingroup\$ Relying on user defaults might not be a good idea, but this is clever. \$\endgroup\$
    – snail_
    Jan 24, 2017 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, 2017 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             []
\$\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")
\$\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!

\$\endgroup\$
6
  • \$\begingroup\$ hG is one byte shorter \$\endgroup\$
    – Dave
    Aug 24, 2017 at 13:10
  • \$\begingroup\$ longer but cuter is Ch^^2 2 3 \$\endgroup\$
    – Dave
    Aug 24, 2017 at 13:14
  • \$\begingroup\$ @Dave Really? Didn't know that's how that worked \$\endgroup\$
    – Stan Strum
    Aug 24, 2017 at 16:07
  • \$\begingroup\$ h of a sequence returns the first value \$\endgroup\$
    – Dave
    Aug 24, 2017 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, 2017 at 16:17
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.

\$\endgroup\$
1
4
5
6 7 8

Your Answer

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

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