4 kyu

BasE91 encoding & decoding

188 of 498user7657844
Description
Loading description...
Algorithms
View
AllIssues8Questions3Suggestions7Show Resolved
  • Please sign in or sign up to leave a comment.
  • swallowstalker Avatar

    This comment has been hidden.

  • Panenojeli Avatar

    Bad kata. We have none of instructions in description. Like already said in comments, if you are good searcher on web you will find what you need to do..

  • RileyHunter Avatar

    Shame to see the feedback in the other comments unaddressed. Not a good kata, not much more to add.

  • syeo66 Avatar

    Holy cow. This looks like a terrible kata. No description. No information about the algorithm available. Only possible sources are code. And as it seems since many years... Should be retired.

  • andreengels Avatar

    Really? We are supposed to implement an encoding but are not told how that encoding works?

  • TheTales Avatar

    I don't get how to decode or encode this! The instructions are not clear!

  • philemmons Avatar

    Are the expected and actual backwards?

  • philemmons Avatar

    This comment has been hidden.

  • McKael Avatar

    The Go translation seems wrong: the apostrophe (') is used instead of the quote character (").

  • challisa Avatar

    Spent a few hours trying to figure out what I am doing wrong. Simple tests work but random tests I fail about 20. Heres an example:

    s = """<txG@<^F#H~H8MxsCYDpde4_SW"yER~]JwO_!g|OcxW$1^:KNRedl$r6l/:=JsiD+[R]bKVws=Op!v"?%9|Tn<7@,{q;r>d:sZH)"""
    b91encode(s) # => _4J>StI@i5oLyF.Th)8=+!tB9!#/`l$e$+Kz<}c6~%DsV@(rcJJ>yZ=?Y3JU@7bjoME3J<b5*KN.6xTP6zT1B1Zpc%nVRQxp1|+Zh|4@53bA$j]nazsFGp.6&5U
    # It should be:   _4J>StI@i5oLyF.Th)8=+!tB9!#/`l$e$+Kz<}c6~%DsV@(rcJJ>yZ=?Y3JU@7bjoME3J<b5*KN.6xTP6zT1B1Zpc%nVRQxp1|+Zh|4@53d">!|$7+)vwUl:>cK
    

    It seems to be the same bug... I am not making my solution using bit shifts as I want to understand it first... Any suggestions would be great!

  • ___i Avatar

    Can someone kindly add JS translation ?

  • gopheratl Avatar

    Hrmph. Solving in go.

    My solution is passing the sample tests, but when I Attempt, it's erroring with this:

    codewarrior/kata_test
    ./kata_test.go:67: Sprintf format %s has arg r() of wrong type int64
    

    since my code never calls Sprintf or uses an int64, I'm fairly sure the problem isn't in my code - but 7 people have completed the kata in go, so I'm not entirely sure what to think.

    :edit: updating after digging about, this error is coming from vet, which is apparently being called on the solution before running it, and which detects this sort of issue, among other things, that the compiler doesn't normally look for.

    So, either in the update today or at some other point in the last 6 months, solutions started to be vetted.

  • samscudder Avatar

    The instructions are somewhat confusing.

    I had trouble finding reference material, and only by reading pre-existing source code did I figure out that I was reading the characters in the wrong direction, and you need to pull the 13/14 bits from the least significant bits, not quite how I understand Base64 works.

    For example: 'H','e' in binary is 01001000 01100101... The first 13 bits would be 0100100001100 which encodes to "pZ". The algorithm to produce a result that starts with ">O" needs the byte order to be reversed to 01100101 01001000 and taking the 13 rightmost bits: 0010101001000 or 78d 14d.

    Biggest issue is that the random tests are not random, just testing against a sequence of "%s".

    Sad to see that most of the solutions are copies of Joachim Henke's C# source code from Codeplex. Some just changed the variable names he used (b, n, v) to more meaningful ones (queue, bits, val); some just changed from string to stringbuilder; some just added a completely superfluous "and 255" operation to an array of bytes...

    This is more an exercise of research skills than coding skills.

  • yanykin Avatar

    Hello everyone!

    I found some strange issue while testing BasE91 encoding/decoding on the site https://www.dcode.fr/base-91-encoding.

    Suppose you have aligned 13-byte input string (such length is chosen because no zero bit will be added while breaking to 13-bit blocks) encode('1234567890123') == 'QztEml0o[2;(8YAS'

    My intuition says that if you replace only one character in the input, the encoded BasE91 result will also differ only in few symbols. The results on the site supports my hypothesis:

    encode('A234567890123') == 'gztEml0o[2;(8YAS'

    encode('1234567_90123') == 'QztEml0o)9;(8YAS'

    encode('12345678901*3') == 'QztEml0o[2;(8Y"R'

    The same thing occurs if you use grave accent (backtick) symbol:

    encode('1234567`90123') == 'QztEml0o[2;(8Y"R'

    But if you place backtick into the second position in the input string, you'll get a wierd result: encode('1`34567890123') == 'z"Yv$Sb%ob^heMAJ'

    It also appears for longer inputs, e.g.: encode('Baby, did you forget to take your meds?') == 'xDOfZfTXwSztI_apVR/2).&Y$F)&nuYiWPgZk>;N%y60PmcW'

    Backtick is in the first place: encode('`aby, did you forget to take your meds?') == '?DOfZfTXwSztI_apVR/2).&Y$F)&nuYiWPgZk>;N%y60PmcW' Backtick is in the third place: encode('Ba`y, did you forget to take your meds?') == 'xD~eZfTXwSztI_apVR/2).&Y$F)&nuYiWPgZk>;N%y60PmcW'

    But the second: encode('B`by, did you forget to take your meds?') == ')"0P6P3LYJ,WF|6U51kbiki5=Cj>TXN!509MSn_zgZe,HTOL'

    It seems that BasE91 implementation on that site doesn't work properly :/

  • MMMAAANNN Avatar

    I found this description of the encoding/decoding algo, hope it helps: https://www.dcode.fr/base-91-encoding

    It is really a bad idea to publish a kata like this without any hints of how the encoding works. As some people mentioned below, it is actually easier to find a working code than the specification when you force users research the algorithm themselves.

    Can anybody of the editors update the description with some specification for this encoding?

  • RobAnthony01 Avatar

    This comment has been hidden.

  • ice1000 Avatar
  • sfoulk Avatar

    Hmm. Needs 4 things - instructions, and C, C++, and JavaScript versions.

  • lechevalier Avatar

    Link down, no instruction to do this kata.

  • AzariasB Avatar

    Java translation, in the exemple test cases, the assertEquals are in the wrong order, it should be assertEquals(<expected>,<actual>).

  • scates Avatar

    The linked documentation was far from sufficient. I ended up having to read the source code to figure out how the encoding actually works. Once I had read the source code, the Kata was not nearly as interesting.

    I think this would be a really good Kata if the instructions included a full specification of basE91 encoding.

  • ice1000 Avatar

    Please review and approve my translations :D

  • ice1000 Avatar
  • Blind4Basics Avatar

    Description is far from sufficient... Unless the process is perfectly equivalent to base64 encoding? (if so, a link toward the other kata would be the minimum to add, I believe!)

  • Voile Avatar

    Approved

    (People ranked it purple for some reasons. Don't ask me why ¯\_(ツ)_/¯)

  • TinoC Avatar

    This comment has been hidden.

  • siebenschlaefer Avatar

    This comment has been hidden.