7 kyu

Do you speak retsec?

556 of 2,823rrolt
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • Jomopipi Avatar

    ceni taka, odgo boj!

  • anter69 Avatar

    Python translation kumited -- please check and approve

  • anter69 Avatar
    • add more random tests
    • seems too easy for 6 kyu
    • FArekkusu Avatar

      Now you can do it yourself ;)

    • Blind4Basics Avatar

      I agree, this should rather be around 7 kyu (if not lower)

    • anter69 Avatar

      Increased the number of random tests in Ruby and JS (no idea about Haskell :-)

      Re-ranked to 7 kyu

      Suggestion marked resolved by anter69 7 years ago
    • Voile Avatar

      QuickCheck executes 100 tests for each property by default. If you want to specify the number of tests for a specific property, you need to replace property with quickCheckWith stdArgs { maxSuccess = t } where t is the number of random tests.

    • JohanWiltink Avatar

      But doing that means tests will never fail anymore. They'll only be logged to the console as failing ( you may have to unfold the test above to see that ), but the actual test will pass regardless. ( Yes, I'd like to know what I might have been doing wrong. )

  • bkaes Avatar

    Haskell translation kumited. I could have sworn I've already translated this kata, sorry.

  • wthit56 Avatar

    A great kata. Good job. I would suggest a tweak to the existing diagrams (the X one is just plain confusing ;P)

    secret
    ^^^===
    ===vvv
    retsec
    
    agent
    ^^ ==
    == vv
    nteag
    

    Not 100% sure this is any better, but worth a try... ;P

  • bkaes Avatar

    I think the description is currently misleading:

    Reverse the given string by its center. If a center character exists, reverse the string around it.

    That's not really reversing. That's reordering chunks. How about the following description?

    Do you talk retsec?

    You and your friends want to play undercover agents. In order to exchange your secret messages, you've come up with the following system: you take the word, cut it in half, and place the first half behind the latter. If the word has an uneven number of characters, you leave the middle at its previous place:

    secret
    |||
    ||+-----+
    |+++++++|
    +-----+||
          |||
       retsec
    
    agent
    \\|//
     \|/
     /|\
    //|\\
    nteag
    

    That way, you'll be able to exchange your messages in private.

    Task

    You're given a single word. Your task is to swap the halves. If the word has an uneven length, leave the character in the middle at that position and swap the chunks around it.

    Examples

    reverseByCenter("house") == "seuho" // center character is u
    reverseByCenter("agent") == "nteag" // center character is e
    
    reverseByCenter("blue")    == "uebl"   // no center character
    reverseByCenter("secret")  == "retsec" // no center character
    
    reverse_by_center("house") == "seuho" # center character is u
    reverse_by_center("agent") == "nteag" # center character is e
    
    reverse_by_center("blue")    == "uebl"   # no center character
    reverse_by_center("secret")  == "retsec" # no center character
    

    Remarks

    Don't use this to actually exchange messages in private.

    If you want to use this description, you can copy the following markdown:

    # Do you talk retsec?
    You and your friends want to play undercover agents. In order to exchange your *secret* messages, you've come up with the following system: you take the word, cut it in half, and place the first half behind the latter. If the word has an uneven number of characters, you leave the middle at its previous place:
    
        secret
        |||
        ||+-----+
        |+++++++|
        +-----+||
              |||
           retsec
           
        agent
        \\|//
         \|/
         /|\
        //|\\
        nteag
    
    That way, you'll be able to exchange your messages in private.
    
    # Task
    You're given a single word. Your task is to swap the halves. If the word has an uneven length, leave the character in the middle at that position and swap the chunks around it.
    
    ## Examples
    ```javascript
    reverseByCenter("house") == "seuho" // center character is u
    reverseByCenter("agent") == "nteag" // center character is e
    
    reverseByCenter("blue")    == "uebl"   // no center character
    reverseByCenter("secret")  == "retsec" // no center character
    ```
    ```ruby
    reverse_by_center("house") == "seuho" # center character is u
    reverse_by_center("agent") == "nteag" # center character is e
    
    reverse_by_center("blue")    == "uebl"   # no center character
    reverse_by_center("secret")  == "retsec" # no center character
    ```
    
    ## Remarks
    Don't use this to actually exchange messages in private.
    
    • bkaes Avatar

      Sometimes, I think my comments are way to long compared to others. Sorry.

    • rrolt Avatar

      Thanks for the developped description, it is actually pretty fun compared to my basic one. I just used your if you don't mind, I also changed the title with your.

    • bkaes Avatar

      I just used your if you don't mind, I also changed the title with your.

      Given a little bit more time and consideration, I think "Do you speak retsec" makes more sense, as in "Do you speak English/German/Italian/French/…?". But I leave that decision to you. If you're happy with the description, mark this suggestion as resolved by adding a comment and checking the box at "Mark suggestion as resolved".

    • rrolt Avatar

      Right'o.

      Suggestion marked resolved by rrolt 10 years ago
  • oldccoder Avatar

    I am unclear as to what you mean. Can you provide some examples?

    "Reverse the given string by its center. If a center character exists, reverse the string around it."

    • ZozoFouchtra Avatar

      Examples yet provided :

      reverse_by_center("house") == "seuho" # center character is u

      "house" == "ho" + "u" (the 'center') + "se" -> "se"+"u"+"ho" -> "seuho"

      reverse_by_center("blue") == "uebl" # no center character

      "blue" == "bl" + "ue" (no center char.) -> "ue" + "bl" -> "uebl"

      Is it clear enough now ?

    • oldccoder Avatar

      Crystal! Thanks.

  • ZozoFouchtra Avatar

    JS translation kumited. (Description modified : JS example added)

  • ZozoFouchtra Avatar

    This comment has been hidden.