Write hand-comparison logic