6 kyu

Encrypt this!

267 of 23,276suic
Description
Loading description...
Fundamentals
Strings
Regular Expressions
Arrays
Ciphers
Algorithms
Cryptography
Security
  • Please sign in or sign up to leave a comment.
  • VladimirBy36 Avatar

    I have been solving this problem for two days. I've tried a lot of options. And yes! It started working in the development environment. And here (For input string: "") Added even a null exception and NOTHING! What did I leave out or is it not a complete description of what should be when entering an empty string.

  • neonvance Avatar

    This comment has been hidden.

  • supersl555 Avatar

    The condition doesn't say anything about changing spaces, it's a little confusing

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • verrakav Avatar

    loved this kata, so much fun <3

  • goyalion17 Avatar

    It was interesting to solve this kata

  • FutureGoose Avatar

    Good difficulty for 6 kyu; highly recommend!

  • Dragic 6 Avatar

    remove the text, "https://www.codewars.com/kata/5848565e273af816fb000449/discuss" at the end of sample test

  • ethanxxxl Avatar

    I am learning Haskell currently, and this was certainly a challenge! I learned a lot about the language from this Kata.

  • avichii Avatar

    I took me few hours, im not going to lie. i took the worst decision by choosing dictionary approach. but i stuck with it for some reason and ultimetly finished the kata. feels good. even tho the time complexity of my code is O(n^2), it doesn't matter ;). thank you for providing this amaizing kata.

  • tolgaersoy Avatar

    I got this. The kata is very nice. I love it.

  • gabrielafh9 Avatar

    This comment has been hidden.

  • monkey_on_a_keyboard_1 Avatar

    This comment has been hidden.

  • KTsonev Avatar

    On the first test "A wise old owl lived in an oak" it's not "65 119esi 111dl 111lw 108dvei 105n 97n 111ka". "lived" is "108devi" not "108dvei" when encrypted

  • zloyded Avatar

    all my tests passed but not accepted '650 119esi 111dl 111lw 108dvei 105n 97n 111ka' should equal '65 119esi 111dl 111lw 108dvei 105n 97n 111ka' or '83Kk 100uLqWP 65pqfADetviVWcrWXKaZ 105AJYCUadf 120m 106ydALFOpBFg 107xEhxdiyTsNYIzRZoGhr 65VNFzQVZTlHxYYj 115JmgMXuhBeTyJJxjo 68avmGgvmYmEaJj 116MM 107OFtcEJGxOINZvhtd 98qaVvs 114HrXUREvAhhFsARS 80HMNZEHHGwjWXLHusv 103gdFCVEU 81ONwZydcxCZSbByFIQM 98pgqgeBuOcPd 102uTaJYKotkVEjWgH 77mO 1010 107JhZFrCBxUIXmJH 1060 82hccrttydtyo 75gjQLKfco 111VHyfzLIeQ 84fLEgNwCw 65SjMweZvCBBIXyug 74NeuUBXjdCTInuFB 73uqXw 77hnjgWssPOwzdkAzjK 121HKtNndIzNFcHjq 80vO 117WtVSRfdCCnBpoHFmIET' should equal '83Kk 100uLqWP 65pqfADetviVWcrWXKaZ 105AJYCUadf 120m 106ydALFOpBFg 107xEhxdiyTsNYIzRZoGhr 65VNFzQVZTlHxYYj 115JmgMXuhBeTyJJxjo 68avmGgvmYmEaJj 116MM 107OFtcEJGxOINZvhtd 98qaVvs 114HrXUREvAhhFsARS 80HMNZEHHGwjWXLHusv 103gdFCVEU 81ONwZydcxCZSbByFIQM 98pgqgeBuOcPd 102uTaJYKotkVEjWgH 77mO 101 107JhZFrCBxUIXmJH 106 82hccrttydtyo 75gjQLKfco 111VHyfzLIeQ 84fLEgNwCw 65SjMweZvCBBIXyug 74NeuUBXjdCTInuFB 73uqXw 77hnjgWssPOwzdkAzjK 121HKtNndIzNFcHjq 80vO 117WtVSRfdCCnBpoHFmIET'

  • pashaOrg Avatar

    learn regex :)))

  • KayleighWasTaken Avatar
  • epicshaner Avatar

    I kinda hate how the solutions are either long and convuluted (like mine) or use a regex to shortcut everything. I do understand that regex is a strong skill to use in C#, but it is difficult to read and may be reducing the core of this challenge.

  • e_zelenkov Avatar

    Sorry, I'm some confused. I have got this result. I don't understand what difference between two string expected '65 119esi 111dl 111lw 108devi 105n 97n 111ka' to equal '65 119esi 111dl 111lw 108dvei 105n 97n 111ka' Can you help me?

  • MammadovAslan Avatar

    I struggled a bit writing code for this kata and not very proud of my solution (47 lines (no regex), gonna spend some time to shorten it), but still enjoyed the process. Nice kata

  • namdoiz Avatar

    this is great practice after "Decipher this!". thank you

  • MFrikken Avatar

    This comment has been hidden.

  • shoplucaaa Avatar

    I just want to say I'm addicted to regex

  • Xe-non Avatar

    My code passed all the conversion test but i keep getting a failed error message. What could be wrong?

  • LotusBastion Avatar

    This comment has been hidden.

  • user1430804 Avatar

    This one was easy.. :)

  • user6800471 Avatar

    In Python, you should import the solution and test framework explicity into Sample Tests

  • Naom-Roads Avatar

    Many of my tests are passing, but I noticed something very strang with the ones that aren't. Without giving too much away, when I convert my first letter into an ascii character there are some words that duplicate the conversion, it looks to happen when the letters are the same and close to each other. e.g that > ttah > 116116ah anyone run into this before, I am completely stumped.

  • 249Ayman  Avatar

    This comment has been hidden.

  • jakelar Avatar

    My results are adding a [] to the end , and then im failing because somehow im returning [ ] a print of my return variable right before the return does not have the [] i dont understand whats happening at all.

  • parsa-fathi Avatar

    This comment has been hidden.

  • Sourdough Avatar

    Damn it made me sweat a bit. But solution was worth it!

  • luki2000 Avatar

    This comment has been hidden.

  • TuCrG123 Avatar

    This comment has been hidden.

  • kshemendr Avatar

    This comment has been hidden.

  • user9644768 Avatar

    Ruby 3.0 should be enabled, see this to learn how to do it

    Please organize the structure of test fixture as following (although it has been mentioned in the attached link, I'm repeated here again)

    describe "<This message should describe the categories of test groups inside this block>" do
      it "<A short message describing this test group>" do
        expect(...).to eq(...) #Assertions
        #Or Test.assert_equals(user_response, reference_response)
      end
    end
    
  • jaypatel9800 Avatar

    This comment has been hidden.

  • ejini战神 Avatar

    Python new test framework should be used and 3.8 enabled

  • imjasonmiller Avatar

    I've forked the Rust translation in order to update it to Rust 1.49 and updated rand::Rng::gen_range to its new signature that takes a std::ops::Range.

    The description now also contains a code block for Rust.

  • prohacker123 Avatar

    This comment has been hidden.

  • nehal9936 Avatar

    This comment has been hidden.

  • mamsaz99@gmail.com Avatar

    This comment has been hidden.

  • DavidFromNorth Avatar

    nice kata, JS done

  • ThisisZak Avatar

    This comment has been hidden.

  • Luksonaッ Avatar

    This comment has been hidden.

  • samrath kumar Avatar

    This comment has been hidden.

  • ealexandrohin Avatar

    Hello. Python. My code passes sample tests or example tests. (If necessary, I can send, but not here.) But, when there is a full test suite, it produces an almost random number of errors, from 25 to 40. Everything is always identical, except for the differences. The differences between my answer and the solution are always the following:

    Answer - 82hbdOh My - 104RbdOh

    Answer - 120YSuUNY My - 89xSuUNY

    Answer - 89rjXpYJBzwwOUnCphr My - 114YjXpYJBzwwOUnCphr

    Here people wrote about double spaces, but this is not a space. And about the fact that always if a word is two letters, then the letters should be interchanged, probably not true, because in the model tests this is not there, in the description either, and in more than half of the full tests there are no errors. I am writing as a last chance. Because I’ve been here for 3 hours on this error. Thanks for everyrhing.

  • medmac01 Avatar

    This comment has been hidden.

  • aravzpatel Avatar

    I'm getting a STDERR main.rb:10:in []=': no implicit conversion of nil into String (TypeError) Question: is there a way to see the test case that it's failing on, so that I can try to fix this?

    Coding in Ruby

  • tangxuguang Avatar

    assert.strictEqual(encryptThis("The more he saw the less he spoke"), "84eh 109ero 104e 115wa 116eh 108sse 104e 115eokp");

    above spoke == 115eokp incorrect

    spoke == 115ekop correct

  • Root-Exec Avatar

    For C Language:

    I'm getting results that I've never seen here before. When it says "expected 65" received "blah blah blah", the kata is telling me I'm getting all of the test cases as a received. My function is returning a run-on combination of all of the strings that are found in the test cases. I'm using calloc for dynamic memory allocation. Is the Kata not wanting us to use malloc/calloc? I've been digging through the test functions and I cannot find how I would be getting this.

  • Alex2295 Avatar

    This comment has been hidden.

  • a-dezh Avatar

    There is in test "The more he saw the less he spoke" double spaces (in JS version).

  • SmilingSumo Avatar

    Please excuse my ignorance but I'm not sure from the below what the [n 97n] part of this expected outcome is actually referring to? I can't think what random input would create this output.

    expected:<...dl 111lw 108dvei 105[n 97n] 111ka>
     but was:<...dl 111lw 108dvei 105[ 97] 111ka>
    
  • WebSamurai Avatar

    ramdom test is failing. can anybody share the input for that random test

  • JDH1101 Avatar

    java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47) at java.base/java.lang.String.charAt(String.java:693) at Kata.encryptThis(Kata.java:13) at TestSuite.fixedTests(TestSuite.java:13) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:40) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80) at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:71) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at io.qualified.junit5.RunTests.main(RunTests.java:25)

    Does anyone know what is the problem with this error statement? The codes passed the Random Test but not the Fixed Test. The codes encrypted all the example provided correctly in JGraps without error. Is there any suggestion?

  • JDH1101 Avatar

    This comment has been hidden.

  • NyuBoy Avatar

    This comment has been hidden.

  • dinglemouse Avatar

    The sample tests in C declare

    int encrypt_this(const char *str);

    Should return char *

  • seger Avatar

    I don't understand if double space is a bug or a feature (Java);

    oxENbHBPzPiZmxzUNY WblByPTlKiVnHXPFL Bi hwocVHPmhrMlN gsCAnDKpVwzDMOfsR umzdS G MORSjhDfZH UiyUwqfzvAVYjJPUHr WPyLMOpGJstkmZcnEDl PAAHVGPkzMGypmEQmCz uvWnHrqcTECb fFnolLCEgNpzyVTDJw   Xz JG  wdvynxIjQ TWRGmizeOaX  CKsmhHSkHKFCQEeyQKP bE KQVDetcsQpVCy lszIYLAoCmKmZaVN  goDTj QCCLjtNz XClUiNwtD RSxRYephe SZG QEhyIJnlyROaLZxCrK AiuK XYXlhwcauc OXzPczhnXaIuIguk ZvBIQCStYkSwJhOtbrn V wfZRoLUznNnLjWLCXVm upDIlVsRGJUWaifeMv igVroSfyMKLMGZlZ YSFdiwrnoTOuAohqa SsmFQlYFlwzNPCW jrxQMcbfKkIK wxZwcRyxkEHiE HZAbzJjwDaeJpw Wav hYYZB BVvPSMb UJ Zs
    

    expected:

    <...02wnolLCEgNpzyVTDJF [  88z 74G  119QvynxIjd 84XRGmizeOaW  67PsmhHSkHKFCQEeyQKK 98E 75yVDetcsQpVCQ 108NzIYLAoCmKmZaVs ] 103jDTo 81zCLjtNC 8...>
    

    but was:

    <...02wnolLCEgNpzyVTDJF [88z 74G 119QvynxIjd 84XRGmizeOaW 67PsmhHSkHKFCQEeyQKK 98E 75yVDetcsQpVCQ 108NzIYLAoCmKmZaVs] 103jDTo 81zCLjtNC 8...>
    
  • hubbldubbl Avatar

    gets the following error message:

    solution.swift:7:26: error: value of type 'Character' has no member 'asciiValue'

    What could be the reason? If I run it locally, it works.

  • Djuliqn Avatar

    expected:<65[ 119esi 111dl 111lw 108dvei 105n 97n 111]ka> but was: <65[ 119esi 111dl 111lw 108dvei 105n 97n 111]ka>

    Can't get it really ? The implementation is on Java... Any suggestions ?

  • stalnox Avatar

    This kata should be 5 kyu if random tests might generate empty strings as random words:

    private def randomWord(): String =
      Random.alphanumeric.filter(_.isLetter).take(Random.nextInt(20)).mkString.toLowerCase
    

    And this would work as expected (no random spaces before/between/after words):

    private def randomWord(): String =
      Random.alphanumeric.filter(_.isLetter).take(Random.nextInt(20) + 1).mkString.toLowerCase
    
  • clcraig Avatar

    Test code for C doesn't provide useful output for errors in the randomized tests. It just tells you that "The expression (as strings) (one) == (two) is false." It's not clear to the user that "one" and "two" are variable names, not the expected and received values. See @Satielo's issue below. The error messaging needs to be reworked.

  • Satielo Avatar

    in the kata encrypt this, with C languaje, theres is a kind of error, because teh kata says, firstable, the first character of each word must be replaced with its ascii code, and in one of the test it shows the next message:

    The expression (as strings) (one) == (two) is false.

    this cant be correct because "t" is not the ascii code for o, and "wo" can not be the reverted position of "ne", i tried to complete the kata, my code passed all the tests, except for this one.

  • user7552630 Avatar

    There are still double spaces in random tests in python version.

  • user3923545 Avatar

    There are spelling mistakes even in the tests. For example "wise" is "119eis" not "119esi" unless you're reversing the letters in the entire string as well, which the instructions don't say.

  • yingyingying Avatar

    This comment has been hidden.

  • Cesar Martinez Avatar

    I do not know what happens with the tests, when I perform my function it does it in the correct way in the way it is in the instructions, but it tells me that it expects another value and it is the sentence with repeat cheracteres. What happen?

  • JessicaSung Avatar

    In Javascript "Run Sample Tests", only the first test runs.

  • midan Avatar

    Shouldn't the fact that the double spaces and the ones at beginning/ end of the string must disappear from the solution? or at least include these examples in the test cases?

  • xavierguihot Avatar

    Scala translation ready for review.

  • Exarillion Avatar

    This comment has been hidden.

  • onurshin Avatar

    This comment has been hidden.

  • anter69 Avatar

    Ruby translation kumited -- please check and approve

  • anter69 Avatar

    You should probably add a test case for an empty string.

  • Blind4Basics Avatar

    why not make the rules a bit more compact?

    The second letter needs to be switched to the last letter
    The last letter needs to be switched to the second letter

    could be The second letter needs to be switched with the last letter only.

  • BigWill Avatar

    The tests can't find the module SimpleEncryption - the default code needs module Kata to be renamed to module SimpleEncryption!

  • JohanWiltink Avatar

    Take a good look at those instructions again.

    What's supposed to happen with the last letter?