CodeUnion loves to get people together to learn and write code. Yesterday we hosted our first meetup. A quiet yet solid learning evening, we worked on a few different CodeUnion kata.

Notably, we worked on the rot13 kata.

The rot13 implementation takes a string as an input and returns another string that has had the character sequence 'rotated' by 13 positions in the English alphabet.

Our two meetup members, Sylvia is a game and animation programmer, Matt is a data science person. The below is a solution we arrived at as a group. Our aim in these sessions is to learn, have fun and make stuff, pretty simple right... ?

def rot13(string)
  n = 13
  # need a list of letters
  lowercase = ("a".."z").to_a
  capitals = ("A".."Z").to_a
  alphabet = capitals + lowercase
  capital_cipher = capitals[n..-1] + capitals[0..n-1]
  lower_cipher = lowercase[n..-1] + lowercase[0..n-1]
  cipher = capital_cipher + lower_cipher
  # take the capitals array
  # compose a cipher
  # take the lower case array
  # compose the cipher
  # iterate through the string
  string.chars.collect do |char|
    if char == " "
      " "

if __FILE__ == $0
  # See to generate test inputs and outputs
  p rot13("The Quick Brown Fox Jumps Over The Lazy Dog") == "Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt"

We host a weekly remote collaborative coding meetup. Feel free to join us and let us know some topics that you'd like to work on [email protected].