我在做overthewire.org和因为我是个脚本孩子,所以我搜索了24级的答案.的强盗战争游戏
password="UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ"
for i in {0000..9999}
//looping to try any possible pin code
do
echo $password' '$i >> wordlist.txt
//save password and possible pin code into wordlist
done我看到了bash脚本,想:“我不可能这么做,因为我不擅长bash。”但后来我意识到这个问题可以用其他语言解决。
挑战很简单。
std::endl自动完成的。我在C++上做了
#include
#include
using namespace std;
int main()
{
string key; //1
getline(cin, key); //I heard that std::getline is
//only standard for linux, so for practical
//purposes use cin.getline(char*,size)
for(int i = 0; i < 10000; i++){ //3
cout << key << setfill('0') << ' ' //2
<< setw(4) << i << endl; //4
}
return 0;
}显然,它可以比301字节做得更好,但是您可以得到gist。
而且,任何语言都是可以接受的,只要它能够产生由新行或换行分隔的相同格式的字符串。
发布于 2020-08-06 11:35:28
E×χφ⁺⁺θ ⭆◧Iι⁴Σλ在网上试试!链接是详细的代码版本。测试用例使用缩短的密码,以避免TIO输出的限制。解释:
×χφ Multiply predefined variables 10 with 1000
E Map over implicit range
ι Current index
I Cast to string
◧ ⁴ Left-pad to width literal `4`
⭆ Σλ Convert non-digits to zeros
⁺⁺θ Concatenate with the password and a space
Implicitly output each entry on its own line发布于 2020-08-06 15:03:52
https://codegolf.stackexchange.com/questions/209149
复制相似问题