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.
RISC-V Translation
I suppose a slightly more detailed explanation is in order. Neither of the two changes the resulting binary at all; it's purely an aesthetic concern.
For the
and
/andi
one, yes the assembler is being permissive here.For the
li
one...The compressed instruction extension has 16-bit versions of
c.mv
andc.li
. However, the source ofc.mv
cannot bex0
/zero
. The assembler here helpfully transformsmv a0, 0
intoaddi a0, zero, 0
then intoc.li a0, 0
, but I'd wantli
here to remind us that this is closer to how the instruction gets encoded.I was not careful enough to distinguish between
and
andandi
, but it seems that the RISC-V assembler was generous enough to fix them for me :)I thought
mv
is pseudoinstruction that used widely...Approved
Nothing really I'd say is wrong here, but some nitpicks:
and t0, a0, 3
andand t0, t0, 3
:and -> andi
mv a0, zero -> li a0, 0
(twice)Fork with some improvements: https://www.codewars.com/kumite/654780f41498050b75cec0f4?sel=654780f41498050b75cec0f4
Improves feedback of failed random tests.
RISC-V translation
This is my first translate submission. Please review carefully. Thanks.
Thanks, very nice solution. I struggled with this one with overflow problems and finally got it working but with not nearly as elegant a solution as this.
Very clever!
added
Suggestion :: Add
"tetrafluoromethane" = {'C': 1, 'F': 4}
as fixed test.This test makes sure that non-exist element should be removed from result.
I made a quick fix to remove those 0 values. The tests are still generating the invalid inputs but at least the output is well formed now. I'll close this issue because it's basically the very same as the one below now.
Cheers
I'll have to rebuild those tests... yeah, ethenyne isn't possible. It shuldn't be generated at all by the tests.
During random test, I got following error ::
I'm not going to argue whether we can call "C2" as "ethenyne".
However, it is very weird that removing non-existent element from result causes errors.
If we should output "ethenyne" as
{'H': 0, 'C': 2}
, why not{'H': 0, 'C': 2, 'O': 0, 'N': 0, 'Cl': 0, 'F': 0, ......}
?Loading more items...