Skip to main content
added 256 characters in body
Source Link
Neil
  • 177.2k
  • 20
  • 9

Ordinal to Cardinal

Given a positive integer represented as the English spelling of an ordinal number, return the equivalent cardinal number.

Rules

  • Where an integer requires multiple words to spell, only the last word changes.

  • The following integers are strongly irregular:

    • "one" becomes "first"
    • "two" becomes "second"
    • "three" becomes "third"
  • Other integers take a suffix of "th", however there are a few integers that are weakly irregular:

    • "five" becomes "fif(th)"
    • "eight" becomes "eigh(th)"
    • "nine" becomes "nin(th)"
    • "twelve" becomes "twelf(th)"
    • "twenty" to "ninety" become "twentie(th)" to "ninetie(th)".
  • The input can be assumed to be the English spelling of an ordinal number that follows the above rules to transform it into the equivalent cardinal number.

Examples

  • "nineteen""one hundred and nineteen" becomes "nineteenth""one hundred and nineteenth"
  • "twenty""one hundred and twenty" becomes "twentieth""one hundred and twentieth"
  • "twenty"one hundred and twenty one" becomes "twenty"one hundred and twenty first"

This is , so the shortest program or function that breaks no standard loopholes wins!

Ordinal to Cardinal

Given a positive integer represented as the English spelling of an ordinal number, return the equivalent cardinal number.

Rules

  • Where an integer requires multiple words to spell, only the last word changes.

  • The following integers are strongly irregular:

    • "one" becomes "first"
    • "two" becomes "second"
    • "three" becomes "third"
  • Other integers take a suffix of "th", however there are a few integers that are weakly irregular:

    • "five" becomes "fif(th)"
    • "eight" becomes "eigh(th)"
    • "nine" becomes "nin(th)"
    • "twelve" becomes "twelf(th)"
    • "twenty" to "ninety" become "twentie(th)" to "ninetie(th)".

Examples

  • "nineteen" becomes "nineteenth"
  • "twenty" becomes "twentieth"
  • "twenty one" becomes "twenty first"

This is , so the shortest program or function that breaks no standard loopholes wins!

Ordinal to Cardinal

Given a positive integer represented as the English spelling of an ordinal number, return the equivalent cardinal number.

Rules

  • Where an integer requires multiple words to spell, only the last word changes.

  • The following integers are strongly irregular:

    • "one" becomes "first"
    • "two" becomes "second"
    • "three" becomes "third"
  • Other integers take a suffix of "th", however there are a few integers that are weakly irregular:

    • "five" becomes "fif(th)"
    • "eight" becomes "eigh(th)"
    • "nine" becomes "nin(th)"
    • "twelve" becomes "twelf(th)"
    • "twenty" to "ninety" become "twentie(th)" to "ninetie(th)".
  • The input can be assumed to be the English spelling of an ordinal number that follows the above rules to transform it into the equivalent cardinal number.

Examples

  • "one hundred and nineteen" becomes "one hundred and nineteenth"
  • "one hundred and twenty" becomes "one hundred and twentieth"
  • "one hundred and twenty one" becomes "one hundred and twenty first"

This is , so the shortest program or function that breaks no standard loopholes wins!

eighth
Source Link
Neil
  • 177.2k
  • 20
  • 9

Ordinal to Cardinal

Given a positive integer represented as the English spelling of an ordinal number, return the equivalent cardinal number.

Rules

  • Where an integer requires multiple words to spell, only the last word changes.

  • The following integers are strongly irregular:

    • "one" becomes "first"
    • "two" becomes "second"
    • "three" becomes "third"
  • Other integers take a suffix of "th", however there are a few integers that are weakly irregular:

    • "five" becomes "fif(th)"
    • "eight" becomes "eigh(th)"
    • "nine" becomes "nin(th)"
    • "twelve" becomes "twelf(th)"
    • "twenty" to "ninety" become "twentie(th)" to "ninetie(th)".

Examples

  • "nineteen" becomes "nineteenth"
  • "twenty" becomes "twentieth"
  • "twenty one" becomes "twenty first"

This is , so the shortest program or function that breaks no standard loopholes wins!

Ordinal to Cardinal

Given a positive integer represented as the English spelling of an ordinal number, return the equivalent cardinal number.

Rules

  • Where an integer requires multiple words to spell, only the last word changes.

  • The following integers are strongly irregular:

    • "one" becomes "first"
    • "two" becomes "second"
    • "three" becomes "third"
  • Other integers take a suffix of "th", however there are a few integers that are weakly irregular:

    • "five" becomes "fif(th)"
    • "nine" becomes "nin(th)"
    • "twelve" becomes "twelf(th)"
    • "twenty" to "ninety" become "twentie(th)" to "ninetie(th)".

Examples

  • "nineteen" becomes "nineteenth"
  • "twenty" becomes "twentieth"
  • "twenty one" becomes "twenty first"

This is , so the shortest program or function that breaks no standard loopholes wins!

Ordinal to Cardinal

Given a positive integer represented as the English spelling of an ordinal number, return the equivalent cardinal number.

Rules

  • Where an integer requires multiple words to spell, only the last word changes.

  • The following integers are strongly irregular:

    • "one" becomes "first"
    • "two" becomes "second"
    • "three" becomes "third"
  • Other integers take a suffix of "th", however there are a few integers that are weakly irregular:

    • "five" becomes "fif(th)"
    • "eight" becomes "eigh(th)"
    • "nine" becomes "nin(th)"
    • "twelve" becomes "twelf(th)"
    • "twenty" to "ninety" become "twentie(th)" to "ninetie(th)".

Examples

  • "nineteen" becomes "nineteenth"
  • "twenty" becomes "twentieth"
  • "twenty one" becomes "twenty first"

This is , so the shortest program or function that breaks no standard loopholes wins!

Source Link
Neil
  • 177.2k
  • 20
  • 9

Ordinal to Cardinal

Given a positive integer represented as the English spelling of an ordinal number, return the equivalent cardinal number.

Rules

  • Where an integer requires multiple words to spell, only the last word changes.

  • The following integers are strongly irregular:

    • "one" becomes "first"
    • "two" becomes "second"
    • "three" becomes "third"
  • Other integers take a suffix of "th", however there are a few integers that are weakly irregular:

    • "five" becomes "fif(th)"
    • "nine" becomes "nin(th)"
    • "twelve" becomes "twelf(th)"
    • "twenty" to "ninety" become "twentie(th)" to "ninetie(th)".

Examples

  • "nineteen" becomes "nineteenth"
  • "twenty" becomes "twentieth"
  • "twenty one" becomes "twenty first"

This is , so the shortest program or function that breaks no standard loopholes wins!