337 questions
3
votes
2
answers
725
views
Why doesn't array_diff() work straight away with an array of enums, whereas in_array() or array_udiff() do?
Using PHP 8.4, given the following functions:
function test_array_diff($all, $filtered)
{
return array_diff($all, $filtered);
}
function test_array_udiff($all, $filtered)
{
return array_udiff(...
1
vote
0
answers
69
views
Difference of sets and read access violation
I'm trying to find a difference of sets (I use vectors but idea is the same: arr1 \ arr2) using inline assembly in VS. But I can't get rid of the following error: "An exception was thrown: read ...
0
votes
1
answer
125
views
Why these 2 codes don't give similar output?
The difference is in 4th line for both code(given below).
In 1st one, I declared some variable and then initialized the array.
In 2nd one, I initialized the array first and then declared the variables....
1
vote
1
answer
90
views
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 ...
-4
votes
1
answer
114
views
Remove elements from a flat array if found in a column of an array of objects
I have a one-dimensional array of values in one array and I need to filter it by a particular property/column in an array of objects.
My input arrays are populated by the following code:
$array_one = ...
1
vote
1
answer
632
views
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 ...
0
votes
1
answer
307
views
Compare two arrays of json object in painless
Trying to compare 2 arrays that contains json objects in painless (elastic)
A: [{"key":"a1"},{"key":"a2"},{"key":"a3"},{"key":&...
2
votes
1
answer
354
views
Array Difference Helpers on Laravel 9
I want to get the difference between the two arrays in my controller. If I use array_diff() function, it gives me an error array_diff(): Argument #1 ($array) must be of type array, Illuminate\Support\...
0
votes
1
answer
77
views
How to get incremental changes between two arrays?
I have a list of items in array, and the number of items are many(more than 100s).
The items in array are updated by user interactions(add, remove, update).
What I want to do is to find incremental ...
3
votes
2
answers
139
views
How to compare 2 Ordered Dictionaries and create a new Ordered one with differences? (Python 3.7)
I'm struggling on how to generate a "Differences" Ordered-Dictionary containing the Different and also New values appearing on a "Modified" Ordered-Dictionary after comparing with ...
0
votes
2
answers
62
views
Get differences between two flat arrays and merge with duplicated values in one array
I have two strings and I need to compare the words of the each sentence.
The strings are this two:
$correctSentence = "The year stations are summer, winter, spring and fall.";
$textSentence ...
0
votes
1
answer
154
views
Show same and different elements between two char vectors
I'm new to C++ programming. I want to make a code that shows elements which two char vectors have and do not have in common.
I started by creating two string by cin and then pass them to vectors. But ...
1
vote
1
answer
52
views
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',
...
1
vote
3
answers
2k
views
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....
0
votes
1
answer
251
views
Getting unique elements and intersection of two (or x) lists efficiently
If I have two (or more) lists, I would like to get all parts of the "venn diagram" made by those lists: i.e. elements unique to A, elements unique to B, and the intersection of A and B.
The &...
0
votes
0
answers
21
views
Comparing Array data [PHP] [duplicate]
In a question form, there is a checkbox for the options of the question. I use the checkboxes as the question has more than one correct answer. When POSTing this form information. (via JSON)
Sample:
{&...
0
votes
2
answers
176
views
Convert an object to an array and remove its default values
I have this class :
class MyObject{
var $title = null;
var $description = null;
var $items = [];
var $metas = [];
var $image = null;
var $country = 'Belgium';
}
And this data :
$data = ...
0
votes
1
answer
250
views
array_diff dont work correctly. How to solve this issue? [duplicate]
Hey i have the following code:
<html>
<table>
<table>
<thead align="left" style="display: table-header-group">
<tr>
<th>Projektnummer ...
0
votes
3
answers
309
views
How to collect the intersection and both complements of two arrays within one task?
Arrays -
const source = [1, 1, 1, 3, 4];
const target = [1, 2, 4, 5, 6];
Empty arrays -
const matches1 = [];
const matches2 = [];
const unmatches1 = [];
Loop -
for (const line of source) {
const ...
0
votes
1
answer
150
views
How can I compare objects in 2 arrays in Javascript & return the missing elements?
Is there a way to compare an incomplete array to the source of truth array & return the missing elements? The array consists of objects & some of the objects have an array of objects.
let ...
0
votes
2
answers
56
views
Check if any element in one flat array are not found in another flat array [duplicate]
I have the following script where I'm checking/matching items between two array. If 2nd array contains different item then return false;
$requiredString = [
"string1",
"string2&...
0
votes
1
answer
97
views
Difference between plots in IDL
I'm working with two plots of density as a function of distance on IDL. What I'd like to do with them is convert them into plots of distance as a function of density and plot their difference, in ...
0
votes
2
answers
422
views
Postgres array comparison - find missing elements
I have the table below.
╔════════════════════╦════════════════════╦═════════════╗
║id ║arr1 ║arr2 ║
╠════════════════════╬════════════════════╬═════════════╣ ...
1
vote
1
answer
94
views
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 ...
0
votes
1
answer
21
views
Calculate value gap between reporting importers/exporters [R}
I need to calculate the "Value Gap" between the reported volume of various commodities. For example (table below), USA reports that they exported 4 apples to China. China reported they they ...
0
votes
2
answers
58
views
How to check it elemets of an array are in another array
I have an issue,
I have this array
$items= array('ABC','DEF',GHI');
and have another two arrays
$array1 = array('ABC','DEF',GHI');
$array2 = array('DEF');
$array1 should return TRUE because all ...
0
votes
1
answer
433
views
Get second flat array's values not found in first flat array [duplicate]
I have to arrays and I have to find difference values from it.
Here is my Laravel Controller code
$product_list = Operation::where('kvit_id', $kvit->id)->pluck('product_id')->toArray();
$...
2
votes
3
answers
78
views
How to properly confront values from array and echo the result?
I have a script with 10 sets of numeric values. Every set has six different numeric values from 1 to 99.
<?php
$set1 = ['23', '11', '52', '33', '1', '4'];
$set2 = ['66', '70', '55', '8', '22', '1'...
0
votes
1
answer
130
views
User input has a different output from assigned-value input though both of them have the same value
I am building a custom string class. However, the user inputs give different output from the assigned-value one. For example:
With the assigned values:
#include"custom_string.h"
int ...
2
votes
2
answers
2k
views
Determining the indicies where 2 numpy arrays differ
I've got 2 long numpy arrays, both having 508 elements. I would like to get the indices of where they differ. Most of the solutions I've seen determining difference here sort the arrays which is not ...
2
votes
0
answers
66
views
How to efficiently generate a percentage difference series from conditionally selected values?
I'm working on a particular problem which I managed to solve in a very inefficient way and I would like to see if there a more efficient way to do it.
I have a Dataframe that has its first column ...
0
votes
1
answer
173
views
I need help in optimization of an array problem that has been asked in interview last month
Given 2 arrays a and b find the max value of b[i] + b[j] + b[k] (i !=j != k) , where the following condition is satisfied
a[i] > a[j] > a[k]
I can calculate it by using 3 loops. I have been ...
0
votes
1
answer
82
views
Determine if two arrays contain identical data
I'm trying to compare 2 arrays and what I want to know from them is if they match and if they don't match.
So what I mean by that is if my old values matches the new values completely, for example all ...
0
votes
1
answer
330
views
Difference between two 2D arrays in VBA
I am trying to get the difference between two arrays in excel VBA.
I found a solution to what I am trying to achieve here: Solution
But it seems to work only with 1D arrays.
Here you have a sample of ...
0
votes
2
answers
226
views
Finding the maximum difference between two same sized rows while ignoring blank cells in Excel
I have two rows, A (assumed to not have any nulls) and B (can contain blank cells) in Excel. A and B are both the same length.
What is the correct Excel formula to compute the maximum positive ...
1
vote
1
answer
263
views
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 ...
0
votes
1
answer
250
views
What is the problem with this Swift Code for finding the Diagonal Difference of a square array?
I'm working on some HackerRank Problem Solving challenges. The language I am using right now is Swift. The objective is to calculate the diagonal difference of a square array with n columns and rows. ...
2
votes
5
answers
131
views
How to find difference between two same array in JS?
I want to find difference between two arrays. I tried below code from one of the solution given on SF community, but not working from me.
My below code is not working if there is number repeated EVEN ...
0
votes
1
answer
41
views
How to find two arrays differences and form differences in new array in JavaScript? [duplicate]
How do I get differences between 2 arrays and form differences in new array?
arr1 = [1,2,3,4,5];
arr2 = [1,2,3,4];
newArr = [5];
Answer must be the same when arr1 and arr2 switch places.
1
vote
1
answer
49
views
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 (...
0
votes
1
answer
93
views
Getting answer in object form after using array_diff
I am comparing 2 arrays but after applying array_diff it returns the result in the object form.
Have a look at the below code and result
<?php
$schedule = ['Monday'=>['12:00','01:20'],'...
0
votes
3
answers
79
views
Get Unique Values from Array 2 Compared to Array 1 and Output in Array 3
I have 2 arrays and need to find the unique values in the second array that are not in the first array and output those to a third array.
Array 1
$array1 = array(
0 => 'value12',
1 => '...
0
votes
1
answer
54
views
how to assign a file to an array of elements which are part of the file
I have a directory which contains .txt files.
In each .txt files are lines, under each other. the 2nd line is the category line.
A txt file looks like this:
id-12345678 // id line
sport // category ...
0
votes
0
answers
241
views
how to exclude some elements from array [duplicate]
In some .txt files i have a line with some "categories".
A line (categories line) in a txt file looks like this:
athletics //category line
or
swim //category line
or
offside //category line offside,...
2
votes
3
answers
299
views
Multiple pairwise differences based on column name patterns
I have a data.table, dt:
dt
Id v1 v2 v3 x1 x2 x3
1 7 1 3 5 6 8
2 1 3 5 6 8 5
3 3 5 6 8 5 1
v1, v2, v3 and x1, x2, x3 are numeric variables
I want to subtract the 'x' columns ...
0
votes
2
answers
163
views
Finding the Difference By Row Between 2 Columns that are Both Arrays in SnowSql
I have a dataset that is comprised of a date and two other columns that are in array format. I am trying to find all the values in array_1 that are not in array_2.
Date | Array_1 | Array_2
-------...
0
votes
1
answer
381
views
Find the biggest difference between indexes
Hey Stackoverflow Community,
I got a little problem where I´m stuck at the moment..
I have to write a code, that have to find the biggest " temperature " difference between given days.
These are my ...
2
votes
1
answer
224
views
Difference between 2 arrays using perl array_diff utility
I am trying to run array_diff on 2 arrays.
sub array_diff(\@\@) {
my %e = map { $_ => undef } @{$_[1]};
return @{[
( grep { (exists $e{$_}) ? ( delete $e{$_} ) : ( 1 ) } @{ $_[0] }...
0
votes
1
answer
173
views
return needle not exist in haystack
im using array_diff to check if ALL needles exist
// my code
$needle = array(' b', 'asb');
$haystack = array('a','b','c','d','e');
if (empty(array_diff($needle, $haystack))) {
...
1
vote
3
answers
551
views
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,...