Objective
Given the name of a robot master inMega Man: Powered Up except the trailing stringMan, output the name of the robot master (again, except the trailing stringMan) whom the inputted robot master has advantage over in fighting (with his weapon).
Mapping
(Input -> Output)Cut -> BombBomb -> IceIce -> FireFire -> OilOil -> ElecElec -> TimeTime -> GutsGuts -> CutI/O Format
It is implementation-defined whether to accept leading or trailing whitespace on the input.
Outputting a trailing newline in the output is permitted.
Otherwise flexible.
- \$\begingroup\$Is a trailing space permitted?\$\endgroup\$Neil– Neil2024-11-28 00:53:39 +00:00CommentedNov 28, 2024 at 0:53
- \$\begingroup\$Potential duplicate\$\endgroup\$Shaggy– Shaggy2024-11-28 01:26:45 +00:00CommentedNov 28, 2024 at 1:26
- \$\begingroup\$@Neil No, unless it's directly followed by a newline.\$\endgroup\$Dannyu NDos– Dannyu NDos2024-11-28 01:36:46 +00:00CommentedNov 28, 2024 at 1:36
- 7\$\begingroup\$Another potential duplicate\$\endgroup\$tsh– tsh2024-11-28 03:36:16 +00:00CommentedNov 28, 2024 at 3:36
16 Answers16
Python, 61 bytes
-3 thanks to @Jonathan Allan
lambda b:"FGBTEOCIiuoiliucrtmmelteesbec"[int(b,36)%9075&7::8]Was:
Python, 66 bytes
lambda b:"GBFETCIOuoiliucitmremtelsbece"["TCIOEGBF".find(b[0])::8]A bit boring.
Python, 67 bytes
for f in 0,eval:*Cut,Guts,Time,Elec,Oil,Fire,Ice,Bomb,Cut=globals()This one is exhilaratingly dirty.
How?
Creates global variables namedCut,Guts, etc. such thateval can be used to retrieve their robot master (or whatever the story is) from their names.
The assignment needs to be done twice: First pass adds the variable names to the global dictionary (which remembers insertion order). Note that the packed assignment ignores the values ofglobals() and assigns whatever names happen to have been last inserted (we don't care in the first pass) as values to the new variables .
At the second pass the names (rotated by one because we listCut twice) will be at the end of the dictionary. So the value"Cut" will be assigned to variableGuts etc.
- 1\$\begingroup\$@JonathanAllan Thanks! I managed to shave off another one by using
intinstead oford. I'm not very good with this whole mod chain business, so feel free to 1up me again ;-)\$\endgroup\$Albert.Lang– Albert.Lang2024-11-30 06:45:01 +00:00CommentedNov 30, 2024 at 6:45 - \$\begingroup\$@JonathanAllan how did you come up with the modular formula?\$\endgroup\$Jonah– Jonah2024-12-01 04:22:22 +00:00CommentedDec 1, 2024 at 4:22
- 1\$\begingroup\$@Jonah I just brute-forced it until I found something short that worked.\$\endgroup\$Jonathan Allan– Jonathan Allan2024-12-05 20:54:35 +00:00CommentedDec 5, 2024 at 20:54
Python 3, 72 bytes
dict(zip(l:="Cut Bomb Ice Fire Oil Elec Time Guts".split()*2,l[1:])).getCreates a dictionary whose keys in order areCut, Bomb, ... (doubled), and whose corresponding values are those with the first item removed. The main function is the.get method of the dictionary; if the dictionary itself suffices, those 4 bytes can be cut.
Also 72 bytes, usingid just for as the shortest predefined variable:
{id:(id:=x)for x in"Cut Bomb Ice Fire Oil Elec Time Guts".split()*2}.getPython, 73 bytes
lambda s:l[l.index(s)-1]l="Guts Time Elec Oil Fire Ice Bomb Cut".split()Uses that indices wrap around into the negatives, so the index before 0 is -1 which selects the last element.
Python 3, 73 bytes
lambda s:"Guts Time Oil Cut Elec Fire | Ice Bomb".split()[ord(s[0])%25%9]Only looks at the boss's letter (which are all distinct), and uses a mod chain to classify it. Bytestring input would save 5 bytes.
Retina 0.8.2, 75 bytes
T`B-H\OITcel-obs`IB_T\OC-Gemit_c_ButBombctceemireiilecitmutsrmlTry it online! Link includes test cases. Explanation:
T`B-H\OITcel-obs`IB_T\OC-Gemit_c_Transliterate as many letters as possible, including all of the upper case letters. This is enough to handleElec toTime andGuts toCut. (O normally means13579 so it needs to be escaped. Other escaped letters are avoided by including them in a range.)
ButBombCut transliterates toBut so fix it to becomeBomb without changingCut transliterated fromGuts.
ctceBomb transliterates toIct so fix it to becomeIce without changingGuts orCut.
emireIce transliterates toFem so fix it to becomeFire.
iilecOil transliterates toEii to fix it to becomeElec.
itmutsTime transliterates toGitm to fix it to becomeGuts.
rmlFire transliterates toOirm to fix it to becomeOil.
JavaScript (Node.js), 61 bytes
x=>'CutGutsTimeElecOilFireIceBombCut'.match(`(.[a-z]*)`+x)[1]-2B emanresu A
- \$\begingroup\$
.instead of\wseems to work?\$\endgroup\$emanresu A– emanresu A2024-11-28 03:15:58 +00:00CommentedNov 28, 2024 at 3:15
APL+WIN, 58 bytes
Prompts for name.
↑(r⍳⊂⎕)⌽r←(+\(⎕av⍳r)>43)⊂r←'CutBombIceFireOilElecTimeGuts'Google Sheets, 64 bytes83 bytes93 bytes
=regexextract("CutBombIceFireOilElecTimeGutsCut",A1&"(.[a-z]+)")Usingl4m2's regex approach.
The other way:
=let(a,split("Cut1Bomb1Ice1Fire1Oil1Elec1Time1Guts1Cut",1),index(a,match(A1,a,)+1))
Charcoal,40 39 bytes
§⪪”↶0²«gR→X?→?ïM↘⌈⟦ⅈH×↷⟲&↨⟧‽≧jβ” ﹪⍘Sγ⁹⁷Try it online! Link is to verbose version of code. Explanation: The input string is converted from base95, then reduced modulo97 and again modulo9 via modular indexing into a compressed string of the relevant words split on spaces.
C (clang), 69 bytes
f(*s){strncpy(s,"GutsElecCut\0FireTimeOil\0Ice\0Bomb"+*s%405%8*4,4);}Jelly, 27bytes
“B¢ċḅßṗœyœḳlsɲṀƥṆQ_»ḲṖ€ṙiḢɗA monadic link that accepts a list of characters and yields a list of characters.
How?
“...»ḲṖ€ṙiḢɗ - Link: list of characters, Name“...» - compressed string -> "Icel Fired Oily Elect Timex Gutsy Cute Bombe" Ḳ - split at spaces Ṗ€ - pop each -> Names = ["Ice","Fire","Oil","Elec","Time","Guts","Cut","Bomb"] ɗ - last three links as a dyad - f(Names, Name) i - 1-indexed index of {Name} in {Names} ṙ - rotate {Names} left by {that} Ḣ - head05AB1E, 29bytes
”GutsížÆÂ™ÄŠÄŠÙµÙ€º”#4δ£Dyk>èTry it online orverify all test cases.
Explanation:
”GutsížÆÂ™ÄŠÄŠÙµÙ€º” # Push dictionary string "Guts Cut Bomb Ice Fire Oil Electricity Time" # # Split it on spaces δ # Map over each word: 4 £ # Only keep the first 4 characters to fix "Electricity"→"Elec" D # Duplicate this list Ik # Get the index of the input in this list > # Increase it by 1 è # Modular index it into the list again # (after which the result is output implicitly)See this 05AB1E tip of mine (sectionHow to use the dictionary?) to understand why”GutsížÆÂ™ÄŠÄŠÙµÙ€º” is"Guts Cut Bomb Ice Fire Oil Electricity Time".
Java (JDK), 71 bytes
It seems splitting is shorter than regex here.
s->"Cut Bomb Ice Fire Oil Elec Time Guts Cut".split(s)[1].split(" ")[1]Alternative solution (74 bytes) if lowercase is allowed in the output:
s->"CbombCBiceBIfireIFoilFOelecOEtimeETgutsTGcut".split(""+s.charAt(0))[1]AWK, 76 bytes
{for(split("Cut Bomb Ice Fire Oil Elec Time Guts",a);a[i++]!~$1;);}$0=a[i%8]Try it at home!
awk '{for(split("Cut Bomb Ice Fire Oil Elec Time Guts",a);a[i++]!~$1;);}$0=a[i%8]' <<< GutsHowever, it would get stuck in a loop with invalid input.
{for(split("Cut Bomb Ice Fire Oil Elec Time Guts",a); # Robot Mastersa[i++]!~$1;);} # match and next$0=a[i%8] # output/catch loopPerl 5-p, 55 bytes
CutBombIceFireOilElecTimeGutsCutX=~/$_(.+?)[A-Z]/;$_=$1Input must have first letter capitalized.
Tcl, 85 bytes
puts [lindex [set L {Cut Bomb Ice Fire Oil Elec Time Guts Cut}] [lsearch $L $argv]+1]Explore related questions
See similar questions with these tags.








