This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NearestIntegerPalindrome { | |
public static int findClosestPalindrome(int x) { | |
if (x < 0) { | |
return -1; | |
} | |
//special case: 100 -> 99 palindrome is closest | |
if (x != 1 && isPower10(x)) { | |
return x - 1; | |
} | |
String value = x + ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""JMdict support.""" | |
# This could be a bit cleaner if I used something like SQLalchemy | |
# perhaps... The create/insert/index bits were done decent enough, | |
# but lookups are done in straight SQL due to the potential | |
# complexity, and this sadly does break the abstraction of the table | |
# objects... | |
from __future__ import print_function |