Skip to content

Instantly share code, notes, and snippets.

View John61590's full-sized avatar

John Bohne John61590

View GitHub Profile
@John61590
John61590 / NearestIntegerPalindrome.java
Created April 25, 2017 08:35
Find nearest integer palindrome in Java (best algorithm)
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 + "";
@John61590
John61590 / JMDict.py
Created June 9, 2013 19:02
JMDict.py from JBLite made by Paul Goins fixed code to add value to lsource changed lsource for loop and insert lsource table query
# -*- 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