Pregunta de entrevista de Jane Street

They asked me to implement two functions in a data class.