New to electronics so it took a while to do this with karnaugh maps. Only have 'and' 'or' 'not' gates so I'm sure I could tidy it up a bit but I did reuse some gates anyway so I think it's good enough. I expected it to count in the other direction so I tried swapping the pulse times but it just got messed up. Please comment if you know how to get around this.