+ 12

[Challenge] Santa Code's Christmas Conundrum

Welcome back, SoloLearners! Another challenge is here! But... not here. Rather, in this code: https://code.sololearn.com/cWe6a2zAJNj0/?ref=app Good luck, and have fun coding! 😉 Christmas - 00:00 GMT

25th Dec 2017, 12:00 AM
blackcat1111
blackcat1111 - avatar
45 ответов
+ 9
Sololearnes likes shortest challenges 😁
25th Dec 2017, 1:39 AM
Vukan
Vukan - avatar
+ 5
@blackcat1111 I made a testcase generator. Tell me if it's right. https://code.sololearn.com/cCQOrk9Zhez3/#py
25th Dec 2017, 4:12 AM
Cépagrave
Cépagrave - avatar
+ 5
@blackcat1111 Yes, it was working but sometimes returning time limit. So ... I learned that "randint()" is a very slow function in python. And corrected with "choice()". I had it working 10 times in a row now. https://code.sololearn.com/cCQOrk9Zhez3/#py Hope it's ok !
25th Dec 2017, 11:26 AM
Cépagrave
Cépagrave - avatar
+ 5
I initially made one that was easier to understand, but because VcC strived to make his as hard to read as possible (Idk much python) I got kinda pissed and did the same :P https://code.sololearn.com/c7cW8ydUwtnf/#py
26th Dec 2017, 6:02 PM
lion
lion - avatar
+ 4
@Cpasgrave It can be of any size, not just limited to 4 by 4, and it can be a rectangle (technically, a square is a rectangle, but yeah.). And yes, start and end are variable. The start and end could even be adjacent! I can give more test cases if you want. 😉
25th Dec 2017, 3:41 AM
blackcat1111
blackcat1111 - avatar
+ 4
@Cpasgrave Hmm, I get 'time limit exceeded' when I run the code... I'll try on IDLE later 😉
25th Dec 2017, 6:28 AM
blackcat1111
blackcat1111 - avatar
+ 4
@VcC That... is a very complicated code. It may take me some time to understand it all... 😵
25th Dec 2017, 12:53 PM
blackcat1111
blackcat1111 - avatar
+ 4
@Cpasgrave Yes, it works perfectly fine now! And yes, the test cases work (the ones I got, at least.) 😉
25th Dec 2017, 1:03 PM
blackcat1111
blackcat1111 - avatar
+ 4
I have this homemade testcase for you all. It's of course a painful one but it's designed to check if my (and thus your) algorithm has really understood the harshness of existence or if he's just taking easy walks, naïve, naked and blind throughout the creepy forest. [ [1, 1, 1, 9, 1, 1, 1, 1, 9, 9] [1, 9, 1, 9, 2, 9, 9, 1, 9, 1] [1, 9, 1, 1, 1, 1, 9, 1, 9, 1] [1, 9, 9, 9, 9, 9, 9, 1, 1, 2] [1, 9, 9, 9, 9, 9, 9, 9, 1, 1] [1, 9, 9, 9, 9, 9, 9, 9, 9, 9] [1, 3, 2, 1, 9, 9, 9, 9, 9, 9] [1, 9, 9, 1, 9, 9, 9, 9, 9, 9] [1, 9, 9, 1, 9, 9, 9, 9, 9, 9] [1, 1, 2, 1, 9, 9, 9, 9, 9, 9] [9, 9, 9, 2, 9, 2, 9, 9, 9, 9] [1, 1, 1, 1, 1, 1, 1, 1, 1, 5]] Start : 110, End : 9 Enjoy !
27th Dec 2017, 5:28 PM
Cépagrave
Cépagrave - avatar
+ 4
@Cristian Stollberg Yes, I tried it also, it works fine. All codes here are doing it well, those from VcC and Lion too. Thanks all ! I'm quite young in coding, and coding this challenge then reading and understanding your codes made me learn a lot ! Thank to blackcat !
27th Dec 2017, 10:09 PM
Cépagrave
Cépagrave - avatar
+ 4
A bit late in the challenge, but here is my try: https://code.sololearn.com/cK6eZrrYIPO1/#py I don't like to compress the code, especially when that would have an impact on its readability. I used the labyrinth generator by @Cpasgrave, and decided to improve a little bit the output.
30th Dec 2017, 12:41 AM
Boris Batinkov
Boris Batinkov - avatar
+ 3
@Pegasus You have to get from start to end taking the least time possible; each square's number represents the amount of time required to move to that square. (And yes, I admit it is very, very confusing.)
25th Dec 2017, 2:16 AM
blackcat1111
blackcat1111 - avatar
+ 3
In depth explanation: [[1, 5, 4, 3], [4, 7, 8, 2], [5, 3, 1, 4], [3, 6, 4, 2]] Start = 12, End = 3 You need to get from bottom left (12th index of the square) to the top right (3rd index of the square), taking the shortest time possible. Each square's number represents the amount of time required to get to that square. You start from the bottom left, taking 3 minutes. Then your best move will be to move up, taking 5 minutes. Next, you should go right, adding another 3 minutes to the total. Keep going... In the end you'll have moved up, right, right, right, up and finally up, taking 21 minutes. You also have to output the string, which is URRRUU (U means up and R means right). If you need any more clarification, feel free to ask. 😉
25th Dec 2017, 2:51 AM
blackcat1111
blackcat1111 - avatar
+ 3
Nice challenge ! Question : Can the input square be bigger than 4x4 ? Can it be a rectangle ? Or will it always be 4x4 ? Also : the "Start = 12, End = 3" thing, do we have to consider it as a variable, that may change, or will it always be the same in all test cases ?
25th Dec 2017, 3:38 AM
Cépagrave
Cépagrave - avatar
+ 3
Hoooh ! It makes it hard and good ! Well, with these conditions, it will be much easier to make a code to automatically generate test cases than to make the code itself. I will start by doing it !
25th Dec 2017, 3:47 AM
Cépagrave
Cépagrave - avatar
+ 3
One solution here. Almost one liner (i left it in 3 functions for the sake of clarity) https://code.sololearn.com/cBy7ASIoU5Yy/?ref=app
25th Dec 2017, 8:32 AM
VcC
VcC - avatar
+ 3
@cpasgrave Hey if you play hardball then we need our friend Dijkstra - no more oneliners done in the taxi. Here you are https://code.sololearn.com/c3XS6uUc5ssI/?ref=app
25th Dec 2017, 8:10 PM
VcC
VcC - avatar
+ 3
@ VcC The matrix is 12x10
25th Dec 2017, 9:36 PM
Cépagrave
Cépagrave - avatar
+ 3
@VcC Just tried your code, it doesn't work for @Cpasgrave's test case 😓
26th Dec 2017, 2:20 PM
blackcat1111
blackcat1111 - avatar
+ 3
@Cristian Stollberg Tried @Cpasgrave's test case, but returns 'list index out of range'. 😓
26th Dec 2017, 2:24 PM
blackcat1111
blackcat1111 - avatar