首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >密码毕晓普善

密码毕晓普善
EN

Code Golf用户
提问于 2019-02-13 13:15:51
回答 10查看 2.2K关注 0票数 10

派生自,现在删除,发布。

给定一个字符串,如果它构成一个好的主教密码,则回答它(真/假或两个一致的值),这是在满足以下所有条件时:

  1. 它至少有10个字符
  2. 它至少有3位数([0-9])
  3. 它不是回文(倒转时与其本身相同)。

如果您的代码是一个很好的毕晓普密码,您将得到0字节的奖励。

警告:不要用主教的善良作为实际密码强度的衡量标准!

示例

好毕晓普密码

PPCG123GCPP

PPCG123PPCG

PPCG123gcpp

0123456789

Tr0ub4dor&3

不好毕晓普密码

PPCG123 (太短)

correct horse battery staple (没有足够的数字)

PPCG121GCPP (回文)

 (太短而没有足够的数字)

abc121cba (太短和回文)

aaaaaaaaaaaa (回文和数字不足)

abc99cba (一切都不对)

EN

回答 10

Code Golf用户

发布于 2019-02-13 13:39:32

05AB1E,12 字节数

代码语言:javascript
运行
复制
gT@Iþg3@IÂÊP

在网上试试验证所有测试用例.

解释:

代码语言:javascript
运行
复制
g      # Get the length of the (implicit) input
 T@    # Check if this length >= 10
Iþ     # Get the input and only leave the digits
  g    # Then get the length (amount of digits)
   3@  # And check if the amount of digits >= 3
IÂ     # Get the input and the input reversed
  Ê    # Check if they are not equal (so not a palindrome)
P      # Check if all three above are truthy (and output implicitly)
票数 4
EN

Code Golf用户

发布于 2019-02-13 13:42:54

果冻,12字节

代码语言:javascript
运行
复制
~Tṫ3ȧL9<Ɗ>ṚƑ

在网上试试!

[]如果没有足够的数字(空列表,falsy),0 (如果不是坏的话)(0,falsy),1 (如果是好的)(非零,真实)。

票数 2
EN

Code Golf用户

发布于 2019-02-13 13:54:40

Java 8,92个字节

代码语言:javascript
运行
复制
s->s.length()>9&s.replaceAll("\\D","").length()>2&!s.contains(new StringBuffer(s).reverse())

在网上试试。

解释:

代码语言:javascript
运行
复制
s->                        // Method with String parameter and boolean return-type
  s.length()>9             //  Check if the length of the input-String is more than 9
  &s.replaceAll("\\D","")  //  AND: remove all non-digits from the input-String
    .length()>2            //       and check if the amount of digits is more than 2
  &!s.contains(new StringBuffer(s).reverse())
                           //  AND: check if the input-String does NOT have the reversed
                           //       input-String as substring (and thus is not a palindrome)
票数 2
EN
页面原文内容由Code Golf提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://codegolf.stackexchange.com/questions/179841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档