My solution

Could use a bit more polish.