Advertisement
musifter

AoC day 25, Smalltalk

Dec 25th, 2020
2,466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/local/bin/gst -q
  2.  
  3. subject_num := 7.
  4. mod := 20201227.
  5.  
  6. public := (stdin contents tokenize: '\n') collect: [ :v | v asNumber ].
  7.  
  8. p1 := public at: 1.
  9. p2 := public at: 2.
  10.  
  11. loop := 0.
  12. val  := 7.
  13. [(val ~= p1) and: [val ~= p2]] whileTrue: [
  14.     val := (val * subject_num) \\ mod.
  15.     loop := loop + 1.
  16. ].
  17.  
  18. other := public detect: [ :v | v ~= val ].
  19. encrypt_key := other.
  20. loop timesRepeat: [ encrypt_key := (encrypt_key * other) \\ mod ].
  21. encrypt_key displayNl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement