package main

import (
	"io"
	"os"
	"strings"
)

//This exercise covers: "rot13Reader"

type rot13Reader struct {
	r io.Reader
}

func (r rot13Reader) Read(b []byte) (n int, err error) {
	count, err := r.r.Read(b)

	for i, x := range b {
		if (x > 'a' && x < 'z') {
			tmp := (x - 'a' + 13) % 26
			b[i] = tmp + 'a'
		} else if (x > 'A' && x < 'Z') {
			tmp := (x - 'A' + 13) % 26
			b[i] = tmp + 'A'
		}
	}
	
	return count, err
}

func main() {
	s := strings.NewReader("Lbh penpxrq gur pbqr!")
	r := rot13Reader{s}
	io.Copy(os.Stdout, &r)
}