Circular Doubly Linked List find length with single pointer I have pointer to circular doubly linked list with random values of 0 or 1.
Example: [{prev,0,next},{prev,0,next},{prev,1,next},{prev,0,next}...]
I have a single pointer to the first item of the list. 
I need to find the length of the list without to create any additional pointers.
In addition, I can change the values of each node between 0 to 1 or 1 to 0.

I thought about Josephus Circle algorithm - with no success.

My main problem is that I don't even know what end of a circle/circular list is.
If you think about that, you will understand it is not an easy question.
I think the following algorithm would do it:


Start by setting the value in the first node to $1$.
Follow next pointers until you encounter a node with value $1$, while keeping a counter $c$ of how many nodes you have encountered.
Set the value of the node to $0$ and follow prev pointers for $c$ steps


If the value of the node (which should be the first node) is now $0$, the list has $c-1$ elements,
otherwise, follow next pointers for $c$ steps and continue with step 2.