How do you rotate a two dimensional array?

Inspired by Raymond Chen's post, say you have a 4x4 two dimensional array, write a function that rotates it 90 degrees. Raymond links to a solution in pseudo code, but I'd like to see some real...

What are the differences between a multidimensional array and an array of arrays in C#?

What are the differences between multidimensional arrays double[,] and array-of-arrays double[][] in C#? If there is a difference, what is the best use for each one?

How to initialize a two-dimensional array in Python?

I'm beginning python and I'm trying to use a two-dimensional list, that I initially fill up with the same variable in every place. I came up with this: def initialize_twodlist(foo): twod_list...

How do I search for a number in a 2d array sorted left to right and top to bottom?

I was recently given this interview question and I'm curious what a good solution to it would be. Say I'm given a 2d array where all the numbers in the array are in increasing order from left to...

How to Sort a Multi-dimensional Array by Value

How can I sort this array by the value of the "order" key? Even though the values are currently sequential, they will not always be. Array ( [0] => Array ( [hashtag] =>...

How to write a multidimensional array to a text file?

In another question, other users offered some help if I could supply the array I was having trouble with. However, I even fail at a basic I/O task, such as writing an array to a file. Can anyone...

How do I copy a 2 Dimensional array in Java?

I need to make a copy of a fairly large 2 dimensional array for a project I am working on. I have two 2D arrays: int[][]current; int[][]old; I also have two methods to do the copying. I need to...

What is wrong with my park_car function?

I'm again doing a task for school and I'm implementing it slowly, I don't know why my park_car function is not working, I just wanted to make a test and the program crashes ... here is my...

Segmentation fault due to large 2D array in C++ structure

I am trying to fix a Segmentation Fault error that occurs when I am running a C++ program which is caused by a structure I am calling to be too large. I am looking for a way to use my...

Retrieving GET and POST data inside Laravel controller

I've been searching the web for how to get POST data inside the controller, so far I have found two solutions: Input::get() and $_POST. The comment for Input::get() reads: /** * Gets a...

C++ 2D array to 1D array

I am attempting to convert a 2D array to 1D. I'm extremely new to C/C++ but I think it's very important to learn how to convert a 2D array to 1D. So here I am stumbling upon this problem. My code...

Dynamic multidimensional array on the heap

I want to create a function which can allocate a multidimensional array on the heap with only one call to malloc. (Pointer array) So a function call would look like this: size_t dim[2] = {2,...

Cannot access element of 2d heap vector using operator[]

I have a 2d vector that needs to be allocated on the heap and am using the below line of code to declare and size it. vector<vector<double>> *myArray = new vector<vector<double>>(x,...

Convert matlab.double array to python array

I am using the matlab python engine to access data from my matlab projects in python. This works quite well, but I do have a problem to efficiently use the matlab arrays in python. For example I...

Convert 1d array to 2d in php

I have a 1d array as follows: $arr = [ 'itemName0' => "first Item", 'itemDesc0' => "first item's description", 'itemName1' => "second item", 'itemDesc1' => "third item's...

PHP foreach loop accessing different parts of multidimensional array

I am still trying to understand how the php foreach loop works with accessing certain parts of it. I have an array setup like this: $product = Array ( [SX- Light weight] => Array ( ...

How can I check if a multidimensional array has a value and its index?

I have a multidimensional array: string[,] array = new string[,] { {"cat", "dog", "plane"}, {"bird", "fish", "elephant"}, }; And I want to identify if it contains a value, and if so, I...

Javascript Map Array Last Item

I have this: map = ranks.map((row, r) => ( row.map((rank, i) => { return [element(r, i, state, rank, toggled, onClick)]; }) )); It maps through a 2-dimentional array. After each row, I'd...

Sort Multidimensional Array in VB.NET

I have a 2X50 array like this- R-125212,11 C-254645,25 R-456598,96 M-456878,35 O-980857,89 And so on... Now I want to sort this array with the values of the 2nd Column. So the output should look...

Can memmap pandas series. What about a dataframe?

It seems that I can memmap the underlying data for a python series by creating a mmap'd ndarray and using it to initialize the Series. def assert_readonly(iloc): try: ...

Minizinc: Initialize each row of 2d array with 1d array

I would like to split the initialization of a large input array into smaller chunks (just for readability). I tried this: array[1..3,1..2] of int: arr; % This works: % arr = array2d(1..3,1..2,...

F# Printing out a 2D String Array

I'm currently working on a board game called Neutron. let boardArray = array2D [ ["*"; "*"; "*"; "*"; "*"; "*"; "*"; "*"; "*"; "*"; "*"]; ["*"; "1"; "*"; "2"; "*"; "3";...

Creating multidimensional array on the heap

After some experiments I've come up with these four ways of creating multidimensional array on the heap (1 and 2 is kinda the same except that the result for 1 I wanted reference): #include...

How to compute new variable from existing variables in xarray?

I have data that consists of measurements of several variables over time for multiple subjects. It's in a 3d xarray.DataArray where the first dimension indexes subjects, the second dimension...

Handling Multidimensional Arrays in Numpy

I've coordinates as groups. All group must be stored as seperated. First I stored them list in list in list like this: PointOne: numpy.array([x, y, z]) GroupOne: numpy.array([PointOne, PointTwo...

How to remove all specific keys from an associative array PHP

I have to unset all 'priority' keys and values from an associative array like the one below. Couldn't find yet a solution to do this. Which do you think is the best method to remove a specific...

Writing a chunk of MPI distributed data via hdf5 in fortran

I have a 3d array distributed into different MPI processes: real :: DATA(i1:i2, j1:j2, k1:k2) where i1, i2, ... are different for each MPI process, but the MPI grid is cartesian. For simplicity...

Generalize hourglass movement in 2D Array - DS in Python

While working through this HackerRank challenge to prepare for interviews, stumbled across a blocker. Basically want to create a function hourglassSum that should return an integer (the maximum...

How to make multi-level (nested) categories in Strapi?

How do I correctly build a nested list of categories so I could use it in frontend with <select> box element ? Collection Type "Categories" have following...

How I can sort two dimensional array's columns?

Helle everyone I want sort two dimensional array's columns.I want to take the dimensions and elements of the array from the user and display it as a matrix. Then subtract the sorted form of the...