-> Output
Input "8 j 8 mBliB8g imjB8B8 jl B" -> "8j8mBliB8gimjB8B8jlB"
"8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd" -> "88Bifk8hB8BB8BBBB888chl8BhBfd"
"8aaaaa dddd r " -> "8aaaaaddddr"
15 Remove String Spaces
8kyu Tantangan #15/366 - 29 Feb 2024
https://www.codewars.com/kata/57eae20f5500ad98e50002c5
15.1 Instruction
Write a function that removes the spaces from the string, then return the resultant string.
Examples:
15.2 YouTube Video
15.3 Solution Code
<- function(x){
no_space gsub(" ", "", x)
}
15.4 Test
library(testthat)
test_that('Basic tests', {
expect_equal(no_space('8 j 8 mBliB8g imjB8B8 jl B'), '8j8mBliB8gimjB8B8jlB')
expect_equal(no_space('8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd'), '88Bifk8hB8BB8BBBB888chl8BhBfd')
expect_equal(no_space('8aaaaa dddd r '), '8aaaaaddddr')
expect_equal(no_space('jfBm gk lf8hg 88lbe8 '), 'jfBmgklf8hg88lbe8')
expect_equal(no_space('8j aam'), '8jaam')
})
Test passed 🥇