5 kyu
City Swim - 2D (TowerFlood And PlainFlood)
115 of 292MikeAlexMartinez
Loading description...
Puzzles
Mathematics
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Am I the only one who doesn't understand what to do? How do I calculate this? (No code needed, I just don't get what do to)
Let's take the first 2 examples in description:
So if it rains, there will be 3 units of water between 5 and 10 (it will become [5, 5, 10] (any more would just fall to left side, or right side of 10, which we don't care about)
So there is space for 1 unit between 1 and 5, 3 units between 5 and 6, and 3 more units between 6 and 10, ending in state [1, 1, 5, 5, 6, 6, 10] (1 + 3 + 3 = 7)
Does that make any sense?
Ahh now I get it. The towers are blocking it against their neighbours. I understood something like they are water towers of a given capacity or such things. Boing. Yea, makes sense now. Thank you!
D translation
Can someone please enable C++ as a programming language?
It's not just enable a language. Someone needs to write a translation of the kata to C++, and then this translation get approved.
Go translation
approved
Kotlin translation ready for review and approval.
approved
Haskell translation
approved
Can you review my JavaScript solution?
https://www.codewars.com/kata/reviews/58e781d2c731c115d9000e01/groups/61e2e39054e22a00012dde53
sum
splice
may seem attractive, but it's generally slow; try avoiding itIt's not as performant as it could be, but it has more or less the right asymptotic performance. It's not as maintainable as it could be ( and this is bigger than you possibly think ), but .. it works.
Left a Rust translation. Please review. I had to drastically reduce the huge and big tests to make it not time out...
https://www.codewars.com/kumite/61df59fd856e34000f6fa384?sel=61df59fd856e34000f6fa384
ps: perf issue is fixed thanks to monadius.
Approved
I pass all the test but when i try to submit i get this error: RangeError: Maximum call stack size exceeded and this one RangeError: Maximum call stack size exceeded. What's happening? The timepass for my test is 3ms
I guess you're getting this on "attempt" rather than "submit"?
It looks like you're using recursion while you're facing a performance oriented kata. Most likely, your solution won't pass even if you increase the recursion limit. Look at the titles of the tests, you'll see the number of elements involved in the random tests, and the typical heights of the towers. The biggest inputs have more than 10_000 elements.
Thanks, for the answer
This comment has been hidden.
C# translation. Please, review and approve (the author is inactive).
approved
COBOL translation (author inactive).
approved
Hi,
could one of you update the random tests of the cobol version so that it doens't allow O(n²) solutions, like JS and python do now? (I took a look, but I don't like the idea to dig into.... that ;s )
edit: monadius is working on it
I published an updated fork: https://www.codewars.com/kumite/61d3c6c68b77d2005c05df48?sel=61d3f82c3457e4003ec730b2
Can't you just edit the kata directly instead of creating numerous forks every time?Nevermind, considering you're using a meme language, where everything has to be double-checked, maybe it's a good idea after all.approved fork
@Farekkusu: a new fork is easier to check with
diff
(it has monadius preference and I agree with him). Moreover in case the new fork doesn't work properly, it may be easier to just fork the sane version again. That's not especially related to the language.Node 12 should be enabled
assert.strictEqual
should be usedTests on inputs being numbers are useless
Description should be language agnostic
Done there, please check and approve if it's ok.
fork with some improvements.
.
dont approve
If your problem is this kata being a duplicate of myjinxin's, that one has performance requirements that make this one rather not a duplicate.
It should probably be ranked a
6
instead of a5
though.Not an issue, the other one has been retired due to copyright issues, so this one is good to goo
Isn't this a duplicate of @myjinxin's https://www.codewars.com/kata/trapping-rain-water?
Yes I guess it is the same :/ I hadn't seen it yet. I was just trying to write my first kata and this seemed like an interesting problem I'd heard of in an interview.
maybe myjinxin2015 applied for the same job :-)
At the moment both this kata and myjinxin's (https://www.codewars.com/kata/trapping-rain-water) are in beta, and both have average assessed ranks of 5 kyu.
The main difference between the two is myjinxin's version also incorporates performance testing (100 random tests using arrays with lengths of up to 1 million) whereas the maximum array length used in test cases for this kata are < 100.
Given this difference, assuming the tests don't change (significantly) for this kata, it's only reasonable that this gets a difficulty rank lower than the other; 6 kyu may be more appropriate for this kata.
Lastly, though this kata is, essentially, a duplicate of myjinxin's, it would seem appropriate to keep both with this one serving as a less difficult version of myjinxin's kata.
Because of difficulty, my kata is sleeping in beta long times ago :( now, I can only give you some simple fun ;-)
I'm in the process of writing another kata which builds on this so was hoping to make a series. Although I would agree regarding my difficulty probably being less than that of myjinxin2015's