Skip to content

Instantly share code, notes, and snippets.

View astropanic's full-sized avatar

Wojciech Pietrzak astropanic

View GitHub Profile
#Time limit exceeded
class Palindrome
def compute(value)
@input_array = value
@size = @input_array.size
@even = @size % 2 == 0
if @even
@pos1 = (@size/2)-1
@pos2 = @pos1+1
#Time limit exceeded
class Palindrome
def compute(value)
@input_array = value
@size = @input_array.size
@even = @size % 2 == 0
if @even
@pos1 = (@size/2)-1
@pos2 = @pos1+1
CHARS64 = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a + ["-", "_"]
# Return a 22 byte URL-safe string, encoded six bits at a time using 64 characters
def to_s22
integer = self.to_i # UUID as a raw integer
rval = ""
22.times do
c = (integer & 0x3F)
rval += CHARS64[c]
integer = integer >> 6
end