refactor: Extract and deduplicate logic
refactor: Extract and deduplicate logic

Bugfry/exercism,Bugfry/exercism,Bugfry/exercism,Bugfry/exercises,Bugfry/exercism,Bugfry/exercises,Bugfry/exercises,Bugfry/exercises,Bugfry/exercism,Bugfry/exercism,Bugfry/exercises,Bugfry/exercises