20
\$\begingroup\$

In the MMORPG Final Fantasy XIV, the Ninja class has the ability to use combinations of up to three handsigns (Ten, Chi and Jin) to perform a variety of ninjutsu skills.

The skill you cast depends on the last sign used, and using two or more of the same sign makes the ninjutsu skill fail and puts a little bunny on your head.

Challenge

Your job is to take up to three handsigns as input, and output the name of the ninjutsu skill this combination does. Of course, since this is , the goal is to make your code as short as possible!

Input

The program should take between 1 and 3 handsigns as input via STDIN or function arguments. You can use any kind of input format you prefer.

Example inputs:

TCJ
Ten Chi Jin
["T", "C", "J"]
["Ten", "Chi", "Jin"]

Output

The program should output the name (in title case) of the ninjutsu skill you get from the handsigns sent to it via input. Here's a table of each combination and their resulting skill.

Mudra table:

| Handsigns                     | Ninjutsu Skill |
|-------------------------------|----------------|
| Any one                       | Fuma Shuriken  |
| Any one + Ten                 | Katon          |
| Any one + Chi                 | Raiton         |
| Any one + Jin                 | Hyoton         |
| Any two + Ten                 | Huton          |
| Any two + Chi                 | Doton          |
| Any two + Jin                 | Suiton         |
| Contains two of the same sign | Bunny          |

Bunny takes precedence over any other ninjutsu.

Examples

TCJ                -> Suiton
J                  -> Fuma Shuriken
['Ten', 'Chi']     -> Raiton
"Jin" "Jin" "Ten"  -> Bunny

Leaderboards

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:

# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=218805;
var OVERRIDE_USER=45220;
var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(d){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+d+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(d,e){return"https://api.stackexchange.com/2.2/answers/"+e.join(";")+"/comments?page="+d+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(d){answers.push.apply(answers,d.items),answers_hash=[],answer_ids=[],d.items.forEach(function(e){e.comments=[];var f=+e.share_link.match(/\d+/);answer_ids.push(f),answers_hash[f]=e}),d.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(d){d.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),d.has_more?getComments():more_answers?getAnswers():process()}})}getAnswers();var SCORE_REG=function(){var d=String.raw`h\d`,e=String.raw`\-?\d+\.?\d*`,f=String.raw`[^\n<>]*`,g=String.raw`<s>${f}</s>|<strike>${f}</strike>|<del>${f}</del>`,h=String.raw`[^\n\d<>]*`,j=String.raw`<[^\n<>]+>`;return new RegExp(String.raw`<${d}>`+String.raw`\s*([^\n,]*[^\s,]),.*?`+String.raw`(${e})`+String.raw`(?=`+String.raw`${h}`+String.raw`(?:(?:${g}|${j})${h})*`+String.raw`</${d}>`+String.raw`)`)}(),OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(d){return d.owner.display_name}function process(){var d=[];answers.forEach(function(n){var o=n.body;n.comments.forEach(function(q){OVERRIDE_REG.test(q.body)&&(o="<h1>"+q.body.replace(OVERRIDE_REG,"")+"</h1>")});var p=o.match(SCORE_REG);p&&d.push({user:getAuthorName(n),size:+p[2],language:p[1],link:n.share_link})}),d.sort(function(n,o){var p=n.size,q=o.size;return p-q});var e={},f=1,g=null,h=1;d.forEach(function(n){n.size!=g&&(h=f),g=n.size,++f;var o=jQuery("#answer-template").html();o=o.replace("{{PLACE}}",h+".").replace("{{NAME}}",n.user).replace("{{LANGUAGE}}",n.language).replace("{{SIZE}}",n.size).replace("{{LINK}}",n.link),o=jQuery(o),jQuery("#answers").append(o);var p=n.language;p=jQuery("<i>"+n.language+"</i>").text().toLowerCase(),e[p]=e[p]||{lang:n.language,user:n.user,size:n.size,link:n.link,uniq:p}});var j=[];for(var k in e)e.hasOwnProperty(k)&&j.push(e[k]);j.sort(function(n,o){return n.uniq>o.uniq?1:n.uniq<o.uniq?-1:0});for(var l=0;l<j.length;++l){var m=jQuery("#language-template").html(),k=j[l];m=m.replace("{{LANGUAGE}}",k.lang).replace("{{NAME}}",k.user).replace("{{SIZE}}",k.size).replace("{{LINK}}",k.link),m=jQuery(m),jQuery("#languages").append(m)}}
body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654"> <div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> 

\$\endgroup\$
6
  • 2
    \$\begingroup\$ Do the names have to be in title case? \$\endgroup\$ – xigoi Feb 9 at 13:52
  • \$\begingroup\$ @xigoi Yes, the names have to be title case. \$\endgroup\$ – SjoerdPennings Feb 9 at 14:09
  • 2
    \$\begingroup\$ Can we choose any arbitrary values to represent T, C, J? \$\endgroup\$ – 79037662 Feb 9 at 16:02
  • \$\begingroup\$ @79037662 Yes, you can. \$\endgroup\$ – SjoerdPennings Feb 9 at 16:04
  • 3
    \$\begingroup\$ As a reference: Ten天(Heaven), Chi地(Earth (ground)), Jin人(Human); Ka火(Fire), Hyo氷 (Ice), Rai雷(Thunder), Hu風(Wind), Do土(Earth (soil)), Sui水(Water) \$\endgroup\$ – tsh Feb 10 at 2:44

12 Answers 12

4
\$\begingroup\$

05AB1E, 54 52 51 bytes

-3 bytes thanks to Kevin Cruijssen!

Takes a string of first letters of the handsigns. A list of integers could probably save a byte.

ÙÊi'åƒë.•!˜Œ¾Ë₂Γ∍Ÿ¾µÓ•#…ton«ι.•E‹ØÁó+±Æ•¸šÁIgèI3öè}™

Try it online! or Try all possible cases!

Commented:

Ù                    # deduplicate the input
 Ê                   # is this different from the input?
  i                  # if this is the case
   'åƒ              '# push compressed string "bunny"

ë                    # else:
 .•!...Ó•            # push compressed string "rai do hyo sui ka hu"
         #           # split on spaces
          …ton«      # append "ton" to each word
               ι     # rearrange the words into two lists
                     # [["raiton", "hyoton", "katon"], ["doton", "suiton", "huton"]]
.•E...Æ•             # push compressed string "fuma shuriken"
        ¸            # wrap into a list 
         š           # prepend to the other list 
          Á          # rotate this list right
                     # [["doton", "suiton", "huton"], ["fuma shuriken"], ["raiton", "hyoton", "katon"]]
           Ig        # take the length of the input
             è       # index into the list of lists
              I      # push the input again
               3ö    # convert from base 3
                 è   # modularly index into the list

}™                   # after the if/else: titlecase each word
\$\endgroup\$
5
  • 1
    \$\begingroup\$ A single sign gives Kama Shuriken instead of Fuma Shuriken. \$\endgroup\$ – SjoerdPennings Feb 9 at 14:19
  • 1
    \$\begingroup\$ @SjoerdPennings Now fixed, thank you. \$\endgroup\$ – ovs Feb 9 at 14:22
  • 1
    \$\begingroup\$ Modulair indexing is done implicitly, and the list it indexes into is either size 3 or size 1, so you don't need the 3%. \$\endgroup\$ – Kevin Cruijssen Feb 9 at 16:04
  • \$\begingroup\$ @KevinCruijssen thanks a lot, seems quite obvious now ;) \$\endgroup\$ – ovs Feb 9 at 16:10
  • 1
    \$\begingroup\$ "ton" is also in the dictionary, so …ton can be 'Ï· for another -1. (And I know the feeling. Some golfs people leave as comments sometimes also leaves me like "Duh! How did I miss that? It's so obvious now that it's pointed out." :) ) \$\endgroup\$ – Kevin Cruijssen Feb 9 at 16:19
11
\$\begingroup\$

JavaScript (ES6), 95 bytes

A shorter version suggested by @tsh

Expects [1,2,3] for "TCJ".

(a,b,c)=>a^b&&a^c&&b^c?',Hu,Do,Sui,Hyo,Rai,Ka'.split`,`[c||7-b]+'ton':b?'Bunny':'Fuma Shuriken'

Try it online!


JavaScript (ES6), 99 bytes

Expects "012" for "TCJ".

s=>/(.).?\1/.test([,b,c]=s)?'Bunny':b?'Hu,Do,Sui,Hyo,Rai,Ka'.split`,`[c||5-b]+'ton':'Fuma Shuriken'

Try it online!

Commented

s =>                         // s = input string
  /(.).?\1/                  // regex to detect a duplicate character
  .test([, b, c] = s)        // apply it to s; at the same time, load the 2nd
                             // and 3rd characters into b and c respectively
  ?                          // if there's a duplicate:
    'Bunny'                  //   return 'Bunny'
  :                          // else:
    b ?                      //   if the 2nd character is defined:
      'Hu,Do,Sui,Hyo,Rai,Ka' //     lookup string of prefixes
      .split`,`              //     split it
      [c || 5 - b]           //     use c if it's defined, or 5 - b otherwise
      + 'ton'                //     append the suffix
    :                        //   else:
      'Fuma Shuriken'        //     return 'Fuma Shuriken'
\$\endgroup\$
4
  • 5
    \$\begingroup\$ wow, this makes me respect JS a lot more \$\endgroup\$ – Wzl Feb 9 at 14:39
  • 16
    \$\begingroup\$ Arnauld, you monster, stop making JS look like a respectable language 🤣 \$\endgroup\$ – EasyasPi Feb 9 at 14:44
  • 1
    \$\begingroup\$ 95 bytes, switch to 1, 2, 3 as input: (a,b,c)=>a^b&&a^c&&b^c?',Hu,Do,Sui,Hyo,Rai,Ka'.split`,`[c||7-b]+'ton':b?'Bunny':'Fuma Shuriken' \$\endgroup\$ – tsh Feb 10 at 3:01
  • 2
    \$\begingroup\$ of course, the reason I respect it a lot more is because it's written in a functional style \$\endgroup\$ – Wzl Feb 10 at 16:15
6
\$\begingroup\$

R, 153 149 144 139 bytes

Edit: -5 bytes thanks to Giuseppe

function(x)`if`(any(table(x)>1),'Bunny',`if`((l=sum(x|1))-1,a[l*3-6+x[l]],'Fuma Shuriken'));a=paste0(scan(,''),'ton')
Ka
Rai
Hyo
Hu
Do
Sui

Try it online!

Input is 1 for 'Ten', 2 for 'Chi', 3 for 'Jin'.

Ungolfed:

a=paste0(scan(,''),'ton')       # scan(,'') reads the subsequent strings until it finds an empty one,
Ka                              # paste0 joins them each together with 'ton'.
Rai
Hyo
Hu
Do
Sui

function(x){
 if(any(table(x)>1))'Bunny'     # if there are any duplicates: 'Bunny'
 else{                          # otherwise
  l=length(x)                   # define l=length of x (the R golfy way: sum(x|1) because 'length' is 6 letters)
  if(l-1)a[l*3-6+tail(x,1)]     # if it isn't length 1, output the relevant element from the vector 'a' of ninjutsu names 
  else'Fuma Shuriken'           # otherwise (it's length 1): 'Fuma Shuriken'.
 }
}
```
\$\endgroup\$
2
  • \$\begingroup\$ since you have already defined l, you can just use x[l] instead of tail(x,1) which should be good for 5 bytes anyway :-) \$\endgroup\$ – Giuseppe Feb 9 at 18:51
  • \$\begingroup\$ @Giuseppe - Yes, of course! Gaah! Why on earth didn't I realise that? Thanks! \$\endgroup\$ – Dominic van Essen Feb 9 at 21:10
6
\$\begingroup\$

x86-16 machine code, IBM PC DOS, 102 101 bytes

00000000: b409 ba38 0149 742d ba46 0151 51ac 8bfe  ...8.It-.F.QQ...
00000010: f2ae 59e0 f759 741d 49ac 7402 0403 2c30  ..Y..Yt.I.t...,0
00000020: 8ad0 b024 b116 bf4b 01f2 aefe ca75 fa8b  ...$...K.....u..
00000030: d7cd 2103 d1cd 21c3 4675 6d61 2053 6875  ..!...!.Fuma Shu
00000040: 7269 6b65 6e24 4275 6e6e 7924 4b61 2452  riken$Bunny$Ka$R
00000050: 6169 2448 796f 2448 7524 446f 2453 7569  ai$Hyo$Hu$Do$Sui
00000060: 2474 6f6e 24                             $ton$

Listing:

B4 09       MOV  AH, 9                  ; DOS display $-terminated string syscall 

                                        ; STEP 1 - check if input is only 1 char
BA 0138     MOV  DX, OFFSET FAM         ;  default output is Fama
49          DEC  CX                     ;  is only 1 char? 
74 2D       JZ   DONE                   ;  if so, output is Fama

                                        ; STEP 2 - check if input has duplicate chars
BA 0147     MOV  DX, OFFSET BUN         ;  next default output is Bunny 
51          PUSH CX                     ;  save original input length
        DUP_LOOP:
51          PUSH CX                     ;  save loop position 
AC          LODSB                       ;  load next char into AL 
8B FE       MOV  DI, SI                 ;  start search at current char 
F2 AE       REPNZ SCASB                 ;   and search for AL 
59          POP  CX                     ;  restore loop position 
E0 F7       LOOPNZ DUP_LOOP             ;  end loop if there was a match 
59          POP  CX                     ;  restore original length 
74 1D       JZ   DONE                   ;  had a dup? output is Bunny

                                        ; STEP 3 - use last char to get correct name
49          DEC  CX                     ;  ZF if two chars, NZ if three chars 
AC          LODSB                       ;  load last char into AL 
74 02       JZ   FIND_NAME              ;  is three chars? 
04 03       ADD  AL, 3                  ;  if so, offset array index by 3
        FIND_NAME: 
2C 30       SUB  AL, '0'                ;  ASCII convert input 
8A D0       MOV  DL, AL                 ;  set number of delimiters to find
B0 24       MOV  AL, '$'                ;  set delimiter char to find ('$')
B1 16       MOV  CL, 22                 ;  length of name array
BF 014C     MOV  DI, OFFSET NAM-1       ;  pointer to name array
        SCAN_LOOP: 
F2 AE       REPNZ SCASB                 ;  search until delimiter found 
FE CA       DEC  DL                     ;  decrement counter 
75 FA       JNZ  SCAN_LOOP              ;  loop until end of counter 
8B D7       MOV  DX, DI                 ;  move found pointer to DX 
CD 21       INT  21H                    ;  write name prefix to STDOUT
03 D1       ADD  DX, CX                 ;  advance to start of suffix string

        DONE:                           ; STEP 4 - display string at DX
CD 21       INT  21H                    ;  write output string to STDOUT
C3          RET                         ;  return to caller

                                        ; Strings and Things
    FAM     DB  'Fuma Shuriken$'        ;  if one char 
    BUN     DB  'Bunny$'                ;  if duplicate chars 
    NAM     DB  'Ka$','Rai$','Hyo$'     ;  name prefix array
            DB  'Hu$','Do$','Sui$'      ;   delimited by $
    TON     DB  'ton$'                  ;  name suffix

Callable function, input as string at [SI], length in CX where Ten = 1, Chi = 2 or Jin = 3. Output to DOS STDOUT.

Test program output: enter image description here

\$\endgroup\$
5
\$\begingroup\$

Haskell, 116 109 bytes

saved 7 bytes thanks to @ovs, and obscure things in the stdlib (why is word but not split in Prelude?)

n[_]="Fuma Shuriken" -- matches a list of one element
n(a:b)|a`elem`b="Bunny" -- matches a list starting with a where a is in b `| `(cond)` =` is a guard that checks cond
n[a,b]=words"Ka Rai Hyo Ho Do Sui"!!b++"ton" -- !! is indexing, ++ is appending
n[a,b,c]=n[b+3,c+3] -- don't mistake n[] as indexing, it's calling n with a list.
-- b+3 so it will still catch duplicates where b=c

Highly readable (IMO), and highly not PHP (sorry PHP). This makes excessive use of pattern matching. It takes input as a list of Ten=0, Chi=1, Jin=2. Trailing whitespace and comments (starting with --) are not counted.

ideone it!

\$\endgroup\$
5
  • \$\begingroup\$ PHP haters be hatin'! :) \$\endgroup\$ – 640KB Feb 9 at 21:53
  • \$\begingroup\$ Doesn't this give the wrong answer for n[1,1,1]? \$\endgroup\$ – Neil Feb 10 at 13:01
  • \$\begingroup\$ @Neil is that supposed to Bunny? if so, then yes :( \$\endgroup\$ – Wzl Feb 10 at 13:59
  • \$\begingroup\$ okay, fixed, but now it's BAREaverageLy below (edit: my cat was stepping on my touchpad, but I'll leave it that way ;) \$\endgroup\$ – Wzl Feb 10 at 16:03
  • 1
    \$\begingroup\$ You can save a few bytes with words"Ka Rai Hyo Ho Do Sui": Try it online! \$\endgroup\$ – ovs Feb 10 at 16:04
4
\$\begingroup\$

PHP, 106 bytes

Inspired by 640KB's answer. Expects input as 123

fn($s)=>$s[1]?max(count_chars($s))>1?Bunny:[Ka,Hu,Rai,'Do',Hyo,Sui][$s[-1]*2-!$s[2]-1].ton:'Fuma Shuriken'

Try it online!

Explanation

fn($s)=> 
  $s[1]?                          // check if 2nd char of input is present
    max(count_chars($s))>1?       // count chars, check if any are present more than once
      'Bunny'                     // input has duplicates
    :                             // input does not have duplicates
      [Ka,Hu,Rai,'Do',Hyo,Sui]    // array of possible results
      [$s[-1]*2-!$s[2]-1]         // find correct index of result
                                  // takes last char of input, multiplied by 2,
                                  // minus boolean value based on input length
                                  // finally adjust index by -1
      .'ton'                      // and add suffix
  :
  'Fuma Shuriken'                 // input length was 1
\$\endgroup\$
1
  • \$\begingroup\$ Very nice work! Oh and welcome to PPCG! \$\endgroup\$ – 640KB Feb 10 at 10:47
4
\$\begingroup\$

PHP, 139 133 128 bytes

fn($s)=>($l=strlen($s))>1?max(count_chars($s))>1?Bunny:[T=>[Ka,Hu],C=>[Rai,'Do'],J=>[Hyo,Sui]][$s[-1]][$l%2].ton:'Fuma Shuriken'

Try it online!

Explanation

fn( $s ) => 
    ( $l = strlen( $s ) ) > 1 ?             // is input longer than one char?
        max( count_chars( $s ) ) > 1 ?      // has more than 1 of any single char?
            'Bunny'                         // if so, contains dupes so... Bunny it is
        :                                   // else, no dupes
            [
                'T' => [ 'Ka',  'Hu'  ],    // two dimensional associative
                'C' => [ 'Rai', 'Do'  ],    //   array containing handsign 
                'J' => [ 'Hyo,  'Sui' ]     //   and length as indexes
            ]
            [ $s[-1] ]                      // access array by last letter and
            [ $l % 2 ]                      //   length mod 2 (2 == 0, 3 == 1)
            . 'ton'                         //   and append "ton"
    :                                       // finally...
    'Fuma Shuriken'                         // input length was only one char

And combining some ideas from Cray's golfier answer, and taking input as 1, 2, 3, gets it down to 111 bytes (Cray's is still shorter though):

PHP, 111 bytes

fn($s)=>$s[1]?max(count_chars($s))>1?Bunny:[0,[Hu,Ka],['Do',Rai],[Sui,Hyo]][$s[-1]][!$s[2]].ton:'Fuma Shuriken'

Try it online!

\$\endgroup\$
3
\$\begingroup\$

J, 84 79 bytes

('Bunny';'Fuma Shuriken';,&'ton'&.>Ka`Rai`Hy`Hu`Do`Sui){~({:+1 1 4{~#)@}.*]-:~.

Try it online!

Takes 1, 2, 3 as inputs, mapping to T, C, J, respectively.

  • ('Bunny';'Fuma Shuriken';,&'ton'&.>Ka`Rai`Hy`Hu`Do`Sui) creates the word list and was the least satisfactory part of the golf, despite some effort. It produces:

    ┌─────┬─────────────┬─────┬──────┬─────┬─────┬─────┬──────┐
    │Bunny│Fuma Shuriken│Katon│Raiton│Hyton│Huton│Doton│Suiton│
    └─────┴─────────────┴─────┴──────┴─────┴─────┴─────┴──────┘
    
  • {~ From that, select the following index:

  • (...)@}. First remove the first element and...

  • {:+1 1 4{~# Take the last element {: of what remains (crucially, this will be 0 for the empty list, i.e., one element inputs) and add to it 1, 1, or 4, depending on if the length is 0, 1, or 2.

  • *]-:~. Multiply that result by 1 if the unique of the input ~. matches the input ]-:, and 0 otherwise. This ensures inputs with duplicates always have 0 index and return bunny.

\$\endgroup\$
2
\$\begingroup\$

Charcoal, 65 bytes

¿⊙θ⊖№θιBunny¿⊖Lθ⁺§⪪§⪪”↶/⊟≡⧴№K5G⁰⁺jM✂⎚Σ”χLθ ℅§θ±¹ton¦Fuma Shuriken

Try it online! Link is to verbose version of code. Takes input as a string of initials. Explanation:

¿⊙θ⊖№θιBunny

If any of the characters appear more than once then print "Bunny".

¿⊖Lθ⁺§⪪§⪪”↶/⊟≡⧴№K5G⁰⁺jM✂⎚Σ”χLθ ℅§θ±¹ton

If the length is more than one then look up the appropriate prefix from either "Ka Rai Hyo" or "Hu Do Sui" (depending on the length) split on spaces and indexed by the ordinal of the last character, concatenated with "ton".

¦Fuma Shuriken

But if the length is 1 then just print "Fuma Shuriken".

\$\endgroup\$
2
\$\begingroup\$

Lua (LuaJIT), 170 167 bytes

r={'Rai','Hyo','Sui','Ka','Hu','Do'}t={'Fuma Shuriken',CT=4,JT=4,JC=1,TC=1,CJ=2,TJ=2,CJT=5,JCT=5,JTC=6,TJC=6,CTJ=3,TCJ=3}print(t[#i]or t[i]and r[t[i]]..'ton'or'Bunny')

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Perl 5, 120 bytes

/(.).?\1/ and$_="Bunny";s/^.$/Fuma Shuriken/;s/..J/Suiton/;s/..C/Doton/;s/..T/Huton/;s/.J/Hyoton/;s/.C/Raiton/;s/.T/Katon/

It's everybody's favorite thing: a bunch of regular expressions sitting in a row. Run with perl -lapE '<the above code>'

First, we deal with the bunny case, by checking if any character appears twice and simply replace the string with "Bunny" in that case. Next, we check if there's exactly one character and replace with "Fuma Shuriken". Beyond that, we simply brute force the remaining options with regular expressions. Finally, if the resulting string does not end in n or y (i.e. it's not "Bunny" or "Fuma Shuriken"), then we add "ton" to the end.

\$\endgroup\$
2
\$\begingroup\$

PowerShell, 214 208 207 205 203 201 188 186 180 177 bytes

$s=$args[0];if($s[1]){if($s|% t*y|group|% c*|?{$_-ne1}){'Bunny'}else{@{'T'=('Ka','Hu');'C'=('Rai','Do');'J'=('Hyo','Sui')}["$($s[-1])"][$s.length%2]+'ton'}}else{'Fuma Shuriken'}

Try it online!

Thanks @640KB for the forkable PHP answer.

Cheers folks, help me to reduce the size!

(Please manually pass the argument, for test I have passed "CT", it worked and others worked too ;-)

Last -3 bytes thanks to @mazzy

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Wasif, param($s) is shorter then $s=$args[0]; and "$s" is more shorter then [string]$s \$\endgroup\$ – mazzy Feb 10 at 18:15
  • \$\begingroup\$ @mazzy many thanks! \$\endgroup\$ – Wasif Feb 11 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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