簡體   English   中英

如何隨機生成不超過2位重復的12位十六進制?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM