是否有一个算法来解决一个5位数的引脚,它不会重复出现在字符串中? [英] Is there an algorithm for solving a 5 digit pin that doesn't repeat making it in a string ?
问题描述
您好......
我对字符串有疑问...
我来了从一个逃生室,他们有一个5键的密码,不能重复所以是5! = 120种可能性所以我问自己是否可以找到一个字符串,在不到120x5 = 600次按下按钮时有所有可能性。
例如:3针组合= 3! = 6次尝试
123 132 213 231 312 321 ...但是我们可以做到123121321所以9次按下不是6x3 = 18
它有一个算法,或者我们可以为更多不重复的字符做一个程序吗?
谢谢你,抱歉我的英文不好!
Vlad Pineta
[已删除] @ gmail.com
我尝试过:
我试图在互联网上找到一个算法,但我没有找到任何东西
Hello...
I have a question about strings...
I came from an escape room and they had a 5 button password that can't repeat so were 5! = 120 possibilities so i've asked myself if i can find a string that have all the possibilities in less than 120x5=600 button presses.
Example: 3 pin combination = 3! = 6 tries
123 132 213 231 312 321 ...but we can do it 123121321 so 9 presses not 6x3=18
It's there an algorith for this or can we do a program that does this for more characters that don't repeat ?
Thank you and sorry for my bad english !
Vlad Pineta
[DELETED]@gmail.com
What I have tried:
I tried to find an algorithm on internet but i didn't found anything
推荐答案
停止尝试在互联网上找到算法并思考问题。
首先生成完整序列字符串:
Stop trying to "find an algorithm on internet" and think about the problem.
Start by generating the "full sequence" string:
123124125132134...
每次添加新序列时,请查看它是否包含在现有字符串中。如果是的话,不要添加它。
BTW:永远不要在任何论坛发布你的电子邮件地址,除非你真的喜欢垃圾邮件!如果有人回复你,你会收到一封电子邮件通知你。
And each time you go to add a new sequence see if it's "contained" in the existing string. If it is, don't add it.
BTW: Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know.
这篇关于是否有一个算法来解决一个5位数的引脚,它不会重复出现在字符串中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!