Background
I saw this very interesting Venn Diagram on wikipedia: https://simple.wikipedia.org/wiki/Alphabet#/media/File:Venn_diagram_gr_la_ru.svg
It shows the letters (physical shapes) in different alphabets that are common between Russian, Greek and Latin alphabets.
The Challenge
Given an input string of characters from any of the three scripts shown (i.e capitalised Greek, Cyrillic or Latin letters), output a percentage of the string that matches each language. Repeated letters count every time.
For example, FFLURS
is all latin-only characters, so the output is FFLURS is 100% Latin, 0% Cyrillic and 0% Greek
.
By contrast, TOX BEAM PHP
is formed completely of characters that appear in all three languages, so the output is TOX BEAM PHP is 100% Cyrillic, 100% Greek and 100% Latin
.
Lookup Tables
The Venn diagram is the source of the letters below:
Latin Only:
J,G,S,D,Q,U,V,W,F,L,R
Latin and Cyrillic:
C, С
Latin and Greek:
I,Ι, N,Ν, Z,Ζ
Greek and Cyrillic
Φ,Ф, Π,П, Γ,Г, Λ,Л
All three:
A,B,E,O,M,K,T,X,Y,H,P (and equivalents in greek and cyrillic), (space)
The rest ...are Greek-only or Cyrillic-only.
IMPORTANT NOTE
Unicode defines (for example) "A" in (at least) three separate ways - one for each language. Whichever is used in the input (Ƈ, ƚ or )), the program should understand it as matching all three languages.
So, A
(Latin), Α
(Greek Alpha) and А
(Cyrillic) should all give 100% Cyrillic, 100% Greek and 100% Latin
as the answer.
Input Format
Any string containing exclusively А-Я
, Α-Ω
, A-Z
and
(space). These characters can be repeated multiple times within the string.
Output Format
The output can be in any format, provided the function produces consistent results. I would like to see output in the format I show in my examples (FFLURS is 100% Latin, 0% Cyrillic and 0% Greek
), but in order to make the challenge more open to anyone I'm happy to accept arrays/strings of percentages/ratios:
[100,0,0]
,
100 0 0
[1.0 0.0 0.0]
as long as it's always clear which number is which language - so the output should be consistent.
Some more test cases
CINEMATICS
-> CINEMATICS is 100% Latin, 70% Greek and 60% Cyrillic
ЩJЩFЩLΞRΞVΞW
-> ЩJЩFЩLΞRΞVΞW is 50% Latin, 25% Cyrillic and 25% Greek
-> is 100% Cyrillic, 100% Greek and 100% Latin
ΨΩTESTINGЯЮ
-> ΨΩTESTINGЯЮ is 63.6% Greek, 63.6% Latin and 45.5% Cyrillic
Winning Criteria
Usual rules and exclusions apply; shortest answer (bytes) wins.
(sandbox link: https://codegolf.meta.stackexchange.com/a/14984/62289)
For the avoidance of doubt, the only Unicode characters valid in the input are:
- 0020, 0041-005A (Latin alphabet)
- 0020, 0391-03A9 (Greek alphabet)
- 0020, 0401, 0410-042F (Cyrillic alphabet)
But as shown in the lookup tables, characters may be cross-alphabetic.
Adding Jonathan Allan's table from the comments:
Latin Greek Cyrillic
U+0020 Space 1 1 1
U+0041 A Latin capital letter A 1 1 1
U+0042 B Latin capital letter B 1 1 1
U+0043 C Latin capital letter C 1 0 1
U+0044 D Latin capital letter D 1 0 0
U+0045 E Latin capital letter E 1 1 1
U+0046 F Latin capital letter F 1 0 0
U+0047 G Latin capital letter G 1 0 0
U+0048 H Latin capital letter H 1 1 1
U+0049 I Latin capital letter I 1 1 0
U+004A J Latin capital letter J 1 0 0
U+004B K Latin capital letter K 1 1 1
U+004C L Latin capital letter L 1 0 0
U+004D M Latin capital letter M 1 1 1
U+004E N Latin capital letter N 1 1 0
U+004F O Latin capital letter O 1 1 1
U+0050 P Latin capital letter P 1 1 1
U+0051 Q Latin capital letter Q 1 0 0
U+0052 R Latin capital letter R 1 0 0
U+0053 S Latin capital letter S 1 0 0
U+0054 T Latin capital letter T 1 1 1
U+0055 U Latin capital letter U 1 0 0
U+0056 V Latin capital letter V 1 0 0
U+0057 W Latin capital letter W 1 0 0
U+0058 X Latin capital letter X 1 1 1
U+0059 Y Latin capital letter Y 1 1 1
U+005A Z Latin capital letter Z 1 1 0
U+0391 Α Greek capital letter Alpha 1 1 1
U+0392 Β Greek capital letter Beta 1 1 1
U+0393 Γ Greek capital letter Gamma 0 1 1
U+0394 Δ Greek capital letter Delta 0 1 0
U+0395 Ε Greek capital letter Epsilon 1 1 1
U+0396 Ζ Greek capital letter Zeta 1 1 0
U+0397 Η Greek capital letter Eta 1 1 1
U+0398 Θ Greek capital letter Theta 0 1 0
U+0399 Ι Greek capital letter Iota 1 1 0
U+039A Κ Greek capital letter Kappa 1 1 1
U+039B Λ Greek capital letter Lambda 0 1 1
U+039C Μ Greek capital letter Mu 1 1 1
U+039D Ν Greek capital letter Nu 1 1 0
U+039E Ξ Greek capital letter Xi 0 1 0
U+039F Ο Greek capital letter Omicron 1 1 1
U+03A0 Π Greek capital letter Pi 0 1 1
U+03A1 Ρ Greek capital letter Rho 1 1 1
U+03A3 Σ Greek capital letter Sigma 0 1 0
U+03A4 Τ Greek capital letter Tau 1 1 1
U+03A5 Υ Greek capital letter Upsilon 1 1 1
U+03A6 Φ Greek capital letter Phi 0 1 1
U+03A7 Χ Greek capital letter Chi 1 1 1
U+03A8 Ψ Greek capital letter Psi 0 1 0
U+03A9 Ω Greek capital letter Omega 0 1 0
U+0401 Ё Cyrillic capital letter Io 0 0 1
U+0410 А Cyrillic capital letter A 1 1 1
U+0411 Б Cyrillic capital letter Be 0 0 1
U+0412 В Cyrillic capital letter Ve 1 1 1
U+0413 Г Cyrillic capital letter Ghe 0 1 1
U+0414 Д Cyrillic capital letter De 0 0 1
U+0415 Е Cyrillic capital letter Ie 1 1 1
U+0416 Ж Cyrillic capital letter Zhe 0 0 1
U+0417 З Cyrillic capital letter Ze 0 0 1
U+0418 И Cyrillic capital letter I 0 0 1
U+0419 Й Cyrillic capital letter Short I 0 0 1
U+041A К Cyrillic capital letter Ka 1 1 1
U+041B Л Cyrillic capital letter El 0 1 1
U+041C М Cyrillic capital letter Em 1 1 1
U+041D Н Cyrillic capital letter En 1 1 1
U+041E О Cyrillic capital letter O 1 1 1
U+041F П Cyrillic capital letter Pe 0 1 1
U+0420 Р Cyrillic capital letter Er 1 1 1
U+0421 С Cyrillic capital letter Es 1 0 1
U+0422 Т Cyrillic capital letter Te 1 1 1
U+0423 У Cyrillic capital letter U 1 1 1
U+0424 Ф Cyrillic capital letter Ef 0 1 1
U+0425 Х Cyrillic capital letter Ha 1 1 1
U+0426 Ц Cyrillic capital letter Tse 0 0 1
U+0427 Ч Cyrillic capital letter Che 0 0 1
U+0428 Ш Cyrillic capital letter Sha 0 0 1
U+0429 Щ Cyrillic capital letter Shcha 0 0 1
U+042A Ъ Cyrillic capital letter hard sign 0 0 1
U+042B Ы Cyrillic capital letter Yeru 0 0 1
U+042C Ь Cyrillic capital letter soft sign 0 0 1
U+042D Э Cyrillic capital letter E 0 0 1
U+042E Ю Cyrillic capital letter Yu 0 0 1
U+042F Я Cyrillic capital letter Ya 0 0 1
Ƈ
- if you meant that as an html character entity, it should beΑ
\$\endgroup\$