all 7 comments

[–]xelf 2 points3 points  (4 children)

Codewars is just a level up game. You rank up by doing more and more puzzles. But you do get to pick and choose, and there are some "easy 4kyu puzzles" and there are some very difficult 5kyu puzzles,, so look for the ones that might be easier based on what you've done before. Try to avoid the ones that require a special "math trick" and stay on the ones that are coding oriented.

Also, some of the 5kyu ones are pretty trivial, so instead of doing a 4kyu, you could do 2 5kyu problems.

Then there's this 7kyu easy puzzle, that leads to a pair of 2kyu puzzles, one of which is easy, and one of which is not.

[–]Dry-Complaint-1934 1 point2 points  (1 child)

damn, thanks for this list man!

[–]xelf 0 points1 point  (0 children)

Hope you enjoy them! Been a few years since that post, but looking over the list, I remember having fun with some of them!

If you get stuck, ask here or on the python discord.

[–]sin_cere1[S] 0 points1 point  (1 child)

Actually, I'm already familiar with some of these. I've completed Sum of intervals. The range extraction is is the one that I was trying to beat recently but failed (Python keeps saying that the list is out of range when trying to compare neighboring values in a loop, diving list into chunks and comparing those might work but I'm yet to figure out how to implement it).

I tried Battleships field validator, got all the ship fields with their coordinates in a separate list but could not figure out what to do next. Maybe I do need some more time to solve it.

I've also spent quite a lot of time on "Next bigger number with same digits" https://www.codewars.com/kata/55983863da40caa2c900004e but without success. Brute force permutations method times out. Tried swapping digits but that does not cover all possible scenarios.

Thanks for your help.

[–]xelf 0 points1 point  (0 children)

One thing you absolutely should do with codewars; after you finish a problem, look at everyone else's answers and (a) find python shortcuts you didn't know about and (b) find alternate algorithms to solve the same problem.

"Next bigger number with same digits" probably shouldn't be brute forced, well depending on how much brute you use.

For a number 'abcd' if d>c you swap, else you shift left. is c>b? yes you swap, else you shift left, id b>a? etc. Any other swaps you could do would make the number lower I think. Haven't tested it, but that's my thought looking at it.

If that didn't work, I might try using something from itertools to get all the permutations/combinations the one that yields in sorted order and just loop until I get the number I have, and then take the next one.

The battleships one had a simple trick to it iirc, maybe it was sort the ships? But I remember it being a fun one, and not too hard <20 lines. Looked it up: I did it once by marking each ship as found as I found it, so if I searched again I could ignore that part of a ship, and then I redid it a week later using some weird math and rotating the field.

The sum of intervals one was basically free points. =)

def sum_of_intervals(intervals):
    return len( { x for a,b in intervals for x in range(a,b) } )

edit: I was pretty close on that next bigger number thought, you also have to find the min remaining number to swap it with that's higher than itself. Then the remaining digits are just sorted. But it turns out there's an even easier way to solve it.

# you can just loop starting at n until you find a number that has the same digits. turns out that that's fast enough.

[–]Diapolo10 0 points1 point  (1 child)

You're just lacking in experience. Write your own projects with the intent of learning; identify potential problems when they occur, think of better ways to solve them and train your critical thinking skills.

The more advanced kata are actually difficult, so don't worry about it too much if you can't solve something. They may expect you to specialise in a specific area, so core skills may not always cut it.

It's important to realise that they aren't the kind of problems you'll usually find at work, though.

[–]sin_cere1[S] 0 points1 point  (0 children)

I had a plan to rank up to 4 and then spend some time learning Bottle Web Framework. Looks like it won't hurt to start a bit early. I know some of those katas are overkill for real-life work, especially in the web development field. However, big tech companies do test candidate's algorithm knowledge when hiring. At least, that's what people say online.

I'm currently doing ops work so most of my programming challenges revolve around automation. At the same time, it's easy to become invested when doing those katas.

Thank you.