Kata of the Day #14

Sort and Star

kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
kata
Kata of the Day #14

You will be given a list of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value.

The returned value must be a string, and have "***" between each of its letters.

You should not remove or add elements from/to the array.

TypeScript


function twoSort(s: string[]): string {
    return s.sort()[0].split('').join('***');
}

console.log(twoSort(['banana','apple']));

Go


package main

import (
    "fmt"
    "sort"
    "strings"
)

func twoSort(s []string) string {
    sort.Strings(s)
    return strings.Join(strings.Split(s[0], ""), "***")
}

func main() {
    fmt.Println(twoSort([]string{"banana", "apple"}))
}

Python


def two_sort(array):
    return '***'.join(min(array))

print(two_sort(['banana','apple']))

PHP


function twoSort($s) {
    sort($s);
    return implode('***', str_split($s[0]));
}

echo twoSort(['banana','apple']);

Go to Kata
ByJulie Kohl

Need some help?

Want us to give you some help with your business? No problem, here's a video on who we can help, and how, along with our calendar so you can book in a call to discuss us working together.

Let's see
budget
budget
budget
budget
budget
budget
budget
budget
budget
budget

Subscribe to our newsletter

subscribe
subscribe
subscribe
subscribe
subscribe
subscribe
subscribe
subscribe
subscribe
subscribe