Ad
  • Custom User Avatar

    Then if you had a very short message such as "A"(.-) or "I"(..) how can it be possible to discriminate between these two messages, when a . and - can be almost exactly the same length??

  • Default User Avatar

    Hi, now I see that you didn't get any answer.

    (1) listOf(...).map { ... }.joinToString(...)

    is equal

    (2) listOf(...).joinToString(...) { ... }

    Intelij simplifying (1) into (2) automatically.

  • Custom User Avatar

    The option is available in traning setup.

  • Default User Avatar

    Privacy. It is not relevant to this example, but it would be a good choice if the programmer did not want the sub-function to be scoped outside of the current function.

  • Custom User Avatar

    Yes, in this particular kata it can happen that 5 is a very long dot and 6 is a very short dash.

  • Custom User Avatar

    Thank you for the reply, I appreciate the feedback :)

    I understand the implication re a given length having a consistent value throughout a stream (eg if length 5 ), but the bit I quoted seems to imply that a dot can be length 5 at the same time as a dash can be length six, in the same stream?

    Are you saying that's not the case, that dot.length==5; dash.length==6 don't occur simultaneously?

  • Custom User Avatar

    The part of the description you're quoting as about a different thing.
    It says that if somewhere in the message 11111 means a dot, then everywhere in that message where 11111 is encountered, it would mean a dot, and the same is true for any other sequence.
    In other words, different number of 1s can mean a dot, but if something is a dot it's a dot, never dash, and vice versa.

  • Custom User Avatar

    "Consistency means that if in the beginning of a message '11111' is a dot and '111111' is a dash, then the same is true everywhere in that message."

    Would these series be distinguishable then:

    1. short=5, long=6: ".-" -> "1111100000111111"
    2. short=5.5: ".." -> "1111100000111111" [extra "1" through variance]
  • Custom User Avatar

    Thank you for that, thought I was going nuts :)

  • Custom User Avatar

    That input is for 3 different tests, the first two expect "E" and the last one expects "I", 101 at a slower speed: 110011.

  • Custom User Avatar

    I passed the sample test but failed when I attempt. To try and debug I'm printing out the bits to console from decodeBits, and this one has me stumped:

    Bits :
    111
    1111111
    110011

    Error:
    expected:<[I]> but was:<[E]>

    I am not seeing how that is supposed to be an "I" which translates to ".." (Morse) or an extrapolation of "101" in binary...which is what the last line is but what about the two lines of 1's above that? Thanks

  • Custom User Avatar

    The old //, never fail.

  • Custom User Avatar

    Is there a good reason to create the sub-function:

    val getJustIntOrRegister = {key: String -> 
            key.toIntOrNull() ?: registers.getOrDefault(key, 0)
        }
    

    rather than:

    fun getJustIntOrRegister(key: String) = key.toIntOrNull() ?: registers.getOrDefault(key, 0)
    
  • Custom User Avatar

    The first case should be "-3--1" instead, so no, no ambiguity.

  • Custom User Avatar

    Seems like an ambiguity in requirment? Quoted example:

    solution([-6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20]);
    // returns "-6,-3-1,3-5,7-11,14,15,17-20"

    Implies:
    (-3, -2, -1) -> "-3-1"
    (-3, -2, -1, 0, 1) -> "-3-1"

  • Loading more items...