<commit_before>package katas.kotlin.leetcode.zigzag

import kotlincommon.test.shouldEqual
import org.junit.Test

class ZigZag {
    @Test fun `zigzag first column`() {
        "ABC".zigzag() shouldEqual "ABC"
    }

    @Test fun `zigzag one cycle`() {
        // A
        // B D
        // C
        "ABCD".zigzag() shouldEqual "ABDC"
    }

    @Test fun `zigzag two cycles`() {
        // A   E
        // B D F
        // C
        "ABCDEF".zigzag() shouldEqual "AEBDFC"
    }
}

private fun String.zigzag(): String {
    return listOf(listOf(0), listOf(1, 3), listOf(2)).joinToString("") { indices ->
        mapIndexedNotNull { i, c ->
            if (indices.any { i % 4 == it }) c else null
        }.joinToString("")
    }
}
<commit_msg>zigzag<commit_after>package katas.kotlin.leetcode.zigzag

import kotlincommon.test.shouldEqual
import org.junit.Test

class ZigZag {
    @Test fun `zigzag first column`() {
        "ABC".zigzag() shouldEqual "ABC"
    }

    @Test fun `zigzag one cycle`() {
        // A
        // B D
        // C
        "ABCD".zigzag() shouldEqual "ABDC"
    }

    @Test fun `zigzag two cycles`() {
        // A   E
        // B D F H
        // C   G
        "ABCDEFGH".zigzag() shouldEqual "AEBDFHCG"
    }
}

private fun String.zigzag(): String {
    return listOf(listOf(0), listOf(1, 3), listOf(2)).joinToString("") { indices ->
        mapIndexedNotNull { i, c ->
            if (indices.any { i % 4 == it }) c else null
        }.joinToString("")
    }
}

{'fraction_non_alphanumeric': 0.14696058784235136, 'fraction_numerical': 0.006680026720106881, 'mean_word_length': 1.8974854932301741, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '669253', 'n_tokens_mistral': 550, 'n_tokens_neox': 512, 'n_words': 130}