title: Minimum Sum Subsequence Least One Every Four Consecutive Elements Picked 1
signature: fun minimumSumSubsequenceLeastOneEveryFourConsecutiveElementsPicked1(ar: ArrayList<Int>, n: Int): Int {
source_py: def minimum_sum_subsequence_least_one_every_four_consecutive_elements_picked_1(ar, n):
      if (n <= 4):
          return min(ar)
      sum = [0 for i in range(n)]
      sum[0] = ar[0]
      sum[1] = ar[1]
      sum[2] = ar[2]
      sum[3] = ar[3]
      for i in range(4, n):
          sum[i] = (ar[i] + min(sum[(i - 4):i]))
      return min(sum[(n - 4):n])
source_cpp: int minimum_sum_subsequence_least_one_every_four_consecutive_elements_picked_1(vector<int> ar, int n) {
    if ( n <= 4 ) return * min_element(ar.begin(), ar.end());
    int sum [ n ];
    sum [ 0 ] = ar [ 0 ];
    sum [ 1 ] = ar [ 1 ];
    sum [ 2 ] = ar [ 2 ];
    sum [ 3 ] = ar [ 3 ];
    for ( int i = 4;
    i < n;
    i ++ ) sum [ i ] = ar [ i ] + ( * min_element ( sum + i - 4, sum + i ) );
    return * min_element ( sum + n - 4, sum + n );
  }
question_info.test_list: [{"idx": 0, "outputs": 188, "inputs": {"ar": [4, 4, 9, 26, 31, 31, 33, 35, 40, 45, 48, 52, 57, 60, 69, 75, 82, 89, 90, 92, 95, 97], "n": 19}}, {"idx": 1, "outputs": -76, "inputs": {"ar": [60, -68, 30, -62, -8, 48, -20, 30, 16, -60, -20], "n": 5}}, {"idx": 2, "outputs": 6, "inputs": {"ar": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 43}}, {"idx": 3, "outputs": 48, "inputs": {"ar": [15, 70, 50, 28, 67, 11, 27, 42, 1, 61, 37, 8, 66, 54, 50, 91, 86, 57, 4], "n": 15}}, {"idx": 4, "outputs": -366, "inputs": {"ar": [-98, -92, -84, -80, -70, -58, -58, -48, -42, -14, -8, 24, 30, 32, 42, 62, 68, 70, 72, 88], "n": 16}}, {"idx": 5, "outputs": 1, "inputs": {"ar": [1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0], "n": 7}}, {"idx": 6, "outputs": 61, "inputs": {"ar": [4, 5, 5, 10, 12, 13, 16, 19, 19, 21, 22, 25, 26, 29, 30, 33, 34, 44, 46, 52, 55, 55, 56, 78, 86, 88, 88, 90, 92], "n": 16}}, {"idx": 7, "outputs": -474, "inputs": {"ar": [40, -50, -96, 78, 82, -16, 26, 8, 38, 38, 54, -24, 88, 96, -42, -84, -28, -32, -64, 74, 74, -10, -8, 66, 14, -78, 56, -22, -90, 66, -68], "n": 26}}, {"idx": 8, "outputs": 0, "inputs": {"ar": [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], "n": 7}}, {"idx": 9, "outputs": 36, "inputs": {"ar": [29, 38, 20, 25, 16, 97, 16, 90, 30, 99], "n": 9}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(ar: ArrayList<Int>, n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(ar, n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(4, 4, 9, 26, 31, 31, 33, 35, 40, 45, 48, 52, 57, 60, 69, 75, 82, 89, 90, 92, 95, 97), 19, 188)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(60, -68, 30, -62, -8, 48, -20, 30, 16, -60, -20), 5, -76)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 43, 6)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(15, 70, 50, 28, 67, 11, 27, 42, 1, 61, 37, 8, 66, 54, 50, 91, 86, 57, 4), 15, 48)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-98, -92, -84, -80, -70, -58, -58, -48, -42, -14, -8, 24, 30, 32, 42, 62, 68, 70, 72, 88), 16, -366)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0), 7, 1)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(4, 5, 5, 10, 12, 13, 16, 19, 19, 21, 22, 25, 26, 29, 30, 33, 34, 44, 46, 52, 55, 55, 56, 78, 86, 88, 88, 90, 92), 16, 61)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(40, -50, -96, 78, 82, -16, 26, 8, 38, 38, 54, -24, 88, 96, -42, -84, -28, -32, -64, 74, 74, -10, -8, 66, 14, -78, 56, -22, -90, 66, -68), 26, -474)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), 7, 0)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(29, 38, 20, 25, 16, 97, 16, 90, 30, 99), 9, 36)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: minimumSumSubsequenceLeastOneEveryFourConsecutiveElementsPicked1
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn