There were and still are many problem in CW about palindrome numbers and palindrome strings. We suposse that you know which kind of numbers they are. If not, you may search about them using your favourite search engine.

In this kata you will be given a positive integer, ```val``` and you have to create the function ```next_pal()```(```nextPal``` Javascript) that will output the smallest palindrome number higher than ```val```.

Let's see:
```python
For Python
next_pal(11) == 22

next_pal(188) == 191

next_pal(191) == 202

next_pal(2541) == 2552
```

You will be receiving values higher than 10, all valid.

Enjoy it!!

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures

Mathematics

Starter code: def next_pal(val):
	

Solutions:
def palindrome(n):
	s = str(n)
	return s[::-1] == s

def next_pal(val):
	val += 1
	while not palindrome(val):
		val += 1
	return val


def next_pal(val):
	int_to_digits = lambda n: [int(d) for d in str(n)]
	digits_to_int = lambda a: int(''.join(map(str, a)))
	digits = int_to_digits(val)
	(half, odd) = (len(digits) // 2, len(digits) % 2)
	build = lambda start: digits_to_int(start + start[::-1][-half:])
	base_start = digits[:half + odd]
	possible = build(base_start)
	if possible > val:
		return possible
	return build(int_to_digits(digits_to_int(base_start) + 1))


def next_pal(val):
	val += 1
	while str(val) != str(val)[::-1]:
		val += 1
	return val


def is_palindrome(n):
	return str(n)[::-1] == str(n)

def next_pal(val):
	for i in range(val + 1, 10 * val):
		if is_palindrome(i):
			return i


def next_pal(val):
	n = val + 1
	while n != int(str(n)[::-1]):
		n += 1
	return n


from itertools import count, dropwhile

def next_pal(val):
	return next(dropwhile(isNotPal, count(val + 1)))

def isNotPal(n):
	return n != int(str(n)[::-1])


def next_pal(val):
	val += 1
	while f'{val}' != f'{val}'[::-1]:
		val += 1
	return val


import itertools

def next_pal(val):
	for n in itertools.count(val + 1):
		s = str(n)
		if s == s[::-1]:
			return n