<- function(s){
solution <- unlist(strsplit(s, ""))
str_split }
7 Reversed Strings
Tantangan #7/366 - 21 Feb 2024
https://www.codewars.com/kata/5168bb5dfe9a00b126000018
8kyu Reversed Strings
7.1 Instruction
Complete the solution so that it reverses the string passed into it.
'world' => 'dlrow'
'word' => 'drow'
7.2 YouTube Video
7.3 Solution Code
Solusi bar-bar
Solusi simple
<- function(s){
solution paste(rev(unlist(strsplit(s, ""))), collapse = "")
}
7.4 Test
library(testthat)
test_that("example", {
expect_equal(solution('world'), 'dlrow')
expect_equal(solution('hello'), 'olleh')
expect_equal(solution(''), '')
expect_equal(solution('h'), 'h')
})
Test passed 🎉