Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Hi Alberto!
Minor observation regarding the Python translation...
The second function has a "{" instead of a ":" after the function definition. Easy to fix for the coders but it might be worth tidying up :-)
cheers, Phil
Hi gdbaldw,
Did you get anywhere with this?
One thing I noticed in terms of the pattern of digits in the two solutions was that they each have a "backward L" shape within at least one district. In the case of the first solution it's in District 2, and in the second solution the backward-L appears within both District 2 and 3 (and arguably 4). By "backward L" I mean that the digits in the district move downward, and then to the left.
When I was solving this Kata, the downwards-then-move-to-the-left was one of the last things I had to code for (as I was getting None even when a valid solution was available). My solution takes a somewhat "brute force" approach in that it first generates every possibility for what each district combination may look like (5 valid districts according to the rules) and then compares the pattern provided in the input with each generated potential solution to see if we get a "hit" of winning 3 districts.
I can't (for unknown reasons!) see beyond the 5th line of your solution so I can't see if your code covers this backward-L scenario fully (not sure I'd understand the code even if I could see it!).
cheers, Phil
Hi davilla!
Well I finally managed to get around to doing this kata again, and the solution seemed a bit easier this time around (maybe I've been thinking about it in my sleep!)
I'm not an expert in how codewars ranks its kata, but I think this one is probably worth a bit more than a "Level 5". I say that for two reasons:
1 - The code needs to be quite strong in terms of performance. Like yourself, I had an initial solution that solved the puzzle, but it took too long when running the tests. The highest number for "n" I saw was 1474, and that combined with other potentially high numbers means that even with the faster version I have now, the code often came close to 12000ms.
2 - The puzzle as its presented in the description is really good (I'm not sure if you're a native English speaker - I am, and I've seen some kata descriptions that are very hard to understand. This one is excellent however!) but the puzzle in itself is a bit tricky to solve, I think. I mean, if you had real dominoes in front of you and someone asked you to make a valid Train out of them, it isn't all that simple. So there's a challenge in even thinking up a method to create a valid train.
In any case, even if this remains a Level 5 kata, I have to say I really enjoyed it and learned some important new ideas in terms of Python coding, so my sincere thanks to you and to everyone else involved in the creation and development of this kata!
Merci beaucoup as they say en France!!
cheers, Phil
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Enjoyed this kata (completed in Python), thanks to all who contributed!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Coded for this kata in Python! A lovely journey, not always as smooth as a real train journey but thanks a million to everyone who contributed! Highly enjoyable experience!
cheers, Phil
Just to expand on this, I believe (please correct me if I'm wrong) that all citizens of other nations actually begin as "banned" unless and until a bulletin states that they are allowed. Of course citizens of nations may be banned/allowed during the execution of the tests, but they all begin as banned as far as I remember?
cheers, Phil
Really good kata, thanks so much for the thought that went into the design. I'm new to Python so it confused me a bit at the start (dicts especially!) but sleeves up, facebook off, radio unplugged, cats outside, you get into it and things become more and more clear as you code :-)
In Python, there might be a slight issue with one of the 3 sample tests, as one of the documents is called something like acces_permit instead of access_permit. Easy to change and it might not matter (depending on how one codes for this kata I guess?). I can't be sure now as I can't see the sample tests as I write this.
Also, I didn't use "def init" (def underscore-underscore init underscore-underscore) when setting up class variables. I just defined them under the Class name. It was only when I submitted my code and was looking through some other solutions that I noticed other people had included this. I wonder what difference does it make, having this or not having this? I checked it out on stackexchange but didn't really find out much.
Anyway, thanks again for a great kata! At this rate I'll have my £1000/day coding job in London in no time :-)
cheers, Phil
Boooooo YEAH! Finally nailed this kata.
If at first you don't succeed, write code to cover every single possibility :-)
Thanks again for your help earlier!
GREAT KATA so thanks to the author(s) too!
cheers, Phil
Loading more items...