回文高尔夫 [英] Palindrome Golf

查看:86
本文介绍了回文高尔夫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:任何语言.最小的函数将返回字符串是否是回文.这是我的 Python :

The goal: Any language. The smallest function which will return whether a string is a palindrome. Here is mine in Python:

R=lambda s:all(a==b for a,b in zip(s,reversed(s)))

50个字符.

可接受的答案将是当前的最小答案-随着找到较小的答案,该答案将发生变化.请指定您的代码使用的语言.

The accepted answer will be the current smallest one - this will change as smaller ones are found. Please specify the language your code is in.

推荐答案

Haskell, 15 个字符:

Haskell, 15 chars:

p=ap(==)reverse

可读性更高的版本, 16 个字符:

More readable version, 16 chars:

p x=x==reverse x

这篇关于回文高尔夫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆