3 kyu
Fluid Volume of a Heightmap
158 of 258thquinn
Loading description...
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.
Could someone please explain why is the correct volume 1 in the below test (I got it as one of the random tests, Python translation):
14, 0, 0, 12, 12
-5, 14, 10, 9, 9
-5, 2, 7, 7, 14
1, 5, 11, 13, 10
9, 0, 1, 1, 7
Thanks in advance!
Hi,
This map is expecting 0, not 1. You must have lookeed at the wrong input/output
That was my expectation also.
Is there a way to paste screenshots here? I have one with the output of the test suite.
I think it would be nice to add to description that big maps have hundreds of different height values. It would prevent warriors from going the wrong path.
This is an issue very specific to your personal approach (see your comment below), not a general issue. You just need to rethink how you tackle the problem. Hint: The number of depth levels should be irrelevant.
This comment has been hidden.
JS translation
cheers
Finally, B4B making a translation after centuries XD
.
Hello there!
Rust translation ready for review! (It's pretty much a 1:1 copy of the Python test suite)
I found one problem, commented in your translation discussion section!
Replied with a new fork fixing the issue. Thanks!
I did not understand this kata. If you look at the example in the instructions, the bottom right element is 0. Hence, when filled, should the last column not contribute 63 and not 64?
Also, what does 4*8 mean? Does each column of 8's (i.e. 4 8's) contribute 8?
Does each column of 4 6's contribute 6? If so, how much would a column of 2 6's (the top two elements being 6 and the bottom 2 elements being 0) contribute?
If there is a column, which reads, from top to bottom: 8 6 4 2 Is this possible? If so, how much does it contribute?
@thquinn
It's a height map. Think of the numbers as heights of square columns stacked next to each other. Water spreads across equally high columns and trickles down into onto lower columns. Water flows in cardinal directions only, not diagonally. Hence the bottom right corner is not a leak.
6*4
: There are 4 colums of height0
surrounded on all sides by columns of height6
;6-0 = 6 -> 4*6
4*8
: Ther eare 4 columns of height0
surrounded on all sides by columns of height8
;8-0 = 8 -> 4*8
.You can think of it like this: if it rained evenly all over the heightmap, where would water fill and stay?
Terrific kata. Had a blast with it.
Might be a duplicate. Something with rainfall, possibly 1D instead of 2D. If I can find the original, I'll post a link.
There it is: City Swim - 2D (TowerFlood And PlainFlood).
That's 1D instead of 2D ( not including height ), so I guess it's not all that duplicate.
There's also a myjinxin kata linked in the
Discourse
of the other one, which is also 1D instead of 2D and has quite the performance requirement. So also not a duplicate of that.Nice kata - I enjoyed that! Thanks.