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

Share

Need a budget?

Let's talk
budget
budget
budget
budget
budget
budget
budget
budget
budget
budget