Questions tagged [array]

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.

89 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
635 views

Intersection of two lists in Python

I am currently working on an algorithm, which involves finding the intersection of two lists. That is, given the following inputs [1,2,2,1],...
6
votes
0answers
273 views

Summing 2D NumPy array by multiple labels

Each element of the array is a coordinate (x, y). Each coordinate has two labels. Goal: sum the elements that have the same two labels. How can ...
6
votes
0answers
412 views

Implementing recursive filters with Haskell/Repa

I recently learned Haskell, and I am trying to apply it to the code I use in order to get a feeling for the language. I really like the Repa library since I manipulate a lot of multi-dimensional data....
4
votes
0answers
206 views

Finding where column slices of elements in multi-dimensional array are equal

Skippable Intro: I have a dataset that corresponds to an observed time-series. The dataset is organized into a dictionary - which contains an array of years, an array of months, an array of days, an ...
4
votes
0answers
100 views

Cryptocurrency forecasting app

I wrote a cryptocurrency (or any other) market forecasting application in Python 3.5. The code is getting bigger and more complex so I would love if some experts would take a look at it and check and ...
3
votes
0answers
40 views

Fixed size 2d array of objects

My Objective is to create a fixed column array object of size 4 columns so that I can form a 2d array in the following format which I can use to print to a pdf later. The solution is working fine. But ...
3
votes
1answer
70 views

Compare and Process Common and Uncommon files separately

I have the following files: STUDENT_D19001.T103412_HU.txt STUDENT_D19001.T103412_KU.txt STUDENT_D19002.T113030_HU.txt STUDENT_D19002.T115055_KU.txt STUDENT_D19003.T115055_KU.txt STUDENT_D19004....
3
votes
0answers
19 views

Speeding up a complex array function in excel

I have a complex array function that takes way too much time to calculate, which is why I'm looking for ways to make it more efficient. Basically, I have a transaction sheet in which I list all goods ...
3
votes
0answers
655 views

Alternative for VLOOKUP/Index-Match in VBA

I am sharing this function I wrote with the community to provide an alternative to slow VLOOKUP and/or Index-...
3
votes
0answers
123 views

A fixed-size dynamic array

Background I implemented the historic std::dynarray according to the specification under the name dynamic_array in C++17. ...
3
votes
2answers
61 views

I/O-TxtFile Line Distance Program

I am trying to write a lab/program that loops through a .txt input file. Reads an entire line of data as a string, then splits that string into an array delimited by a space. If there are 4 items in ...
3
votes
0answers
108 views

Substitute for `std::array::operator[]` in C++11 by using template-based recursion

What follows is a simplified version of a tentative implementation for a template-based set, named TemplateArgs. For the sake of clarity and focus on the question ...
3
votes
0answers
49 views

Scrolling 2D Tiles

update: So, this is weird, I just reinstalled Adobe Animate, and now, when I do ctrl+enter (test movie), it pulls up an AIR window, and plays my app, and it works smooth as butter! (now I'm just not ...
3
votes
0answers
38 views

Create archive webpage for newsletters based on nested array

I am creating a webpage for my newsletter archives. The archives are divided by year (currently there is only 1, but there could be many), then by topic, before listing each newsletter. There will ...
3
votes
0answers
91 views

Implementing a templated Array class

I have implemented an Array class using templates. I have used a std::allocator object for memory allocation. Will it be better to use operator new along with placement new for memory allocation? ...
3
votes
0answers
1k views

Add values to a multidimensional array of unknown depth

I have the following class: ...
3
votes
0answers
167 views

any that can hold arrays

I've tried to make a better any than before: ...
2
votes
0answers
25 views

Rotational Symmetry Indexing in a 1D “Square” Array

I managed to find a way to rotate a slice in-place (previous question on SO). The slice is linear, but represents a 2d square of elements. Is this approach efficient? Please check the previous ...
2
votes
0answers
70 views

LeetCode: House Robber II C#

https://leetcode.com/problems/house-robber-ii/ You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place ...
2
votes
0answers
178 views

LeetCode: trapping rain water C#

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. The above elevation map is represented by array [...
2
votes
0answers
49 views

Python list operation - merge adjacent cubes into minimum number of shapes

I am hoping to find a way to make the process a lot faster. The lists are made of rows of 6 numbers, i.e. [[float] * 6, ...]. The intent is to pass a list of cube ...
2
votes
0answers
66 views

Breadth-first search in Java: Competitive style - follow-up

I have improved my BFS in Java according to vnp's suggestions. Again, we wish to find shortest paths in directed unweighted graphs using BFS, competitive style (no ...
2
votes
0answers
25 views

RC4 in Sinclair BASIC; Working around one-indexed arrays

This is a program written in Sinclair BASIC (48 BASIC) for the Sinclair ZX Spectrum. It uses a hardcoded key (null right now) as seen in the bottom and outputs a stream of integers generated with RC4. ...
2
votes
0answers
593 views

Mapping nested arrays from API response

I have some selects on my html page that I want to populate with the response from my backend API. The response looks like this JSON response ...
2
votes
0answers
414 views

VBA array functions: push, pop, shift, unshift

I want to write my snake game procedurally, using as much windows call as I can so as to practice. Looking into GetAsyncKeyState to capture keyboard inputs and play sound functions. Also making a ...
2
votes
0answers
38 views

Fixed Size Resource Array with Versioned Indexes

I'm trying to implement a fixed sized array that uses versioned keys for dangling safety. This structure is similar to a slot map data structure, with the exception that this does not automatically ...
2
votes
0answers
1k views

Deepest pit of an array

Following is based on a problem description from a Codility test, as a task in an interview. DeepestPit - problem description A non-empty zero-indexed array B ...
2
votes
1answer
56 views

Monitoring navigation function: logic judgment

Write a simple monitoring navigation function. I feel logic judgment still needs to be optimized. I don't have a clear idea right now about code logic such as reducing ...
2
votes
0answers
88 views

Project Euler #81 in Haskell: minimal path sum through a matrix

I just completed Project Euler Problem 81 in Haskell: In the 5 by 5 matrix below, ...
2
votes
1answer
275 views

Longest Substring Without Repeating Characters in Scala

Question is taken from Leetcode and solution works for their test cases. I do see a scope of improvement and make it more functional (getting rid of vars and mutables data structures). Please suggest ...
2
votes
0answers
85 views

Use arrays to perform 'VLookUp' type activity between workbooks

Background I have the below UDF that opens a workbook (this workbook has extracted data from a queue within another app). I get the used range from this workbook and assign it to an array (...
2
votes
0answers
117 views

x64 Windows Assembly - Structs in Assembly

I'm trying to code a simple person database using structs and arrays in assembly. Each person has a firstName, lastName, ...
2
votes
0answers
39 views

Find target in sorted array pivoted at some unknown point in O(log n)

You are given an array sorted in ascending order which is rotated at some pivot unknown to you beforehand. Find your target in \$O(log n)\$ which means it should be a binary search. If the value ...
2
votes
0answers
187 views

Getting all unique permutations from a slice of integers slices in golang,

For a project I'm working on I have a set of number sets, and I need all unique permutations of them. I want to return only one copy of each unique number set, and I'm struggling to figure out how ...
2
votes
0answers
272 views

Drawing an ASCII grid in Ruby based on a 2D array

I'm writing a function that renders a grid using ASCII line-drawing characters, based on a provided 2D array (or array of arrays), with each top-level array representing a row, and the items inside ...
2
votes
0answers
82 views

Kaitai Struct: shift rotate >1 byte groups

This is an implementation of rotation (cyclic shift) of many-byte groups to the left. Rotate right is supported as negative amount. I would like to request, if someone would be willing, to review this ...
2
votes
0answers
37 views

Multilang sentence to N-gram

Task: Transform sentence to n-gram and remove all punctuation Tests: Input: ngram('Name, + other ~ name!', 1) Result: ['Name', 'other', 'name'] Input: ngram('Name, + other ~ name!', 2) ...
2
votes
0answers
57 views

intersection of two arrays

I have written a logic to find out the intersection of two arrays. Please review my logic and guide me if my logical approach is not correct. ...
2
votes
0answers
99 views

With 2 sets of strings, find a string that can be constructed from either set

Given the following sets of strings: are yo you u how nhoware alan arala dear de I need to find a sequence that can be constructed by concatenating the strings ...
2
votes
0answers
128 views

Spellchecker program is having issues due to vowel checking method

This program takes in a list of 275k or so words from '/usr/share/dict/words' and loads them into HashSet. It then takes in a list of 1000 words (taken from the dictionary and are scrambled (vowel ...
2
votes
0answers
841 views

Converting [UInt32] -> [UInt8] -> [[UInt8]]

I am trying to speed up my current implementation of a function that converts [UInt32] to a [UInt8] which in turn is split up ...
2
votes
0answers
106 views

One-based array in JavaScript

One day I stumbled upon a question on Stack Overflow: How do I create an array in javascript whose index starts from 1. The top answer says that it's impossible. However, that answer was posted ...
2
votes
0answers
269 views

Beginner grid-based game movement engine (PART 2)

I've tried to make the code overall more PEP-8 friendly and added more comments to make it more readable. Added some new functions and methods like ranged attack and allegiance. Play around with it. ...
2
votes
0answers
723 views

Nested loops with linear array

i have found this article on how to loop through multi-dimensional arrays quickly. http://nadeausoftware.com/articles/2012/06/c_c_tip_how_loop_through_multi_dimensional_arrays_quickly I am using ...
2
votes
0answers
359 views

Cluster arrays according to similarity of key values

The below script will compare a set of arrays according to similarities between their key's values. For example, if the first 4 keys values of an array are equal to another array's first 4 keys values,...
2
votes
0answers
50 views

leftMerge function to deep overlay saved state

This code is used to deep overlay saved state (as an object) over a template object, which is the current model, this model can change (e.g have new attributes added), and a simple _.clone call will ...
2
votes
0answers
46 views

Complete date ranges for two years

I have array contents with some date ranges, fetched from the database: ...
2
votes
0answers
402 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. ...
2
votes
1answer
347 views

Nested loop to transform MongoDB results

I have the following structure returned from MongoDB: ...
1
vote
0answers
15 views

LeetCode: Search a 2D Matrix C#

https://leetcode.com/problems/search-a-2d-matrix/ Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row ...