+ 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 :)
30 ответов
+ 4
https://code.sololearn.com/cfLeDq0kbS16/?ref=app
My python solution. Probably not the fastest, but I think it works. Thanks for the challenge!
+ 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.
+ 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.
+ 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)
+ 6
Yeah advwrtisement is illegal in sololearn let people get attracted.
+ 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 !!!
+ 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
+ 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.
+ 3
Don't advetise your challenge in other threads please
+ 3
I think it should be [0,1] in example 2 instead of [1,0].
+ 2
It looks hard eheh :) I will give it a try! Have you done it yet?
+ 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 ;)
+ 2
looking in this past days challenge.
hey, Julian report yourself for spam you :)
ps:where is your dominoes code?
+ 1
sorry, i don't understand the challenge
+ 1
@Lakshay
Don't forget dominos can be flipped. so the 1,0 can become 0,1
+ 1
@julian any other challenge
+ 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)
+ 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)!!!
+ 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!
+ 1
NEW DAILY PRINT-CHALLENGE:
https://www.sololearn.com/discuss/628136/?ref=app