Skip to content

Instantly share code, notes, and snippets.

@amlang
Last active May 22, 2018 14:09
Show Gist options
  • Save amlang/65bc8856e9c7bbe16c762f5e79dc7616 to your computer and use it in GitHub Desktop.
Save amlang/65bc8856e9c7bbe16c762f5e79dc7616 to your computer and use it in GitHub Desktop.
ruby - Get random character except 'F' and 'T'
#!/usr/local/bin/ruby -w
puts ( ['A'..'Z'].map(&:to_a) # create field with characters A-Z
.flatten - ["F", "T"] # reduce nesting level and exclude 'F' and 'T'
)[rand(23)] # take a random value from the remainung 24 letters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment