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.
This comment is hidden because it contains spoiler information about the solution
Oh, I see. That's right.
But the description says "Output: A list of strings representing "suspicious" apartments in the format room number based on the criteria outlined below, ordered by ascending room number."
At least two neighbouring apartments toggled lights four or more times during the night(4C and 4E), while the occupant(4D) of the apartment in question wasn't consistently in sight that night.
Bur for choosing 4D as suspicious, the two neighbours (in this case 4E and 4C) don't have to be suspicious. They just need to toggle lights at least 4 times. The occupant refers to 4D, not to 4E and 4C.
I am not sure I used 'visible' correctly there, because you are right, 'visible' means 'occupant present'.
But 4D is suspicious in your example because:
and
4E is not always visible. Iniitally is 3 (ligths on), then comes 2 (ligths off) -> 3 (lights on) - > 2 (ligths off) -> 3 (ligths on). So you get 4D because of 4C and 4E.
The occupant of 4D should not always be visible. In your example: 4D is suspicious because 4E and 4C toggle ligths at least 4 times and the occupant of 4D is not visible at the starting point (initially 4D is 0, so lights off, no person).
@SpandexTiger, I just solved it and I also found it hard to understand for a couple of hours. But reading some of the first comments from this kata (between Blind4Basics and Johan) should help you understand how to calculate the oddness (without those comments I wouldn't have been able to complete it xD).
Approved as 6 kyu.
Approved as 5 kyu (average voted rank). :)
Yep, I think now it's definitely clear. Thanks. :)
The way I read it initially was that I should count the toggles in the neighbour apartment only if in that particular moment the occupant is not there.
So like, checking if B2 is suspicious: (B1 0), (B1 1) -> I count these toggles. Now if (B2 3) comes, someone is there in B2, so if after that (B1 0) comes, I thought I should ignore this toggle, until B2 becomes 0 or 1, so until the person leaves. I thought this because of the "while the occupant wasn't consistently visible". I understood that this is not the case from the tests. It's much more, "if there is at least one moment in the entire night when the occupant leaves/is not seen". But it could be my bad english that didn't help to understand it better. :DNice kata! :D At first the last condition was a bit difficult to understand, but the examples helped a lot. Really a new and nice idea, it was fun. :)
Description should specify the formula used for golden ratio, or at least remove the 1.618 part, since one may think that that's the used value for this particular kata.
Am I missing something?
0.9999709702062644 should be close to 0.9999789937973299 with absolute or relative margin of 1e-090.6180290297937356 should be close to 0.6180210062026701 with absolute or relative margin of 1e-09
1.1755432033417759 should be close to 1.175545810312674 with absolute or relative margin of 1e-09
0.6180110885384781 should be close to 0.6180080239281595 with absolute or relative margin of 1e-09
Loading more items...