# How to calculate the $r^{\text{th}}$ digit of $\sum ^{j−1}_{p=i}d^p_{\pm k}$ using PyQUBO?

I am going to implement "turn circuit encoding" method of Coarse-grained lattice protein folding on a quantum annealer(Babej, Ing & Fingerhuth; 2018) using PyQUBO to run on the DWave qbsolv environment.

In this method I have to implement equation 36 given below. $$s^r_{\pm k}(i,j) = r^{\text{th}} \text{ digit of } \sum ^{j−1}_{p=i}d^p_{\pm k}$$

Where $$d^p_{\pm k} \implies$$

$$d^j_{+x} = (1−q_2+\varphi)q_1 + \varphi q_3+\varphi,$$

$$d^j_{−x} = (1−q_3+\varphi)q_1 + \varphi q_2+ \varphi,$$

$$d^j_{+y} = (1−q_1+\varphi)(1−q_2+\varphi)q_3+\varphi,$$

$$d^j_{−y} = (1−q_1+\varphi)(1−q_3+\varphi)q2+\varphi,$$

$$d^j_{+z} = q_1+\varphi q_2+\varphi q_3+\varphi,$$

$$d^j_{−z} = (1−q_2+\varphi)(1−q_3+\varphi)q_1+\varphi$$

and $$\varphi = 3(j − 2).$$

When we calculate $$\sum ^{j−1}_{p=i}d^p_{\pm k},$$ we get a list of qubits and want to find the $$r^\text{th}$$ digit using PyQUBO. Is it possible to calculate $$r^\text{th}$$ digit using PyQUBO and how should I do it?