Name the Hadrons

19

1

Challenge

Given a quark composition of a particle as input, output the corresponding hadron's name.

Quarks will be represented by a capital letter and antiquarks by a lowercase letter.

The quarks may be in any order, not necessarily the order given below.

Built-in functions the access data about particles and/or quarks are disallowed.

The only quarks you will be given are U (up), u (antiup), D (down), d (antidown), S (strange), s (antistrange), C (charm), c (anticharm), B (bottom or beauty), b(antibottom or antibeauty).

List of Hadrons and their quark compositions

Note that although there are various other hadrons such as pentaquarks and glueballs etc., you only need to support the hadrons given in the following lists

Baryons (QQQ) and Antibaryons (qqq)

The names in brackets are alternative names for the particles. You may output either name.

Input - Output

UUU - delta++
uuu - antidelta++
UUD - delta+ (proton)
uud - antidelta+ (antiproton)
UDD - delta0 (neutron)
udd - antidelta0 (antineutron)
DDD - delta-
ddd - antidelta-
UUS - sigma+
uus - antisigma+
UDS - sigma0
uds - antisigma0
DDS - sigma-
dds - antisigma-
USS - xi0
uss - antixi0
DSS - xi-
dss - antixi-
SSS - omega-
sss - antiomega-

UUC - charmed sigma++
uuc - charmed antisigma++
UDC - charmed sigma+
udc - charmed antisigma+
DDC - charmed sigma0
ddc - charmed antisigma0
UUB - bottom sigma+
uub - bottom antisigma+
UDB - bottom sigma0
udb - bottom antisigma0
DDB - bottom sigma-
ddb - bottom antisigma-
USC - charmed xi+
usc - charmed antixi+
DSC - charmed xi0
dsc - charmed antixi0
UCC - double charmed xi++
ucc - double charmed antixi++
DCC - double charmed xi+
dcc - double charmed antixi+
USB - bottom xi0
usb - bottom antixi0
DSB - bottom xi-
dsb - bottom antixi-
UBB - double bottom xi0
ubb - double bottom antixi0
DBB - double bottom xi-
dbb - double bottom antixi-
UCB - charmed bottom xi+
ucb - charmed bottom antixi+
DCB - charmed bottom xi0
dcb - charmed bottom antixi0
SSC - charmed omega0
ssc - charmed antiomega0
SSB - bottom omega-
ssb - bottom antiomega-
SCC - double charmed omega+
scc - double charmed antiomega+
SCB - charmed bottom omega0
scb - charmed bottom antiomega0
SBB - double bottom omega-
sbb - double bottom antiomega-
CCB - double charmed bottom omega+
ccb - double charmed bottom antiomega+
CBB - charmed double bottom omega0
cbb - charmed double bottom antiomega0
CCC - triple charmed omega++
ccc - triple charmed antiomega++
BBB - triple bottom omega-
bbb - triple bottom antiomega-

Mesons (Qq)

Input - Output

Ud - pion+
Uu - pion0
Dd - pion0
Du - pion-
Us - kaon+
Ds - kaon0
Sd - antikaon0
Su - kaon-
Ss - phion0
Cd - D meson+
Dc - D meson-
Cu - D meson0
Uc - antiD meson0
Cs - strange D meson+
Sc - strange D meson-
Cc - psion0
Bu - B meson-
Ub - B meson+
Db - B meson0
Bd - antiB meson0
Sb - strange B meson0
Bs - strange antiB meson0
Bb - upsilon0

Winning

Shortest code in bytes wins.

Beta Decay

Posted 2017-05-14T14:38:16.593

Reputation: 21 478

11Built-in functions the access data about particles and/or quarks are disallowed. I'm looking at you, Mathematica. – Okx – 2017-05-14T14:42:59.547

So, this challenge is essentially to compress aa look up table? – Rohan Jhunjhunwala – 2017-05-14T15:32:10.257

@RohanJhunjhunwala there is actually quite a lot of logic behind the values albeit it takes time to find. – dzaima – 2017-05-14T15:35:33.430

3Mathematica does have a ParticleData function with a QuarkContent option. – Ian Miller – 2017-05-14T15:36:30.683

@dzaima what I meant was, there is a look up table which can be generated through a logical means, but the goal is to generate it with the shortest code. – Rohan Jhunjhunwala – 2017-05-14T15:39:47.387

1Doesn't look hard. I mean, each quark has its own electric charge, you only have to handle the name, not the charge. – Matthew Roh – 2017-05-14T17:39:12.213

1>

  • It seems the baryons can be any combination of 3 quarks of the same case. Mesons are combinations of 2 quarks of opposite case, but for mesons Cb and Bc are missing. Is this intentional? 2. Ordering the letters differently would mean the same thing - must our program be able to handle different orders of letters, or will they always be ordered as shown? (i.e. will it always be UDS for example or could it be SUD or DSU for example?) Similarly for mesons could we have uD?
  • < – Level River St – 2017-05-15T00:56:43.760

    @LevelRiverSt Cb and Bc being missing are most likely an oversight. Since there's no ordering to the quarks in QCD, I'd expect that the quarks could be named in any order. However, clarification is needed from the author. – Mego – 2017-05-15T03:38:15.587

    @Level, "the quarks may be in any order, not necessarily the order given below." – Peter Taylor – 2017-05-15T05:22:14.843

    There is no Top quark in your challenge, but it's too late to change. (Also its just bottom, not beauty or something. There is no such quark as a 'beauty quark'.) – Matthew Roh – 2017-05-15T07:41:29.197

    @SIGSEGV 1. A top quark decays too quickly for it to interact via the strong force and form into hadrons. 2. The bottom quark at one point was called a beauty quark, as per Murray Gell-Mann's poetic naming of charm and beauty, but bottom was favoured by boring physicists – Beta Decay – 2017-05-15T08:57:14.507

    @LevelRiverSt I couldn't find any mention of a Cb or a Bc meson anywhere, so I couldn't find a name for it – Beta Decay – 2017-05-15T08:58:26.857

    Read name the hard-ons... I'll go back to elementary school now ._.. – Magic Octopus Urn – 2017-05-16T19:54:48.480

    Answers

    5

    SOGL 0.11, 341 339 333 310 305 305 300 bytes

    ‘θw±
    on”≥
    0c{≤
    ”=?"▒
    on0”←"█
    c SW?"▲
    ?ļ0←j ►
    ?"anti”o}▼
    SD”;W¡+}□
    =?ļ-←ļ+←■
    ‘B≤a=+}:?"⁽¬Τk⅜K±l?@+}ob@+o}▓
    UCl2-? CA"K¼⁶▓ BA"δ╬▓cd≠▼≤: U=; D=++}"8}↕x╔:⁵F┘¹±o≤"B□"κ§)Ƨ7%s±p←"Ss▒phi█Cc▒psi█Bb▒upsil█SdUcBd”2n{=▼}≤"U□1>?▲ka≥pc DW►S■"pi≥Pcρ►D■▲)»β⁴‘o}ƧBs=▼ Dc BW?X B}" mes≥+p"D═S┐╔¬ν↑FνF⌠V3╗βstA\≈²‘:cW2+Wp
    

    dzaima

    Posted 2017-05-14T14:38:16.593

    Reputation: 19 048

    12

    JavaScript (ES6), 456 448 431 420 bytes

    This code is using only two small lookup tables:

    • one to identify the quarks: 'CUBDScubds'
    • another one to detect the 'anti' prefix of Mesons: 'SdUcBdBs'

    Everything else is deduced from the quarks.

    (s,[a,b]=[...s].map(c=>(i='CUBDScubds'.search(c)%5,m|=1<<i,j+=i<2,k+=i&1,p+=i?i-2?'':'bottom ':'charmed ',i),m=j=k=0,p=''))=>s[2]?p.replace(/(\w+) \1( \1)?/,(_,a,b)=>b?'triple'+b:'double '+a)+(s>'Z'?'anti':'')+['omega','xi','sigma','delta'][k]+('-0+'[j]||'++'):(m&16&&m&5?'strange ':'')+(~'SdUcBdBs'.search(s)?'anti':'')+(m&1?m^1?'D mes':'psi':m&4?m^4?'B mes':'upsil':m&16?m^16?'ka':'phi':'pi')+'on'+'-0+'[(a<2)-(b<2)+1]
    

    let f =
    
    (s,[a,b]=[...s].map(c=>(i='CUBDScubds'.search(c)%5,m|=1<<i,j+=i<2,k+=i&1,p+=i?i-2?'':'bottom ':'charmed ',i),m=j=k=0,p=''))=>s[2]?p.replace(/(\w+) \1( \1)?/,(_,a,b)=>b?'triple'+b:'double '+a)+(s>'Z'?'anti':'')+['omega','xi','sigma','delta'][k]+('-0+'[j]||'++'):(m&16&&m&5?'strange ':'')+(~'SdUcBdBs'.search(s)?'anti':'')+(m&1?m^1?'D mes':'psi':m&4?m^4?'B mes':'upsil':m&16?m^16?'ka':'phi':'pi')+'on'+'-0+'[(a<2)-(b<2)+1]
    
    res = [
      "UUU", "uuu", "UUD", "uud", "UDD", "udd", "DDD", "ddd", "UUS", "uus", "UDS", "uds", "DDS", "dds", "USS", "uss",
      "DSS", "dss", "SSS", "sss", "UUC", "uuc", "UDC", "udc", "DDC", "ddc", "UUB", "uub", "UDB", "udb", "DDB", "ddb",
      "USC", "usc", "DSC", "dsc", "UCC", "ucc", "DCC", "dcc", "USB", "usb", "DSB", "dsb", "UBB", "ubb", "DBB", "dbb",
      "UCB", "ucb", "DCB", "dcb", "SSC", "ssc", "SSB", "ssb", "SCC", "scc", "SCB", "scb", "SBB", "sbb", "CCB", "ccb",
      "CBB", "cbb", "CCC", "ccc", "BBB", "bbb", "Ud",  "Uu",  "Dd",  "Du",  "Us",  "Ds",  "Sd",  "Su",  "Ss",  "Cd",
      "Dc",  "Cu",  "Uc",  "Cs",  "Sc",  "Cc",  "Bu",  "Ub",  "Db",  "Bd",  "Sb",  "Bs",  "Bb"
    ]
    .map(s => s + ' - ' + f(s)).join("\n");
    
    console.log(res);

    Arnauld

    Posted 2017-05-14T14:38:16.593

    Reputation: 111 334

    2

    Perl 5, 318 bytes

    $_=<>;$h=qw/- ++ + 0/[y/uc//*2*($i=3-map{${lc;}++}/./g)-$u-$c-$i];$a=($i?!$h&&/[dUB]/:/[a-z]/)&&anti;map{/(.)/;$q.=("","$_ ","double $_ ","triple $_ ")[$$1]}charmed,bottom;print(($i?($u+$d>1?pi:$s>1?phi:$c>1?psi:$b>1?upsil:$c+$b?($s?"strange $a":$a).($b?B:D).' mes':$a.ka).on:$q.$a.qw/omega xi sigma delta/[$u+$d]).$h)
    

    Newlines added for readability (slightly):

    $_=<>
    $h=qw/- ++ + 0/[y/uc//*2*($i=3-map{${lc;}++}/./g)-$u-$c-$i]
    $a=($i?!$h&&/[dUB]/:/[a-z]/)&&anti
    map{/(.)/;$q.=("","$_ ","double $_ ","triple $_ ")[$$1]}charmed,bottom;
    print(($i?($u+$d>1?pi:$s>1?phi:$c>1?psi:$b>1?upsil:$c+$b?($s?"strange $a":$a).($b?B:D).' mes':$a.ka).on:$q.$a.qw/omega xi sigma delta/[$u+$d]).$h)
    

    faubi

    Posted 2017-05-14T14:38:16.593

    Reputation: 2 599