You need to sign in or sign up before continuing.×
7 kyu

Hungarian Vowel Harmony (easy)

1,238 of 3,631suic

Description:

Vowel harmony is a phenomenon in some languages. It means that "A vowel or vowels in a word are changed to sound the same (thus "in harmony.")" (wikipedia). This kata is based on vowel harmony in Hungarian.

Task:

Your goal is to create a function dative() (Dative() in C#) which returns the valid form of a valid Hungarian word w in dative case i. e. append the correct suffix nek or nak to the word w based on vowel harmony rules.

Vowel Harmony Rules (simplified)

When the last vowel in the word is

  1. a front vowel (e, é, i, í, ö, ő, ü, ű) the suffix is -nek
  2. a back vowel (a, á, o, ó, u, ú) the suffix is -nak

Examples:

dative("ablak") == "ablaknak"
dative("szék") == "széknek"
dative("otthon") == "otthonnak"
dative("ablak") == "ablaknak"
dative("szék") == "széknek"
dative("otthon") == "otthonnak"
dative("ablak"); // "ablaknak"
dative("szék"); // "széknek"
dative("otthon"); // "otthonnak"
dative "ablak"   -- "ablaknak"
dative "szék"    -- "széknek"
dative "otthon"  -- "otthonnak"
Kata.dative("ablak") == "ablaknak"
Kata.dative("szék") == "széknek"
Kata.dative("otthon") == "otthonnak"
Kata.Dative("ablak") == "ablaknak"
Kata.Dative("szék") == "széknek"
Kata.Dative("otthon") == "otthonnak"
Kata.dative("ablak") == "ablaknak"
Kata.dative("szék") == "széknek"
Kata.dative("otthon") == "otthonnak"
Kata.dative("ablak") == "ablaknak"
Kata.dative("szék") == "széknek"
Kata.dative("otthon") == "otthonnak"
Dative("ablak") ==> "ablaknak", nil
Dative("szék") ==> "széknek", nil
Dative("otthon") ==> "otthonnak", nil
dative("ablak") // "ablaknak"
dative("szék") // "széknek"
dative("otthon") // "otthonnak"

Preconditions:

  1. To keep it simple: All words end with a consonant :)
  2. All strings are unicode strings.
  3. There are no grammatical exceptions in the tests.
Strings
Fundamentals

Stats:

CreatedOct 11, 2016
PublishedOct 12, 2016
Warriors Trained6676
Total Skips284
Total Code Submissions13232
Total Times Completed3631
Python Completions1238
C# Completions284
JavaScript Completions1156
Haskell Completions81
PHP Completions127
Groovy Completions46
Scala Completions70
Java Completions394
Ruby Completions110
CoffeeScript Completions9
TypeScript Completions85
Go Completions124
Rust Completions73
Total Stars76
% of votes with a positive feedback rating90% of 656
Total "Very Satisfied" Votes543
Total "Somewhat Satisfied" Votes99
Total "Not Satisfied" Votes14
Total Rank Assessments10
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • suic Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • user5036852 Avatar
  • Voile Avatar
  • hobovsky Avatar
  • username0 Avatar
  • ejini战神 Avatar
Ad