<commit_before>import math._
import scala.util._
import scala.io._

/**
  * Auto-generated code below aims at helping you parse
  * the standard input according to the problem statement.
  **/
object Solution extends App {
  val encrypt = StdIn.readLine
  //val pattern = """((00 0+ ?)|(0 0+ ?))+""".r
  Console.err.println("encrypt : " + encrypt)
  /*val decoded = encrypt match {
    case pattern(_*) => {*/
  val encryptToArray = encrypt.split(" ")
  val decoded = if (encryptToArray.size % 2 == 0) {
    val encryptToList = encryptToArray.sliding(2, 2).toList
    Console.err.println("encryptToList : " + encryptToList.mkString(" "))
    val binarySequence = encryptToList.foldLeft("") {
      (accumulator, current) => {
        Console.err.println("accumulator : " + accumulator)
        Console.err.println("current : " + current.mkString(";"))
        if (accumulator.equals("INVALID")) {
          "INVALID"
        } else {
          val value = current(0) match {
            case "0" => "1"
            case "00" => "0"
            case _ => "INVALID"
          }
          if (value.equals("INVALID")) {
            "INVALID"
          }
          else {
            accumulator + value * current(1).length
          }
        }
      }
    }
    Console.err.println("binarySequence : " + binarySequence.mkString(""))
    if (!binarySequence.equals("INVALID")) {
      if (binarySequence.length >= 7) {
        binarySequence.sliding(7, 7).map(it => Integer.parseInt(it, 2).toChar.toString).mkString("")
      }
      else {
        "INVALID"
      }
    } else {
      "INVALID"
    }
  } else {
    "INVALID"
  }
  /*}
  case _ => "INVALID"
}*/

  Console.err.println("decoded : " + decoded)
  println(decoded)
}<commit_msg>Solution en Scala au puzzle "community" "<NAME>". Il existe probablement des solutions plus élégantes mais elle a le mérite de fonctionner. Il était intéressant d'essayer d'utiliser le foldLeft.<commit_after>import scala.io._

object Solution extends App {
  val InvalidInput = "INVALID"
  val encrypt = StdIn.readLine
  Console.err.println("Given input string : " + encrypt)
  val encryptToArray = encrypt.split(" ")
  val decoded = if (!encrypt.isEmpty && encryptToArray.size % 2 == 0) {
    val encryptToList = encryptToArray.sliding(2, 2).toList
    val binarySequence = encryptToList.foldLeft("") {
      (accumulator, current) => {
        if (accumulator.equals(InvalidInput)) {
          InvalidInput
        } else {
          current(0) match {
            case "0" => accumulator + "1" * current(1).length
            case "00" => accumulator + "0" * current(1).length
            case "" => InvalidInput
            case _ => InvalidInput
          }
        }
      }
    }
    if (!binarySequence.equals(InvalidInput) && (binarySequence.length >= 7) && (binarySequence.length % 7 == 0)) {
      binarySequence.sliding(7, 7).map(it => Integer.parseInt(it, 2).toChar.toString).mkString("")
    } else {
      InvalidInput
    }
  } else {
    InvalidInput
  }
  println(decoded)
}
{'fraction_non_alphanumeric': 0.1418673705047839, 'fraction_numerical': 0.012537116463213462, 'mean_word_length': 2.433748584371461, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 19, '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': '5398167', 'n_tokens_mistral': 963, 'n_tokens_neox': 913, 'n_words': 211}