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??
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.
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?
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.
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
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??
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.
The option is available in traning setup.
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.
Yes, in this particular kata it can happen that 5 is a very long dot and 6 is a very short dash.
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?
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 where11111
is encountered, it would mean a dot, and the same is true for any other sequence.In other words, different number of
1
s can mean a dot, but if something is a dot it's a dot, never dash, and vice versa."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:
Thank you for that, thought I was going nuts :)
That input is for 3 different tests, the first two expect "E" and the last one expects "I", 101 at a slower speed: 110011.
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
The old //, never fail.
Is there a good reason to create the sub-function:
rather than:
The first case should be
"-3--1"
instead, so no, no ambiguity.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...