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.
The compensation is the sum of all grains on the board; not just the grains in the last square.
You're right; there's no question it should be
what_note
. I went ahead and fixed it myself. Better to do it now. Fixing it broke the solutions that have passed already, though, so you will have to update yours.I fixed the "octaves" thing too while I was at it.
Fixed
The initial solution's method name is in snake case (
what_note
), but the default and kata test cases expectwhatnote
. I think it would be better to use snake case. I didn't change it myself because it would break the solutions up to this point, but if you agree, there are only a couple of solutions so it's not too late to change it.letter
is sometimesundefined
in the random tests. In the test cases,Math.random()*27
needs to beMath.random()*26
(alpha
is not defined at index 26).Great opportunity to put
switch(true)
to work.I like this kata. I suggest a couple of things:
Speed is supplied as two instantaneous values, so an assumption has to be made about how to determine the average speed beteween the two instances. It seems that the intended assumption is that speed will increase linearly between the two, as the test cases expect that if instance #1 is 0 mph and instance #2 is 100 mph, the average speed between them is 50 mph. I think this could use clarification in the description.
Also, I think the test cases should check that subsequent calls (third, fourth, etc.) continue to work as expected. Or, if the intention is to only measure between two instances, it should test that the solution resets after working for the first pair, and that should be mentioned in the description.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Could you make this a translation of this kata?
Yes, it is for the sake of the inject. If
d1
is the first digit ofid
, after themap.with_index
step it looks like:[d1 * 7, -d2, d3 * 7, -d4, d5 * 7, -d6, d7 * 7, -d8]
Add it all up and factor out the 7 and it looks like:
(d1 + d3 + d5 + d7) * 7 - d2 - d4 - d6 - d8
.This takes care of the instruction to "Take the sum of 1st, 3rd, 5th, 7th and 9th digit and multiply it by 7. Then subtract the sum of 2nd, 4th, 6th and 8th digits from this value." It would probably read more clearly if
id
was first partitioned into even/odd indices and both were manipulated separately, but the end result is the same.This kata by BattleRattle is essentially identical to this one and does have a JS translation, but not a Ruby translation, so translating this one into JS might be introducing a duplicate. Always appreciative of your contributions to CW, I just remembered this and thought I would give you a heads up.
All better.
In the description, it says
If there is a tie in improvements then order by name.
In the above examples, where there is a tie, my solution puts the names in order by the first letter of the name field (or more letters as necessary). For instance, in the first example, where all of the improvements are0
,{"name":"leroy, plum","improvement":0}
should be last if we sort by that method, because the first letter of the name (l
) comes after the first letter of all the other names alphabetically. Hypothetically, we could be sorting by the second name, but in that caseleroy, plum
would be second to last, andfrog, cow
would be first. Same goes for the improvements of-100
, I would think thatfreeman, Act
should precedegod, cow
.There is an issue with sorting in the random tests. From expected results:
{"name":"leroy, plum","improvement":0},{"name":"blop, King","improvement":0},{"name":"frog, cow","improvement":0},{"name":"jeff, willow","improvement":0}
{"name":"god, cow","improvement":-100},{"name":"freeman, Act","improvement":-100},{"name":"whimpy, brown","improvement":-100}
Loading more items...