简体   繁体   中英

How to randomly generate a 12 digit hexadecimal where no more than 2 digits repeated?

I want to generate randomly 12 digit hexadecimal. The constraint is that no more 2 digits are repeated as the whole and no consecutive repetition. How to write the efficient code?

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个字符。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM