This file contains hidden or 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
namespace PalindromeGist | |
{ | |
struct Program | |
{ | |
public static bool Espalindromo(string word) | |
{ | |
char[] origin = word.ToCharArray(); | |
for (int i = 0; i < word.Length; i++) | |
{ | |
if (origin[i] != origin[(origin.Length - 1) - i]) |
This file contains hidden or 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
#!/usr/bin/env python | |
def is_palindrome(num): | |
return str(num) == str(num)[::-1] | |
def closest_higher(target, collection) : | |
"""Return the closest number to `target` in `collection` | |
that is higher than `target`""" | |
return max((target - i, i) for i in collection if (target - i) < 0)[1] |