Last active
July 4, 2022 11:15
-
-
Save multicurrency/b340e15cd37b7b049f3f10e13f63bcd1 to your computer and use it in GitHub Desktop.
Final Version of the Deck Lottery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| import random | |
| # The blockhash is a string and bare (no "0x" prefix). | |
| # The placeholder is BTC genesis hash | |
| BLOCKHASH_396963 = "000000000000000000fea6c8d1ee3a89662452b2f3eb85fb109942ff11d0902d" | |
| # The salt solidfies the rules and card assignments | |
| SALT = """ | |
| Rules | |
| ----- | |
| - The blockhash 396963 is a hex string and bare (no "0x" prefix). | |
| - The salt is this rule and card assignment string. | |
| - The cards for each lottery are shuffled with python built-ins:: | |
| random.seed(SALT + BLOCKHASH_396963) | |
| random.shuffle(cards) | |
| - Keys are not shuffled. | |
| Card Assignments | |
| ---------------- | |
| - The first character is the card value, second is the suit. | |
| - High card abbreviations are: Q:Queen, J:Jack, T:Ten | |
| - Suits: S:Spades, D:Diamonds, C:Clubs, H:Hearts | |
| - Examples: QS is the Queen of Spades. TD is the Ten of Diamonds. | |
| """ | |
| # Data structures | |
| TITLES = ["Top Lottery", "Second Lottery", "Third Lottery"] | |
| CARDS = [ | |
| # Top Lottery | |
| [ | |
| "QS", "QD", "QC", "QH", | |
| "JS", "JD", "JC", "JH", | |
| "TS", "TD", "TC", "TH", | |
| "9S", "9D", "9C", "9H", | |
| "8S", "8D", "8C", "8H", | |
| "7S", "7D", "7C", "7H" | |
| ], | |
| # Second Lottery | |
| [ | |
| "6S", "6D" | |
| ], | |
| # Third Lottery | |
| [ | |
| "6C", "6H", | |
| "5S", "5D" | |
| ] | |
| ] | |
| # Public Keys | |
| KEYS = [ | |
| # Top Lottery | |
| [ | |
| "03f445047839579f8d3bc173706364a67f9eb80aa9c88dcab6bf75aa8af65677e1", | |
| "0300436642e93deb285f5495cda0575ab42c863dbc182c176765c6dd3c163d6cc7", | |
| "02df412cec8342418a14e5937f7d9c133207d435967f85f842e27b7ef8a04ba3f8", | |
| "02dbe0decb529d11e1b3d44a77bac1b8e760fb56de2e3081dd2310b3fbd09ada4c", | |
| "020f52b2acc8b3661dc5c5a8ad4e3f0e5c0f0d24b4ab0caec581164af8ffbacb2c", | |
| "023cc7238c33f2652783e37e2f2bb91f13f79f04e7ba6f579ccd3e83b018442a5e", | |
| "034e0ae9c206cae43a5a0a19fe3ac1f1aa990ad5f828989e76ae96e69419bc53b2", | |
| "02ef5cd5a6870954df3627498012b1c669e4d284fe5ae59520c92a3718f1dded87", | |
| "03f104c1ef2b5d8c7856a5de862536779b74514707808f96bd3dc2311bf561c3fe", | |
| "0275b01ff13a66b20b335b178f396b88c3bed888cbad9d74bae611bb00fa6fd3d8", | |
| "02e55a6690325afdb740eeeb808a8de63c19ddeb1320bce09de9a5516a6aafda61", | |
| "02b2eadc2e67ddd2ee5c5998880d50380bdee7ddd51f6c0430720403a417d7bc49", | |
| "022d8f24425e9e8a713d7e490051737ca7dddf1d03e118d330ffa014d0d69c5a59", | |
| "022a281ede735215f044579ac15d0a0492a991a248a76093a3894848ff2deb15cd", | |
| "033bfe49d857e4a0772924c968938ff3cdaaee84f38545e1941624d8ea3be96af1", | |
| "03f37ed2f90e7ee7e83c73150e90cb0991a009e7248be27ef49af171a4b3f2c046", | |
| "0293723173b69e305c19718809c88c38cec07cc7ca2309189510242a6645a2b363", | |
| "02d94b98676079e224321a739711bff2a87e8c94733b4c35347ef1238b23505f86", | |
| "02487e8e7492509991e90351481c3f20a61b10b20fbef7a6040660893cc01201da", | |
| # Privkey lost | |
| # "023b7376ec234ccb1b496b3c2e8f25d06dc25cfcf06cf65bfb9251e91a9676c327", | |
| # Now | |
| "0205a082034dc381d56a558003b36e3cc397bf7cb6796ffb27f2504d84dd6e53d8", | |
| "0308e5de76f8a717680eb7736e8e239c873421fd296f7afb2668ad9a0738dbb3f3", | |
| "0252d95e1fa54d65925c710a1d35cfc5fe65087087342448d3ff78eceb1072e617", | |
| "0235b042a1197a87de57f24161a3c69beaef0bb62ac406f31ef957d5e304496f1c", | |
| "03149c5eb2628d0bc59ee74fd87b124d7bc133d125e96336b1a4cd919d1963bd37" | |
| ], | |
| # Second Lottery | |
| [ | |
| "023fd1635baf253bd07284997f7fbd7bf80a56c42086c553a4a298091202c4b9a5", | |
| "04271c3c323ddc37ddd515602d8ad82657836ab469ccbb444b0073ade3bde67cb" + | |
| "1d31f791318fe404adbaf3a546009aefd59b37b76a588ca44ea417649dea25421" | |
| ], | |
| # Third Lottery | |
| [ | |
| "02f487e99ccd3a0dc2cab71178b866152ddc60d6156a75a5138f6fd9535f2f10e2", | |
| "027845366fb68ed5b6534dc5cdebbba8dc8bf68dd9c870843d6dbea7ccb1106252", | |
| "02e577ddbc08edb6c5195c5389ca319bcbb585674d05627b4b52682bc06d3d460e", | |
| "0218ab151b864b5d869f2054c3e8fef93ec59f0c2bbc536657b21bc8bf85dc24c4" | |
| ] | |
| ] | |
| def main(): | |
| # ensure data structures are sane | |
| for title, keys, cards in zip(TITLES, KEYS, CARDS): | |
| assert len(keys) == len(cards) | |
| random.seed(SALT + BLOCKHASH_396963) | |
| random.shuffle(cards) | |
| print "============================================================================" | |
| print title | |
| print "----------------------------------------------------------------------------" | |
| for pair in zip(keys, cards): | |
| print pair | |
| print "============================================================================" | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment