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.

Filter by
Sorted by
Tagged with
-2
votes
0answers
14 views

Extract from Array only word [closed]

Hello i have an array: ...
-4
votes
1answer
73 views

Get surrounding neighbours of a 2D array [closed]

...
2
votes
2answers
66 views

Keeping only every nth element in an array in JavaScript

I have two arrays, arr_of_frequencies and float_array, of the same length — around 500-800k values each. I have to get that down ...
4
votes
2answers
67 views

File naming (two files cannot have equal names)

This is a challenge I completed at CodeSignal. You are given an array of desired filenames in the order of their creation. Since two files cannot have equal names, the one which comes later will have ...
3
votes
1answer
62 views

Java i/o speed less than python i/o while printing an array

Motivation: I was solving an array based i/o problem and encountered Time Limit Errors, it was later found that the code for java ran roughly 10x slower than the ...
1
vote
2answers
63 views

Each item of the array must loop and show message for some time (duration) and repeat msg each value of delay

Is there a better way to loop item of an array using forEach and make repeat it using setTimout/...
10
votes
4answers
1k views
4
votes
2answers
161 views

Linux backup script written in bash for tar

This is my first attempt at scripting with bash. I am running Ubuntu server, so I don't get to use all the gui back ups out there. Besides, tar works fine for personal use. Please let me know of any ...
3
votes
1answer
47 views

Haskell implementation of Needleman-Wunsch

The code below is a Haskell implementation of Needleman-Wunsch algorithm for sequence alignment (and string edit distance). It's an experiment in trying to closely imitate the dynamic programming ...
0
votes
0answers
14 views

Pulling data from an API and working with it in Google Sheets

I'm trying to build out some DeFi position tracking pages in Google Sheets. I want to pull from the Zapper API (or other APIs) to track trades, positions, gains, losses, fees...etc. This is my first ...
1
vote
1answer
50 views

Sports DataSheet

This program asks the user for a players name, # of goals, saves, games played, etc. This information is ten organized on a .txt file along with the time the information was logged. users can also ...
4
votes
1answer
78 views

Dataframe transformation to numpy ndarray takes ages to complete

I would like to transform my dataframe into an array of fixed-sized chunks from each unique segment. Specifically, I would like to transform the ...
0
votes
2answers
63 views

Simplifying the array of objects with comma separated values

Looking a way to reduce the below code to get comma separated values from the list of arrays By using ECMA or plain old vanilla JS. How should we achieve this? Actual Array Data: ...
2
votes
2answers
95 views

Java Simple Phonebook

This Program is a simple phonebook, user is given 3 choice, add a number to the phone book, dial a number or exit the program. Are there Any Improvements that i can make, either efficient or cleaning ...
1
vote
1answer
63 views

Gather all IP addresses of a host as a vector

I have the following working code to get IPv4/v6 addresses from host names: ...
3
votes
3answers
55 views

PHP Sort Associative Array first by relativity of value then by other value desc

I am trying to sort an associative array by following this scheme: Sort by 'qt': positives first, non-positives after. Magnitude does not matter, only sign. In positive part: sort by sa DESC In ...
4
votes
1answer
57 views

Finding number of possible arrangements of books on a shelf with a Monte-Carlo approach

The Problem I am trying to determine numerically how many possible ways a number of books can be arranged on a shelf. Specifically, there are x3 categories "physics", "sci-fi", and ...
2
votes
1answer
64 views

Generating a performance report for clans in Clash Royale

The following code generates a report showing performance of clan members in a game called Clash Royale. Everything is pretty self-explanatory, we are working with a lot of https requests, arrays and ...
1
vote
1answer
61 views

Go Lang custom convert array into string with two separators

This is my custom function to join strings from an array into one string. We can provide normal separator and the last one. ...
5
votes
3answers
961 views

Separating the even and odd numbers in an array in C

I wrote a working program in C that takes an array with size 2ⁿ, and separates all the even numbers from the odd numbers. For example: Input: {1,2,3,4,5,6,7,8}, Output: {8,2,6,4,5,3,7,1} I want my ...
6
votes
2answers
148 views

Usage of Factory pattern for maintaing bookshelf having books, magazine and notes

I have tried to achieve the following task using Factory Pattern with php-7.0. Define the classes and their methods (including parameters and return types) for a system that consist of a bookshelf, ...
0
votes
1answer
50 views

Fill missing dates into array of np.datetime

Here is the problem: Given an array of a non-continuous sequence of dates. Make it a continuous sequence of dates, by filling in the missing dates. ...
-3
votes
1answer
42 views

Form a flat indexed array from a multidimensional result set [closed]

I want make my looped data into one flat array without associative keys. I have solved it with my code, but I think it is so crowded and not simple. This my code: ...
3
votes
3answers
68 views

C string parser criticism

I have written a program to parse a string depending on the string the user provides. Any advise/criticism is appreciated. ...
2
votes
2answers
60 views

Finding distance between vectors of matrices

So here is the problem: Given 2D numpy arrays 'a' and 'b' of sizes n×m and k×m respectively and one natural number 'p'. You need to find the distance(Euclidean) of the rows of the matrices 'a' and ...
0
votes
2answers
49 views

Functional Programming Style in Javascript Picking a Random Item from an Array

I'm trying to understand the Functional Programming Paradigm (or style) implemented with Javascript. There are a few things I have difficulties with. The naming conventions, and dependency injections. ...
-1
votes
1answer
52 views

Scanning multiple strings in one line to a pointers array in C [closed]

I'm trying to write a code for a function that takes an empty array of pointers and its length n. And scans n strings of max length of MAX_LEN (a defined constant) until a new line is given by the ...
6
votes
3answers
567 views

Marking duplicate entries in a numpy array as True

So the problem is Find the duplicate entries (2nd occurrence onwards) in the given numpy array and mark them as True. First time occurrences should be False. And my solution is: ...
2
votes
2answers
39 views

Combine data from array of objects

I got this data structure and I am checking to see which properties are true, then I am adding the key for all the properties that are true to that object on a new ...
2
votes
1answer
37 views

Dynamic generic array list implementation in C99

As an exercise to get to know C a bit more, I decided to implement a dynamic array implementation in C99 with generic support. Everything is implemented with series of macros. The array_list struct ...
0
votes
1answer
36 views

extents_to_array and array_to_extents functions for Boost.MultiArray in C++

This is a follow-up question for A get_extents helper function for Boost.MultiArray in C++. In order to retrieve, manipulate and calculate size information in each dimension from Boost.MultiArray in ...
1
vote
2answers
53 views

PHP strpos() as a way to implement an swear word filter

I wrote a short function that should check if user input does contain any bad words that I predefined inside $bad_words array. I don't even care to replace them - I ...
4
votes
2answers
72 views

Creating nxm index list of array a

Here is the problem: Given a numpy array 'a' that contains n elements, denote by b the set of its unique values ​​in ascending order, denote by m the size of array b. You need to create a numpy array ...
0
votes
1answer
25 views

Create a two dimensional int array and find the smallest and biggest member along with the indexes

From a CS Diploma course question set: Create a two dimensional array of ints, fill it with any random integers. Now find the minimum and maximum number, also find the index of those numbers. I was ...
1
vote
1answer
35 views

dynarr - yet another simple C dynamic array library

I wrote my own dynamic array library for C as I was not happy with the others I found. It is very crude but the basic logic should be correct, it mainly revolves making ...
3
votes
0answers
68 views

Quicksort using Lomuto partition scheme in C

This is my implementation of the divide-and-conquer Quicksort algorithm using the Lomuto partition scheme in C. This is part of a personal project and I'm following Linus Torvalds's coding style. <...
0
votes
1answer
98 views

Array member set its own index in the array

I'm writing a code where a class member, if != -1, set its own position at array. If the value is == -1, the next free index (whose range is 0 too array's length) is used. In this review, I'm more ...
2
votes
1answer
82 views

Parsing glider data from IGC files

I have to do a program in PHP that reads IGC files like this IGC file and gets records about the glider. For now I came up with something like this: ...
3
votes
1answer
230 views

Count the number of distinct subarrays

I want to determine the number of distinct subarrays that can form having at most a given number of odd elements. Two subarrays are distinct if they differ at even one position. The subarray is a ...
2
votes
1answer
60 views

Molybdenum2019 challenge efficient implementation

I'm working on a solution that is correct but inefficient. https://app.codility.com/programmers/task/leader_slice_inc/ This is my code : ...
6
votes
2answers
123 views

Another dynamic array implementation in C

I saw quite a few posts about making a dynamic array so I tried making my own for learning purposes. Here it is: ...
0
votes
0answers
72 views

C ArrayList implementation criticism

I have written a ArrayList class in C and I just wanted some criticism on what I can improve on. Any criticism helps, and I was wondering If there is any better way of doing error handling other than ...
0
votes
1answer
64 views

Exists Method Implementation for Multidimensional Array in C#

To determine whether the specified array contains specific element or not, Array.Exists can be used if the given array is one dimensional. I am attempting to implement ...
3
votes
1answer
43 views

Generating multiple new arrays using numpy

Say I have the following two different states: state1 = [0, 1, 0, 1, 1] state2 = [1, 1, 0, 0, 1] And I want to generate n number of new states by only changing the ...
0
votes
1answer
58 views

Markdown table strings to two dimensional array converter implementation in C#

I am attempting to implement a converter which can convert List<string> type markdown table into two dimensional array ...
1
vote
1answer
154 views

Insert an array[4] to an array[8] (C++, SSE)

I have this code to get audio output levels in dB to an array (peak_dB[8]) to be used in real time peakmeter: ...
0
votes
0answers
25 views

Boost.MultiArray Based Two Dimensional Array to Markdown Table Converter Implementation in C++

I am attempting to implement a converter which can convert two dimensional array (using Boost.MultiArray library) into markdown table. The experimental implementation ...
1
vote
2answers
84 views

Recursively find data in array of objects

On this script I look up properties in an array of objects. There is an original array of strings list to get the objects that match the ...
3
votes
1answer
84 views

Smart/Dynamic array in C

I attempted to make a smart/dynamic array implementation in C which is supposed to be a hybrid between a C++ vector/stack/queue. This is what i came up with: Header (smart_array.h): ...
2
votes
1answer
169 views

Two Dimensional Array to Markdown Table Converter Implementation in C#

I am attempting to implement a converter which can convert two dimensional array (such as string[,]) into markdown table. The experimental implementation The ...

1
2 3 4 5
39