Ad

Now the Test Cases can detect if you displayed the correct thing!

Code
Diff
  • //// Created by RHB
    // Your code here
    const hello=()=>{
      console.log("Hello, World!")
    }
    • ## Created by RHB
    • # Your code here
    • [print(chr(i),end="") for i in [100, 108, 114, 111, 87, 32, 111, 108, 108, 101, 72][::-1]]
    • //// Created by RHB
    • // Your code here
    • const hello=()=>{
    • console.log("Hello, World!")
    • }
Fundamentals
Strings
Code
Diff
  • reverse_string = lambda n: n[::-1]
    • reverse_string = lambda n: ''.join(reversed(n))
    • reverse_string = lambda n: n[::-1]

Add a given separator to a string at every n characters. When n is negative or equal to zero then return the orginal string.

but now in python

Code
Diff
  • def insert_separator(seperator, after_every_x_chars, into_string):
        if after_every_x_chars <= 0:
            return into_string
        
        output = ""
        for index, c in enumerate(into_string):
            if index % after_every_x_chars == 0 and index > 0:
                output += seperator
            output += c
        
        return output
    
    • func insert(seperator: String, afterEveryXChars: Int, intoString: String) -> String {
    • guard afterEveryXChars > 0 else { return intoString }
    • var output = ""
    • intoString.enumerated().forEach { index, c in
    • if index % afterEveryXChars == 0 && index > 0 {
    • def insert_separator(seperator, after_every_x_chars, into_string):
    • if after_every_x_chars <= 0:
    • return into_string
    • output = ""
    • for index, c in enumerate(into_string):
    • if index % after_every_x_chars == 0 and index > 0:
    • output += seperator
    • }
    • output.append(c)
    • }
    • output += c
    • return output
    • }
Fundamentals
Strings

short and simple

Code
Diff
  • reverse_string = lambda s: s[::-1]
    • def reverse_string(s):q=list(s);q.reverse();return ''.join(q)
    • reverse_string = lambda s: s[::-1]