Reddit daily programmer hard challenge #174