从0-9生成所有可能的8位数字

发布于 2025-01-25 09:08:41 字数 281 浏览 4 评论 0原文

我在Mac上,试图从0-9的每一个可能的8位数字愚弄,重复允许到文件,为100 000 000 000。

我已经尝试过

jot -r 100000000 00000000 99999999

,只给了我100 000 000的随机数,而重复的数字并非全部是8位。我无法弄清Jot中是否有一个开关可以做我想做的事,或者Jot是否能够做我要做的事情。我该怎么做?

我需要10^8的所有可能的8位序列号,即100 000 000。我不知道哪些程序可以生成这些数字。

I'm on a mac, and trying to dumb every possible 8 digit number from 0-9, with repetitions allowed, to a file, which would be 100 000 000 numbers.

I've tried

jot -r 100000000 00000000 99999999

That just gives me 100 000 000 random numbers with duplicates, and not all are 8 digits. I can't figure out if there's a switch in jot that does what I want to do, or if jot is even able to do what I to do. How can I do this?

I need every possible 8 digit serial number for 10^8, which is 100 000 000 number. I don't know what program can generate these numbers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

带上头具痛哭 2025-02-01 09:08:41

您要求的等同于从0到10^8计数。如果您想要随机订单并仍然保证命中每个数字,则可以执行此操作:

import numpy as np
numbers = np.random.choice(10**8, size=10**8, replace=False).astype(str)
numbers = list(map(lambda s: s.zfill(8), numbers))
with open('out.txt', 'w') as file:
    file.write("\n".join(numbers))

what you are asking for is equivalent to counting from 0 to 10^8. If you want random order and still guarantee hitting every number, you can do this:

import numpy as np
numbers = np.random.choice(10**8, size=10**8, replace=False).astype(str)
numbers = list(map(lambda s: s.zfill(8), numbers))
with open('out.txt', 'w') as file:
    file.write("\n".join(numbers))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文