First ever solution. Probably a bit janky but looking forward to seeing all the wonderful submissions that inevitably beat this.