Questions tagged [array-difference]

Used for questions concerning the difference between arrays. For example, where elements in two arrays differ from each other, or subtracting the content of one array from another. Since the tag can be broadly applied to any programming language that supports arrays, use use one or more additional tags in order to help identify the specific language the question relates.

An array is a data structure that encompasses a group of elements. When working with arrays there can be a requirement to determine the difference between two or more arrays, and this tag is for questions relating specifically to finding that difference.

The difference between arrays can be determined in a number of ways, including finding where elements within the array differ, and can include operations such as subtracting the contents of one array from another to produce an outcome.

273 questions
1
vote
1 answer

Temperature array difference for MetPy

I'm trying to use a metpy script to make Skew-T diagram. My source data uses the Dew Point Depression (dewpt) parameter and the original script uses the Dew Point (Td) parameter. Knowing the Temperature (T), I should change the script for Dew Point…
Marina
  • 13
  • 3
1
vote
1 answer

DolphinDB: How to calculate the difference between two rows in a table?

I have a table containing the four columns “order_book_id”, “date”, “Q”, and “revenue”. I want to perform the following operations: Group the table by “order_book_id” and “date”. Verify if the values of column "Q" are equal to 1 within each group…
Smalllpotato
  • 241
  • 4
1
vote
4 answers

PHP - how to compare value of arrays in dynamic way?

Ok, I have following 'challange'; I have array like this: Array ( [0] => Array ( [id] => 9 [status] => 0 ) [1] => Array ( [id] => 10 [status] => 1 ) [2] =>…
Smilie
  • 13
  • 1
  • 5
1
vote
1 answer

How to calculate the differences between the adjacent elements from two vectors?

I want to calculate the differences between of the Nth value of the vector X and the N-1th value of the vector Y. All I know is the function delta, but it can only work within one vector. Does anyone know a better method? Thanks in advance.
1
vote
0 answers

RangeError: Potential infinite loop: exceeded 1500 iterations

Hi all I need to return the minimum possible absolute difference. My code is below, function minAbsDiff(nums) { const n = nums.length; const sum = nums.reduce((acc, val) => acc + val); const halfSum = Math.floor(sum / 2); const dp =…
1
vote
1 answer

Find missing elements from array based on another (keys not values)

I need to test an array to make sure it has all elements I am expecing. The twist here is that we are talking about multidimensional arrays. Here is an example: $required_data = [ 'firstname', 'lastname', 'shipping' => [ …
user1274113
  • 436
  • 8
  • 21
1
vote
3 answers

find out if object in two arrays of objects is unique

Compare two array of objects to find distinct values by all key values So I found a lot of documentation like Get unique values by comparing old and new array objects but my case is a bit more complex. In my case I want to compare two databases of…
1
vote
1 answer

How do I get the difference between two FIFO array states?

I have two arrays that represent a fifo-like state, an old state and a new state. I need a function that finds the newly added items by comparing the new array with the old one. Below 3 examples of two arrays where 1 has items added to the front of…
1
vote
1 answer

Swift's Array conformance to Collection

Given two arrays of RandomModelObject that conform to Codable, Equatable and Hashable I want to calculate a diff between them and animate content changes in a UICollectionView. Having to support iOS 11 made me pick…
mgapinski
  • 483
  • 2
  • 7
1
vote
1 answer

Calculate the difference of every registered value and the average of every 5th registered value with VBA

I continuously need to evaluate sets of raw data (1-1000 rows, 3 columns) in 5-15 sheets every time. For two of the columns I have written a code that helps me take the average of every 5th value (every 5th row) adjusted to the number of rows by a…
MatRyt
  • 13
  • 2
1
vote
3 answers

Kotlin check if two lists are the same apart from one list having an additional element?

So I have list A and list B. A is of size n and B is of size n + 1. I need to know if all elements in A are the same as all elements in B.sublist(0, n - 1). A: [5,7,2,9] B: [5,7,2,9,1] true A: [5,7,2,9] B: [5,7,2,9,9] true A: [7,5,2,9] B:…
nicoqueijo
  • 872
  • 2
  • 11
  • 28
1
vote
2 answers

how to compare the values of 2 arrays with each other in php and output the differences

I have 2 arrays with each 10 values. print_r of var $correct answers gives me this output: Array ( [0] => 3 [1] => 0 [2] => 2 [3] => 3 [4] => 2 [5] => 2 [6] => 3 [7] => 1 [8] => 3 [9] => 1 ) print_r of var $choosen_answers gives me this…
john
  • 1,263
  • 5
  • 18
1
vote
1 answer

TapeEquilibrium task from Codility, failing to pass 100% tests, performance and correctness (76% total score)

Sorry if I wrote too much. I tried to be very detailed so I could find my own answer while describing the problem (the solution, and how I got there), and yet ,if I didn't, not leaving doubts to the reader. I don't want the problem to be solved by…
newbie
  • 1,199
  • 1
  • 10
  • 25
1
vote
4 answers

Find the difference from a multi-dimencional array to a normal array in php

I have 2 arrays one contains just a list of email address and the other contains emails and names. The list of emails in array1 are stored in a database and the other array is a list of new and current users. I have tried using array_diff however…
Fazberry
  • 117
  • 8
1
vote
1 answer

trying some customize array difference like approach in PHP

$a = ["a","b","c","a","b"]; $b = ["a","c"]; array_diff($a,$b); //output will be [b,b] but that is not a proper difference it can also be //output [b,a,b] <- this is what I am trying to achieve I tried foreach loop and for loop but failed to get…
Sayed Mohd Ali
  • 2,156
  • 3
  • 12
  • 28