[Community Puzzle] Nicholas Breakspeare and Hugh of Evesham

https://www.codingame.com/training/easy/nicholas-breakspeare-and-hugh-of-evesham

Send your feedback or ask for help here!

Created by @anon91538998,validated by @fgsdt,@LifeStream and @VirtualAtom.
If you have any issues, feel free to ping them.

Cardinal definitions should be part of the problem statement since pretty much all non-English speakers need to check them out somewhere.

Hereā€™s one https://grammartop.com/cardinal-and-ordinal-numbers/

5 Likes

Test case 6 breaks the provided Dart input parser. Use double and double.parse() instead of int to make it work

1 Like

PHP NumberFormatter class doesnā€™t work with case 4 and 6 either. 32-bit versions of PHP will not handle integers bigger than 2,147,483,647 (2 billion and change). 64-bit versions will handle up to like 9 quintillion or something.

I switched everything to BigInt and that worked as well.

CG runs 64-bit PHP so there is no problem: all test cases within 64 bits.

Using NumberFormatter::SPELLOUT is a clever idea, but maybe it is for the better that the expected format is slightly different. The ability to use this would render the puzzle to a single library function call.

My solution became long and quite not elegant.
I am wondering if some Haskell magicians will come up with a clever one-liner solutionā€¦ :slight_smile:

Nice puzzle title! :slight_smile:

No, they are not. The smallest is -2ā¶ā“ in testcase 6. Even when I remove the minus and parse it as an unsigned long, I get this:

Unhandled exception. System.OverflowException: Value was either too large or too small for a UInt64.

I submitted anyways and passed the validators. Obviously you donā€™t even have to parse the input as a number, so I modified the stub of this contribution to read a string instead of the 32bit int it was before. Now the default code doesnā€™t crash anymore at least.
I also question the moderation process here. someone even commented ā€œI had fun trying to handle -2^64 in C++ā€ in the approval message, another user mentioned the overflow caused by the default code too.

3 Likes

You are right, my short term memory is <1 bit. By the time I posted in the forum, I already forgot that I parsed and processed the input as string 1 hour earlier, thatā€™s why I did not encounter any overflow.

I passed all 7 tests but when I submit it I have only 85%. The validator ā€œOther powers of 10ā€ is not passed.
Iā€™ve checked it manually and every power of 10 (from 10 to even one sextillion) worksā€¦ What can be wrong?

Did you test it locally or in CodinGame platform? Maybe thereā€™s a timeout issue. You may test it as a custom case inside CodinGame platform and see what the error message is, if any.