6 kyu

Error Correction Codes

73 of 100mathsisfun
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • ahmet_popaj Avatar

    Pretty interesting programming concept, very funny.

  • docgunthrop Avatar

    JavaScript translation awaiting approval.

  • Blind4Basics Avatar

    you should add to the description the equivalent linear string, used as input (below the second grid)

  • docgunthrop Avatar

    Here's one of the sample tests: correct(2,3,'11011000001') === '11011000011'

    Laid out, it looks like:

    1 1 0
    1 1 0
    0 0 0
    1 1  <-- why are these 1?
    

    Shouldn't the last row consist of just 0s since the number of 1s in each column is even?

    • mathsisfun Avatar

      I recently had to change how I did it to resolve one of the issues raised, so the examples now look like: Test.assert_equals(correct(2,3,'11111010001'), '11111010001') Test.assert_equals(correct(2,3,'11011010001'), '11111010001') Test.assert_equals(correct(2,3,'11111011001'), '11111010001') Test.assert_equals(correct(2,3,'11111010011'), '11111010001') So it is '111110' + '10'(rows) + '001'(cols). laid out it looks like: 111 1 110 0 00 1 I think your looking at the previous versions of the examples, which made sense then because I was doing columns and rows the wrong way around.

    • docgunthrop Avatar

      Marking question resolved.

      Question marked resolved by docgunthrop 6 years ago
  • Blind4Basics Avatar

    seems like your random tests almost never swap one of the parity bits => you'll need to make those two cases much more current (for now, changes in the message and no changes at all represent like 95% of the whole batches of tests).

    • mathsisfun Avatar

      I've added another batch of random tests that only modify the parity bits. Does that work?

      Issue marked resolved by mathsisfun 6 years ago
    • Blind4Basics Avatar

      almost: the problem is that you announce to the user where the error will be ;)

      => you need to merge the 3 batches and pick randomly a strategy when you do one test. (note: is that necessary to do that many tests?)

    • mathsisfun Avatar

      I've changed it so that for the random cases, it randomly decides to either do no errors (20%), a message error (40%), or a parity error (40%), and have combined the larger and smaller tests into one batch.

      I mostly am doing many tests because an answer which is almost correct might only fail in a small number of cases, and I wouldn't want slightly wrong answers to pass just because the case where they fail didn't come up in the testing.

  • Voile Avatar

    I think you have your m and n flipped through out the entire kata:

    In this system, a message is arrayed out on a M x N grid. A 24-bit message could be put on a 6x4 grid like so:

    1 0 1 0 0 1
    1 0 0 1 0 0
    0 1 1 1 0 1
    1 0 0 0 0 1

    In the standard terminology for matrices, M x N means M rows and N columns, not the opposite. See https://en.wikipedia.org/wiki/Matrix_(mathematics)