An array is an ordered data structure consisting of a collection of elements (values or variables), each identified by one (single dimensional array, or vector) or multiple indexes.

learn more… | top users | synonyms

0
votes
0answers
10 views

Create array from SQL queries

I have been working on this for a while and have finally made things work how I want them to work. I realise that my code is super inefficient and this is showing by the really long time it takes to ...
0
votes
0answers
30 views

Reading, processing, writing a text file in C

The processing is the following: The program first will open a text file caled xxx_big.txt (see The text file) The program will create an array with the size of N and will put all the values from ...
0
votes
0answers
10 views

sorting an array using php [on hold]

I have a php array $data which contains a list of files ...
1
vote
4answers
129 views

Reversing a string in place without using iteration in C

This is function for reversing a string in C using recursive calls: ...
1
vote
2answers
49 views

Combining two arrays using nested foreach loops

I have the following arrays: ...
13
votes
7answers
1k views

Determining whether two scrambled strings are equivalent

I was able to complete the problem doing it in this manner, but I would assume there has to be an easier way. Sample input: abc, cba Output: ...
0
votes
0answers
19 views

Im having trouble creating this yahtzee game in java [closed]

Basically i have to create the yahtzee game with the methods like 4 of kind 3 of kind, small straight, large straight, etc. Im having trouble figuring out a way to check if the dice rolled fit in any ...
3
votes
2answers
179 views

Get missing sequential numbers from array

I have an array like Original = {1, 2, 3, 6, 7, 8, 9, 10, 12}. After removing some elements like Delete = {6, 7} from it, I want ...
5
votes
1answer
82 views

Building navigation structure for multiple users by adding values to multiple arrays at once

I have a multidimensional array with associative values... I want to add some information to multiple arrays at the same time. Doing $array1=$array2=array(... seems ...
1
vote
1answer
42 views

Concatenating 2 array variable names to create a new variable name

I'm developing a room booking system using PHP for a school project. I'm trying to create a variable name by concatenating values from two arrays together. here are the two arrays: ...
11
votes
3answers
398 views

Random permutation of int[] and ArrayList<Integer>

I wrote a simple program using int[] and ArrayList<Integer> which aims to get a random permutation output between 1 to 10, ...
4
votes
3answers
294 views

Checking two arrays for matches

Is there a better way to do this? ...
1
vote
0answers
59 views

Filling a cumulative array in Swift

I have a "cumulative" lookup array for a custom collection view layout. The idea is that I have an array of rectangles, each with an index. The index is not unique, and is monotonically increasing. ...
-1
votes
3answers
101 views

Dijkstra in C++ to find shortest path for every vertex of a directed graph

I am trying to implement the Dijkstra algorithm in c++ that finds the shortest path for a graph from a text file. The text file contains a matrix that represents a directed graph. What I am trying ...
4
votes
2answers
116 views

Counting the longest increasing subsequence in an array of integers

This is my finished function to find the length of the longest consecutive subsequence of an input array of integers. It's for an assessment so things like the numerical method used and the format of ...
0
votes
2answers
43 views

Simple print function, passing in various arrays [closed]

I wanted to create a print method that could take in a given array and print it. I can only seem to make the print function specific to my specific array. My print function only can print 1 array, but ...
0
votes
1answer
50 views

More elegant array multiplication than multiple concat statements

Background Trevor wishes to duplicate an array, transforming it by multiplying its elements four times. Existing Solution ...
1
vote
1answer
41 views

Create an Array with n values that is able to use Array methods instantly

As it is impossible to use Array methods on new Array(n), e.g. new Array(5).map(/* [some callback] */), I deviced a pseudo ...
3
votes
1answer
40 views

Comparing two implementations of smoosh()

In this question, the suggested solution for smoosh() is as shown below, ...
6
votes
1answer
63 views

Returning multiplied matrix array

Is there a more clever way of writing this piece of code? It does work but I thought there might be a better way of returning a matrix from multiplying the parameter by itself. ...
3
votes
1answer
30 views

Generating a complicated data structure in a more efficient manner

I need to convert some CSV data into a format recognizable by some old script my work uses. Changing the format is pretty much out of the question. So I've written this: ...
3
votes
1answer
56 views

Traversing a tile-based 2D-array map using keyboard controls

I've produced the beginnings of an RPG-style game using HTML5 and canvas. So far you can use the keyboard controls WASD to move an avatar around a simple tile-based map. The map is constructed of ...
6
votes
4answers
233 views

Optimizing smoosh() method further

Part I of this question says: Fill in the smoosh() method in the Homework3 class so that it performs as indicated in the ...
2
votes
0answers
53 views

Sorting an array to match the order of values of another array

I'm running hundreds of curl operations in parallel to my own API, the response array that I get is out of order ( the reason being that the first one to finish gets added to the response array ...
4
votes
1answer
109 views

Using array values to create variables, if statements and highchart dataset

I am trying to make my script maintenance-free by replacing some "static" variables and labels with dynamic ones. The main function of my code is to extract data from a SharePoint-list which contains ...
13
votes
4answers
410 views

Array alive/dead entity “refresh” algorithm

I have an Entity class that can be either dead or alive. I store entities contiguously in a resizable array. During an ...
2
votes
2answers
152 views

Function that takes an array of integers and returns that array rotated by N positions

Example: if \$N=2\$, given the input array \${[1, 2, 3, 4, 5, 6]}\$ the function should return \${[5, 6, 1, 2, 3, 4]}\$ Here is my code: ...
3
votes
2answers
81 views

Making this arraycopy more efficient

I'd like to find out how I can make my function more efficient: ...
3
votes
1answer
34 views

Loop through products and return first product that matches criteria

I am writing a function which loops through an array of products. The function needs to return: the ID of the first product that has an image and is ...
6
votes
4answers
222 views

Simple resizable array

In some (lower-level) parts of my codebase I often have the need to allocate resizable array storage for certain objects, that usually are not default-constructible. I created a simple class using ...
5
votes
1answer
34 views

Concurrently Iterable Poor Array List

As I wrote on SO, I need an ArrayList-like structure allowing just the following operations get(int index) add(E element) ...
9
votes
1answer
105 views
+50

Passing a 1D array (single column of a Range object) to .NET to manipulate it without loops and returning it back to VBA

Background Kind of a follow up - slightly related to my other SO question. I thought that if somehow I find a way in VBA to pass a single column to .NET and convert it to a native .NET type then I ...
3
votes
2answers
261 views

Squaring numbers in an array

I want to know if there is a better way to square numbers in an array. This is what I wrote: ...
6
votes
3answers
279 views

Copying one array to the end of another array

I wrote a program that places values in one array to the end of another array. It keeps the order of the values. If the second array is bigger, then there will be leading zeroes. Is there anything I ...
2
votes
3answers
91 views
2
votes
1answer
92 views

Calculate percentage of values in an array with a certain condition

I had to write a function that calculates the percentage of values in table less or equal to 2. Is my code right or is there anything missing? ...
6
votes
3answers
141 views

Byte swapping functions

I recently programmed some byte swapping functions. As a special I did a function which can convert an entire int array. I please you to look at the following aspects: portability performance ...
4
votes
3answers
138 views

Implementing an ArrayList

I implemented ArrayList functionality in C as follows: ...
2
votes
2answers
78 views

Extracting maximum values from each of the subsets of an array

Problem description: I have a numpy array cps from which I want to extract the maximum value in each of the subsets of the array (a subset is defined as non-zero ...
-1
votes
1answer
68 views

ArrayList implementation in C [closed]

Although I know I can use calloc then realloc to make a dynamic array in C, and that I also need a variable to keep track of the ...
5
votes
1answer
74 views

Efficiently displaying elements in an array

I wrote the below method to list out the elements of an array, as well as adding the Oxford comma to the list if desired. However, my for-loop looks, perhaps, a little convoluted. Is there a better ...
4
votes
4answers
379 views

Array Implementation of Queue

I've implemented the queue data structures using array in java. Anything I need to change in my code? Queue.java ...
4
votes
2answers
204 views

Printing element combinations that make a neutral compound

An array is given with the element name and their respective pH values. Print the combination of 2 elements which make a neutral compound Here is the solution that I came up with but uses a ...
5
votes
1answer
242 views

Shortening jQuery array

In short, the code picks up to 9 different ids from li in jailplayer. If a hillside, it ...
3
votes
0answers
37 views

Simplifying the building of an adjacency array starting from a flat structure

Purpose: to make an adjacency PHP array with parent_id, name, level and ...
14
votes
3answers
987 views

Project Euler #1 in PHP

The code below works & as far as I can tell the result is correct. Would you please review and let me know what I could have done better? I tried to use variables as much as possible, that way it ...
4
votes
1answer
53 views

Bernoulli trials using a condition in a vectorized operation

I was wondering how to vectorize the following code instead of using the for-loop and still be able to check for a condition. ...
7
votes
1answer
62 views

Merging lines of an array

I've got an array like this, which is a result from a Google analytics request. I asked for the amount of visits for the last three months. ...
5
votes
1answer
62 views

Optimizing a loop for catalogue manipulation

I have a catalogue of 56000 objects and I want to replace some columns with new values for instance replace NaN with -99 and ...
5
votes
2answers
52 views

Select grand child in array knockout

I'm trying to select a grand child from an array in an array. If it was C# I would have wrote something like below ...