+ 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
45 odpowiedzi
+ 9
Sololearnes likes shortest challenges 😁
+ 5
@blackcat1111
I made a testcase generator. Tell me if it's right.
https://code.sololearn.com/cCQOrk9Zhez3/#py
+ 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 !
+ 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
+ 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. 😉
+ 4
@Cpasgrave Hmm, I get 'time limit exceeded' when I run the code... I'll try on IDLE later 😉
+ 4
@VcC That... is a very complicated code. It may take me some time to understand it all... 😵
+ 4
@Cpasgrave Yes, it works perfectly fine now! And yes, the test cases work (the ones I got, at least.) 😉
+ 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 !
+ 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 !
+ 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.
+ 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.)
+ 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. 😉
+ 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 ?
+ 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 !
+ 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
+ 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
+ 3
@ VcC
The matrix is 12x10
+ 3
@VcC Just tried your code, it doesn't work for @Cpasgrave's test case 😓
+ 3
@Cristian Stollberg Tried @Cpasgrave's test case, but returns 'list index out of range'. 😓