/**
 * Given a string and a segment length, split the string into segments of the given length.
 *
 * @param string The input string.
 * @param segmentLength The desired length of each segment.
 * @return A list of segments.
 *
 * Example:
 * splitStringIntoSegments("historian", 3) -> ["his", "tor", "ian"]
 */
fun splitStringIntoSegments(string: String, segmentLength: Int): List<String> {

    return (0 until string.length step segmentLength).map { string.substring(it, minOf(it + segmentLength, string.length)) }
}
/**
 * Given a string and a segment length, split the string into segments of the given length.
 *
 * @param string The input string.
 * @param segmentLength The desired length of each segment.
 * @return A list of segments.
 *
 * Example:
 * splitStringIntoSegments("historian", 3) -> ["his", "tor", "ian"]
 */
fun splitStringIntoSegments(string: String, segmentLength: Int): List<String> {
/**
 * Given a string and a segment length, split the string into segments of the given length.
 *
 * @param string The input string.
 * @param segmentLength The desired length of each segment.
 * @return A list of segments.
 *
 * Example:
 * splitStringIntoSegments("historian", 3) -> ["his", "tor", "ian"]
 */
fun splitStringIntoSegments(string: String, segmentLength: Int): List<String> {

    return (0 until string.length step segmentLength).map { string.substring(it, minOf(it + segmentLength, string.length)) }
}