-6
Input
A single integer in your language's preferred format. This format is non-negotiable (no input as strings, arrays of digits, etc.), but standard I/O formats do apply if otherwise it would be impossible in your language.
Output
A truthy or falsely value, depending on whether the given number is palindromic (same forwards and backwards)
Rules
- Numbers will always be positive, at least two digits long.
- This is fastest-algorithm, so lowest O(n) time complexity wins.
Test cases
- 123454321 - true
- 296296 - false
- 296692 - true
- 5499456 - false
- 0 - false/error/any value
2In your rules you state the input is less than
99999999
, but the first test case is larger than this. – Kevin Cruijssen – 2019-07-01T13:22:58.0274You state that the input is a 16-bit integer, but 4 of the 5 test cases don't fit on 16 bits. – Grimmy – 2019-07-01T13:26:19.137
1Indeed, the upper bound, 99999999, doesn't fit in 16 bits. – Adám – 2019-07-01T13:27:04.800
6Also: specifying any upper bound makes the problem trivially O(1). You should either change to fastest-code or remove the upper bound altogether. – Grimmy – 2019-07-01T13:33:08.090
OK, fixed all issues. – Geza Kerecsenyi – 2019-07-01T13:46:15.957
6@GezaKerecsenyi No you didn't fix the issue of an upper bound making O(1) solutions trivial. – Adám – 2019-07-01T13:50:04.860
in your language's preferred format — What if my language's integer type is bounded? (E.g. 8, 16, or 32 bits.) – Adám – 2019-07-02T06:50:38.200
@Adám I assume you're referring to C & co., with long and long long being separate? Do it for the maximum your language supports. If that means hardcoding everything up to 32 bits, sure, but that will likely not be the winning entry. The same with the upper bound: it means it's possible to hardcode everything, but that doesn't mean you should. Plus it makes the challenge pretty boring. – Geza Kerecsenyi – 2019-07-02T07:05:07.540
1If boring solutions are the optimal solutions then that's a reflection of the challenge, not the solutions. – Shaggy – 2019-07-02T13:30:20.910