Tokitozuka Tokarinku

Using the above image, one would can Ninja-encode a phrase by replacing each letter by the corresponding phrase.

For example, my name (Lokesh) came out to be 'ta~mo~me~ku~ari~ri' . Notice, I have placed '~' among the sub-words to make the reverse translation easier. I will follow the same notation while converting any other word to Ninja name.

Now, write a program that converts any name in English to Ninja name. Solve this puzzle and enter the answer below

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
chi~ri~ku
ka~to~ari~mei~ku~shi
chi~mo
chi~ri~ki~ari
no~shi~mo~zu~ta~ku~rin
ki~ari
ari~ki~na
te~ki~ru~ki~te~ku~te
zu~fu
ri~ka~ta~lu


The answer is 12.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

6 solutions

Discussions for this problem are now closed

Lokesh Sharma
Apr 11, 2014

Python Solution:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import string

# Makes a dictionary to convert English letters to Japense letters
EngtoJap = {'a':'ka', 'b':'zu', 'c':'mi', 'd':'te', 'e':'ku',
            'f':'lu', 'g':'ji', 'h':'ri', 'i':'ki', 'j':'zu',
            'k':'me', 'l':'ta', 'm':'rin', 'n':'to', 'o':'mo',
            'p':'no', 'q':'ke', 'r':'shi', 's':'ari', 't':'chi',
            'u':'do', 'v':'ru', 'w':'mei', 'x':'na', 'y':'fu',
            'z':'zi'}


# Makes a dictionary to convert Japenese letters to English letters
JaptoEng = {}

# Makes use of previous dictionary to create this one
for i in EngtoJap:
    JaptoEng[EngtoJap[i]] = i



def loadWords(fileName):
    '''
    Returns list of words from file fileName
    '''
    fileData = open(fileName, 'r')
    words = []
    for line in fileData:
        words.append(line.rstrip())
    return words

def convertToJap(words):
    '''
    Takes list of words in English and
    returns list of words in Japense
    '''
    convertedWords = []
    for word in words:
        convertedWord = ''
        for letter in word:
            convertedWord += EngtoJap[letter] + '~'
        convertedWords.append(convertedWord[:-1])
    return convertedWords

def convertToEng(words):
    '''
    Takes list of words in Japenese and
    returns list of words in English
    '''
    convertedWords = []
    for word in words:
        convertedWord = ''
        for subword in word.split('~'):
            convertedWord += JaptoEng[subword]
        convertedWords.append(convertedWord)
    return convertedWords


words = loadWords('nameProblem.txt')
toeng = convertToEng(words)
print ' '.join(toeng)

-By ta~mo~me~ku~ari~ri

Cool problem,but the mapping is not one to one. B B and J J are both k u 'ku' ,thus making the inverse function have to choose. I got "THE ANSWER TO THIS PROJLEM IS SIX DIVIDED JY HALF".

Also If I were a Ninja I would be killed before I finished saying my name 'chirikatetekudoari ' :)

Thaddeus Abiy - 7 years, 2 months ago

Yeah, I once got concerned about this regard of mapping being not one to one but later I thought that people would figure it out and hence left it out.

Nice name by the way :P

Lokesh Sharma - 7 years, 2 months ago

I know right :) -Zikashitamodorinkajitoku (zikashi for short XD)

Zarloumagne Paragas - 7 years, 1 month ago

C Plus Plus solution

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <string.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;

int main(int argc, char** argv) 
{
    char njName[1024]="", name[1024]="";
    char ninja_dic[26][4]={"ka","zu","mi","te","ku","lu","ji","ri","ki","zu","me","ta","rin","to","mo","no","ke","shi","ari","chi","do","ru","mei","na","fu","zi"};
    char dic[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

    cout<<" Your name: ";
    cin>>name;
    int namelen = strlen(name) ;
    strupr(name);

    for(int i=0;i<namelen;i++)
    {
        for(int j=0;j<26;j++)
        {
            if(name[i] == dic[j] )
            {
                strcat(njName,ninja_dic[j]);
                strcat(njName,"~");
                break;
            }
        }
    }

    cout<<" Ninja Name : "<<njName;
    cin>>name;

    return 0;
} 

Shubham Gaikwad - 7 years, 1 month ago

Mekarukichirika - _ _-

Kavitha mahan - 7 years, 1 month ago
Cameron Bernhardt
Apr 21, 2014

I threw together a crude website to "ninja-ify" and "de-ninja-ify" phrases: tinyurl.com/ninjaify

As for the code, I used JavaScript:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var cypher = { //a JS object that holds the translation info
  "a": "ka",
  "b": "zu",
  "c": "mi",
  "d": "te",
  "e": "ku",
  "f": "lu",
  "g": "ji",
  "h": "ri",
  "i": "ki",
  "j": "zu",
  "k": "me",
  "l": "ta",
  "m": "rin",
  "n": "to",
  "o": "mo",
  "p": "no",
  "q": "ke",
  "r": "shi",
  "s": "ari",
  "t": "chi",
  "u": "do",
  "v": "ru",
  "w": "mei",
  "x": "na",
  "y": "fu",
  "z": "zi"
};

var alpha = []; //all this does is get the keys from the object

for(var k in cypher){//for cypher, that's just the English alphabet
  alpha.push(k);
}

Now, the decryption function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
function decode(code){//decodes ninja-ified string
  var str = code.toLowerCase(); //downcases input for compatability
  var newStr = ""; //will hold decrypted string

  str = str.split("~"); //splits input into an array of ninja 'letters'

  for(var i = 0; i < str.length; i++){//goes through encoded array and checks for matches
    for(var j = 0; j < alpha.length; j++){
      var b = alpha[j];
      if(cypher[b] === str[i]){
        newStr += b;
      }
    }
  }

  return newStr; //returns decrypted string
}
alert("Decoded: " + decode(prompt("Enter ninja-ified stuff.")));

And, just for fun, an encryption function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
function encode(notcode){//function for ninja-ifying
  var str = notcode.toLowerCase(); //downcases input for compatability
  var newStr = ""; //will hold decrypted string

  for(var i = 0; i < str.length; i++){//goes through string and encrypts each letter
    var b = str[i];//letter
    if(i != str.length - 1){//checks to see whether or not it's the last letter
      newStr += cypher[b] + "~"; //if not, adds ~ to separate words
    }else{
      newStr += cypher[b]; //if so, don't add it
    }
  }

  return newStr; //returns encrypted string
}
alert("Encoded: " + encode(prompt("Enter stuff to be ninja-ified.")));

Sudipta Kar
Apr 17, 2014
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.HashMap;
import java.util.StringTokenizer;

public class NinjaName {

    public static void main(String[] args) {
        HashMap map = new HashMap();
        map.put("ka","A");
        map.put("zu","B");
        map.put("mi","C");
        map.put( "te", "D");
        map.put( "ku", "E");
        map.put( "lu", "F");
        map.put( "ji", "G");
        map.put( "ri", "H");
        map.put( "ki", "I");
        map.put( "zu", "J");
        map.put( "me", "K");
        map.put( "ta", "L");
        map.put( "rin", "M");
        map.put( "to", "N");
        map.put( "mo","O" );
        map.put( "no", "P");
        map.put( "ke", "Q");
        map.put( "shi", "R");
        map.put( "ari", "S");
        map.put( "chi", "T");
        map.put( "do", "U");
        map.put( "ru", "V");
        map.put( "mei", "W");
        map.put( "na", "X");
        map.put( "fu", "Y");
        map.put( "zi", "Z");

        String s = "chi~ri~ku~ka~to~ari~mei~ku~shi~chi~mo~chi~ri~ki~ari~no~shi~mo~zu~ta~ku~rin~ki~ari~ari~ki~na~te~ki~ru~ki~te~ku~te~zu~fu~ri~ka~ta~lu";
        StringTokenizer st = new StringTokenizer(s, "~");

        while(st.hasMoreTokens()){
            String ss = st.nextToken();
            System.out.print(map.get(ss));
        }
    }
} 

Nicholasi Flamel
Apr 15, 2014

Lang used: java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.*;

public class NameNinja{

    static String[] ninjaAlphabet = {"ka", "zu", "mi", "te", "ku", "lu", "ji", "ri", "ki", "zu", "me", "ta", "rin", "to", "mo", "no", "ke", "shi", "ari", "chi", "do", "ru", "mei", "na", "fu", "zi"};

    static String[] alphabet = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};

    public static void main(String[] args){
        getName();
    }
    public static void getName(){
        Scanner s = new Scanner(System.in);
        String nameString = new String();
        int size;
        try{
            while(true){
                nameString = s.nextLine();
                String[] ninjaName = nameString.split("~");
                System.out.println(getName(ninjaName));
            }
        }catch(Exception e){}
    }
    public static String getName(String[] ninjaName){
        String name = new String();
        for(int i = 0; i < ninjaName.length; i++){
            for(int j = 0; j < 26; j++)  
                if(ninjaName[i].equals(ninjaAlphabet[j])){
                    name += alphabet[j];
                    break;
                }
        }
        return name;
    }
} 

Connor Kenway
Apr 14, 2014

include<iostream>

#include<stdio.h>
#include<string.h>

```c++ using namespace std; char store[26][6]={"ka","zu","mi","te","ku","lu","ji","ri","ki","zu","me","ta","rin","to","mo","no","ke","shi","ari","chi","do","ru","mei","na","fu","zi"}; int main() { int test=10; while(test--) { char ch[50]; gets(ch); int length=strlen(ch); for(int i=0;i<=length;i++) { if(ch[i]=='~'||ch[i]=='\0') { int j=i-1; for(;(j-1)!=-1&&(ch[j-1]!='\0');j--); ch[i]='\0'; for(int k=0;k<26;k++) { char *c=ch; c=c+j; if(strcmp(c,store[k])==0 ) {cout<<(char)(97+k);break;}

            }
        }
    }
    cout<<endl;
       }
    return 0;
}

``` btw the code for b and j is same that is 'zu' so my program shows b for a 'zu' .MY name - ri~ ki~ rin~ ka~ to~ ari~ ri~ do

Check the link .

Connor Kenway - 7 years, 2 months ago
Sanjay Kamath
Apr 14, 2014

Here is my solution in C#

         ArrayList ar = new ArrayList();

        Hashtable ht = new Hashtable();

        ht.Add("ka","A");
        ht.Add("zu", "B");
        ht.Add("mi", "C");
        ht.Add("te", "D");
        ht.Add("ku", "E");
        ht.Add("lu", "F");
        ht.Add("ji", "G");
        ht.Add("ri", "H");
        ht.Add("ki", "I");
        ht.Add("zu2", "J");
        ht.Add("me", "K");
        ht.Add("ta", "L");
        ht.Add("rin", "M");
        ht.Add("to", "N");
        ht.Add("mo", "O");
        ht.Add("no", "P");
        ht.Add("ke", "Q");
        ht.Add("shi", "R");
        ht.Add("ari", "S");
        ht.Add("chi", "T");
        ht.Add("do", "U");
        ht.Add("ru", "V");
        ht.Add("mei", "W");
        ht.Add("na", "X");
        ht.Add("fu", "Y");
        ht.Add("zi", "Z");

        string s1 = "chi~ri~ku";
        string s2 = "ka~to~ari~mei~ku~shi";
        string s3 = "chi~mo";
        string s4 = "chi~ri~ki~ari";
        string s5 = "no~shi~mo~zu~ta~ku~rin";
        string s6 = "ki~ari";
        string s7 = "ari~ki~na";
        string s8 = "te~ki~ru~ki~te~ku~te";
        string s9 = "zu~fu";
        string s10 = "ri~ka~ta~lu";

        string[] sarr = new string[10];
        ArrayList are = new ArrayList();

        are.Add(s1);
        are.Add(s2);
        are.Add(s3);
        are.Add(s4);
        are.Add(s5);
        are.Add(s6);
        are.Add(s7);
        are.Add(s8);
        are.Add(s9);
        are.Add(s10);


        string sg = String.Empty;

        for (int j = 0; j < 10; j++)
        {
            string[] res = are[j].ToString().Split('~');


            for (int y = 0; y < res.Length; y++)
            {
                sg += ht[res[y]].ToString();
            }

            ar.Add(sg);

            sg = "";
        }

        for (int h = 0; h < ar.Count; h++)
        {
            MessageBox.Show(ar[h].ToString());
        }

       Output is "THE ANSWER TO THIS PROBLEM IS SIX DIVIDED BY HALF" - equals 12.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...