Klingon Keyboard Malfunction

Par 5
Question 4intermediateSheet 1750822302

Deep Breath

The Star Trek-obsessed system administrator configured all keyboards to Klingon after a Discovery marathon. Users can only input pagh, wa', cha', wej... The admin was last seen at a convention declaring "petaQ! English is for p'tahk!" He left behind only a note: "Qapla'! The Federation will never decode our superior mathematical prowess!" Your task: Convert Klingon number words to perform mathematical operations because apparently this is what your CS degree prepared you for.

Why You're Doing This

You're building a parser for an artificial language with mathematical operations. It's localization gone completely off the rails. This tests string parsing, lookup tables, expression evaluation, and your ability to maintain dignity while implementing Klingon mathematics. The goal is SHORTEST CODE that can handle warrior mathematics without dishonoring your ancestors or your IDE.

Take the W

  • Correctly translates Klingon numbers to integers
  • Evaluates basic mathematical operations accurately
  • Handles Klingon operation words without crashing

Hard L

  • Crashes on unknown Klingon words (dishonorable)
  • Returns floating point when integers expected
  • Confuses Klingon with Vulcan (cultural insensitivity)

Edge Cases

  • Division by pagh (zero) - mathematically and culturally offensive
  • Numbers higher than basic Klingon vocabulary
  • Operations between traditional enemies (Federation vs Klingon mathematics)
  • Expressions in wrong word order (Klingon grammar matters)
  • Calculator displaying results in Federation Standard (potential betrayal)
Input Format:
function(klingon_expression_string)
Expected Output:
integer_result
Example:
klingonMath("wa' naDev cha'") → 3
Hints
  • 💡 Klingon numbers: pagh=0, wa'=1, cha'=2, wej=3, loS=4, vagh=5
  • 💡 Operations: naDev=+, woD=-, DIch=*, nugh=/
  • 💡 The apostrophe in wa' is critical for Klingon pronunciation and parsing