<commit_before>package leetcode

/**
 * https://leetcode.com/problems/time-needed-to-buy-tickets/
 */
class Problem2073 {
    fun timeRequiredToBuy(tickets: IntArray, k: Int): Int {
        TODO()
    }
}

fun main() {
    val prob = Problem2073()
    println(prob.timeRequiredToBuy(intArrayOf(2,3,2), 2)) // 6
    println(prob.timeRequiredToBuy(intArrayOf(5,1,1,1), 0)) // 8
    println(prob.timeRequiredToBuy(intArrayOf(6,4,1,2,3), 4)) // 12
    println(prob.timeRequiredToBuy(intArrayOf(6,4,1,2,3), 3)) // 8
    println(prob.timeRequiredToBuy(intArrayOf(6,4,1,2,3), 3)) // 12
    println(prob.timeRequiredToBuy(intArrayOf(6,4,7,8,3), 4)) // 15
    println(prob.timeRequiredToBuy(intArrayOf(6,4,1,1,2,3,3), 6)) // 16
    println(prob.timeRequiredToBuy(intArrayOf(6,4,1,1,2,3,3,7), 6)) // 18
    println(prob.timeRequiredToBuy(intArrayOf(6,4,5,5,5,3,3,7), 6)) // 23
    println(prob.timeRequiredToBuy(intArrayOf(6,4,5,5,5,4,3,7), 6)) // 23
}<commit_msg>Solve problem 2073<commit_after>package leetcode

/**
 * https://leetcode.com/problems/time-needed-to-buy-tickets/
 */
class Problem2073 {
    fun timeRequiredToBuy(tickets: IntArray, k: Int): Int {
        var answer = 0
        while (tickets[k] > 0) {
            for (i in tickets.indices) {
                if (tickets[i] == 0) {
                    continue
                }
                tickets[i]--
                answer++
                if (i == k && tickets[i] == 0) {
                    break
                }
            }
        }
        return answer
    }
}
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.068359375, 'mean_word_length': 2.4308035714285716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '2479306', 'n_tokens_mistral': 644, 'n_tokens_neox': 566, 'n_words': 84}