Questions about "Find the Symmetric Difference" in Freecodecamp's algorithms course

So I've been stuck on this for hours and had to look at solutions. This is the solution I've been using:

function sym(args) {
  let argumentsArray = [...arguments]
  function symDiff(arr1, arr2){
    let result = []
    arr1.forEach(a=>{
      if (arr2.indexOf(a)<0 && result.indexOf(a)<0){
        result.push(a)
      }
    })
    arr2.forEach(a=>{
      if (arr1.indexOf(a)<0 && result.indexOf(a)<0){
        result.push(a)
      }
    })
    return result
  }
  return argumentsArray.reduce(symDiff)
}

sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5])

The result to this is [ 1, 4, 5 ]

From what I understand, it:

  1. Turns the arguments into a 2d array so it's easier to work with

  2. Creates a callback function called symDiff, where it takes 2 arrays, looping through each one, and if the other array doesn't contain the element AND if it doesn't already exist in the result array, it pushes it into the result array

  3. Applies the callback function on the reduce method used on the 2d array of arguments, the reduce method goes through each array of arguments until it returns the result

I have 2 questions here:

How is 5 in result? Doesn't the symDiff function only push elements that don't exist in the other array? If arr1 is [1, 1, 2, 5] and arr2 is [2, 2, 3, 5], isn't arr2.indexOf(5) going to be 3, and same for arr1.indexOf(5), which means it shouldn't be pushed into result?

And my other question is, I noticed if I declare the result variable outside of the symDiff function, it gives a different result, it becomes [ 1, 3, 4, 5 ] instead. How does that work?

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Jan 23 2022
🚨︎ report
How can I prove that sets A, B are equal A=B given the following symmetric differences are equal?
πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/sasugey
πŸ“…︎ Nov 25 2021
🚨︎ report
Can someone explain me in plain English (or ELI5) what the difference between the 'symmetric corridor', 'floor' and 'ceiling' principle is, and when a certain method would be preferable? I need to make an assignment on this but I cant grasp it.

This would help me out a lot. Any tips are welcome!

Kindest regards, BHTA!

EDIT right away: this is not homework, the actual questions are not at all answered by this. I just cant understand it from the resources I find on internet. Im merely asking for an easier explanation of the concepts :)

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/BHTAelitepwn
πŸ“…︎ Dec 11 2021
🚨︎ report
What are some of the most important differences on the two halfs of mostly-symmetric (cp or ctf) maps?

Lately a trick I've been using on 2fort is to go in the front door and then sticky jump up the little hole in the grate to get to the upper level. This allows you to avoid the courtyard, which is where like 80% of 2fort sentries end up getting placed.

This has caused me to notice a difference: in the Blu fort, the upper area here is enclosed, with a roof. But on the red side, it's wide open, up to the sky. This means that when I enter the red side, I fly way up and end up taking fall damage, while on Blu I usually just bounce off the roof and stand right on the grate. If I took damage on my way across the bridge, I can easily die entering the red fort, while on the Blu fort I know I'm probably okay (and the health pickup at the top of the spiral helps top me off until I can get to the next health, right outside the Intel room).

This is a big difference in the two halves, and I would have thought the game would be made to be perfectly balanced. Are there other examples of big differences between the two sides of a map that initially seem functionally identical?

πŸ‘︎ 325
πŸ’¬︎
πŸ“…︎ Jun 08 2020
🚨︎ report
Test for symmetric distribution of differences

Hi All,

I am using the Wilcoxon signed-rank test to pairwise compare data. This test assumes an approximately symmetric distribution of differences. Right now, I am verifying this by making a boxplot of the differences between the data and looking at the shape of the boxplot.

Is there maybe a more clear way to test this? Like a statistical test that investigates the distribution of differnces? I thought that maybe using the Levene's test to check equal variances between 2 groups could be an indication, but this is something different I think?

Thanks!

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/florisvdr
πŸ“…︎ Jun 28 2020
🚨︎ report
Exploring the Symmetric Difference Interview Question in JavaScript typeofnan.dev/exploring-t…
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/garboooge
πŸ“…︎ Jan 13 2020
🚨︎ report
Set Operations(union, intersection, difference and symmetric difference) using Python itvoyagers.in/set-operati…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/VijayRawool
πŸ“…︎ Jul 14 2020
🚨︎ report
Coding Interview Prep: Find the Symmetric Difference (Video Tutorial)

Hey guys, I plan on going through each of the algorithms under the coding prep's algorithm section. Here is the first one: https://youtu.be/XG3O5xJgMA0

Enjoy!

πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/justinkim943
πŸ“…︎ Feb 06 2020
🚨︎ report
Defining symmetric difference in own class

In my class i’m working with sets. I defined

  • via sub & via and | via or But how do you define symmetric difference (^)? I can’t find it
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/Sir_Thomas_III
πŸ“…︎ Dec 20 2019
🚨︎ report
Symmetric vs Asymmetric encryption:What’s the difference? blog.mailfence.com/symmet…
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/mailfence
πŸ“…︎ Mar 30 2020
🚨︎ report
STL Algorithms 7: std::set_union, std::set_intersection, std::set_difference & std::set_symmetric_difference youtu.be/oNnatJtPWjI
πŸ‘︎ 45
πŸ’¬︎
πŸ‘€︎ u/arkethos
πŸ“…︎ Jun 15 2018
🚨︎ report
Exploring the Symmetric Difference Interview Question in JavaScript typeofnan.dev/exploring-t…
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/garboooge
πŸ“…︎ Jan 13 2020
🚨︎ report
Coding Interview Algorithm: Find the Symmetric Difference (Video Tutorial) youtu.be/XG3O5xJgMA0
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/justinkim943
πŸ“…︎ Feb 06 2020
🚨︎ report
[C++]Symmetric Difference function only adding the common values found in first array

I've been looking at this one for hours, but can't seem to figure out where I'm going wrong The arrays do get passed in correctly, their values are:

this->pInteger {15,16,17,18,19,20,21,22,23,24}

That.pInteger {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}

By the time the program finishes, IntSet3's values are {15,16,17,18,19} Which is the opposite of what I want, the values I want it to return are {1,2,3,4,5,6,7,8,9,10,11,12,13,14,20,21,22,23,24}

Here's the function: https://www.pastebucket.com/564484

My thinking is that since match2 is initialized as false, then it should only flag as true when the numbers do line up, and NOT add the value to the array. Where am I going wrong on this one?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/El_Eric
πŸ“…︎ Nov 04 2017
🚨︎ report
[Pre Calculus] What is the difference between a function that is symmetric to the x axis and y axis vs even or odd?

Is this the same thing? Are one of these evens or one of these odd? If that makes sense? I'm not understanding the difference between the two and wonder if it is the same process to solve.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/juravenator99
πŸ“…︎ Nov 24 2018
🚨︎ report
What is the symmetric difference in probability?

So I get that it omits the intersections. What throws me off is the venn diagrams for >3 events also include some of the overlaps and I don’t understand why.

Can someone explain what it means in a real-world scenario without using the word intersection? Everywhere I look explains it as omitting the intersection but I need a non-jargon explanation.

Is it the same as β€œthe probability that exactly one of these events occur” (but not more than one, hence the intersection being omitted)?

If so why is the middle overlaps included (for >3 events)? I can only find examples using discrete sets which I can understand. But what if the venn’s represent events with probabilities? Like 10% of people choose ABC, while only 40% choose A, 30% choose B, 20% choose C, etc. Why would you include the people that select all 3 in the centre of the venn?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/catelemnis
πŸ“…︎ May 24 2018
🚨︎ report
Krita Development News - Symmetric Difference Selection is almost finished! Need input from users to define shortcut.

Hi guys,

I have to tell you guys that the long blocky selection issue has been solved by one of the Krita developer that worked on selection tool a long time ago, and thus that means symmetric difference selection can technically be pushed soon.

There's one or two thing that needs to be done on my end - Define the shortcuts, and add layer-based selection shortcut as Dmitry has added those.

What should the shortcut be for symmetric difference selection tool, and layer-based symmetric difference selection be?

Image of the new selection tool (Note the 5th selection tool)

  • https://i.imgur.com/HfQsOxo.png

Brief info of the new tool - Symmetric Difference invert the selected area which means that any area that intersect are not included as selection, and any area that don't intersect are included.

More info here - https://en.wikipedia.org/wiki/Symmetric_difference


Phabricator Discussion - https://phabricator.kde.org/D15085

πŸ‘︎ 14
πŸ’¬︎
πŸ‘€︎ u/Reptorian
πŸ“…︎ Oct 07 2018
🚨︎ report
[High school] symmetric difference

Hey Pls i need some help to do the logical approach for showing that:

(A+B = A inter B ) implies A=B={ }

Thanks in advance

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/zakariaT
πŸ“…︎ Oct 15 2017
🚨︎ report
[C++] Problem with implementing symmetric difference for sets.

So, I was supposed to implement symmetric difference for two sets of numbers of, respectively, n and m size. I was supposed to assume that every set is valid (doesn't have duplicates, have only integers etc.), the sets can range in size (min. 0, max. 10^7) and have numbers no bigger than 10^9. The result should be a single line consisting of three numbers separeted by spaces (in that order: number of elements of the resulting set, it's smallest element and it's largest element, both -1 if the resulting set is empty). The catch is I can use only primitive data types and primitive, one dimensional arrays. Here is my code:

http://pastie.org/private/bzp22ayvg851bq5efiqaq

Now, here's the fun part. I'm evaluated by automated platform. This code works for first five of it's 16 test cases. The next nine report wrong answer and final two say that I took too long (reported run time is more than 1.01 seconds). And that's all the information I have. No details whatsoever. Me and my friends have been trying to figure out what's wrong witht that code for the past week. We haven't come up with any possible reasons, so at this point I'm desperate.

Also, I should mention, while this is the most recent version of that implementation, it isn't the most succesful one. This one scored the most points:

http://paste.ofcode.org/38T7H2eh8QsxDUPHc7h8FvQ

It passed succesfully eight checks and took too long in the rest.

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/Bearfayce
πŸ“…︎ Mar 23 2016
🚨︎ report
Need help with this symmetric difference.

Prove: Aβ–³(Aβ–³B)=B

Knowing that Aβˆ†B = (A βˆ’ B)βˆͺ(B βˆ’ A)

I have to prove the above without using its associativity. All kinds of help are appreciated since I'm stuck on this one.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Sovere1gn
πŸ“…︎ Feb 20 2017
🚨︎ report
[Undergraduate Proofs/Set Theory] Prove that symmetric difference is associative

Hi, I need to prove the problem stated in the title.
I do know that the problem basically simplifies to proving that AΞ”(BΞ”C)=(AΞ”B)Ξ”C.

Would it be sufficient to show that there exists an element x within AΞ”(BΞ”C) that is also (AΞ”B)Ξ”C and also show the converse, that there exists an element within (AΞ”B)Ξ”C that is also in AΞ”(BΞ”C)? I don't really feel like expanding out the definition of the symmetric difference but I will if that's the only reasonable way.

Thank you!

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/ShwangCat
πŸ“…︎ Sep 11 2017
🚨︎ report
Symmetric Difference Selection Patch Update - Two blocker bugs remaining to be ready for push. One for my end though.

One blocker bug remaining on my end, but it's at the point where the full functionality can be explored. There's a issue of needing a custom shortcut to assign symmetric difference selection using opaque information from layers, but Dmitry had worked on that end without the new symmetric difference selection feature, and since I have no idea about how to go on about that, I'll probably leave that up to him. So, technically two blocker bug, but one on my end. I think it should be cntrl+shift+space to activate selection using opaque on layers, but feel free to oppose this design.

In any case, here's a video of the symmetric difference selection patch. - https://streamable.com/i0k6w

And the differentials - https://phabricator.kde.org/D15085

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/Reptorian
πŸ“…︎ Sep 05 2018
🚨︎ report
What is The Difference Between Symmetric Arms and Asymmetric Arms On a Two Post Lift? youtube.com/watch?v=7O3f9…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Freekmagnet
πŸ“…︎ Mar 11 2018
🚨︎ report
[java] Hello, need help with Symmetric set difference.

Hello, i have a problem i am trying to solve. Basically i has two sets of emails. One email per line and i have two files a.txt and b.txt. Is there a way to maybe use a built in java method to get the Symmetric set difference from these two text files? So far what i did was take each email and add it to two different hash sets, s1 and s2. Now i need to compare these two hash sets and basically find the emails that are missing in a from b.txt. Is there a java method to do this? or anything that someone can think of to help me come up with a solution. I appreciate any help, thanks. Here is what i have so far.

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

public class test {

public static void main(String[] args) throws FileNotFoundException,IOException {
	File f1 = new File("a.txt");// OUTFILE
	File f2 = new File("b.txt");// INPUT

	Set<String> s1 = new HashSet<String>();

	try (BufferedReader br = new BufferedReader(new FileReader(f1))) {
		String line;
		while ((line = br.readLine()) != null) {
			s1.add(line);
		}
	}
	
	Set<String> s2 = new HashSet<String>();
	
	try (BufferedReader br2 = new BufferedReader(new FileReader(f2))) {
		String line;
		while ((line = br2.readLine()) != null) {
			s2.add(line);
		}
	}
	
	System.out.println("" + s1.containsAll(s2)); 


}

}

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/AngleMan
πŸ“…︎ Jun 15 2016
🚨︎ report
[Proofs University] Symmetric difference

Let A and B be sets. Prove: If A(+)B subset A, Then B subset A [(+)= symmetric difference and I'll use C's for subset e= element of]

Claim: If (AUB)-(AnB) C A, Then B C A Suppose x e (AUB)-(AnB) Claim: x e A SInce x e(AUB)-(AnB) x e A or x e B, but x not e of (AnB)

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/adeptplatypus
πŸ“…︎ Apr 17 2015
🚨︎ report
Interactions between people of different races, genders, etc. are not symmetrical

It seems to me that many people think one way to determine whether a situation is discriminatory by taking that situation, inverting the roles and seeing if it appears problematic.

But I think that is a detrimental oversimplification, as it completely occludes the associated context.

For instance, if a black man disguises as a white character, many people will get riled up against them because "if it were a white man doing a blackface everyone would think it's racist". But that's forgetting completely that for decades, blackface was used to severely mock black people.

Another example I can take is that of my own university. Women make up 25% of the students and in this male dominated environment, they're too often victim of sexual harassment and assault. To help with that, my university has hired someone to oversee gender equality on the campus. It would have been perfectly sexist to require a man for that job. But requiring a woman is not only okay but necessary as female victims of sexual assault are typically reluctant to open up to a man.

So yeah, sometimes situations are problematic when the roles are reversed, but that's because those roles aren't symmetrical, and we need to stop pretending that they are.

πŸ‘︎ 55
πŸ’¬︎
πŸ‘€︎ u/_LususNaturae_
πŸ“…︎ Jan 27 2022
🚨︎ report
I understand the difference between Imperial & Metric, but what's the difference between Metric & Symmetric?
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/lufcmattylad
πŸ“…︎ Apr 03 2014
🚨︎ report
[Probability] Prove the symmetric difference of A XOR B

The question asks to show that

P(A XOR B) = P(A) + P(B) - 2P(A ∩ B)

directly using the axioms of probability.

I have no clue how to even start this proof.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/SquirtlexTurtwig
πŸ“…︎ Sep 20 2015
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.