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>

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

158 Answers 158

up vote 78 down vote accepted

Pluso, 1 byte

o

Pluso Esolangs Page.

Pluso contains a single accumulator, that starts with the value 1. It uses two commands, p which increments the accumulator (mod 27), and o which prints the current value as an uppercase ASCII character, A-Z or space (where 1-26 represents A-Z respectively, and 0 represents space).

As the accumulator starts at 1, the command o with no prior p will output A.

  • 13
    Welcome to PPCG! I would recommend putting the explanation in your answer, in case the link dies for whatever reason. – TheBikingViking Aug 22 '16 at 7:48
  • Explanation added. Waiting for moderator approval. – KPM Aug 23 '16 at 20:22
  • 2
    Thanks for the recommendation (and the welcome), I have updated my answer to include a brief explanation. – cdw Aug 24 '16 at 3:02
  • I just upvoted to put you at 666 rep. Sorry about that. – Aidan F. Pierce Aug 25 '17 at 1:05
  • 3
    Doesn't this fail the "is an esolang" test because it can't do primality checking? – Magic Octopus Urn Oct 12 '17 at 18:52

Python 2, 14 bytes

print`3<3`[~3]

The expression 3<3 gives the Boolean False, and the backticks give its string representation 'False'. From here, it remains to extract the letter a. Python is 0-indexed, so the a is at index 1, which is a banned character. It can be expressed as 3-2, but there's a shorter way. Python allows indexing from the back, with index -1 for the last entry, -2 for the one before it, and so on. We want index -4, but 4 is also a banned number. But, we can express it as ~3 using the bit-complement ~, which gives -n-1 for ~n.

  • 6
    That's a really cool solution. Also, couldn't you do [2] instead of [~3]? – DJMcMayhem Aug 19 '16 at 22:11
  • 5
    @DJMcMayhem It's 0-indexed unfortunately, it would need [1]. – xnor Aug 19 '16 at 22:12
  • 4
    ... why are 1 and 4 'banned' numbers?? – Chris Cirefice Aug 23 '16 at 21:22
  • 4
    The challenge's rules say so. – xnor Aug 23 '16 at 23:46
  • 18
    I'm now even considering using "~0" being read as "zero indexed first element from the back". I wonder why we would use "-1" notation in Python.... – PascalVKooten Aug 24 '16 at 8:36

Pyth, 2 bytes

hG

Test it in the Pyth Compiler.

How it works

 G  Yield the lowercase alphabet.
h   Extract the first character.

PHP, 9 6 bytes

<?=O^_^Q;

For 9 bytes: Inspired by @Ton Hospel's answer. Plus, it has the added benefit of looking a bit like a Kaomoji. :-)

The 6 bytes improved version:

<?=~¾;

wherein ¾ has the hex code of 0xBE (it is important to save the file in Latin-1 encoding, not UTF-8!).

  • An alternative version is f^E^b. – Ismael Miguel Aug 20 '16 at 0:53
  • Yes, the 9-byte solutions are abundant. I started with y^'8' and x^'9', unfortunately numbers have to be cast to string or it will XOR the resulting type will be an integer. – YetiCGN Aug 20 '16 at 7:39
  • 23
    +1 for the face ^_^ – Cyoce Aug 21 '16 at 6:46
  • The 6 Byte version doesn't print A. It prints =A. – UTF-8 Aug 21 '16 at 9:56
  • 1
    I know the answer to this riddle now: In UTF-8 the "fraction three quarters" codepoint is encoded as two bytes: 0xC2 0xBE, 0xBE being the same as in ISO-8859-1. I noticed that when I saved this to a file on my linux box, which I access via SSH with UTF-8, of course, that the file is 7 bytes. So, save the script with Latin-1 encoding and it will be 6 bytes and not output the = character. – YetiCGN Aug 22 '16 at 18:38

05AB1E, 3 2 bytes

Th

Explanation

T   # push 10
 h  # convert to hex

Try it online

Saved 1 byte thanks to Adnan

  • 5
    Th for two bytes :) – Adnan Aug 19 '16 at 22:15
  • 1
    @Adnan Oh of course. Hex :) – Emigna Aug 19 '16 at 22:29

brainfuck, 16 bytes

-[-[---<]>>-]<-.

This is based on Esolang's brainfuck algorithm for 159.

Try it online!

  • 3
    This.... this is wizardry. – Conor O'Brien Aug 19 '16 at 22:38
  • 3
    This solution uses the cell at index -1, which isn't supported across all brainfuck interpreters and would result in a crash. You can run it here to see fatiherikli.github.io/brainfuck-visualizer/… – Cody Aug 19 '16 at 22:55
  • 37
    @Cody On PPCG, languages are defined by their implementation. As long as there is one interpreter that behaves as desired, it is a valid solution. – Dennis Aug 19 '16 at 22:59
  • 3
    How hard was it for you to avoid the forbidden characters? – Hagen von Eitzen Aug 23 '16 at 20:15
  • 1
    @HagenvonEitzen I had to dig a bit to find an algorithm that could avoid +. (the shortest way to print A would be >+[+[<]>>+<+]>.), but thanks to list of constants on Esolang, not too hard. – Dennis Aug 23 '16 at 20:25

JavaScript (ES6), 17 16 14 bytes

Saved two bytes thanks to Neil!

_=>` ${-_}`[2]

Returns the second character of NaN, which is a.

This is the shortest I could come up with for A, 43 42 bytes:

_=>`${[][`constr${`${!_}`[2]}ctor`]}`[-~8]

Who says being an obfuscator doesn't help with code golf? Not I!

Explanations

The first one, in depth.

_=>` ${-_}`[2]

-_ is NaN, because _ is undefined. To get this as a string, one would need one of the following:

-_+""
`${-_}`
(-_).toString()

The last is too long, and the first uses +. So we use the second one. Now, the a is at index 1. This isn't any good, because 1 is forbidden. However, being a template string, we can put a space in there to make it at index 2, thus leaving us with ` ${-_}`.


The second one, in depth.

_=>`${[][`constr${`${!_}`[2]}ctor`]}`[-~8]

This one was a doozy.

_=>`                                `[-~8]

This is the 9th character of the inside template string, -~8 being equal to 9. In this case, this template string is just for stringification. This is the inside equation being stringified, in between ${...}:

[][`constr${`${!_}`[2]}ctor`]

Let's expand this a bit:

(new Array())[`constr${`${!_}`[2]}ctor`]

This gets the property `constr${${!""}[2]}ctor` from an empty array. This property is, of course, a template string, but it has some text around it. It's roughly equivalent to:

"constr" + `${!_}`[2] + "ctor"

The inside is in turn equivalent to:

(!_).toString()[2]

!_ is true (because _ is undefined, and !undefined === true), and stringified is "true". We get the second character of it, u; we have to get it this way to avoid explicitly putting u in our code.

So, this inside bit is equivalent to:

"constr" + "u" + "ctor" === "constructor"

So we are getting the constructor of the Array, the Array function. I couldn't put this down explicitly because it contains the forbidden A. Now, stringifying the Array function yields "function Array() { [native code] }".

Back to the original code:

_=>`${[][`constr${`${!_}`[2]}ctor`]}`[-~8]

This is equivalent to, as we've seen:

_=>Array.toString()[-~8]

Equivalent to:

_=>Array.toString()[9]

Finally equivalent to:

_=>"A"
  • 1
    @ColdGolf It's alright. – Conor O'Brien Aug 19 '16 at 23:07
  • 2
    Would it be against the principles of an obfuscator to add an explanation...? I'm curious about how this works. – trichoplax Aug 20 '16 at 17:47
  • 2
    @trichoplax I suppose it wouldn't hurt to reveal my methods here ;) I added an explanation for both. – Conor O'Brien Aug 20 '16 at 19:48
  • 1
    @OldBunny2800 No. a is a forbidden character, and is in toUpperCase. – Conor O'Brien Aug 21 '16 at 18:26
  • 3
    I thought this was Perl at first. – Οurous Aug 22 '16 at 22:51

Hexagony, 4 bytes

Ayyy lmao? Quite golfy for a non-golfing language haha. Code:

B(;@

Try it online!

A more readable form:

 B (
; @ .
 . .

This puts the ASCII value of the letter B, which is 66, on the current memory edge. It substracts it by one using ( and prints it with ;. After that, the program is terminated using @.

Obligatory path image:

enter image description here

Actually, 2 bytes

úF

Try it online!

Explanation:

úF
ú   lowercase English alphabet
 F  first element
  • are you the author? I haven't seen this language before. – loa_in_ Aug 23 '16 at 12:52
  • I've seen it pop up a couple times in challenges now. I think it has the most clever name of any of the golfing languages on the site :-) I've been watching Suits lately and I find it to be very Harvey. – corsiKa Aug 24 '16 at 14:52

Jelly, 3 bytes

ØWḢ

Try it online!

How it works

ØWḢ  Main link. No arguments.

ØW   Yield "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_".
  Ḣ  Head; extract the first character.

Jelly, 4 bytes

l-ṾṂ

Try it online!

How it works

l-ṾṂ  Main link. No arguments.

l-    Take the logarithm of 0 with base -1. Yields (nan+infj).
  Ṿ   Uneval; yield the string representation, i.e., "nanıinf".
   Ṃ  Take the minimum, returning 'a'.
  • 1
    Too bad the second approach is longer. ._. – Dennis Aug 19 '16 at 22:26
  • 6
    Thanks for including the second approach. It's beautiful – trichoplax Aug 20 '16 at 17:53

CJam, 3 bytes

'@)

Try it online!

How it works

'@   Push the character '@' on the stack.
  )  Increment its code point, yielding 'A'.

Bubblegum, 1 byte

"

or

B

Everyone seemed to forget it existed...

  • Never used Bubblegum before, so perhaps excuse my ignorance, but where can I find the docs for Bubblegum? Also, I tried bubblegum.tryitonline.net with both your answers, but it doesn't seem to output anything. – Kevin Cruijssen Aug 22 '16 at 12:38
  • 1
    @KevinCruijssen Doc: esolangs.org/wiki/Bubblegum TIO seemed to accept only the hexdump of the source code, so try it like this: bubblegum.tryitonline.net/… – jimmy23013 Aug 22 '16 at 12:44
  • Ah, that's my problem; not using the hexdump. Thanks and +1 for being the shortest with a single-byte answer (tied with Pluso). – Kevin Cruijssen Aug 22 '16 at 12:56
  • @KevinCruijssen There is a 1 byte Pluso answer. It has some problems with a strange site rule, though. – jimmy23013 Aug 22 '16 at 12:59

Perl, 9 8 bytes

xor is still allowed, but say isn't. So for 9 bytes:

print$/^K

However using output to STDERR gives 8 bytes:

die~"\x9e\xf5"

Replace \x9e and \xf5 by their literal versions. Or generate the executable file using:

perl -e 'printf q(die~"%s"),~"a\n"' > a.pl
  • @ColdGolf: That's not clear to me. Do you mean I can use say (contains a) for printing as long as the construction of the argument doesn't use the forbidden characters ? – Ton Hospel Aug 19 '16 at 23:13
  • "However, you must not use any of the below characters in your code: * A, whether uppercase or lowercase." From that, I'd print "No using the letter with code point 65";. – haykam Aug 19 '16 at 23:22
  • @ColdGolf is that meant to answer the question in any way? – hobbs Aug 20 '16 at 22:55

><>, 6 bytes

'|;o-$

this creates a string of characters, bounces and creates it again in reverse, flips the top 2 stack items and subtracts: '|' (124) minus ';' (59) is 'A' (65)

Try it online

  • 2
    Nice! I got '$-o;| which is almost the same but without the bouncing. (|;o-$' also works.) – randomra Aug 20 '16 at 20:32
  • 1
    @randomra oh true! that would definitely run faster, so nice job – torcado Aug 21 '16 at 5:24

Ruby, 15 12 bytes

$><<to_s[-3]
  • 1
    You can save 2 bytes changing $><< to p , makes p to_s[-3] – Ephi Aug 22 '16 at 8:56
  • @Ephi p calls inspect on its arguments, so the output will be quoted, which would disqualify it. – Jordan Aug 22 '16 at 12:56
  • I missed that part of the challenge, I'll let those comments as I think it's an interesting information :) – Ephi Aug 22 '16 at 13:06

Javascript, 18 bytes 16 bytes 12 bytes 11 bytes

` ${!2}`[2]

Based on modified jsfuck basics (had to figure out how to replace + with -).

Ungolfed?

Well, at least a version with comments (note that this version will probably not run):

` ${      // whitespace to make "a" the third letter
  !2      // returns false
}`        // convert to string "false"
[2]       // index the third letter in " false" (note the whitespace)

Old solution:

`${![]}`[-(-!![])]
  • You can replace the parenthesis with a space between the minus signs. – Pietu1998 Aug 20 '16 at 13:44
  • @Pietu1998: I noticed that 3 is allowed so replaced the whole thing with boring old 3-2 to get 1 – slebetman Aug 20 '16 at 14:53
  • Saved one byte thanks to Conor O'Brien's answer – slebetman Aug 20 '16 at 15:03
  • 1
    Uh, no offense, but this pretty much is my answer. Except you use false instead of NaN and don't use a function. – Conor O'Brien Aug 21 '16 at 6:28

Java, 55 bytes

void f(){System.err.write('c'-2);System.err.println();}

Since the code has to print it, one of the two built-in writers are required. System.out is, well, out, because it contains u. System.err works, however.

The next hurdle is Java's handling of char and int. Since it is not allowed to cast to char because it contains a, and because 'c' - 2 gets promoted to int, another mechanism is required. System.err is a PrintWriter, which has a write(char) method but not write(int). Putting 'c' - 2 in there forces it to char without a cast.

Finally, every time I ran the program the buffer for System.err would not flush like it is supposed to, and the program printed nothing. So I had to flush it manually. However, System.err.flush() is not allowed, so I called println() which implicitly flushes the underlying stream.

MATL, 5 bytes

YNVH)

Try it Online

Explanation

YN      % Creates a NaN value (not a number)
V       % Convert it to a string
H)      % Grab the second letter ('a')
        % Implicitly display the result

My original answer was the straight forward approach using the pre-defined literal lY2 which yields 'A'...'Z' and then selecting the first element, 'A'.

lY2l)

Vim, 16 13 11 10 keystrokes

Thanks to H Walters for saving two keys

Thanks to DJMcMayhem for saving another!

:h%<cr>jvyZZp
:h%<cr> #open help for percent
jvy     #move down one char (to the letter "a"), visual mode the character, yank
ZZ      #exit help for percent
p       #put yanked character
  • Very nice approach! – YetiCGN Aug 20 '16 at 12:19
  • 2
    Save 3 bytes; instead of :h<cr>, try :h%<cr>. That's one extra character, but you wind up on the help for %, with your cursor right over an a. So from here you can replace 33ll with j. – H Walters Aug 21 '16 at 2:30
  • Apologies for obvious typo (save 2 bytes) – H Walters Aug 21 '16 at 3:06
  • You can use ZZ instead of :q<cr> to save another one. – DJMcMayhem Aug 25 '16 at 21:12

><>, 7 4 bytes

Saved 3 bytes thanks to Teal pelican

"-o.

Try it online!

Explanation

"-o."   # pushes the string "-o."
-       # subtracts the charcode of o from the charcode of . (dot), 111-46=65
o       # prints as character
.       # tries to pop 2 coordinates to jump to, but as nothing is left on the stack
        # the program ends in an error
  • I would have done "B"1-o; – DanTheMan Aug 22 '16 at 18:36
  • @DanTheMan That should have been the more obvious solution. I wonder why I didn't think of that :P – Emigna Aug 22 '16 at 18:46
  • @DanTheMan :- Going off what Dan posted you can reduce this down further to; "1-o;B or even better "+o;& as either case is allowed making this 5 bytes :) - you can even make it 4 bytes with an error; "-o. – Teal pelican Jul 18 '17 at 15:06
  • @Tealpelican: That's brilliant! Using strings are often shortest in challenges like these, but I didn't even consider that :) – Emigna Jul 18 '17 at 15:29
  • Once I saw Dan's comment it reminded me of an older challenge quite like this so just used the same concept :) – Teal pelican Jul 18 '17 at 15:46

R, 27 12 bytes

EDIT : New version, from an excellent idea from @Jarko Dubbeldam

LETTERS[T*T]

Quite a funny challenge !

Basically, this takes the 26th element of the reversed vector containing the uppercase letters (LETTERS, which is a R's built-in vector)

Previous versions (same number of bytes) :

L=LETTERS;rev(L)[length(L)]
rev((L=LETTERS))[length(L)]
  • 1
    A bit late, but you can save quite a bit with LETTERS[T*T]. T evaluates to 1 when doing numerical operations. – JAD Jan 1 '17 at 17:30
  • I found a shorter solution! – Giuseppe Jul 18 '17 at 15:52
  • This isn't technically a solution --- it prints '[1] "a"' , rather than just 'a' – JDL Aug 28 '17 at 22:07

Brainfuck, 192 19 bytes

----[>---<----]>--.

Thanks to @NinjaBearMonkey for helping me save hella bytes

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.

I'm not good at Brainfuck so I'm sure theres a shorter solution, but it works by decrementing below 0, rolling the byte over, and keep going until it gets down to 'A', then it prints.

  • 1
    not a serious competitor. If you actually golf it down, the downvoter might invert their vote – Destructible Lemon Aug 19 '16 at 22:30
  • Wouldn't it be much shorter to just count up to 65, even with 65 plusses? – NinjaBearMonkey Aug 19 '16 at 22:33
  • 2
    '+' isn't allowed, so I had to go backwards – Cody Aug 19 '16 at 22:34
  • Sorry, I didn't see that. There's still far shorter ways to make 191, though. – NinjaBearMonkey Aug 19 '16 at 22:36
  • 2
    That was the 192 byte solution, I just left it up and did the strikethrough instead of deleting it because I thought it was funny going from 192 to 19 – Cody Aug 19 '16 at 23:30

JavaScript (ES6), 21 bytes

_=>(8^2).toString(22)

I originally tried converting false to string to do this, but it took me 23 bytes at the time. I've since come up with a shorter way, which is this for 14 bytes:

_=>`!${!2}`[2]

I don't think you can get an uppercase A under the rules, since you need one of String.fromCharCode or .toUpperCase(), both of which contain a.

  • You can get uppercase a using JSF or a derivative using computed properties – Downgoat Aug 20 '16 at 2:41
  • 1
    @Downgoat Conor O'Brien already showed how. – Neil Aug 20 '16 at 9:31

C, (19?) 24 bytes

Thanks to Dennis:

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

same length:

f(){printf("%c",'C'-2);}

which enables also lowercase:

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

There is a 19 bytes solution as a function modifying its parameter, which has a flaw:

g(int*p){*p='C'-2;}

//Usage:

main(){
  int c; //cannot be char
  g(&c);
  printf("%c\n",c);
}

If c was declared char, g modifies the whole int so it smashes the stack which causes other values to be modified or the programm to abort with an error message. The only way to circumvent is to declare int c; in main and print with "%c", but that feels like a loophole.

older solutions

f(){printf("%c",'B'-2/2);} //26 bytes
f(i){i='B';printf("%c",--i);} //29 bytes
f(){int*i="B";int j[]={*i-(2/2),2-2};printf("%s",j);} //53 bytes

Just a function, since main is forbidden.

  • 3
    88-23 should save a few bytes. – Dennis Aug 19 '16 at 22:43
  • For lower case a, you can use (333-33)/3-3. It's not as short as 'c'-2, but it's 3er. 33*3-2 is also possible. – rici Aug 20 '16 at 19:42
  • If you use write() instead of printf you can make it a program; specify the build steps to ensure you don't link against any libc at all; if there is no _start the first symbol is jumped to and _exit is allowed so it's safe. At least one version of gcc will optimize write() into the direct syscall with no function call at all. – Joshua Aug 24 '16 at 22:58
  • Depending on your IDE you can do something like this: printf("%c",~'ɦ');, though the "A" will have an accent mark added heh – Albert Renshaw Jan 24 '17 at 9:48
  • @AlbertRenshaw ɦ is a 2-byte-character – Karl Napf Jan 25 '17 at 19:49

dc, 4 bytes

833P

UCHAR_MAX overflow rolls through the table six three times before landing at 65.

Lua, 36 bytes

This one took me a while since MANY of the standard Lua functions are taken away from the rules (all of math, string.char, string.match, pairs, even next)

This takes advantage of the fact that Lua has a global _VERSION that usually starts with "Lua" (e.g., Lua 5.1, or similar for other versions), so unless this is run on a non-mainstream interpreter, the third character will be an 'a'

print(({_VERSION:find("..(.)")})[3])

The {...}[3] is to group the results of find which also includes the indices where it matched, and then return the third item which is the matched character (the a)

  • 1
    print(({type{}:find".(.)"})[3]) 31 bytes – Egor Skriptunoff Aug 27 '16 at 13:14

Vim, 2 Keystrokes

vim -u NONE then run the following (-u NONE turns off customization)

i<up>

When vim is run in compatible mode the arrow keys are don't get interpreted properly. <up> gets interpreted <esc>OA which leave the following in insert mode. Which would leave (with a couple of trailing newlines)

A

i starts insert mode.
<up> exits insert mode, opens a line above and enters A into the buffer

Example of people encountering this in the wild. https://stackoverflow.com/questions/6987317/while-moving-the-cursor-across-a-vim-process-open-in-a-tmux-session-every-now-a/6988748#6988748

  • I laughed as I read it. This is good work. Great weaponization of something I know, but wouldn't have thought of. – udioica Oct 13 '16 at 15:50

Haskell, 10 bytes

As a function (or rather a statement as no input is required)

f=pred 'B'

does the trick. Try it on Ideone. A full program is impossible as this would need to contain a main.

  • I don't think this is valid. The task requires to "print" or "display" A. Your functions just returns it and the linked program displays it via putChar which uses u. – nimi Aug 19 '16 at 22:43
  • You're right, however the rules have been updated and now returning from a function seems to be ok. – Laikoni Aug 19 '16 at 23:02
  • No, the rules still say print and/or display. – nimi Aug 19 '16 at 23:05
  • 2
    Dennis asked explicitly whether returning from a function instead of printing is ok and OP replied with yes, but the afterwards updated wording of the question still doesn't reflect this. I guess we still have to wait for further clarification. – Laikoni Aug 19 '16 at 23:33
  • 1
    The OP confirmed that A should be printed/displayed and not returned. – nimi Aug 20 '16 at 18:49

Brachylog, 4 bytes

@Ztw

Try it online!

Explanation

@Z      The string "zyxwvutsrqponmlkjihgfedcba"
  tw    Write the last element to STDOUT

dc, 8 7 bytes

-1B thanks to Dennis

88 23-P

Pushes 88, pushes 23, subtracts, leaving 65. Print top of stack (65) as an ASCII string, sans trailing newline.

Edit:

These are a few of the other ways I came up with. It basically became a game of "generate the numbers 65 and 97 using only [238B-F] and without addition". Ironically, I find the longest ones most interesting.

_Fdd/r-oC 2-n  # involves changing the base
2_2/8d*3*2/-P
Idd2/2/-2*on   # also changes base
2d8r^r_2/-P
8d*2_2/-P
B 3d**2-P
33 3*2-P

protected by Community Nov 11 '16 at 15:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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