Since 2009, Android's version code names have been confectionery-themed. Android 1.5 is Cupcake, Android 1.6 is Donut, Android 2.0 is Eclair, etc.. In fact, the version names are alphabetical!

C -> Cupcake
D -> Donut
E -> Eclair
F -> Froyo
G -> Gingerbread
H -> Honeycomb
I -> Ice Cream Sandwich
J -> Jellybean
K -> Kitkat
L -> Lollipop
M -> Marshmallow
N -> Nougat
O -> Oreo

In order:

Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice Cream Sandwich, Jellybean, Kitkat, Lollipop, Marshmallow, Nougat, Oreo


Write a program/function that takes a letter from C to O and outputs its respective Android version code name.


  • Standard I/O rules apply.
  • Standard loopholes are forbidden.
  • You can choose to either support lowercase input or uppercase input or even both.
  • The output may be in title case (Cupcake) or completely lower case (eclair). Ice cream sandwich may be capitalized however you like. (I didn't expect it to cause so much confusion...)
  • This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
  • Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
  • Built-in functions (Mathematica might have one :P) that compute this sequence are allowed but including a solution that doesn't rely on a built-in is encouraged.
  • Explanations, even for "practical" languages, are encouraged.

Test cases

These are uppercase and title case.

Input   Output

F       Froyo
I       Ice Cream Sandwich
J       Jellybean
N       Nougat
G       Gingerbread
L       Lollipop

In a few better formats:

F, I, J, N, G, L
f, i, j, n, g, l

f i j n g l
  • 8
    \$\begingroup\$ @Mr.Xcoder Are you saying its not a dupe because its easier? This is a dupe precisely because it is an easier version of an existing question. We've already done this type of question to death and this one provides absolutely nothing new or interesting to the genre. \$\endgroup\$ – Sriotchilism O'Zaic Aug 22 '17 at 17:30
  • 2
    \$\begingroup\$ @WheatWizard I think the former is a better dupe, since the latter is restricted source. \$\endgroup\$ – Mr. Xcoder Aug 22 '17 at 17:57
  • 9
    \$\begingroup\$ It might be a dupe of some other challenge. But Help me recognize my monster is asking for string to symbol conversion (which leads to hash-based solutions). This one is asking for symbol to string. \$\endgroup\$ – Arnauld Aug 22 '17 at 18:02
  • 6
    \$\begingroup\$ coughs \$\endgroup\$ – Magic Octopus Urn Aug 22 '17 at 20:15
  • 5
    \$\begingroup\$ @MagicOctopusUrn Yeah, I saw that, too. Unfortunately, it doesn't include MARSHMALLOW and later. \$\endgroup\$ – mbomb007 Aug 22 '17 at 20:49

35 Answers 35


Charcoal, 73 bytes

θ§⪪”%↖↙1¬¢/vy⁵⸿ψJPP±≔S×5Jρνξ–Gu ◧;Yx³F▶ψ;εB↥:P¹N﹪J$α✂χ✳⦄⟲*±¶Sp:ς↘V◧◧”x℅θ

Try it online! I/O is in lower case. Based on this verbose version. Explanation:

                Implicitly print:
θ               Input character
                Implicitly print:
   ”...”        Long compressed string "oneycombx...xingerbread"
  ⪪            Split on
        x       The string "x"
 §              Circularly indexed by
          ℅     Character code of
           θ    Input character
  • 4
    \$\begingroup\$ I... What? How. \$\endgroup\$ – Magic Octopus Urn Aug 22 '17 at 20:13
  • \$\begingroup\$ @MagicOctopusUrn Sorry I was too busy to add an explanation at the time. Hope this one suffices. \$\endgroup\$ – Neil Aug 22 '17 at 20:24
  • 1
    \$\begingroup\$ Oh wow, I didn't know it did compressed strings! \$\endgroup\$ – Magic Octopus Urn Aug 22 '17 at 20:24
  • \$\begingroup\$ How Charcoal beats SOGL here is just unbelievable. \$\endgroup\$ – Erik the Outgolfer Aug 23 '17 at 9:41
  • \$\begingroup\$ Jelly's still beating it :joy: codegolf.stackexchange.com/a/140092/73675 \$\endgroup\$ – Hugo H Aug 23 '17 at 17:39

Bash + Core Utils 131 128 122 117 bytes.

The script is encoded as Base64 because it contains special (weird) characters.

Accepts the Android codename letter only in lowercase as its first positional parameter. Returns the full codename also in lowercase.



#�Q��������s�X����!�>0�������`N`x������~$�^@7�D�    ��X5�0'�D�� 
base32 $0|tr 'A-Z47
' 'a-z
 '|grep ^$1
  • The first two lines are the binary blob with the data (see a the end of the answer for more information). The first line is empty, to avoid problems with Bash, as otherwise it may think that is being fed with a binary file.
  • base32 $0 encodes the script contents with Base32, with the default line wrapping of 76 characters.
  • tr 'A-Z47\n' 'a-z\n ' (note that the \n is written as a literal newline) will lowercase the input and replace 4, 7 and \n by \n, space and space respectively.
  • grep ^$1 will output the lines matching the string provided as first argument to the script.

Binary data

This octet stream was forged so it doesn't contain newlines and when it's decoded with Base32 as per RFC 4648, the resulting string is the list of Android codenames (using 4 as item delimiter and 7 to replace the space character). Among its peculiarities, it begins with a newline character and a hash (#) so it behaves as a comment and, therefore, isn't executed by the interpreter.

Also, the default line wrapping to 76 characters of this Base32 implementation helped me a byte, as I reordered the items to use the line break as one of the Ice cream sandwich spaces.

Also, and going a bit off-topic, I think that Google shouldn't indirectly advertise commercial products in the Android codenames.

  • 2
    \$\begingroup\$ Nice, this is a really cool answer! Welcome to the site :) \$\endgroup\$ – DJMcMayhem Aug 23 '17 at 17:22
  • \$\begingroup\$ Another Bash answer: codegolf.stackexchange.com/a/140147/41835 \$\endgroup\$ – Helio Aug 23 '17 at 20:48
  • 1
    \$\begingroup\$ This version is buggy, at least on my system (bash 4.4.12, coreutils 8.27). For f, it outputs two lines: one with froyo and another with mysterious fgeyltmuzteibno. \$\endgroup\$ – MarSoft Aug 24 '17 at 12:40
  • 1
    \$\begingroup\$ @MarSoft: Thanks! Fixed. The pity is that now I need a byte more. \$\endgroup\$ – Helio Aug 24 '17 at 12:58
  • \$\begingroup\$ @MarSoft: Solved! Now with the same bytes! \$\endgroup\$ – Helio Aug 24 '17 at 15:59

Python 3, 139 bytes

lambda x:x+'upcake,onut,clair,royo,ingerbread,oneycomb,ce cream sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo'.split(",")[ord(x)-67]

Try it online!


Bash + Core Utils (Grep): 132 130 Bytes

Simple as could be

grep ^$1<<<'Cupcake
Ice Cream Sandwich
  • 1
    \$\begingroup\$ Input via dd is clever, but could you save as a script and use $1 instead? \$\endgroup\$ – Dom Hastings Aug 23 '17 at 5:35

Jelly, 57 bytes

Oị“¡ȥọ⁴ḷæĿɱ}#n#i®ÞSỊ3ƙɼıjṁ)-⁵g7ḥjC?4ƘẠʂ+ḋ¤⁺jṣð£?v»Ḳ¤F⁾! y

Try it online!

-5 thanks to Jonathan Allan.

  • \$\begingroup\$ Save four bytes by using a placeholder for the spaces in "ice cream sandwich" and using spaces for splitting, for example: Oị“¡ḟ¤Y7bh%XO€ḥıṣẎṄṢ°ḊḞİỌĿż0Y⁷ẠỵƈƭV>tÐNY_LɠðṅẒọX?v»Ḳ¤F⁾! y \$\endgroup\$ – Jonathan Allan Aug 24 '17 at 14:00
  • \$\begingroup\$ ...actually make that five bytes (I had used "lair" when "clair" is in the dictionary): Oị“¡ȥọ⁴ḷæĿɱ}#n#i®ÞSỊ3ƙɼıjṁ)-⁵g7ḥjC?4ƘẠʂ+ḋ¤⁺jṣð£?v»Ḳ¤F⁾! y \$\endgroup\$ – Jonathan Allan Aug 24 '17 at 14:10
  • \$\begingroup\$ @JonathanAllan thanks...wait why would I need the F? oh it's because I get input as a string not char \$\endgroup\$ – Erik the Outgolfer Aug 24 '17 at 14:28

C++, 206 201 198 bytes

Thanks to @sergiol for helping to save 3 bytes!

void f(int l){char*w[]={"upcake","onut","clair","royo","ingerbread","oneycomb","ce Cream Sandwich","ellybean","itkat","ollipop","arshmallow","ougat","reo"};printf("%c%s",l,w[l-67]);}

Try it online!

C, 173 bytes

f(l){char*w[]={"upcake","onut","clair","royo","ingerbread","oneycomb","ce Cream Sandwich","ellybean","itkat","ollipop","arshmallow","ougat","reo"};printf("%c%s",l,w[l-67]);}

Well, it started as C++, but now it's also valid C, and some bytes can be saved by compiling it as C.

Try it online!

  • 1
    \$\begingroup\$ My failed attempt to turn it shorter by removing the first letter of each entry: tio.run/… \$\endgroup\$ – sergiol Aug 22 '17 at 22:46
  • \$\begingroup\$ @sergiol Thanks! I was able to save three bytes with that after a bit of golfing. \$\endgroup\$ – Steadybox Aug 23 '17 at 1:55
  • 4
    \$\begingroup\$ #import in c++? what am I missing here? \$\endgroup\$ – Abhinav Gauniyal Aug 23 '17 at 5:17
  • \$\begingroup\$ @AbhinavGauniyal: IIRC I think some compiling warning advised me also to add #import <cstdio> because the lack of #include <stdio.h>; or may be I am wrong \$\endgroup\$ – sergiol Aug 23 '17 at 8:04
  • \$\begingroup\$ @AbhinavGauniyal It's not standard C++, but at least GCC and MSVC have it. \$\endgroup\$ – Steadybox Aug 23 '17 at 13:24

JavaScript (ES6), 137 136 bytes

Saved 1 byte thanks to Neil

c=>'CupcakeDonutEclairFroyoGingerbreadHoneycombIce Cream SandwichJellybeanKitkatLollipopMarshmallowNougatOreo'.match(c+'([a-z]| .)+')[0]


let f =

c=>'CupcakeDonutEclairFroyoGingerbreadHoneycombIce Cream SandwichJellybeanKitkatLollipopMarshmallowNougatOreo'.match(c+'([a-z]| .)+')[0]

;[...'CDEFGHIJKLMNO'].map(c => console.log(c, '->', f(c)))

  • \$\begingroup\$ can't you include the space in the character range, probably with \s? haven't used much JS Regex \$\endgroup\$ – michi7x7 Aug 22 '17 at 18:26
  • 1
    \$\begingroup\$ @michi7x7 Hes need the match to stop at an uppercase letter except in the case of Ice Cream Sandwich, although ([a-z]| .)+ (saving 1 byte) would work even with Ice Cream Sandwich in the middle of the string (it would start failing when code names reached S though). \$\endgroup\$ – Neil Aug 22 '17 at 18:35
  • \$\begingroup\$ @Neil well, [a-z\s]+ doesn't match uppercase letters. I just don't know if you can do that in JS \$\endgroup\$ – michi7x7 Aug 22 '17 at 18:39
  • \$\begingroup\$ @michi7x7 So how would it work with Ice Cream Sandwich? \$\endgroup\$ – Neil Aug 22 '17 at 18:54
  • 2
    \$\begingroup\$ Use Ice cream sandwich, like in the test case (although this is not Title Case) \$\endgroup\$ – michi7x7 Aug 22 '17 at 19:03

Japt, 81 79 bytes

Contains a few characters that won't display here.

U+`Æ+tfÆ÷¯kef©fclairfê $ßdfey¬mbf­ ×Äm ÑØrfÁKÞ fkfo¥ipopfÂâÚaow`qf gUc

Test it

  • 2 bytes saved thanks to Oliver.


Implicit input of uppercase character string U.

A compressed string (everything between the backticks) of the names, separated with an f and without their first letter is split (q) into an array on f.

Within that array we get the element at the index (g) of Us character code. (Yay, index wrapping!)

We append that to U and implicitly output the resulting string.

  • 1
    \$\begingroup\$ Nice. You can save a couple bytes if you split on f instead if newlines: ethproductions.github.io/japt/… \$\endgroup\$ – Oliver Aug 22 '17 at 18:07
  • \$\begingroup\$ @Oliver: Oh, nice, thanks :) On my phone, walking down the street so definitely wouldn't have gotten that for a while (if at all). \$\endgroup\$ – Shaggy Aug 22 '17 at 18:10

Excel VBA, 137 134 132 Bytes

Anonymous VBE immediate window function that takes input as expected type Variant\String and length 1 holding a capital letter from cell [A1] and outputs to the VBE immediate window function

?[A1]Split("upcake onut clair royo ingerbread oneycomb ce cream sandwich ellybean itkat ollipop arshmallow ougat reo")(Asc([A1])-67)

-5 Bytes for changing the spaces in ce cream sandwich from (char 32) to  (char 160) `` (char 127) and removing comma delimiter in the Split function


SOGL V0.12, 81 bytes


Try it Here!


...‘            push "cupcake donut eclair froyo gingerbread honeycomb ice_cream_sandwich jellybean kitkat lollipop marshmallow nougat oreo"
    θ           split on spaces
     ╔@ŗ        replace underscores with spaces
        z,W     find the inputs index in the lowercase alphabet
           HH   decrease by 2
             w  get that item from the array

Now there is a shorter 80 byte version, but I added the +2/-2 built-ins because of this challenge :p

The compressed string is split like "cup","cake"," donut eclair fro","yo gingerbread honeycomb ice","_","cream","_","sandwich jelly","bean kit","kat loll","i","pop marsh","mallow"," nougat oreo" for maximum usage of english words (many weren't in SOGLs dictionary), right now I can't find any improvements.


><>, 181 bytes

 v"ce Cream Sandwich"

Try it online!

This works by self-modifying the program to place a < in front of the correct name to print, the position of which is determined by the value of the inputted letter.


Dyalog APL, 158 143 131 bytes

1 byte saved thanks to @Zacharý

12 bytes saved thanks to @Gil

{⍵,(⎕A⍳⍵)⊃','(1↓¨=⊂⊢)',,,upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo'}

Try it online!


',,,upcake...' - list of words

','(1↓¨=⊂⊢) - split by ','

(⎕A⍳⍵)⊃ - take from the place of the argument in the alphabet

⍵, - and append to the letter

  • \$\begingroup\$ Why did you describe as flatten? \$\endgroup\$ – Zacharý Aug 22 '17 at 19:08
  • \$\begingroup\$ Also, {⍵,∊⍬⍬'upcake' 'onut' 'clair' 'royo' 'ingerbread' 'oneycomb' 'ce cream sandwich' 'ellybean' 'itkat' 'ollipop' 'arshmallow' 'ougat' 'reo'[⎕A⍳⍵]} works for 1 less byte! \$\endgroup\$ – Zacharý Aug 22 '17 at 19:10
  • \$\begingroup\$ @Zacharý because it is... "mix". nice one! why ∊ and not ↑? \$\endgroup\$ – Uriel Aug 22 '17 at 19:27
  • \$\begingroup\$ Because is flatten as well, but actually flatten and not "mix". ↑(1 2)(3 4) is NOT flat, while ∊(1 2)(3 4) is. \$\endgroup\$ – Zacharý Aug 22 '17 at 20:21
  • \$\begingroup\$ @Zacharý OP changed that... AGAIN. \$\endgroup\$ – Uriel Aug 22 '17 at 20:34

EXCEL, 154 bytes

=A1&CHOOSE(CODE(A1)-66,"upcake","onut","clair","royo","ingerbread","oneycomb","ce Cream Sandwich","ellybean","itkat","ollipop","arshmallow","ougat","reo")
  • \$\begingroup\$ I've never thought of using excel in this way. Perfect. Now do it with WORD \$\endgroup\$ – tisaconundrum Aug 24 '17 at 0:11
  • \$\begingroup\$ @tisaconundrum - we do not speak of that accursed thing; Even VBA could not save it \$\endgroup\$ – Taylor Scott Oct 10 '17 at 15:57

C (gcc), 195 192 190 bytes

-2 bytes thanks to @Quentin

*V[]={"upcake","onut","clair","royo","ingerbread","oneycomb","ce Cream Sandwich","ellybean","itkat","ollipop","arshmallow","ougat","reo"};main(c,v)char**v;{printf("%c%s",c,V[(c=*v[1])-67]);}

Try it online!


Tcl, 158 bytes

proc A s {puts $s[lindex {upcake onut clair royo ingerbread oneycomb "ce Cream Sandwich" ellybean itkat ollipop arshmallow ougat reo} [expr [scan $s %c]-67]]}

Try it online!

  • 2
    \$\begingroup\$ Tcl! You don't see too many Tcl solutions on here. It's a shame. \$\endgroup\$ – Silvio Mayolo Aug 23 '17 at 3:14

Haskell, 145 bytes

f c=takeWhile(/=succ c)$dropWhile(/=c)"CupcakeDonutEclairFroyoGingerbreadHoneycombIce Cream SandwichJellybeanKitkatLollipopMarshmallowNougatOreo"
  • 3
    \$\begingroup\$ takeWhile can be fst.span and dropWhile accordingly snd.span. \$\endgroup\$ – Laikoni Aug 22 '17 at 22:29

Gaia, 110 bytes

:c“reo“upcake“onut“clair“royo“ingerbread“oneycomb“ce Cream Sandwich“ellybean“itkat“ollipop“arshmallow“ougat”=+

Try it online!


:          Push two copies of the input
 c         Get the codepoint of the top one
  “...”    Push the list of version names without their first letters
       =   Modularly index the code point into the list
        +  Append to the input

Ruby, 127 bytes

->c{c+%w[upcake onut clair royo ingerbread oneycomb ce\ Cream\ Sandwich ellybean itkat ollipop arshmallow ougat reo][c.ord-67]}

Takes uppercase input. Try it online!


Pyth, 117 116 bytes

Port of my Python answer.

+Q@c"upcake,onut,clair,royo,ingerbread,oneycomb,ce cream sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"\,a67C

Try it here! or Check out the Test Suite

Pyth, 99 bytes (70 characters)

-15 bytes thanks to @insert_name_here!

+Q@c." y|çEC#nZÙ¦Y;åê½9{ü/ãѪ#¤

Try it here!

  • \$\begingroup\$ You could save 15 bytes by using compressed strings (though the answer would have to contain unprintable characters then). \$\endgroup\$ – insert_name_here Aug 23 '17 at 18:36
  • \$\begingroup\$ @insert_name_here Thanks. \$\endgroup\$ – Mr. Xcoder Aug 23 '17 at 18:38

Java (OpenJDK 8), 128 bytes

c->c+"upcake#onut#clair#royo#ingerbread#oneycomb#ce Cream Sandwich#ellybean#itkat#ollipop#arshmallow#ougat#reo".split("#")[c-67]

Try it online!

Using regexes, 149 bytes

s->"CupcakeDonutEclairFroyoGingerbreadHoneycombIce cream sandwichJellybeanKitkatLollipopMarshmallowNougatOreo".replaceAll(".*?("+s+"[a-z ]+).*","$1")

Try it online!

  • 4 bytes saved on the regex solution thanks to Kevin Cruijssen!
  • 1
    \$\begingroup\$ Was about to post the same .split answer (only with different delimiter) when I read the challenge and couldn't find a Java answer (until I went to the second page of answers), so +1. As for the regex answer, ([a-z]| .)+ can be [a-z ]+, since you are allowed to output "Ice cream sandwich" ("The output may be in title case (Cupcake) or completely lower case (eclair). Ice cream sandwich may be capitalized however you like. (I didn't expect it to cause so much confusion...)") \$\endgroup\$ – Kevin Cruijssen Oct 11 '17 at 11:52

Cubically, 1047 852 830 bytes

Functions sure help golf large programs...


Try it online! This is 830 bytes in Cubically's SBCS.

  • ~ reads input, @ prints it. (This breaks when the input is invalid.)
  • Each of the +.../...+...=7?6{...} compares the input to each ASCII value (C, D, E, F, etc) and executes the code within {...} if they are equal.
  • Each code block ({...}) prints the rest of the name (the first character is already printed).

Thanks to TehPers' ASCII to Cubically translator which was very helpful.

  • 1
    \$\begingroup\$ That's 1060 bytes \$\endgroup\$ – Conor O'Brien Aug 24 '17 at 22:32

V, 125 bytes

ice cream sandwich

Try it online!


Pyke, 117 bytes

Port of my Python answer.

"upcake,onut,clair,royo,ingerbread,oneycomb,ce cream sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"\,cQ.o67-@+

Try it here!

Encoded as hex codes, the new technique of golfing in Pyke, it would be 116 bytes:

22 75 70 63 61 6B 65 2C 6F 6E 75 74 2C 63 6C 61 69 72 2C 72 6F 79 6F 2C 69 6E 67 65 72 62 72 65 61 64 2C 6F 6E 65 79 63 6F 6D 62 2C 63 65 20 63 72 65 61 6D 20 73 61 6E 64 77 69 63 68 2C 65 6C 6C 79 62 65 61 6E 2C 69 74 6B 61 74 2C 6F 6C 6C 69 70 6F 70 2C 61 72 73 68 6D 61 6C 6C 6F 77 2C 6F 75 67 61 74 2C 72 65 6F 22 5C 2C 63 51 EF 36 37 2D 40 2B

(Paste in and check Use hex encoding?).

  • 1
    \$\begingroup\$ Pyke needs an "Android releases" builtin right? \$\endgroup\$ – Erik the Outgolfer Aug 22 '17 at 18:00
  • 1
    \$\begingroup\$ @EriktheOutgolfer It has Pokemons, so why not? \$\endgroup\$ – Mr. Xcoder Aug 22 '17 at 18:01

C#, 147 136 129 bytes


  • Input Char c The first letter of the version name
  • Output String The full name of the version


// Requires the input to be uppercase.
// This is the one counting for the challange
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-67];

// Optional. Requires the input to be lowercase.
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-99];

// Optional. Works with both uppercase and lowercase with the additional cost of 10 bytes.
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-(c<99?67:99)];


c =>
    c + "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
        .Split( ',' )[ c - 67 ];

Ungolfed readable

// Takes a char 
c =>
    // Appends the input letter to...
    c + 

    // ... the name in the resulting index of the subtraction of the char with 67 ('C'), or with 99 ('c') for the lowercase version
    "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
        .Split( ',' )[ c - 67 ];

// Takes a char 
c => 
    // Appends the input letter to...
    c + 

    // ... the name in the resulting index of the subtraction of the char with 67 ('C') if the char is uppercase ( 'C' == 67, 'O' == 79 )
    //    or with 99 ('c') if the char is lowercase ( 'c' == 99, 'o' == 111 )
    "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
        .Split( ',' )[ c - ( c < 99 ? 67 : 99 ) ];

Full code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestBench {
    public static class Program {
        private static Func<Char, String> f = c =>
            c + "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
                .Split( ',' )[ c - 67 ];

        static void Main( string[] args ) {
                testCases = new List<Char>() {

            foreach(Char testCase in testCases) {
                Console.WriteLine($" Input: {testCase}\nOutput: {f(testCase)}\n");



  • v1.0 - 147 bytes - Initial solution.
  • v1.1 - -11 bytes - Borrowed Olivier Grégoire's idea.
  • v1.2 - - 7 bytes - Changed the function input from explicit to implicit.


  • None
  • \$\begingroup\$ Could you save anything by removing the first letter from each name and appending the string you retrieve from the array to the input character? \$\endgroup\$ – Shaggy Aug 23 '17 at 8:52
  • \$\begingroup\$ (char c) can just be c \$\endgroup\$ – LiefdeWen Aug 23 '17 at 10:40

R, 169 155 bytes

sub(paste0(".*(",scan(,""),"[^A-Z]+).*"),"\\1","CupcakeDonutEclairFroyoGingerbreadHoneycombIce cream sandwichJellybeanKitkatLollipopMarshmallowNougatOreo")

Dyalog APL, 125 bytes

{⍵/⍨⍞=⎕A[+\⍵∊⎕A]}'ABCupcakeDonutEclairFroyoGingerbreadHonecombIce cream sandwichJellybeanKitkatLollipopMarshmallowNougatOreo'

Try it online!


  • ⍵∊⎕A (the long string) with 1 for capital letters, 0 for lowercase/spaces.
  • +\ Group (returning numbers) ⍵ by capital letters.
  • ⎕A[...] The capital letter signified by a number
  • ⍵/⍨⍞= The group signified by that number
  • {...}'...' Set to the long string
  • \$\begingroup\$ Clever approach. \$\endgroup\$ – Adám Aug 23 '17 at 19:41

R, 131, 126, 123, 112, 178 bytes

grep(paste0('^',scan(,'')),c("Cupcake","Donut","Eclair","Froyo","Gingerbread","Honeycomb","Ice Cream Sandwich","Jellybean","Kitkat","Lollipop","Marshmallow","Nougat","Oreo"),v=T)

Thanks for @Mark for saving 5 + 8 + 3 bytes


Recursiva, 130 119 118 bytes

+aYQ'upcake!onut!clair!royo!ingerbread!oneycomb!ce cream sandwich!ellybean!itkat!ollipop!arshmallow!ougat!reo''!'-Oa99

Try it online!


C (gcc), 168 bytes

main(){puts(memchr("Cupcake\0Donut\0Eclair\0Froyo\0Gingerbread\0Honeycomb\0Ice cream sandwich\0Jellybean\0Kitkat\0Lollipop\0Marshmallow\0Nougat\0Oreo",getchar(),117));}

Try it online!


PowerShell, 136 134 bytes

param($c)$c+('upcake0onut0clair0royo0ingerbread0oneycomb0ce cream sandwich0ellybean0itkat0ollipop0arshmallow0ougat0reo'-split0)[$c-99]

Try it online!

Takes a [char] input character, in lowercase, and outputs in lowercase.

-2 thanks to AdmBorkBork's suggestion to -split0 instead of -split','.

  • \$\begingroup\$ You could use 0 as a separator and then -split0 to save the quotes. \$\endgroup\$ – AdmBorkBork Aug 29 '17 at 14:40
  • \$\begingroup\$ @AdmBorkBork good suggestion, thanks! \$\endgroup\$ – TessellatingHeckler Aug 29 '17 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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