Having some major confusion regarding this particular FCC challenge + solution. via /r/learnprogramming


Having some major confusion regarding this particular FCC challenge + solution.

So thus far I've been having a reasonably easy time with FCC algorithm challenges, but now I've come to this one that even with a working solution, I cant understand.

Here's the link to the challenge

Here is a working solution, kindly provided by @nsuchy in the FCC gitter chat

So what I dont get is why the test case

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

expect this result

[1, 4, 5] 

when 5 is in all arguments.

The solution given to me gives that output (and passes all test) which I also cant understand.

You are checking each element of the first argument against an array of unique values and the elements of the second argument, so why does the 5 end up in the unique values list? Shouldnt it always get skipped?

Im not sure if I dont understand symmetrical difference or the reduce() method but theres something Im missing here and I decided to post cause I really have to sleep and cant sit in gitter all day.

Submitted July 17, 2017 at 12:05AM by HarryHayes
via reddit http://ift.tt/2v81JrV

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s