Given the name of a Stack Exchange site which doesn't have their own design yet, decide how many ASCII characters (non-ASCII ones are counted separately) are there on their icons. Your code should distinguish these 4 cases:

1 character:

Music: Practice & Theory
The Great Outdoors

2 characters:

3D Printing
Amateur Radio
Biblical Hermeneutics
Board & Card Games
Chinese Language
Community Building
Computational Science
Computer Graphics
Data Science
Earth Science
French Language
Gardening & Landscaping
Genealogy & Family History
German Language
Hardware Recommendations
Italian Language
Japanese Language
Martial Arts
Mathematics Educators
Motor Vehicle Maintenance & Repair
Music Fans
Open Data
Personal Productivity
Physical Fitness
Portuguese Language
Project Management
Quantitative Finance
Reverse Engineering
Russian Language
Software Quality Assurance & Testing
Software Recommendations
Sound Design
Space Exploration
Spanish Language
Sustainable Living
Vi and Vim
Video Production
Windows Phone

3 characters:

Cognitive Sciences
elementary OS
History of Science and Mathematics
Open Source
Programming Puzzles & Code Golf
Signal Processing


Anime & Manga

Excluded in this challenge for having non-ASCII characters in their names:

LEGO® Answers
Русский язык

Your code should output a consistent distinct value for each of the 4 sets. Each output (or its string representation for non-string values returned from a function) should be no more than 10 bytes, not counting the optional trailing newline.

You can create multiple pieces of code in the same language. The output of your submission is considered to be the output of each piece of code concatenated in a fixed order (so you can use Regex).

Shortest code wins.

  • 1
    \$\begingroup\$ This seams like regex golf \$\endgroup\$
    – HEGX64
    Commented Mar 3, 2016 at 12:33
  • 1
    \$\begingroup\$ Or could be image analysis using the favicon, given that "Anime and Manga" has a Japanese character in that logo - hence being on the "Non-ASCII" list. \$\endgroup\$
    – Callie J
    Commented Mar 3, 2016 at 12:50
  • \$\begingroup\$ @ChrisJ You are not supposed to access Internet for the purpose of this challenge. That might be another question... \$\endgroup\$
    – jimmy23013
    Commented Mar 3, 2016 at 12:59
  • \$\begingroup\$ The character on Anime & Manga is obviously a . But it's not easy to argue whether the thing on Aviation is a . So I decided to follow the easiest way. \$\endgroup\$
    – jimmy23013
    Commented Mar 3, 2016 at 13:13
  • \$\begingroup\$ So we input the name and output the amount of ascii characters? \$\endgroup\$
    – GamrCorps
    Commented Mar 3, 2016 at 13:16

6 Answers 6


CJam, 50 48 45 bytes

l22b391"þÁ "+{i%}/"Yª>Þÿ9cîÂcVáòe~"322b4b=

There's unprintable characters in the strings above, which can be obtained by the snippets

[254 193 160]:c
[89 170 62 222 30 255 20 57 99 238 194 99 86 225 242 101 126 20]:c

This also shows that the code points are all below 256. Output is 0 for 1 letter, 1 for 2 letters, 2 for 3 letters and 3 for non-ASCII.

The program simply converts the input string to a base 22 number, performs a series of modulos to reduce the number down, before performing a lookup from a base-4 encoded table.

Try it online | Test suite

  • 1
    \$\begingroup\$ You lie! Open Source has 3 letters! How could you do this to my site! I'm... I'm... I'm heartbroken! \$\endgroup\$
    – Zizouz212
    Commented Mar 4, 2016 at 1:10
  • \$\begingroup\$ @Zizouz212 The 0123 outputs don't correspond to the number of letters each. By "respectively" I was referring to the order listed in the OP, so 0 is 1 letter, 1 is 2 letters, 2 is 3 letters and 3 is non-ASCII. Confusing, yes, but it was the golfiest output choice. \$\endgroup\$
    – Sp3000
    Commented Mar 4, 2016 at 3:00

Retina, 146 136 134 130 124 107 102 bytes


Thanks @Sp3000 for golfing off 4 bytes!
Thanks @Mwr247 for golfing off 17 bytes by letting me use regexes from his answer!
Thanks @jimmy23013 for golfing off 5 bytes by reminding me that I can change output values!

The output is 1, 3, 2, and 4 for 1-char, 2-char, 3-char, and non-ASCII, respectively.

Version with all testcases has edits in few places to make it work with multiple lines.

Try it online!
Try it online with all testcases!

  • \$\begingroup\$ @Sp3000 Oh...yeah, thanks! Didn't notice that. That's what happens when you type too fast and don't check it properly afterwards, I guess. I can even i?(ni|vi) -> [nv]?i now. \$\endgroup\$
    – daavko
    Commented Mar 3, 2016 at 15:22
  • 1
    \$\begingroup\$ I have some pretty compact regexes in my JS answer. Feel free to use them if they'll help ;) \$\endgroup\$
    – Mwr247
    Commented Mar 3, 2016 at 16:18
  • 1
    \$\begingroup\$ @Mwr247 Thanks, I think I'll use them. \$\endgroup\$
    – daavko
    Commented Mar 3, 2016 at 17:35
  • 1
    \$\begingroup\$ I think you can output 3 for 2-char to get rid of the (?!D). \$\endgroup\$
    – jimmy23013
    Commented Mar 3, 2016 at 19:03
  • \$\begingroup\$ @jimmy23013 That makes sense... I somehow forgot I can move the output values around. \$\endgroup\$
    – daavko
    Commented Mar 3, 2016 at 19:10

Javscript ES6, 342 339 330 327 bytes

a=>{for(c of "9As4BebFr6He7Hi3LaoMu9PaiTh7Wrzb3DdAmlBi7BiiBo8BugCh6CoiColCohCocDadEa6Eb9Ec5EmbEnbExfFrnGaqGefGeoHa8HibHo5IsgIthJa6Jo9LicMalMayMoaMu9My9OplPe4PeaPhgPh8PojPoiPr8PukQujRe8RogRu10SooSocSohSpgSp6Sp8StiSu7TraVigVidWibWodWoziCodel8EtyHibLibOpvPrhSi3To".split`z`)if(~c.indexOf(a.length.toString(36)+a[0]+a[1]))return c}

Returns a long string starting with 9 for one character, a different long string starting with b for two, a third string starting withi for three, and simply undefined for non-ascii.

  • \$\begingroup\$ Is there anywhere to test it out? I've detected a series of acts of treason against Open Source... \$\endgroup\$
    – Zizouz212
    Commented Mar 4, 2016 at 1:12
  • \$\begingroup\$ @Zizouz212 here's a fiddle: jsfiddle.net/fpt60bpg \$\endgroup\$ Commented Mar 4, 2016 at 1:14
  • \$\begingroup\$ Is it just me, or can I not make it work? \$\endgroup\$
    – Zizouz212
    Commented Mar 4, 2016 at 1:20
  • \$\begingroup\$ It seems to be working for me. \$\endgroup\$ Commented Mar 4, 2016 at 1:33

PowerShell, 212 181 bytes


I found that if you take the first, third, and last characters of each of the possible entries ([0,2,-1] when zero-indexed), we obtain a unique three-letter string for each entry. We then are simply using a string-based lookup to determine which one we have.

Takes input $args[0], and applies the above unique-ness function, saves as $a.

This is then sent through our lookup list via .IndexOf($a) and the result stored in $b. Then, we go through a pseudo-ternary that indexes based on the value of $b to output the appropriate value.

Outputs 1, 2, 3, and 4 for one-character, two-character, three-character, non-ASCII, respectively.

Edit - discovered that [0,2,-1] creates a unique three-character string for each entry, saving 31 bytes

  • 2
    \$\begingroup\$ I see that you've got "coffee" hardcoded. My brain does, too. \$\endgroup\$
    – dotancohen
    Commented Mar 3, 2016 at 14:51
  • \$\begingroup\$ Is there a place where I can test it out? \$\endgroup\$
    – Zizouz212
    Commented Mar 4, 2016 at 1:20
  • \$\begingroup\$ @Zizouz212 Any Windows computer. There's also this, but it doesn't seem to be working and apparently it's PASH, not PowerShell proper. \$\endgroup\$
    – Bob
    Commented Mar 4, 2016 at 3:17
  • \$\begingroup\$ @Zizouz212 PowerShell is pseudo-proprietary, in that it's Windows-only. There are free ways to install virtualized Windows (evaluation versions, developer editions, etc.) if you're a FOSS user. PASH is an open-source blend of PowerShell and BASH, but it's reverse-engineered rather than direct, and only implements about 40% of the PowerShell v1 features, so it is rather limited. \$\endgroup\$ Commented Mar 4, 2016 at 13:28

JavaScript (ES6), 108 bytes


Creates an array composed of regex matches unique to each of the three smallest groups (1 character, 3 character, and non-ascii), then maps a test on the data for each array. When the output is stringified, it evaluates to 1,0,0 for non-ascii, 0,1,0 for 3 characters, 0,0,1 for 1 character, and 0,0,0 for 2 characters.


Jelly, 41 bytes


Try it online!

Full program: input from standard input, output to standard output. Output is 1/2/3/0 for 1 character / 2 characters / 3 characters / non-ASCII.


Hey, I found another question where my algorithm for automatically generating answers to "map this input to that output" questions beats all the existing answers. So here we go.

I used this generator (which I wrote myself) in order to automatically generate this output. For information on the underlying algorithm and how it works, see this answer and this answer.

This question isn't an ideal fit for the algorithm in question, incidentally. There are two issues which mean that it could well be beatable.

The first issue is that 4 (the number of possible outputs) is not a prime number. The algorithm itself doesn't technically require the number of outputs to be prime, just a prime power (because we need a finite field of the appropriate size). 4 is a prime power (2²), so it would be an ideal fit for the question. However, Jelly doesn't have any builtins for operating on GF(4), so we're using GF(5) instead, which multiplies the size of our long constant by a factor of log(5)/log(4), an increase of about 16%.

The second issue is that 2 is an overwhelmingly common output, with most of the inputs mapping to it. The algorithm doesn't care about this at all, and works equally well with any distribution of outputs. However, an output that did care about this fact could probably take advantage of it in order to use a shorter constant string. Although it's easy to imagine what such an algorithm could look like (and it could use almost the same program shell), I can't think of any efficient way to calculate the string constant that most of the program is built around.

Of course, there's also the fact that the total amount of data required is so small that the overhead of the decompressor is rather notable, and a less efficient algorithm could beat it simply by needing a smaller amount of boilerplate!

So I imagine there's scope for improvement here, although I can't immediately see how. It's still interesting to see a machine-generated solution beating all the human-written solutions, though.


ȷ;€ȷ               Generate 1000 different (arbitrary) hash configurations
    ḥ              Hash
      ɠ              standard input
     €               using each of the hash configurations
       ḋ           Take the dot product of the resulting vector of 1000 hashes
             ¤       with
        “…’b5        a particular list of numbers in the range 0…4 inclusive
              %5   {The output is} that dot product, modulo 5

The long list of numbers is chosen to give the correct output for every input (by asking a computer, specifically my generator written in a mix of Jelly and Sage, to find a short list that happens to give the correct input/output mapping).

  • \$\begingroup\$ Why'd you make this CW? \$\endgroup\$
    – Makonede
    Commented Apr 8, 2021 at 22:28
  • \$\begingroup\$ I make all my posts community wiki. There's normally no real connection between the sorts of answers that get you lots of reputation and the sorts of answers that actually make the site better. I'd much rather be posting the latter than the former, and CWing all my posts helps to avoid any incentive to post answers purely to get upvotes. (It also makes my posts easier to edit – I think people should be editing posts more often, although I don't do it myself because there's an unavoidable +2 reputation gain for low-reputation post editors.) \$\endgroup\$
    – ais523
    Commented Apr 8, 2021 at 22:32

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.