17
\$\begingroup\$

Magic the gathering has many unique names for colour combinations in decks, as an example when Blue and White appear together in a deck, the deck maye sometimes be named after the Ravnican Guild that features those colours, namely 'Azorius'. There are some exceptions, and oddities though.

Below is a list of colour letters (one of WUBRG) combinations, and a list of their corresponding example colour deckname part (the order of letters is not fixed for this challenge):

W: Monowhite/Mono-White
U: Monoblue/Mono-Blue
B: Monoblack/Mono-Black 
R: Monored/Mono-Red
G: Monogreen/Mono-Green
WU: Azorius
WB: Orzhov
WR: Boros
WG: Selesnya
UB: Dimir
UR: Izzet
UG: Simic
BR: Rakdos
BG: Golgari
RG: Gruul
GWU: Bant
WUB: Esper
UBR: Grixis
BRG: Jund
RGW: Naya
WBG: Abzan/Indatha/Necra
URW: Jeskai/Raka/Raugrin
BUG: Sultai/Ana/Bug/Zagoth
RWB: Mardu/Dega/Savai
URG: Temur/Ceta/Rug/Ketria
UBRG: Chaos/Glint/Glint-Eye/Non-White
BRGW: Aggression/Dune/Dune-Brood/Non-Blue
RGWU: Altruism/Ink/Ink-Treader/Non-Black
GWUB: Growth/Witch/Witch-Maw/Non-Red
WUBR: Artifice/Yore/Yore-Tiller/Non-Green
WUBRG: Domain/Five-Color
C: Colorless/Monobrown/Mono-Brown

The challenge is to take in any of the letter combination entries above as input, and then output only one of the listed names. As previously started, the order of letters is not important, so BWRG is the same as BRGW etc, and should output one of Aggression/Dune/Dune-Brood/Non-Blue.

Input and output should be case insensitive, so that it will accept either as input, but either case of output (or both!) is fine.

Nonsense input is allowed to error or give a nonsense output. e.g. inputting 'wubrger' can throw an error or output 'Mark Rosewater' (or any string, even valid output) for example.

\$\endgroup\$
6
  • \$\begingroup\$ I can't help but feel like some of the classics are missing: sunburst, patriot, maverick, Canadian, and - everyone's favourite - wet Jund :) \$\endgroup\$ Nov 9, 2020 at 15:56
  • 1
    \$\begingroup\$ @FryAmTheEggman where were you when I was in the sand box :'(.... I think it's actually moist jund. I didn't think of any besides that so I kept it 'standard'. It's too late to change now \$\endgroup\$ Nov 9, 2020 at 15:58
  • 1
    \$\begingroup\$ Haha, I think I've heard both wet and moist (I suspect the choice largely depends on which one finds more amusing). I'm sorry I missed it, but I think this challenge is quite good! My comment was only meant to bring up some of the other fun names, not to be a criticism. As an aside, I think a backward-ish mapping from name to the number of colours would be an interesting follow up. \$\endgroup\$ Nov 9, 2020 at 16:32
  • \$\begingroup\$ @FryAmTheEggman As the author of the post on BCG.se that lists these, my research indicates the difference between moist Jund and wet Jund is how much blue you have. If you're splashing for a single card, it's moist. If it's for more, it's wet. \$\endgroup\$
    – corsiKa
    Nov 10, 2020 at 4:55
  • 1
    \$\begingroup\$ @corsiKa An interesting find! Here's a link to your post for the interested. \$\endgroup\$ Nov 10, 2020 at 5:30

5 Answers 5

5
\$\begingroup\$

05AB1E, 136 135 133 132 bytes

“ƒÏˆ¨†¾‡—„¸ ŽÌ“#'Î×ì.•вO₁ŸĀ0Ð뜴0+Eм/#‰TôbHüÆΣÇÐζfβq₅([²åOÇηB₂È¥ƶ]9í$µÅ–tå(h0!Ãα9½êT₄Ì€+µxΩ;'Äçî9©ÙÝ“R_Ÿ U„δ
ÅíÂu•#5ǝ˜.•Iλβ•æé¦Il{kè

Outputs in full lowercase; uses the shortest outputs if multiple are allowed.

Try it online or verify all test cases (uses a random permutations for each test case input).

Explanation:

“ƒÏˆ¨†¾‡—„¸ ŽÌ“ # Push dictionary string "black green red blue white  brown"
 #              # Split it on spaces: ["black","green","red","blue","white","","brown"]
  'Î×ì         '# Prepend dictionary string "mono" to each string
.•вO₁ŸĀ0Ð뜴0+Eм/#‰TôbHüÆΣÇÐζfβq₅([²åOÇηB₂È¥ƶ]9í$µÅ–tå(h0!Ãα9½êT₄Ì€+µxΩ;'Äçî9©ÙÝ“R_Ÿ U„δ\nÅíÂu•
                # Push compressed string "golgari rakdos gruul dimir simic izzet orzhov selesnya boros azorius jund ana grixis rug abzan dega naya esper bant raka chaos dune witch yore ink domain"
 #              # Split on spaces as well
  5ǝ            # Insert this list at 0-based index 5
    ˜           # And flatten the list to complete the list of deck-names
.•Iλβ•          # Push compressed string "bgruw"
      æ         # Pop and push all its permutations
       é        # Sort them by length: ["","b","g","r","u","w","bg","br","gr","bu","gu","ru","bw","gw","rw","uw","bgr","bgu","bru","gru","bgw","brw","grw","buw","guw","ruw","bgru","bgrw","bguw","bruw","gruw","bgruw"]
        ¦       # Remove the first empty string
I               # Push the input-string
 l              # Convert it to lowercase
  {             # Sort its characters
   k            # Get the index of this string in the list of permutations,
                # or -1 if it isn't present in the case of input "c"/"C"
    è           # And use that index to index into the list of deck-names
                # (0-based, where -1 will wrap around to the end)
                # (after which the result is output implicitly)

See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress strings not part of the dictionary?) to understand how the compressed strings work.

\$\endgroup\$
3
  • \$\begingroup\$ That is super impressive \$\endgroup\$ Nov 9, 2020 at 15:18
  • \$\begingroup\$ …š³wr is one byte shorter than .•Iλβ•. It yields "bugwr" instead of "bgruw", so it’s gonna require reordering the table. "urw" and "rug" are also in the dictionary, if that helps. \$\endgroup\$
    – Grimmy
    Nov 9, 2020 at 15:51
  • 1
    \$\begingroup\$ @Grimmy Nice find, but I'm afraid I would then need to sort all individual permutations as well (or use …š³wr{, which is the same byte-count as .•Iλβ•). The bgruw are in alphabetical order, which is why I do the l{ on the input before indexing. \$\endgroup\$ Nov 9, 2020 at 16:15
4
\$\begingroup\$

05AB1E, 133 132 bytes

Thanks to Kevin Cruijssen for -1 byte!

.•αćðoвÍ‘óÉp₂›qt8¬Ôтõ—qŠ¤öôI‚¦æâ\₄²5₃1.Ćåuc[âY™FŒ¸VOœ₂9>îÓ‰ìîʒO=|e₁e²Ì¯ß₅m4ÖāHŠBÌz©?Ωć¨_¶∊á‘ÂΔHÓÄ÷U}úÙÕF„k{%ì6?“:Rƒá•#¬æIl{kèIgi'Î×ì

Try it online!

Commented:

.•α...á•                  -- compressed alphabet string
                          --   "bgruw black ... domain brown"
        #                 -- split on spaces
         ¬                -- get the first element "bgruw"
          æ               -- take the powerset ["", "b", "g", ..., "bgruw"]
           I              -- push the input
            l             -- convert to lowercase
             {            -- sort it
              k           -- find the index of this string in the powerset
                          --   b -> 1, ..., bgruw -> 31, c -> -1
               è          -- index with this integer into the word list
                Ig        -- push the length of the input
                  i       -- if this is truthy (equal to 1):
                   'Î×ì   --   prepend compressed string "mono"
\$\endgroup\$
2
  • 1
    \$\begingroup\$ “Îד can be 'Î×. And smart to put the bgruw inside the compressed string so there is also no need to compress it loose or remove the "" from the permutations, and using the Igi as indication to append "mono". Nice answer, +1 from me! \$\endgroup\$ Nov 9, 2020 at 15:39
  • 1
    \$\begingroup\$ @KevinCruijssen thanks for the suggestion, didn't know these short string builtins would work with dictionary strings. I got 131 bytes by combining ideas from both our answers. \$\endgroup\$
    – ovs
    Nov 9, 2020 at 23:00
3
\$\begingroup\$

JavaScript (ES6), 254 bytes

Expects an array of characters as input.

a=>`SelesnyaXXGolgariChaosXDuneXXXXMonoblackColorlessEsperRakdosXMonogreenDimirJundOrzhovDomainAnaXAbzanGrixisInkDegaMonoredXIzzetMonoblueBorosMonowhiteRugAzoriusNayaXWitchBantGruulYoreRakaSimic`.match(/.[a-z]*/g)[parseInt(a.sort().join``,33)%472%244%44]

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Does this help: codegolf.stackexchange.com/a/62488/9534? \$\endgroup\$ Nov 10, 2020 at 14:39
  • 1
    \$\begingroup\$ @Pureferret Yes, it could probably be shortened that way. But personally, I don't like having so many unprintable characters and almost never use that trick for that reason -- which I admit is very subjective and completely biased. \$\endgroup\$
    – Arnauld
    Nov 10, 2020 at 14:51
2
\$\begingroup\$

Charcoal, 138 bytes

×›²Lθmono§⪪”&⌈⧴ν;IjWκ,êQD↷$εe⪫_S�✂σ¶⍘↶Ja↧ ‖wυ^z‖U›ï^?F$←P↗Wιº+F|γaÀ⁹?t*a≕∨0]X‹75·¡≔⁸“↨⊟E⦃⌈&?q⍘⌕�,QDπnB ✂a|⁹℅Uξ⟲ⅈK´φN›~t\`$⊕ζ⊕”q↨Ewubrg№↧θι²

Try it online! Link is to verbose version of code. Explanation:

×›²Lθmono

Print mono if the number of characters in the input is less than 2.

§⪪”...”q↨Ewubrg№↧θι²

Split the compressed string of colour names on q and index it by taking the counts of each of the colour letters in the input and interpreting them as a number in base 2.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ @Pureferret Sorry, I suck at reading minor details of challenges... \$\endgroup\$
    – Neil
    Nov 9, 2020 at 23:17
1
\$\begingroup\$

Jelly, 149 bytes

“®×bẒAJ²ṘẈ!sỵḷ:-Þ5M£LƇ(¥Ḋg½Bm%³ḣʠĊ¢*¶|ƭ⁾Ḳ¹øṡ(:d,g5ṚVW]t;/ẓẇpⱮṄḟɗæ(ƓYẎĖẹḲA’b27ṣ0ịØa
“-e“ẠỤ“¡cy“/⁷“¡ḷọ»µ“ċ¦⁶»;Ɱ;¢;Ṛ“ċ=€»;ⱮƊ;“ÐOẈ“µƬḞ»
ŒuṢ“BGRUW”ŒPḊ¤iị¢

Try it online!

Explanation

“...’b27ṣ0ịØa   Auxiliary niladic link
“...’           A big number in base 250
     b27        Convert to base 27
        ṣ0      Split on zeros
          ịØa   Index into the lowercase alphabet
                => ["golgari", "rakdos", ..., "bant", "raka"]

“...»µ“ċ¦⁶»;Ɱ;¢;Ṛ“ċ=€»;ⱮƊ;“ÐOẈ“µƬḞ»   Auxiliary niladic link
“...»                                 ["Black", "Green", "Red", "Blue", "White"]
     µ                                Use as new argument
      “ċ¦⁶»;                          Prepend "Mono-"
            Ɱ                           to each
             ;¢                       Join with link above
               ;                      Join with
                        Ɗ             (
                Ṛ                       Reverse [the list of colors]
                 “ċ=€»;                 Prepend "Non-"
                       Ɱ                  to each
                        Ɗ             )
                         ;            Join with
                          “ÐOẈ“µƬḞ»     ["Domain", "Colorless"]

ŒuṢ“BGRUW”ŒPḊ¤iị¢   Main monadic link
Œu                  Uppercase
  Ṣ                 Sort
              i     Find index in
             ¤      (
   “BGRUW”            "BGRUW"
          ŒP          Power set
            Ḋ         Remove first element [the empty string]
             ¤      )
               ị    Index into
                ¢     Link above
\$\endgroup\$
5
  • \$\begingroup\$ Does this use the same dictionary approach as the other answers? \$\endgroup\$ Nov 17, 2020 at 14:57
  • \$\begingroup\$ @Pureferret I don't understand exactly how the other answers work, but it's probably quite similar. \$\endgroup\$
    – xigoi
    Nov 17, 2020 at 15:01
  • \$\begingroup\$ Would you mind adding an explanation? \$\endgroup\$ Nov 17, 2020 at 15:19
  • \$\begingroup\$ @Pureferret Done. I thought there isn't really a point since my score is worse than most of the other answers, but when you asked... \$\endgroup\$
    – xigoi
    Nov 17, 2020 at 17:20
  • \$\begingroup\$ Ahh, I see now. You've handled it a little more cleverly, by using/resuing some strings. Thats really interesting \$\endgroup\$ Nov 17, 2020 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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