[Question]
  [
Japanese kana characters correspond to a single sound in the Japanese language. With the exception of ん (*n*), every other kana consists of a consonant part and a vowel part. There is a natural ordering to Japanese kana, a sort of "alphabetical order", which is typically arranged in a 10 by 5 table:
```
   |   a    i    u    e    o
-----------------------------
*  |   a    i    u    e    o
k  |  ka   ki   ku   ke   ko
s  |  sa   si   su   se   so
t  |  ta   ti   tu   te   to
n  |  na   ni   nu   ne   no
h  |  ha   hi   hu   he   ho
m  |  ma   mi   mu   me   mo
y  |  ya        yu        yo
r  |  ra   ri   ru   re   ro
w  |  wa                  wo
```
This ordering is called *[gojuuon](https://en.wikipedia.org/wiki/Goj%C5%ABon)*, or "fifty sounds", even though some of the fifty cells in the table are in fact empty.
## The challenge
Input will be any of the listed kana above, with the exception for *wo*. Your program or function should output the next kana along in left-to-right, top-to-bottom reading order, e.g:
```
Input       Output
------------------
a     ->    i
i     ->    u
o     ->    ka
ke    ->    ko
so    ->    ta
ni    ->    nu
ya    ->    yu
yu    ->    yo
wa    ->    wo
wo    ->    (undefined behaviour)
```
With the exception of an optional single trailing newline, there should be no leading or trailing whitespace in the output.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the goal is to minimise program size, in bytes.
## Additional notes
* In order to keep things simple, this challenge uses [Nihon-shiki romanisation](https://en.wikipedia.org/wiki/Nihon-shiki_romanization). [Hepburn romanisation](https://en.wikipedia.org/wiki/Hepburn_romanization) is more common, but has a few kinks which make things more annoying for golf (e.g. *si* becomes *shi*, *hu* becomes *fu*).
* Kana *do* exist for the empty spots (see [Japanese SE](https://japanese.stackexchange.com/questions/643/when-did-the-wu-character-drop-out-of-use)), but they were either non-standard or are now obsolete.
  
[Answer]
## [Retina](https://github.com/mbuettner/retina), ~~54~~ 53 bytes
```
T`au`ie`y.
wa
we
T`\oeuia`ao
T`ko`stn\hmyr\w`.a
^a
ka
```
[Try it online.](http://retina.tryitonline.net/#code=VGBhdWBpZWB5Lgp3YQp3ZQpUYFxvZXVpYWBhbwpUYGtvYHN0blxobXlyXHdgLmEKbWBeYQprYQ&input=YQppCm8Ka2UKc28KbmkKeWEKeXUKeW8Kd2EKd28)
### Explanation
Wooo, showing off even more features from today's 0.7.2 release. :) ([The release predates this challenge](https://github.com/mbuettner/retina/releases/tag/v0.7.2) by about 7 hours.)
```
T`au`ie`y.
```
This is a transliteration which replaces `a` with `i` and `u` with `e`, but only in matches of `y.`. The purpose of that is to treat `ya` and `yu` like `yi` and `ye`, respectively, in order to skip the gaps.
```
wa
we
```
Replace `wa` with `we` to skip that gap as well.
```
T`\oeuia`ao
```
Here is the new feature. When rotating sets of characters, the "from" and "to" set in a transliteration are usually almost identical. So now we've got `o` (without a backslash) to refer to the other set, which allows us to get rid of some duplication. The `\o` just stands for a literal `o` in that case. So the two sets expand to:
```
oeuia
aoeuia
```
The extraneous `a` in the second set is ignored and the vowels are replaced cyclically as expected.
```
T`ko`stn\hmyr\w`.a
```
This does the same thing for the consonants, but using `o` in the first set (just because we can...). `h` and `w` need escaping because they are character classes. The expanded sets are:
```
kstnhmyrw
stnhmyrw
```
The `.a` restricts this operation to syllables that end in `a`, i.e. those that wrap to the next line of the table.
```
^a
ka
```
Finally, we replace a single `a` with `ka`, because that case cannot be handled by the previous transliteration.
[Answer]
# GNU sed, 65
Comments not included in score:
```
:                        # Define unnamed label
y/aiueo/iueoa/           # Rotate vowels
/a/y/kstnhmyr/stnhmyrw/  # If at end of row, rotate consonants
s/^a/ka/                 # If at end of 1st row, prefix a "k"
/[yw][ie]\|wu/b          # If one of the invalid values, jump back to label and redo
```
Oy, this is beginning to look a lot like @Martin's [Retina answer](https://codegolf.stackexchange.com/a/68717/11259) (but longer, of course).
[Answer]
## Pyth, ~~42~~ ~~40~~ 38 bytes
```
s.r]z.DrR6*" kstnhmyrw""aiueo"CM"$&./0
```
This takes the outer product between vowels and consonants, and removes elements at the ords of each number in `$&./0`. Then it outputs the element after the input.
```
@J.DrR6*" kstnhmyrw""aiueo"CM"$&./0"hxJz    Implicit: z=input()
       *" kstnhmyrw""aiueo"                 Outer product: [' a',...,' o','ka',...]
    rR6                                     Strip each string—'a'~'o' now single letters
                           CM"$&./0"        Map ord onto the string: [36,38,46,47,48]
  .D                                        Remove elements at those indices.
 J                                          That's the list of kana; assign it to J
                                     xJz    Find the index (x) of z in J,
                                    h       add one,
@J                                          and access J at that index.
```
Try it [here](https://pyth.herokuapp.com/?code=s.r%5Dz.DrR6%2a%22+kstnhmyrw%22%22aiueo%22CM%22%24%26.%2F0&input=ya&debug=0).
[Answer]
# Ruby, 105
```
->n{a=['wo','wa']
'rymhntsk '.chars{|c|a+='*o *e *u *i *a'.tr(?*,c).split}
a[8..10]='yu'
a[a.index(n)-1]}
```
Commented in test program
```
f=->n{a=['wo','wa']                     #initialize array to last line of table, begin to build table backwards                                
  'rymhntsk '.chars{|c|                 #for each consonant, 
    a+='*o *e *u *i *a'.tr(?*,c).split  #perform a sustitution to get that line of table in string form,  
  }                                     #then split into array at spaces and append to a
  a[8..10]='yu'                         #substitute 3 elements ye yu yi with 1 element yu
  a[a.index(n)-1]                       #return element before argument (array is backwards.)
}
puts f[gets.chop]
```
[Answer]
# [TXR](http://nongnu.org/txr) Lisp, ~~135~~ ~~127~~ ~~124~~ 91 bytes
```
(ret[(memqual @1(diff(maprod(op trim-str`@1@2`)" kstnhmyrw""aiueo")'#"yi ye wi wu we"))1])
```
Run:
```
1> (ret[(memqual @1(diff(maprod(op trim-str`@1@2`)" kstnhmyrw""aiueo")'#"yi ye wi wu we"))1])
#<interpreted fun: lambda (#:arg-1-0208 . #:arg-rest-0207)>
2> [*1 "a"]
"i"
3> [*1 "o"]
"ka"
4> [*1 "ki"]
"ku"
5> [*1 "mu"]
"me"
6> [*1 "ya"]
"yu"
7> [*1 "yo"]
"ra"
8> [*1 "wa"]
"wo"
```
[Answer]
# Bash + sed, 83
```
echo {,k,s,t,n,h,m,y,r,w}{a,i,u,e,o}|sed -E "s/[yw][ie]|wu//g;s/.*\b$1 +//;s/ .*//"
```
* Brace expansion to create full table on one line
* sed to:
	+ remove `yi`, `ye`, `wi`, `wu` and `we`
	+ remove everything up to and including the input entry (but not the next entry)
	+ remove everything after the next entry
[Answer]
## JavaScript, ~~145~~ ~~162~~ ~~131~~ 118 bytes
```
x=>(d=" kstnhmyrw".replace(/./g,"$&a$&i$&u$&e$&o").replace(/ |yi|ye|wiwuwe/g,"").match(/[^aiueo]?./g))[d.indexOf(x)+1]
```
~~Admit it, you couldn't imagine a more ridiculous solution to solve this problem ;)~~ ok, done this in a more interesting way.
Demo:
```
function p(x) {
  return (d=" kstnhmyrw".replace(/./g,"$&a$&i$&u$&e$&o") //build the sequence of kana, regex rulez!
        .replace(/ |yi|ye|wiwuwe/g,"")                   //remove the spaces and excess kana
        .match(/[^aiueo]?./g))[d.indexOf(x)+1]           //split it into array using regex and get the index of input in it
}
alert(p(prompt()))
```
[Answer]
## Japt, ~~75~~ ~~70~~ 68 bytes
```
X=" kstnhmyrw"£"aiueo"®+X w} r" |yi|ye|wiwuwe"P f"[^aiueo]?.")g1+XbU
```
[Try it online!](http://ethproductions.github.io/japt?v=master&code=WD0iIGtzdG5obXlydyKjImFpdWVvIq4rWCB3fSByIiB8eWl8eWV8d2l3dXdlIlAgZiJbXmFpdWVvXT8uIilnMStYYlU=&input=IndhIg==)
[Answer]
## Haskell, ~~114~~ 96 bytes
```
f"ya"="yu"
f"yu"="yo"
f"wa"="wo"
f x=snd(span(/=x)[words[a,b]!!0|a<-" kstnhmyrw",b<-"aiueo"])!!1
```
`[words[a,b]!!0|a<-" kstnhmyrw",b<-"aiueo"]` is a list of all kanas, including the "holes". I break up the list into the part before the input kana and from the input kana up to the end. From the 2nd part I pick the second element. The exceptions around the "holes" a caught before by separate cases.
Edit: @xnor came up with the idea of using `span`which saved 18 bytes.
[Answer]
# [Lexurgy](https://www.lexurgy.com/sc), 115 bytes
```
a:
{a,i,u,e,o}=>{i,u,e,o,'a}
b:
'=>k/$ _
{',k,s,t,n,h,m,y,r,w} '=>{k,s,t,n,h,m,y,r,w,`} *
y:
{i,e}=>{u,o}/y _
```
Explained:
```
# advance the vowel
a:
{a,i,u,e,o}=>{i,u,e,o,'a}
# advance the consonant
b:
'=>k/$ _ # o => ka case
{',k,s,t,n,h,m,y,r,w} '=>{k,s,t,n,h,m,y,r,w,`} * # everything else
# force yu yo
y:
{i,e}=>{u,o}/y _
```
[Answer]
# Perl 6, 105 bytes
```
.[.first(@*ARGS[0],:k)+1].say with (" kstnhmyrw".comb X~ <a e i o u>).grep(* !~~/[y|w][i|e]|wu/)».trim
```
This is as short as I can get it on my first go, I might have another crack at it later but I feel pretty good about this.
[Answer]
# JavaScript (ES6), 127 bytes
```
s=>s>"yt"?"yo":s=="ya"?"yu":s=="wa"?"wo":(m=[].concat(...["",..."kstnhmyrw"].map(c=>[..."aiueo"].map(v=>c+v))),m[m.indexOf(s)+1])
```
## Explanation
```
s=>
  // Hardcode "yu", "ya" and "wa"
  s>"yt"?"yo":
  s=="ya"?"yu":
  s=="wa"?"wo":
  // Generate table
  (m=[].concat(...                                   // flatten the array of arrays
    ["",                                             // first consonant is blank
    ..."kstnhmyrw"].map(c=>[..."aiueo"].map(v=>c+v)) // combine each consonant and vowel
  ))[m.indexOf(s)+1]                                 // return the next sound
```
## Test
```
var solution = s=>s>"yt"?"yo":s=="ya"?"yu":s=="wa"?"wo":(m=[].concat(...["",..."kstnhmyrw"].map(c=>[..."aiueo"].map(v=>c+v))),m[m.indexOf(s)+1])
```
```
<input type="text" id="input" value="mo" />
<button onclick="result.textContent=solution(input.value)">Go</button>
<pre id="result"></pre>
```
[Answer]
## Perl 6, 96 bytes
```
{my @a=(" kstnhmyrw".comb X~ <a i u e o>).grep({!/[y|w][e|i]|wu/})>>.trim;@a[[[email protected]](/cdn-cgi/l/email-protection)($_,:k)]}
```
[Answer]
# Python 2, 107 bytes
```
L=[(x+y).lstrip()for x in' kstnhmyrw'for y in'aiueo'if x+y not in'yiyewiwuwe']
print L[L.index(input())+1]
```
Expects input enclosed in quotes, `'he'` for example
[Answer]
## Racket 151 bytes
```
(second(member s '(a i u e o ka ki ku ke ko sa si su se so ta ti tu te to na
ni nu ne no ha hi hu he ho ma mi mu me mo ya yu yo ra ri ru re ro wa wo)))
```
Ungolfed:
```
(define (f s)
  (second
   (member s
           '(a i u e o ka ki ku ke ko sa si su se so ta ti tu te to na ni nu ne
               no ha hi hu he ho ma mi mu me mo ya yu yo ra ri ru re ro wa wo))))
```
Testing: 
```
(f 'a)
(f 'i)
(f 'o)
(f 'ke)
(f 'so)
(f 'ni)
(f 'ya)
(f 'yu)
(f 'wa)
```
Output: 
```
'i
'u
'ka
'ko
'ta
'nu
'yu
'yo
'wo
```
There is an error message if 'wo is sent. 
[Answer]
# C, ~~138~~ 135 bytes
```
char*s="aiueokstnhmyrw";i,j;k(*v){j=strchr(s,*v>>8)-s;i=strchr(s,*v)-s;j=i<4?i++:j<4?j-~(2520%i&3):!++i;printf("%c%c",s[i],i<5?:s[j]);}
```
[Wandbox](http://melpon.org/wandbox/permlink/ZYmhjKjp7fEBjHXn)
]