Reverse engineering numeric patterns - matrix

I'm having a difficult time trying to figure out a general equation or function for some patterns generated using 4 variables C, x, y and z. M is a 3D matrix of shape (p, q, C) containing these values, where p and q are some large but likely irrelevant integers.
Shown below is a small selection of patterns. Can anyone see what the function f(C, x, y, z) might be like? Please note that the values of C, x, y and z are not limited to those below, but can be any integers.
C = 1
(x =) 0 0 0 0 0 0 0 0 0
(y =) 0 1 2 3 4 5 6 7 8
(z =) 0 0 0 0 0 0 0 0 0
M = [[[0]], [[1]], [[2]], [[3]], [[4]], [[5]], [[6]], [[7]], [[8]], ...]
---------------------------------------------------------------------------
(x =) 1 1 1 1 1 1 1 1 1
(y =) 0 1 2 3 4 5 6 7 8
(z =) 0 0 0 0 0 0 0 0 0
M = [[[0]], [[1]], [[2]], [[3]], [[4]], [[5]], [[6]], [[7]], [[8]], ...]
C = 2
(x =) 0 0 0 0 0 0 0 0 0 0
(y =) 0 0 1 1 2 2 3 3 4 4
(z =) 0 1 0 1 0 1 0 1 0 1
M = [[[0, 2], [1, 3]], [[4, 6], [5, 7]], [[8, 10], ...]
---------------------------------------------------------------------------------
(x =) 1 1 1 1 1 1 1 1 1 1
(y =) 0 0 1 1 2 2 3 3 4 4
(z =) 0 1 0 1 0 1 0 1 0 1
M = [[[0, 4], [1, 5]], [[2, 6], [3, 7]], [[8, 12], ...]
C = 3
(x =) 0 0 0 0 0 0 0 0 0 0 0 0
(y =) 0 0 0 1 1 1 2 2 2 3 3 3
(z =) 0 1 2 0 1 2 0 1 2 0 1 2
M = [[[0, 2, 4], [1, 3, 5]], [[6, 8, 10], [7, 9, 11]], ...]
-----------------------------------------------------------------------------------------------
(x =) 1 1 1 1 1 1 1 1 1 1 1 1
(y =) 0 0 0 1 1 1 2 2 2 3 3 3
(z =) 0 1 2 0 1 2 0 1 2 0 1 2
M = [[[0, 4, 8], [1, 5, 9]], [[2, 6, 10], [3, 7, 11]], ...]
C = 4
(x =) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(y =) 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3
(z =) 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
M = [[[0, 2, 4, 6], [1, 3, 5, 7]], [[8, 10, 12, 14], [9, 11, 13, 15], ...]
-------------------------------------------------------------------------------------------------------------------------
(x =) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
(y =) 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3
(z =) 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
M = [[[0, 4, 8, 12], [1, 5, 9, 13]], [[2, 6, 10, 14], [3, 77, 11, 15], ...]
Quite clearly, when C > 1, there is some interleaving/skipping going on. For instance, when C == 2, M(1,1,1) == 0, M(1,2,1) == 1, M(1,1,2) == 2, etc. But it's not clear to me how the skipping across the values of C can be generalised.

Related

Resetting an array of numbers by repeated subtraction from a sub-array

There is an array of numbers between 0 and 6 (base 7). For example {0 4 6 2 2 0 3 1}. Its maximum length can be 501 elements.
Each step we can subtract a number from any number of elements. All of the elements must be adjacent (form a continuous sub-array). The number subtracted from all of the elements must be the same.
If an element (let's call it A) after subtraction doesn't fit in the range of 0 to 6, then A becomes A modulo 7. For example after subtracting 3 from the whole array {0 4 6 2 2 0 3 1}, we would get
{4 1 3 6 6 4 0 5}.
The task is to find the smallest amount of steps necessary to get an array with just zeros.
For example for the array {0 4 6 2 2 0 3 1} it would take 4 steps:
{0 4 6 2 2 0 3 1} subtract 2 from elements with indexes 2-4
{0 4 4 0 0 0 3 1} subtract 4 from elements with indexes 1 and 2
{0 0 0 0 0 0 3 1} subtract 3 from the second to last element
{0 0 0 0 0 0 0 1} subtract 1 from the last element
{0 0 0 0 0 0 0 0}
First of all finding the solution using brute force is not possible, as for an array of 501 numbers
there are 126 505 506 possible first steps.
(6x(1x501 + 2x500 + 3x499 + 4x498 +...+ 501x1) = 6x21084251 = 126505506).
There would be a lot more possibilities if we include the steps following the first one.
I noticed we can remove an element if it has the same number next to it.
So the array {0 4 6 2 2 0 3 1} becomes {0 4 6 2 0 3 1}. This should simplify the problem.
I've tried dividing the array into sections using zeros as the dividers.
So for the array {0 4 6 2 0 3 1} we could consider two separate arrays: {4 6 2} and {3 1}.
I thought I could find the answers for those arrays and add them together for the final answer.
But I discovered arrays for which this approach doesn't work.
For example, for the array {3 2 1 0 1 2 3} this approach would yield the answer 3 + 3 = 6 while it should be 4 steps:
{3 2 1 0 1 2 3} subtract 3 from the whole array
{0 6 5 4 5 6 0}subtract 6 for indexes 1 to 5
{0 0 6 5 6 0 0} subtract 6 for indexes 2 to 4
{0 0 0 6 0 0 0} subtract 6 from the middle element
{0 0 0 0 0 0 0}
Another approach I tried was looking for pairs of the same number and dividing the array accordingly.
For example the array: {0 3 1 5 3 5 6 2 1 5 1}
would divide into three arrays {3 1 5 3} and {5 6 2 1 5} and {6}.
This would allow me to shorten a sub-array by two elements in just one step:
{3 1 5 3} {5 6 2 1 5} {6} subtract from the first subarray
{0 5 2 0} {5 6 2 1 5} {6} subtract from the second subarray
{0 5 2 0} {0 1 4 3 0} {6} remove zeroes on the sides -> {5 2} {1 4 3} {6}
But I couldn't find a final solution using this approach. Also I don't know how to check whether it always would return the best answer.

Sortperm for matrix sorting in Julia lang

I am using Julia 1.6.1.
B is a matrix. For example,
B =
[ 2 4 4 4 5 ;
1 2 2 3 5 ;
1 2 3 3 3 ;
1 2 2 5 6 ;
1 3 4 4 4 ; ]
I wanted to sort it forcsing on each row.
sortedB = sortslices( B, dims=1, rev=true)
Then, we get sorted B
sortedB =
[ 2 4 4 4 5 ; # 1st row of the original matrix B
1 3 4 4 4 ; # 5th row of the original matrix B
1 2 3 3 3 ; # 3rd row of the original matrix B
1 2 2 5 6 ; # 4th row of the original matrix B
1 2 2 3 5 ;] # 2nd row of the original matrix B
I would like to get the array [1 5 3 4 2].
How can I do that ?
It seems that sortperm does not work.
sortperm( sortslices( B, dims=1, rev=true) )
# ERROR: MethodError; no method matching sortperm(::Matrix{Int64})
If performance is an issue use a non-allocating version.
julia> sortperm(view.(Ref(B), 1:size(B,1), :), rev=true)
5-element Vector{Int64}:
1
5
3
4
2
Here are some benchmarks using BenchmarkTools:
julia> #btime sortperm(view.(Ref($B), 1:size($B,1), :),rev=true);
376.471 ns (3 allocations: 432 bytes)
julia> #btime sortperm(collect(eachslice($B,dims=1)),rev=true)
642.683 ns (6 allocations: 496 bytes);
you can use eachrow or eachslice:
julia> C = collect(eachslice(B,dims=1))
5-element Vector{SubArray{Int64, 1, Matrix{Int64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}:
[2, 4, 4, 4, 5]
[1, 2, 2, 3, 5]
[1, 2, 3, 3, 3]
[1, 2, 2, 5, 6]
[1, 3, 4, 4, 4]
julia> sortperm(C,rev=true)
5-element Vector{Int64}:
1
5
3
4
2
although this will allocate more than necessary (collect is needed apparently)

How do I implement a nested for loop that converts every element in a 2D array into zeros in Clojure

I wish to implement (in Clojure) a nested for loop that converts every element in a 2D array into zero. Like the C code written below.
void set_to_zero(int n, int m[v][v]) {
int i, j;
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
m[i][j] = 0;
}
This is what I was able to do
(defn trial [n m]
(loop [i 0
j 0]
(if (= i (count (range n)))
(println m)
(if (= j (count (range n)))
(recur i j)
(assoc-in m[i j] 0)
)
)
)
)
This is what I get: i.e only one element changes and the rest stays same.
(trial 4 [[9 8 2 3][8 4 5 6][6 1 8 9][3 1 8 9]])
=> [[0 8 2 3] [8 4 5 6] [6 1 8 9] [3 1 8 9]]
Update
(defn trial [n m]
(for [i (range n)
j (range n)]
(if (> i n)
m
(if-not (> j n)
;(recur (inc i) j)
(assoc-in m[i j] 0)
;(println i j)
)
)
)
)
New result
(trial 4 [[9 8 2 3][8 4 5 6][6 1 8 9][3 1 8 9]])
=>
([[0 8 2 3] [8 4 5 6] [6 1 8 9] [3 1 8 9]]
[[9 0 2 3] [8 4 5 6] [6 1 8 9] [3 1 8 9]]
[[9 8 0 3] [8 4 5 6] [6 1 8 9] [3 1 8 9]]
[[9 8 2 0] [8 4 5 6] [6 1 8 9] [3 1 8 9]]
[[9 8 2 3] [0 4 5 6] [6 1 8 9] [3 1 8 9]]
[[9 8 2 3] [8 0 5 6] [6 1 8 9] [3 1 8 9]]
[[9 8 2 3] [8 4 0 6] [6 1 8 9] [3 1 8 9]]
[[9 8 2 3] [8 4 5 0] [6 1 8 9] [3 1 8 9]]
[[9 8 2 3] [8 4 5 6] [0 1 8 9] [3 1 8 9]]
[[9 8 2 3] [8 4 5 6] [6 0 8 9] [3 1 8 9]]
[[9 8 2 3] [8 4 5 6] [6 1 0 9] [3 1 8 9]]
[[9 8 2 3] [8 4 5 6] [6 1 8 0] [3 1 8 9]]
[[9 8 2 3] [8 4 5 6] [6 1 8 9] [0 1 8 9]]
[[9 8 2 3] [8 4 5 6] [6 1 8 9] [3 0 8 9]]
[[9 8 2 3] [8 4 5 6] [6 1 8 9] [3 1 0 9]]
[[9 8 2 3] [8 4 5 6] [6 1 8 9] [3 1 8 0]])
At the moment, it changes all the elements into 0 but does it separately would like it to return as one array with all the elements equal to zero.
P.S I am sure there are more efficient ways to achieve all zeros in a 2D vector but I'm particularly interested in the for loop method since it's popular in other languages and can help one more easily translate codes from other languages to Clojure (in some cases).
Thanks.
Since you already have the sizes of the structure (its a vector of
vectors) I think there is no need to pass in any sizes. So the one
thing to make sure is to keep the vectors (many tools in the clojure
belt use (lazy) sequences).
Using mapv does that. The function to map with can be (constantly
0). Then map that again over the outer vector. E.g.
Plain clojure:
(mapv (partial mapv (constantly 0)) [[9 8 2 3][8 4 5 6][6 1 8 9][3 1 8 9]])
; → [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]
Alternative:
Using specter:
(setval [ALL ALL] 0 [[9 8 2 3][8 4 5 6][6 1 8 9][3 1 8 9]])
; → [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]
First, you're never increasing the values of i and j. So, they never change. Thus, you never get to the recur call.
They way you phrase your question gives the impression that you think, you edit the vector in-place. You don't. With every assoc-in you're creating a new vector. (A new associative data-structure to be more precise, but regardless.) A lot of copying will happen under the hoods.
My take on this is that you'd best create a fresh data-structure from the sizes of the existing one. If the nested vectors can be of differing sizes, the code #cfrick wrote (map ... constantly) is good. If all of the nested vectors have the same size, there's a simpler alternative. Try to find it and tell us how it goes. :-)
Clojure arrays are immutable, so if you want to operate in an imperative/mutable fashion you need to use an atom. Consider the following code:
(ns tst.demo.core
(:use tupelo.core tupelo.test))
(defn new-array
[M N]
(vec (for [i (range M)]
(vec (for [j (range N)]
(* i j))))))
(defn set-array-elem
[arr i j val]
(assoc-in arr [i j] val))
(defn change-array
[arr]
(let [work (atom arr)]
(doseq [i (range (count #work))]
(doseq [j (range (count (get #work i)))]
(swap! work set-array-elem i j
(* (inc i) (+ 3 j))))) ; set it to an "interesting" value
#work))
(dotest
(let [arr1 (new-array 3 5)]
(is= arr1
[[0 0 0 0 0]
[0 1 2 3 4]
[0 2 4 6 8]])
(is= (change-array arr1)
[[3 4 5 6 7]
[6 8 10 12 14]
[9 12 15 18 21]])))
Function set-array-elem returns a modified copy of the input array. The swap! in change-array calls this function and keeps the output in the atom work, replacing the previous immutable value. Thus we slowly transition from the original array to the final result, one element at at time.
I understand this is a learning exercise. If you ever need to manipulate arrays (nested vectors), please consider using either tupelo.array or tupelo.array.mutable and save a lot of writing (& debugging!)
Clojure template project to get you started. Includes many documentation links.
Tupelo Clojure library on Github
Tupelo Array
Tupelo Array Mutable
You can build a list of 0 with repeat:
(repeat 3 0)
; (0 0 0)
You can convert that into a vector with vec:
(vec (repeat 3 0))
; [0 0 0]
You just need to replace 3 with the length of each sub vectors:
(mapv #(-> (count %) (repeat 0) vec) [[1] [2 3] [4 5 6]])
; [[0] [0 0] [0 0 0]]
So if you know what the dimensions of your array are, create a new one.
(defn make-ary [m n]
(vec (repeat m (vec (repeat n 0)))))
I guess i was using assoc-in the wrong way. Was meant to use recur to implement assoc-in. I assume that was why I got several instances of the 2D vector returned instead of one. Using recur helped do that.
Thanks #cfrick #Stefan Kamphausen #Alan Thompson for pointing me to the right direction.
(defn trial [n m]
(loop [i 0
j 0
m m
]
(if (= i n)
m
(if (= j (dec n))
(recur (inc i) 0 (assoc-in m[i j] 0))
(recur i (inc j) (assoc-in m[i j] 0))
)
)
)
)
(trial 8 [[6 1 8 8 6 1 8 8][8 4 5 6 6 1 8 8][6 1 8 8 6 1 8 8][3 1 8 9 6 1 8 8][6 1 8 8 6 1 8 8][6 1 8 8 6 1 8 8][6 1 8 8 6 1 8 8][6 1 8 8 6 1 8 8]])
[[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]]

How to compute all unique permutations and keep the same positive adjacent elements always adjacent?

I have a list or a vector V of n nonnegative integers. There are some positive integers that are equal and adjacent, say V=[2, 3, 3, 0, 0]. (I do not care about the zero integer.)
I would like to find all unique permutations of V such that all the same and positive integers remain adjacent. How to write an algorithm for this? (For an implementation, you can choose Python or Matlab or any other language.)
Under Matlab and for the example of V=[2, 3, 3, 0, 0], I get all the unique permuations as follows:
V = [2, 3, 3, 0, 0];
unique(perms([2, 3, 3, 0, 0]), 'rows')
and I get:
0 0 2 3 3
0 0 3 2 3
0 0 3 3 2
0 2 0 3 3
0 2 3 0 3
0 2 3 3 0
0 3 0 2 3
0 3 0 3 2
0 3 2 0 3
0 3 2 3 0
0 3 3 0 2
0 3 3 2 0
2 0 0 3 3
2 0 3 0 3
2 0 3 3 0
2 3 0 0 3
2 3 0 3 0
2 3 3 0 0
3 0 0 2 3
3 0 0 3 2
3 0 2 0 3
3 0 2 3 0
3 0 3 0 2
3 0 3 2 0
3 2 0 0 3
3 2 0 3 0
3 2 3 0 0
3 3 0 0 2
3 3 0 2 0
3 3 2 0 0
As you may know, I get 30 such permutations. Among these 30, there are 18 that do not respect the constraint of adjacency. For example, [3, 2, 3, 0, 0] can not be in the final result because 3 is no longer adjacent to 3. Finally, all unique permutations can be given by:
0 0 2 3 3
0 0 3 3 2
0 2 0 3 3
0 2 3 3 0
0 3 3 0 2
0 3 3 2 0
2 0 0 3 3
2 0 3 3 0
2 3 3 0 0
3 3 0 0 2
3 3 0 2 0
3 3 2 0 0
The first idea (and the simplest) that came to my mind is to generate all unique permutations like so and then, for each one, verify the constraint. But is there any other efficient algorithm?
We can first compress the given array so that there is just one entry for every positive number, while keeping a count of how many times each number occurred (the zeroes should be left as is).
Generate the permutations of the compressed array.
Decompress each of the permutation and retain only the unique ones.
To Compress
def compress(arr):
counts = {}
compressed = []
curr_ele = arr[0]
count_ele = 0
for ele in arr:
if ele != curr_ele or ele == 0:
counts[curr_ele] = count_ele
compressed.append(curr_ele)
count_ele = 1
curr_ele = ele
else:
count_ele += 1
counts[curr_ele] = count_ele
compressed.append(curr_ele)
return compressed, counts
To Uncompress
def uncompress(arr, counts):
res = []
for ele in arr:
if ele == 0:
res.append(0)
continue
num_reps = counts[ele]
for _ in range(num_reps):
res.append(ele)
return res
Putting it together: Compress, Permute, Uncompress and Retain Unique
import itertools
ip = [2, 3, 3, 0, 0]
ip_compressed, counts = compress(ip)
set([tuple(uncompress(perm, counts)) for perm in itertools.permutations(ip_compressed)])
Result:
{(0, 0, 2, 3, 3),
(0, 0, 3, 3, 2),
(0, 2, 0, 3, 3),
(0, 2, 3, 3, 0),
(0, 3, 3, 0, 2),
(0, 3, 3, 2, 0),
(2, 0, 0, 3, 3),
(2, 0, 3, 3, 0),
(2, 3, 3, 0, 0),
(3, 3, 0, 0, 2),
(3, 3, 0, 2, 0),
(3, 3, 2, 0, 0)}
A simple algorithm is:
1.traverse the initial table and make another table with two rows like:
input: V = [2, 3, 3, 0, 0];
new array: V2 = |2,3,0|
|1,2,2|
As you can see V2 comes from V keeping one time the elements and in second row counting how many times we have seen them.
Now generate all permutations of columns
And for every result e.g:
V2 = |3,2,0|
|2,1,2|
you have kept how many times the elements appear.

Go concurrent worker routines using slice type input and output channels

I am relatively new to the Go language. Even though I don't hope so, I maybe bother you with a silly question. My apologies upfront, just in case...
Here's my example: I defined a worker() function which is called from main() as a set of concurrent Go routines. Input and output data is provided via an input and an output channel both of slice type []int. In one case everything works as expected, in the other case the result is faulty. See the comments in the code and the program output below the code.
Honestly, I don't see the actual difference between both code variants. What did I miss here? Thank you for any advice!
package main
import "fmt"
import "runtime"
func worker(x_ch <-chan []int, y_ch chan<- []int, wid int) {
for x := range x_ch {
y := x
fmt.Println(" worker", wid, "x:", x)
fmt.Println(" worker", wid, "y:", y)
y_ch <- y
}
}
func main() {
n_workers := runtime.NumCPU()
n_len := 4
n_jobs := 4
x := make([]int, n_len)
x_ch := make(chan []int, 10)
y_ch := make(chan []int, 10)
for j := 0; j < n_workers; j++ { go worker(x_ch, y_ch, j) }
for k := 0; k < n_jobs; k++ {
// variant 1: works!
x = []int{k, k, k, k}
// variant 2: doesn't work!
// for i := range x { x[i] = k }
fmt.Println("main x:", k, x)
x_ch <- x
}
close(x_ch)
for i := 0; i < n_jobs; i++ {
z := <- y_ch
fmt.Println(" main y:", i, z)
}
}
Correct output (variant 1):
main x: 0 [0 0 0 0]
main x: 1 [1 1 1 1]
main x: 2 [2 2 2 2]
main x: 3 [3 3 3 3]
worker 3 x: [3 3 3 3]
worker 3 y: [3 3 3 3]
worker 2 x: [2 2 2 2]
worker 2 y: [2 2 2 2]
worker 1 x: [0 0 0 0]
worker 1 y: [0 0 0 0]
worker 0 x: [1 1 1 1]
worker 0 y: [1 1 1 1]
main y: 0 [3 3 3 3]
main y: 1 [2 2 2 2]
main y: 2 [0 0 0 0]
main y: 3 [1 1 1 1]
Wrong output (variant 2):
main x: 0 [0 0 0 0]
main x: 1 [1 1 1 1]
main x: 2 [2 2 2 2]
main x: 3 [3 3 3 3]
worker 3 x: [3 3 3 3]
worker 3 y: [3 3 3 3]
main y: 0 [3 3 3 3]
worker 0 x: [2 2 2 2]
worker 0 y: [3 3 3 3]
main y: 1 [3 3 3 3]
worker 1 x: [1 1 1 1]
worker 1 y: [3 3 3 3]
main y: 2 [3 3 3 3]
worker 2 x: [3 3 3 3]
worker 2 y: [3 3 3 3]
main y: 3 [3 3 3 3]
The difference is that in variant 1, you're sending a different slice every time, whereas in variant 2, you're sending the same slice every time (the one created above the for loops). Without creating a new slice, you're just setting the elements of the same slice to different values, so the goroutines see whatever values happen to be in the slice when they look at it. In variant 2, main will always see [3 3 3 3] because that's the final value after you've gone through the loop 4 times. The value of a slice object contains a reference to the underlying elements, not the elements themselves. There's a good explanation of slices here.
Thanks a lot for your explanation, now I see where the problem is. I added some debug code to output the pointer addresses and the result is (with slighty reformatted output):
Variant 1:
main 0 x=[0 0 0 0] &x=0x1830e180 &x[0]=0x1830e1e0
main 1 x=[1 1 1 1] &x=0x1830e180 &x[0]=0x1830e230
main 2 x=[2 2 2 2] &x=0x1830e180 &x[0]=0x1830e270
main 3 x=[3 3 3 3] &x=0x1830e180 &x[0]=0x1830e2a0
worker 3 x=[3 3 3 3] &x=0x1830e1d0 &x[0]=0x1830e2a0
worker 3 y=[3 3 3 3] &y=0x1830e2e0 &y[0]=0x1830e2a0
main 0 y=[3 3 3 3] &y=0x1830e2d0 &y[0]=0x1830e2a0
worker 0 x=[0 0 0 0] &x=0x1830e1a0 &x[0]=0x1830e1e0
worker 0 y=[0 0 0 0] &y=0x1830e370 &y[0]=0x1830e1e0
main 1 y=[0 0 0 0] &y=0x1830e360 &y[0]=0x1830e1e0
worker 1 x=[1 1 1 1] &x=0x1830e1b0 &x[0]=0x1830e230
worker 1 y=[1 1 1 1] &y=0x1830e400 &y[0]=0x1830e230
main 2 y=[1 1 1 1] &y=0x1830e3f0 &y[0]=0x1830e230
worker 2 x=[2 2 2 2] &x=0x1830e1c0 &x[0]=0x1830e270
worker 2 y=[2 2 2 2] &y=0x1830e480 &y[0]=0x1830e270
main 3 y=[2 2 2 2] &y=0x1830e470 &y[0]=0x1830e270
Variant 2:
main 0 x=[0 0 0 0] &x=0x1830e180 &x[0]=0x1830e190
main 1 x=[1 1 1 1] &x=0x1830e180 &x[0]=0x1830e190
main 2 x=[2 2 2 2] &x=0x1830e180 &x[0]=0x1830e190
main 3 x=[3 3 3 3] &x=0x1830e180 &x[0]=0x1830e190
worker 3 x=[3 3 3 3] &x=0x1830e1d0 &x[0]=0x1830e190
worker 3 y=[3 3 3 3] &y=0x1830e2a0 &y[0]=0x1830e190
main 0 y=[3 3 3 3] &y=0x1830e290 &y[0]=0x1830e190
worker 0 x=[3 3 3 3] &x=0x1830e1a0 &x[0]=0x1830e190
worker 0 y=[3 3 3 3] &y=0x1830e330 &y[0]=0x1830e190
main 1 y=[3 3 3 3] &y=0x1830e320 &y[0]=0x1830e190
worker 1 x=[3 3 3 3] &x=0x1830e1b0 &x[0]=0x1830e190
worker 1 y=[3 3 3 3] &y=0x1830e3c0 &y[0]=0x1830e190
main 2 y=[3 3 3 3] &y=0x1830e3b0 &y[0]=0x1830e190
worker 2 x=[3 3 3 3] &x=0x1830e1c0 &x[0]=0x1830e190
worker 2 y=[3 3 3 3] &y=0x1830e440 &y[0]=0x1830e190
main 3 y=[3 3 3 3] &y=0x1830e430 &y[0]=0x1830e190

Resources