Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashes
- import combinatorics
- echo()
- echo "testing permutations"
- echo()
- # https://bitbucket.org/nimcontrib/nimcombinatorics
- let cc = @["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
- let ts = "efghi" # a string which will be hit early
- let okhash = hash(ts)
- var ms = ""
- var trials = 0
- for x in permutations[string](cc):
- for z in x:
- ms = ms & z
- if ms.len == ts.len:
- inc trials
- echo "Trials : ",trials," ms : ",ms
- if hash(ms) == okhash:
- echo()
- echo ms," hash : ",okhash
- echo "trials : ",trials
- quit(0)
- else: ms = ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement