6
\$\begingroup\$

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 -> Cut

I/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.

askedNov 27, 2024 at 22:08
Dannyu NDos's user avatar
\$\endgroup\$
4
  • \$\begingroup\$Is a trailing space permitted?\$\endgroup\$CommentedNov 28, 2024 at 0:53
  • \$\begingroup\$Potential duplicate\$\endgroup\$CommentedNov 28, 2024 at 1:26
  • \$\begingroup\$@Neil No, unless it's directly followed by a newline.\$\endgroup\$CommentedNov 28, 2024 at 1:36
  • 7
    \$\begingroup\$Another potential duplicate\$\endgroup\$CommentedNov 28, 2024 at 3:36

16 Answers16

15
+300
\$\begingroup\$

Python, 61 bytes

-3 thanks to @Jonathan Allan

lambda b:"FGBTEOCIiuoiliucrtmmelteesbec"[int(b,36)%9075&7::8]

Attempt This Online!

Was:

Python, 66 bytes

lambda b:"GBFETCIOuoiliucitmremtelsbece"["TCIOEGBF".find(b[0])::8]

Attempt This Online!

A bit boring.

Python, 67 bytes

for f in 0,eval:*Cut,Guts,Time,Elec,Oil,Fire,Ice,Bomb,Cut=globals()

Attempt This Online!

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.

answeredNov 29, 2024 at 9:28
Albert.Lang's user avatar
\$\endgroup\$
3
  • 1
    \$\begingroup\$@JonathanAllan Thanks! I managed to shave off another one by usingint instead oford. I'm not very good with this whole mod chain business, so feel free to 1up me again ;-)\$\endgroup\$CommentedNov 30, 2024 at 6:45
  • \$\begingroup\$@JonathanAllan how did you come up with the modular formula?\$\endgroup\$CommentedDec 1, 2024 at 4:22
  • 1
    \$\begingroup\$@Jonah I just brute-forced it until I found something short that worked.\$\endgroup\$CommentedDec 5, 2024 at 20:54
5
\$\begingroup\$

Python 3, 72 bytes

dict(zip(l:="Cut Bomb Ice Fire Oil Elec Time Guts".split()*2,l[1:])).get

Try it online!

Creates 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}.get

Try it online!

Python, 73 bytes

lambda s:l[l.index(s)-1]l="Guts Time Elec Oil Fire Ice Bomb Cut".split()

Try it online!

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]

Try it online!

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.

answeredNov 27, 2024 at 23:00
xnor's user avatar
\$\endgroup\$
0
4
\$\begingroup\$

Retina 0.8.2, 75 bytes

T`B-H\OITcel-obs`IB_T\OC-Gemit_c_ButBombctceemireiilecitmutsrml

Try 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.)

ButBomb

Cut transliterates toBut so fix it to becomeBomb without changingCut transliterated fromGuts.

ctce

Bomb transliterates toIct so fix it to becomeIce without changingGuts orCut.

emire

Ice transliterates toFem so fix it to becomeFire.

iilec

Oil transliterates toEii to fix it to becomeElec.

itmuts

Time transliterates toGitm to fix it to becomeGuts.

rml

Fire transliterates toOirm to fix it to becomeOil.

answeredNov 28, 2024 at 0:49
Neil's user avatar
\$\endgroup\$
3
\$\begingroup\$

Bash +coreutils, 56

grep -Po $1\\K.[a-z]+<<<CutBombIceFireOilElecTimeGutsCut

Try it online!

answeredNov 27, 2024 at 22:50
Digital Trauma's user avatar
\$\endgroup\$
3
\$\begingroup\$

JavaScript (Node.js), 61 bytes

x=>'CutGutsTimeElecOilFireIceBombCut'.match(`(.[a-z]*)`+x)[1]

Try it online!

-2B emanresu A

answeredNov 28, 2024 at 2:01
l4m2's user avatar
\$\endgroup\$
1
  • \$\begingroup\$. instead of\wseems to work?\$\endgroup\$CommentedNov 28, 2024 at 3:15
2
\$\begingroup\$

APL+WIN, 58 bytes

Prompts for name.

↑(r⍳⊂⎕)⌽r←(+\(⎕av⍳r)>43)⊂r←'CutBombIceFireOilElecTimeGuts'

Try it online! Thanks to Dyalog Classic

answeredNov 28, 2024 at 11:06
Graham's user avatar
\$\endgroup\$
2
\$\begingroup\$

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))

screenshot

answeredNov 27, 2024 at 22:44
doubleunary's user avatar
\$\endgroup\$
2
\$\begingroup\$

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.

answeredNov 28, 2024 at 6:05
Neil's user avatar
\$\endgroup\$
2
\$\begingroup\$

C (clang), 69 bytes

f(*s){strncpy(s,"GutsElecCut\0FireTimeOil\0Ice\0Bomb"+*s%405%8*4,4);}

Try it online!

answeredDec 24, 2024 at 16:58
jdt's user avatar
\$\endgroup\$
1
\$\begingroup\$

Jelly, 27bytes

“B¢ċḅßṗœyœḳlsɲṀƥṆQ_»ḲṖ€ṙiḢɗ

A monadic link that accepts a list of characters and yields a list of characters.

Try it online!

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}          Ḣ  -   head
answeredDec 1, 2024 at 0:53
Jonathan Allan's user avatar
\$\endgroup\$
1
\$\begingroup\$

05AB1E, 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".

answeredNov 28, 2024 at 10:46
Kevin Cruijssen's user avatar
\$\endgroup\$
1
\$\begingroup\$

Kotlin, 81 bytes

{s->"Cut Bomb Ice Fire Oil Elec Time Guts Cut".split(" ").run{get(indexOf(s)+1)}}

Try it online!

or if you accept leading spaces:

Kotlin, 67 bytes

{s->"CutBomb IceFire OilElecTimeGutsCut".substringAfter(s).take(4)}

Try it online!

both of these useval f:(String)->String= as the header

answeredNov 28, 2024 at 15:14
Joon Yorigami's user avatar
\$\endgroup\$
1
\$\begingroup\$

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]

Try it online!


Alternative solution (74 bytes) if lowercase is allowed in the output:

s->"CbombCBiceBIfireIFoilFOelecOEtimeETgutsTGcut".split(""+s.charAt(0))[1]

Try it online!

answeredNov 29, 2024 at 8:49
Fhuvi's user avatar
\$\endgroup\$
1
\$\begingroup\$

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]' <<< Guts

However, 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 loop
answeredNov 29, 2024 at 14:12
xrs's user avatar
\$\endgroup\$
1
\$\begingroup\$

Perl 5-p, 55 bytes

CutBombIceFireOilElecTimeGutsCutX=~/$_(.+?)[A-Z]/;$_=$1

Try it online!

Input must have first letter capitalized.

answeredDec 2, 2024 at 5:55
Xcali's user avatar
\$\endgroup\$
1
\$\begingroup\$

Tcl, 85 bytes

puts [lindex [set L {Cut Bomb Ice Fire Oil Elec Time Guts Cut}] [lsearch $L $argv]+1]

Try it online!

answeredDec 3, 2024 at 18:08
sergiol's user avatar
\$\endgroup\$

Your Answer

More generally…

  • …Please make sure to answer the question and provide sufficient detail.

  • …Avoid asking for help, clarification or responding to other answers (use comments instead).

Draft saved
Draft discarded

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.