From c4d28bbe42ca88109ab462742f2b72ad30af209a Mon Sep 17 00:00:00 2001 From: siddharth Date: Tue, 17 Aug 2021 20:21:59 -0400 Subject: challenge: update C22 Use MTRand.Extract and MTRand.Seed instead of MTExtact and MTSeed. --- challenge/c22.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'challenge') diff --git a/challenge/c22.go b/challenge/c22.go index 603cb9e..c947f94 100644 --- a/challenge/c22.go +++ b/challenge/c22.go @@ -11,6 +11,7 @@ import ( ) func C22() { + mt := new(lib.MTRand) minWait := 40 * time.Second maxWait := 1000 * time.Second randomWait := func() { @@ -25,17 +26,17 @@ func C22() { randomWait() fmt.Printf("Generating seed from current time...\n") - lib.MTSeed(uint32(time.Now().Unix())) + mt.Seed(uint32(time.Now().Unix())) randomWait() fmt.Printf("Extracting first random 32-bit garbage fron RNG...\n") - random := lib.MTExtract() + random := mt.Extract() fmt.Printf("Cracking seed...\n") guess := uint32(time.Now().Unix()) for { - lib.MTSeed(guess) - x := lib.MTExtract() + mt.Seed(guess) + x := mt.Extract() if x == random { fmt.Printf("Found seed %v\n", guess) break -- cgit v1.2.3