Answers for "change 1d array to 2d array python"

C++
1

convert 2d list to 1d python

import itertools

a = [[1, 2], [3, 4], [5, 6]]
list(itertools.chain.from_iterable(a))

Output:- [1, 2, 3, 4, 5, 6]
Posted by: Guest on August-27-2021
1

array 2d to 1d

int array[width * height];

 int SetElement(int row, int col, int value)
 {
    array[width * row + col] = value;  
 }
Posted by: Guest on January-28-2020

Browse Popular Code Answers by Language