7 kyu
Quadrants 2: Segments
217 of 892EntityPlantt
Loading description...
Fundamentals
Mathematics
Geometry
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.
I recommend adding more unit testing.
JS && TS: function name should be
quadrantSegment
This comment has been hidden.
incredible work
Thanks
Hi,
this sentence has to be changed. It's currently meaningless => replace
; except that
with just:
cheers
It reads expect, not except
oh... oops... 'x)
( JS )
Where is that array suddenly coming from? This is not a correct encoding of the arguments. Again, confusing for people who read it, and they may be beginners.
I may need some more advice: how to label a segment?
A segment is defined by two
Coord
Object
s, which JS itself shows asCoord { x: $X, y: $Y }
( each ).But it is entirely possible to ignore the whole
Coord
thing and just treat the arguments as genericObject
s, so{ x: $X, y: $Y }
is also perfectly appropriate.I'm not entirely sure JS will show objects correctly ( might show
"[object Object]"
or"[object Coord]"
); test and applyJSON.stringify
as necessary.But I made a
toString()
method to show them as (x
,y
)That hides all relevant internals. :[ Is that appropriate for 7 kyu solvers? Would they expect that?
I changed it to show
A: {a}, B: {b}
instead of[{a}, {b}]
( JS )
Example tests use a wrapper which does not use its first argument. This is confusing for people who read the tests, esp. in a 7kyu kata. Don't be afraid of a little code duplication in example tests, and don't do things that only matter in submit tests.
Duplicated some code, and I think it's done!
Python translation: https://www.codewars.com/kumite/64410b8d772f278a4fddf695?sel=64410b8d772f278a4fddf695
Seems very nice. Thank you!
C Translation
This comment has been hidden.
Added. Forgot to make it resovled 😁
This comment has been hidden.
Oh, I don't know how to use the
<random>
header...Generally the random inputs generation is somewhat clunky, because insteat of generating numbers from range
-n...n
it generates values from range0...2n
only to subtractn
from the generated value.Additionally, definition of
rand_gen
seems off, because it reseeds the generator constantly, and I think that even worse, it reseeds it with a fixed value, effectively making tests non-random (but id have to check docs to confirm).I think I pasted a link to docs somewhere which shows an example? I can also explain over Discord when I'm back to my machine sometime later.
Solved! I learnt from
<random>
- cplusplus.comJavascript: now that console logs are gone, you should add an error message to the assertion:
Nice! Thank you!
Done!
C++ version:
"solution.cpp:1:6: runtime error: execution reached the end of a value-returning function without returning a value"
error from the initial solution setup (ideally, add something likereturn true;
to solution setup).random
torand/srand
.vector
,array
rand
,cout
are missing.Describe
struct, or local in theIt
method.See this article for some ideas about authoring C++ kata: https://docs.codewars.com/languages/cpp/authoring
Done:
Describe
structrandom
instead ofrand
To do: None, everything done!
Done everything!
Instead of adding sections for each language in the description, I suggest to make a language agnostic (pseudo code) section in the description and add the real preloaded code as comments in the solution setup. This makes translating AND maintaining the kata bearable.
Nice idea! I'm going to first solve the issues and the I'll make the pseudo-code
if language specific stuff is absolutely needed, use language/conditional blocks, so that only the info specific to the user's language are visible (see docs)
Nice, thanks. But are conditional blocks built with "~" or "`"?
Done!
javascript: don't use console log in test cases, instead put that info in the "it" block
Deleted
console.log
! It was useless anyway, left it while debuggingjavascript: no sample tests
Added sample tests!
Fixing it ASAP
coord
parameter in the samples toconst coord&
int
iterator tosize_t