9
\$\begingroup\$

Choi Hong Hi died on the 15th June 2002 at the honorable age of 83. He founded Taekwondo.

15 years after his death, I would like to be a Taekwondo master. This is my time to shine !

Task

Given a string you should output a Taekwondo version.

Rules

  • You will receive a non-empty string/sentence by any valid input
  • You must replace each titles (case insensitive) by the revised romanization equivalent.
  • You must add , *side kick* at the end of the sentence because I like to do side kicks.
  • You must output this changed sentence as a string.
  • This is you should aim to minimize the byte count of your answer

Examples

"I am a Student and I do Taekwondo twice a week" 
  => "I am a Geup and I do Taekwondo twice a week, *side kick*"

"I am a Teacher willing to be a President" 
  => "I am a Gyosa nim willing to be a Gwanjang nim, *side kick*"

List of titles

English             =>  Revised Romanization
============================================
President           =>  Gwanjang nim
Founder             =>  Gwanjang nim
Master instructor   =>  Sabeom nim
Teacher             =>  Gyosa nim
Black Belt          =>  Dan
Student             =>  Geup
Color Belt          =>  Geup
Master level        =>  Godanja
\$\endgroup\$
17
  • 1
    \$\begingroup\$ case insensitive? and is a space needed before *side kick* \$\endgroup\$
    – LiefdeWen
    Jun 15, 2017 at 14:26
  • 11
    \$\begingroup\$ @LiefdeWen The space is obviously needed. How can you do a side kick without space between you and your opponent ? \$\endgroup\$
    – Weedoze
    Jun 15, 2017 at 14:28
  • 1
    \$\begingroup\$ As a Korean guy, I approve of this challenge. But I must say that Geup (급) doesn't really mean 'student.' Haksaeng (학생) would be better. Also, you would use Sabeom nim (사범님) instead of Gyosa nim (교사님) when it comes to martial arts instructor, regardless of the mastery (The word Gyobeom nim (교범님) exists, but it's rarely used). \$\endgroup\$ Jun 15, 2017 at 14:47
  • 2
    \$\begingroup\$ side kick is different of side-kick \$\endgroup\$
    – sergiol
    Jun 15, 2017 at 15:27
  • 1
    \$\begingroup\$ @sergiol Question updated \$\endgroup\$
    – Weedoze
    Jun 15, 2017 at 16:22

8 Answers 8

3
\$\begingroup\$

PHP, 241 bytes

<?=preg_replace(["#\b(President|Founder)\b#i","#\bMaster instructor\b#i","#\bTeacher\b#i","#\bBlack Belt\b#i","#\b(Studen|Color Bel)t\b#i","#\bMaster level\b#i"],[Gwanjang.$n=" nim",Sabeom.$n,Gyosa.$n,Dan,Geup,Godanja],"$argn, *side-kick*");

Try it online!

\$\endgroup\$
10
  • 1
    \$\begingroup\$ As I count, it would be shorter with str_ireplace(). \$\endgroup\$
    – manatwork
    Jun 15, 2017 at 15:56
  • \$\begingroup\$ Unclear what “You must output this changed sentence as a string.” actually means, but given the side kick must always be added, I would say the sentence will always change, so something should always be output. For example in case of input like “Me coder, no Taekwondo”. \$\endgroup\$
    – manatwork
    Jun 15, 2017 at 16:08
  • \$\begingroup\$ @manatwork It is say valid input. Under valid input I assume a input with a title. Your count with str_ireplace was right \$\endgroup\$ Jun 15, 2017 at 16:16
  • 1
    \$\begingroup\$ There seems to be enough “ nim” to worth a variable: [$a=Gwanjang.$n=" nim",$a,Sabeom.$n,Gyosa.$n,…. \$\endgroup\$
    – manatwork
    Jun 15, 2017 at 16:26
  • \$\begingroup\$ @manatwork Yes it saves two bytes. I have tried a version with additional strtr but it saves nothing \$\endgroup\$ Jun 15, 2017 at 16:34
2
\$\begingroup\$

Retina, 154 bytes

i(`president|founder
Gwanjang_
master instructor
Sabeom_
teacher
Gyosa_
black belt
Dan
student|color belt
Geup
master level
Godanja
_
 nim
$
, *side kick*

Try it online!

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

C#, 262 bytes

s=>{for(int i=0;i<8;)s=s.ToUpper().Replace("PRESIDENT|FOUNDER|MASTER INSTRUCTOR|TEACHER|BLACK BELT|MASTER LEVEL|STUDENT|COLOR BELT".Split('|')[i],(i<2?"GWANJANG":i>3?"GEUP":"SABEOM|GYOSA|DAN|GODANJA".Split('|')[i-2])+(i++<4?" NIM":""));return s+", *SIDE KICK*";}

Full/Formatted version:

class Program
{
    static void Main(string[] args)
    {
        System.Func<string, string> f = s =>
        {
            for (int i = 0; i < 8;)
                s = s.ToUpper().Replace("PRESIDENT|FOUNDER|MASTER INSTRUCTOR|TEACHER|BLACK BELT|MASTER LEVEL|STUDENT|COLOR BELT".Split('|')[i],
                                        (i < 2 ? "GWANJANG"
                                               : i > 3 ? "GEUP"
                                                       : "SABEOM|GYOSA|DAN|GODANJA".Split('|')[i-2])
                                        + (i++ < 4 ? " NIM" : ""));

            return s + ", *SIDE KICK*";
        };

        System.Console.WriteLine(f("I am a Student and I do Taekwondo twice a week"));
        System.Console.WriteLine(f("I am a Teacher willing to be a President"));

        System.Console.ReadLine();
    }
}
\$\endgroup\$
3
  • \$\begingroup\$ We should ask if *SIDE KICK* can be in this form, in the examples it was lowercased \$\endgroup\$
    – Mr. Xcoder
    Jun 15, 2017 at 15:02
  • \$\begingroup\$ @Mr.Xcoder The comment on the OP says it is case-insensitive, either way it isn't a change in byte count. Also a kick in upper case is more powerful so it should be allowed... \$\endgroup\$ Jun 15, 2017 at 15:04
  • 1
    \$\begingroup\$ Yes, just making that remark... This answer is Lethal anyways :)) \$\endgroup\$
    – Mr. Xcoder
    Jun 15, 2017 at 15:05
1
\$\begingroup\$

Retina, 163 bytes

i`President|Founder
Gwanjang¶
i`Master instructor
Sabeom¶
i`Teacher
Gyosa¶
i`Black Belt
Dan
i`Student|Color Belt
Geup
i`Master level
Godanja
¶
 nim
$
, *side kick*

Try it online!

\$\endgroup\$
0
\$\begingroup\$

tcl, 212

puts "[string map -nocase {President Gwanjang\ nim Founder Gwanjang\ nim Master\ instructor Sabeom\ nim Teacher Gyosa\ nim Black\ Belt Dan Student Geup Color\ Belt Geup Master\ level Godanja} $argv], *side kick*"

demo

\$\endgroup\$
1
  • \$\begingroup\$ @manatwork: fixed. \$\endgroup\$
    – sergiol
    Jun 15, 2017 at 16:00
0
\$\begingroup\$

Python 3, 281 bytes

import re
x=input();a="Gwanjang";b=" nim";c="Geup";d="Master";e=" Belt"
for i in range(8):x=re.sub("(?i)"+["President","Founder",d+" instructor","Teacher","Black"+e,"Student","Color"+e,d+" level"][i],[a+b,a+b,"Sabeom"+b,"Gyosa"+b,"Dan",c,c,"Godanja"][i],x)
print(x+", *side kick*")

Try it online!

\$\endgroup\$
0
\$\begingroup\$

JavaScript (ES6), 251 bytes

a=>a.replace(RegExp(b='president|founder|master instructor|teacher|black belt|student|color belt|master level','gi'),c=>((d='Gwanjang nim|')+d+'Sabeom nim|Gyosa nim|Dan|Geup|Geup|Godanja').split`|`[b.split`|`.indexOf(c.toLowerCase())])+', *side kick*'

Try it online!

This is not as compact as it could be since JavaScript is so verbose, but it's a great question. I recognized most of these terms as I am a 2nd Dan Black Belt in Taekwondo.

Explanaion

a=>
  a.replace(                                    // Replace on input string
    RegExp(                                     // Regex matching English phrases
      b='president|founder|master instructor|teacher|black belt|student|color belt|master level',
      'gi'                                      // Match all, case insensitive
    ),
    c=>
      ((d='Gwanjang nim|')+d+                   // Duplicate string portion
        'Sabeom nim|Gyosa nim|Dan|Geup|Geup|Godanja') // Add remaining phrases
      .split`|`                                 // Split into array by pipe
        [b.split`|`.indexOf(c.toLowerCase())])  // Access Korean phrase by corresponding index of matched English phrase
      +', *side kick*'                          // I like to do side kicks
\$\endgroup\$
0
\$\begingroup\$

JavaScript (ES6), 233 bytes

s=>(btoa`>·¬×§·mÁ©ãjx4)µ§uêö§©àÒx¦ÔƬµêô{-®ç-¢½i·¨IâTÞiÈ^¯a²¢Æ´)µV@^Ýj}R¶ç^Ýzêu
h¯@^Ýzêu1«-z½%z÷¥ØjjxÚ`.split(0).join` `.split`1`.map(d=>([a,b]=d.split(/2+/),s=s.replace(RegExp(a,'gi'),b))),s+', *side kick*"')

f=
s=>(btoa`>·¬‰×§·m†Á©ãjx4ž)µ‹§uêö§©àÒx¦ÔƬµêôŠ{-®ç-¢½’i·¨›Iâ›TÞiÈ^¯a²¢Æ´ž)µVœ“@^–݃j}R¶ç^žÝ†zêu
‰h¯@^–݆zêu1«-z½%z÷¥ØjjxÚ`.split(0).join` `.split`1`.map(d=>([a,b]=d.split(/2+/),s=s.replace(RegExp(a,'gi'),b))),s+', *side kick*"')

console.log(f('I am a Teacher willing to be a President'))


JavaScript (ES6), 243 bytes

s=>(`President${A=':Gwanjang nim|'}Founder${A}Master instructor:Sabeom nim|Teacher:Gyosa nim|Black Belt:Dan|Student:Geup|Color Belt:Geup|Master level:Godanja`.split`|`.map(r=>([a,b]=r.split`:`,s=s.replace(RegExp(a,'gi'),b))),s+', *side kick*')

f=
s=>(`President${A=':Gwanjang nim|'}Founder${A}Master instructor:Sabeom nim|Teacher:Gyosa nim|Black Belt:Dan|Student:Geup|Color Belt:Geup|Master level:Godanja`.split`|`.map(r=>([a,b]=r.split`:`,s=s.replace(RegExp(a,'gi'),b))),s+', *side kick*')

console.log(f('I am a Teacher willing to be a President'))

\$\endgroup\$

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.