+ 7

CHALLENGE: Write a function that gets an array of dominoes as input and outputs the length of the longest domino-sequence!

EXAMPLE 1: - input: [[1,2],[4,5],[9,6],[2,3],[5,8]] - output: 2 ([1,2]-[2,3] OR [4,5]-[5,8]) EXAMPLE 2: - input: [[7,8],[1,2],[8,4],[2,3],[1,0]] - output: 3 ([0,1]-[1,2]-[2,3]) INFO: Rotating pieces is possible! WINNER WILL BE NOMINATED TOMORROW NIGHT! GOOD LUCK AND HAVE FUN :)

26th Jul 2017, 10:40 PM
Julian Fechner
Julian Fechner - avatar
30 Respostas
+ 4
https://code.sololearn.com/cfLeDq0kbS16/?ref=app My python solution. Probably not the fastest, but I think it works. Thanks for the challenge!
26th Jul 2017, 11:49 PM
Ready
Ready - avatar
+ 9
Do not spam in existing threads to advertise your own thread. Please remove all the posts that you have made within 24 hours. If you do not comply, there is a risk that your profile will be blocked. Kindly take note. Thank you.
27th Jul 2017, 3:07 AM
Hatsy Rei
Hatsy Rei - avatar
+ 8
Don't advertise your thread in other posts (1 or 2 is ok but you've gone full fledged). Please delete those posts, or you will risk being reported.
27th Jul 2017, 2:12 AM
Pixie
Pixie - avatar
+ 7
TIME IS UP CODERS... ONLY 1 PERSON WAS ABLE TO SOLVE THE PROBLEM. SO NO NEED OF NOMINATING ANYBODY ! MAYBEE THIS ONE WAS A LITTLE TO HARD ... TRY THE NEXT ONE!!! https://www.sololearn.com/Discuss/569992/daily-challenge-write-a-code-that-get-as-input-a-mathematical-function-as-string-calculate-and-print (ps: my domino-code will be uploaded tommorow)
27th Jul 2017, 9:36 PM
Julian Fechner
Julian Fechner - avatar
+ 6
Yeah advwrtisement is illegal in sololearn let people get attracted.
27th Jul 2017, 2:14 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
@Pixie @/*S Vengat*/ @Janhangeer @hatsi rey I'm NOT trying to advertise anything or anybody. Actually, I just felt in love with those challenges, like others did too! The reason why I've posted it a few times is, that I want EVERBODY to be able to educate them selfs in a playful way. And therefore I would recommend to start a seperate section for code challenges/competitions. The idea of people posting smaller challenges for other people is brilliant, because this will improve ALL our SKILLS! ps: don't block me !!!
27th Jul 2017, 7:28 AM
Julian Fechner
Julian Fechner - avatar
+ 4
@André Oliveira yes code will be uploaded tonight! btw: we had to solve this problem in university homeworks one day. I've got more of them... and will let you try them all (if you dare) :D
27th Jul 2017, 10:57 AM
Julian Fechner
Julian Fechner - avatar
+ 4
@Ready: Your algorithm only seems to work for increasing sequences of domino tiles. If your input consists of multiple copies of the piece [0-1] it would fail. My ad hoc, but admittedly very inefficient, solution would look something like this: - Turn the input into a graph: Every domino tile is a pair of nodes connected by an edge and there is an edge between nodes of different tiles iff the corresponding sides of the tile have the same number. - Use dynamic programming to solve the Longest Path Problem on this graph. I'm not going to implement this, because I don't have the time now, but maybe this helps someone.
27th Jul 2017, 2:57 PM
Tob
Tob - avatar
+ 3
Don't advetise your challenge in other threads please
27th Jul 2017, 2:27 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 3
I think it should be [0,1] in example 2 instead of [1,0].
27th Jul 2017, 12:43 PM
Lakshay
Lakshay - avatar
+ 2
It looks hard eheh :) I will give it a try! Have you done it yet?
27th Jul 2017, 9:55 AM
André Oliveira
André Oliveira - avatar
+ 2
@Ready result should be a single line of chain. but for calculating the longest you can use the more linked to a single domino idea ;)
27th Jul 2017, 6:12 PM
Julian Fechner
Julian Fechner - avatar
+ 2
looking in this past days challenge. hey, Julian report yourself for spam you :) ps:where is your dominoes code?
15th Aug 2017, 11:39 PM
ysraelcon
ysraelcon - avatar
+ 1
sorry, i don't understand the challenge
27th Jul 2017, 2:32 AM
‎ ‏‏‎Anonymous Guy
+ 1
@Lakshay Don't forget dominos can be flipped. so the 1,0 can become 0,1
27th Jul 2017, 2:18 PM
Ready
Ready - avatar
+ 1
@julian any other challenge
27th Jul 2017, 2:54 PM
‎ ‏‏‎Anonymous Guy
+ 1
my hint: to prevent the problem of copies you could easily write a class (eg: Element) containing the touple and then you can check if a certain Element is already used (by comparing the refernece to the Element instead of the touples it self)
27th Jul 2017, 4:45 PM
Julian Fechner
Julian Fechner - avatar
+ 1
@Tobi Your suggestion is totally right. converting it to a bellman-ford like (graph) alogorithm would solve the problem efficiently (but that's to hard for beginners)!!!
27th Jul 2017, 4:56 PM
Julian Fechner
Julian Fechner - avatar
+ 1
HEY PEOPLE OUT THERE. I'M BACK FROM VACATION. AND ANOTHER DAY MEANS ANOTHER CHALLENGE. CHECK IT OUT!!! https://www.sololearn.com/discuss/622449/?ref=app SOLUTION WILL BE UPLOADED TOMORROW NIGHT!
13th Aug 2017, 8:05 PM
Julian Fechner
Julian Fechner - avatar
15th Aug 2017, 8:19 PM
Julian Fechner
Julian Fechner - avatar