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
; | |
; Generate a table of the products of prime numbers | |
; | |
(defn √ [x] | |
"Integer square root of x" | |
(int (Math/sqrt x))) | |
(defn prime? [x] | |
"Return true if x is a prime number, using naïve trial division algorithm." |
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
PAIRS="..LEXEGEZACEBISOUSESARMAINDIREA.ERATENBERALAVETIEDORQUANTEISRION" | |
planet = (3+rand(2)).times.map { PAIRS[rand(32) * 2,2] }.join.gsub('.', '').capitalize |
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
# Returns an enumerator that generates password from the standard dictionary | |
# Only parameter is the number of words to use. | |
# Example: passwordy(2).next -> "GarlicUngulp" | |
def passwordy(wc=4) | |
words = File.readlines('/usr/share/dict/words') | |
.select {|w| w.size>5 && w.size<=9} | |
.shuffle | |
Enumerator.new do |yielder| | |
yielder.yield(words |
NewerOlder