0

Let's say I have two lists, X, Y.

X = {limegreen, forestgreen, seagreen}, Y = {babyblue, navyblue, ultramarineblue}

And I have the elements $d_0, d_1, d_2, ..., d_n$. I want it so no two consecutive elements are from the same set.

I know I can do: For every $d_i, d_{i+1}$, if $d_i \in X$, then $d_{i+1} \in Y$ for $i \geq 0$.

But is there a better way to do this?

2 Answers2

0

You can write $\forall i (d_i \in X \implies d_{i+1} \not \in X \land d_i \in Y \implies d_{i+1} \not \in Y)$ I don't know if the reuse of $i$ is bothersome. An alternate is $\forall i (d_i \in X \implies d_{i+1} \not \in X) \land \forall j (d_j \in Y \implies d_{j+1} \not \in Y)$

Ross Millikan
  • 374,822
0

$$\forall i\in\{1,\dots,n\},(d_i\in X\iff d_{i-1}\in Y)$$

assuming $X,Y$ are disjoint, as they appear to be in your example.