How many characters are there on the icon of a Stack Exchange site?

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:

Astronomy
Beer
Freelancing
Health
History
Law
Music: Practice & Theory
Parenting
The Great Outdoors
Writers


2 characters:

3D Printing
Biblical Hermeneutics
Bitcoin
Board & Card Games
Buddhism
Chinese Language
Coffee
Community Building
Computational Science
Computer Graphics
Data Science
Earth Science
Ebooks
Economics
Emacs
Engineering
Expatriates
French Language
Gardening & Landscaping
Genealogy & Family History
German Language
Hardware Recommendations
Hinduism
Homebrewing
Islam
Italian Language
Japanese Language
Joomla
Lifehacks
Martial Arts
Mathematics Educators
Motor Vehicle Maintenance & Repair
Music Fans
Mythology
Open Data
Personal Productivity
Pets
Philosophy
Physical Fitness
Politics
Portuguese Language
Project Management
Puzzling
Quantitative Finance
Reverse Engineering
Robotics
Russian Language
Software Quality Assurance & Testing
Software Recommendations
Sound Design
Space Exploration
Spanish Language
Sports
Startups
Sustainable Living
Tridion
Vi and Vim
Video Production
Windows Phone
Woodworking
Worldbuilding


3 characters:

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


Non-ASCII:

Anime & Manga
Arduino
Aviation
Chess
CiviCRM
Poker


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.

• This seams like regex golf – HEGX64 Mar 3 '16 at 12:33
• 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. – Chris J Mar 3 '16 at 12:50
• @ChrisJ You are not supposed to access Internet for the purpose of this challenge. That might be another question... – jimmy23013 Mar 3 '16 at 12:59
• 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. – jimmy23013 Mar 3 '16 at 13:13
• So we input the name and output the amount of ascii characters? – GamrCorps Mar 3 '16 at 13:16

CJam, 5048 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.

• You lie! Open Source has 3 letters! How could you do this to my site! I'm... I'm... I'm heartbroken! – Zizouz212 Mar 4 '16 at 1:10
• @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. – Sp3000 Mar 4 '16 at 3:00

Retina, 146136134130124107 102 bytes

A\w*i|Che|CR|ke
4
my|Be|lan|^H.*y$|lt|aw|:|Pa|Ou|Wr 1 gn.|^e|Et|^H.*S|gui|rc|lf|To 2 .*(\d).*$1
..+
3


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.

• @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. – daavko Mar 3 '16 at 15:22
• I have some pretty compact regexes in my JS answer. Feel free to use them if they'll help ;) – Mwr247 Mar 3 '16 at 16:18
• @Mwr247 Thanks, I think I'll use them. – daavko Mar 3 '16 at 17:35
• I think you can output 3 for 2-char to get rid of the (?!D). – jimmy23013 Mar 3 '16 at 19:03
• @jimmy23013 That makes sense... I somehow forgot I can move the output values around. – daavko Mar 3 '16 at 19:10

Javscript ES6, 342339330 327 bytes

a=>{for(c of "9As4BebFr6He7Hi3LaoMu9PaiTh7Wrzb3DdAmlBi7BiiBo8BugCh6CoiColCohCocDadEa6Eb9Ec5EmbEnbExfFrnGaqGefGeoHa8HibHo5IsgIthJa6Jo9LicMalMayMoaMu9My9OplPe4PeaPhgPh8PojPoiPr8PukQujRe8RogRu10SooSocSohSpgSp6Sp8StiSu7TraVigVidWibWodWoziCodel8EtyHibLibOpvPrhSi3To".splitz)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.

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

PowerShell, 212 181 bytes

$a=-join$args[0][0,2,-1];$b="Aty,Ber,Feg,Hah,Hsy,Lww,Msy,Prg,Tes,Wis,Cgs,eeS,Ehm,Hss,Lns,Oee,Pof,Sgg,Trr,Aia,Ado,Ain,Ces,CvM,Pkr".IndexOf($a);(((1,3)[$b-ge40],4)[$b-ge76],2)[$b-lt0]  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

• I see that you've got "coffee" hardcoded. My brain does, too. – dotancohen Mar 3 '16 at 14:51
• Is there a place where I can test it out? – Zizouz212 Mar 4 '16 at 1:20
• @Zizouz212 Any Windows computer. There's also this, but it doesn't seem to be working and apparently it's PASH, not PowerShell proper. – Bob Mar 4 '16 at 3:17
• @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. – AdmBorkBork Mar 4 '16 at 13:28

JavaScript (ES6), 108 bytes

a=>[/A\w*i|Che|CR|ke/,/my|Be|lan|^H.*y\$|lt|aw|:|Pa|Ou|Wr/,/gn.|^e|Et|^H.*S|gui|rc|lf|To/].map(b=>+b.test(a))


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

ȷ;€ȷḥ€ɠḋ“¥ẏ⁻ỵŻŀ]Ḥ6Iɠçịƥṃƈ=ẈQk®bȷƥ!?’b5¤%5


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.

Discussion

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.

Explanation

ȷ;€ȷḥ€ɠḋ“…’b5¤%5
ȷ;€ȷ               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).

• Why'd you make this CW? – Makonede Apr 8 at 22:28
• 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.) – ais523 Apr 8 at 22:32