[英]How to randomly generate a 12 digit hexadecimal where no more than 2 digits repeated?
我想随机生成12位十六进制。 约束条件是整体上不再重复2位,也没有连续的重复。 如何编写高效的代码?
xx11xxxxxxxx is not valid because the same digit (e.g., 1) appears consecutively.
12121xxxxxxx is not valid as well because the digit 1 appears thrice.
创建字符串var“ 0123456789ABCDEF0123456789ABCDEF”,然后使用随机生成器将字符的顺序混合,如果没有两次,则按一下chek,最后一步将其剪切为12个字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.