Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
math / math-words-koOpenRuns on Liberas

Number in Korean words

n as Sino-Korean numerals in Hangul. n is an integer: an optional - then 1 or more ASCII digits (leading zeros allowed), at most 100 bytes, with |n| < 10^24. 0 (and -0) is 영; a negative n is 마이너스, a space, then the words for |n|. |n| is split into groups of four digits from the right, with the units (none), 만, 억, 조, 경, 해; each non-zero group, most significant first, is its words followed by its unit; zero groups are left out; groups are separated by single spaces (spacing by units of 만, Hangul orthography article 44). Within a group the thousands, hundreds, tens and ones digits that are not 0 are written as the digit word then 천, 백, 십 or nothing, with digit words 일 이 삼 사 오 육 칠 팔 구, and 일 left out before 천, 백 and 십 (1111 is 천백십일). A 만 group that is exactly 1 is just 만 (10000 is 만, 10001 is 만 일), while higher units keep 일 (일억, 일조). So 123456789 is 일억 이천삼백사십오만 육천칠백팔십구, 110000 is 십일만, 100000000 is 일억. The result is value(text). Errors are invalid(reason), in this order: over 100 bytes → too-long; not an integer → syntax; |n| ≥ 10^24 → out-of-range.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init math-words-ko --lang rust
cd math-words-ko && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)32 lines›
math-words-ko.wit
package root:component;

world root {
  import liberas:math/types@0.1.0;

  export liberas:math/words@0.1.0;
}
package liberas:math@0.1.0 {
  interface types {
    enum math-error {
      syntax,
      too-long,
      division-by-zero,
      too-large,
      out-of-range,
      not-finite,
      empty,
      too-deep,
    }

    variant number-outcome {
      value(string),
      invalid(math-error),
    }
  }
  interface words {
    use types.{number-outcome};

    words: func(n: string) -> number-outcome;
  }
}
Test vectors23›
math-words-ko.cases.json
[
  {
    "args": {
      "n": "0"
    }
  },
  {
    "args": {
      "n": "-0"
    }
  },
  {
    "args": {
      "n": "1"
    }
  },
  {
    "args": {
      "n": "10"
    }
  },
  {
    "args": {
      "n": "11"
    }
  },
  {
    "args": {
      "n": "20"
    }
  },
  {
    "args": {
      "n": "100"
    }
  },
  {
    "args": {
      "n": "1111"
    }
  },
  {
    "args": {
      "n": "10000"
    }
  },
  {
    "args": {
      "n": "10001"
    }
  },
  {
    "args": {
      "n": "110000"
    }
  },
  {
    "args": {
      "n": "123456789"
    }
  },
  {
    "args": {
      "n": "100000000"
    }
  },
  {
    "args": {
      "n": "100010000"
    }
  },
  {
    "args": {
      "n": "-2024"
    }
  },
  {
    "args": {
      "n": "1000000000000"
    }
  },
  {
    "args": {
      "n": "100000000000000000000"
    }
  },
  {
    "args": {
      "n": "999999999999999999999999"
    }
  },
  {
    "args": {
      "n": "0000056"
    }
  },
  {
    "args": {
      "n": "1000000000000000000000000"
    }
  },
  {
    "args": {
      "n": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    }
  },
  {
    "args": {
      "n": "-"
    }
  },
  {
    "args": {
      "n": "십"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 23 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • A remote call may execute up to 1,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.