floyds algorithm for cycle detection linked list ruby