<commit_before>(* Specialized bonus problem solver. *)
structure Bonus =
struct
  open BV;
  infixr 0 $
  fun f $ x = f x

  fun findPairs [] = []
    | findPairs (x::L) =
    let
      fun outerLoop curThing [] curAcc = curAcc
        | outerLoop curthing (L as (x::xs)) curAcc = 
          let
            fun inner (t, acc) = if BitVec.orFills(curThing, t) then 
                (curThing, t)::acc
              else acc
            val newAcc = foldr inner curAcc L
          in
            outerLoop x xs newAcc
          end
    in
      outerLoop x L []
    end

  val minsize = 5 (* Believed minimum size of f, g, or h. *)

  fun solve 0 _ = raise Fail "Minsize became too min. We suck. :("
    | solve minsize (spec: Solver.spec) : unit =
    let
      val ops = #ops spec
      val _ = Assert.assert "not a bonus prob" $ List.exists (fn x => x = O_Bonus) ops
      val _ = Assert.assert "minsize way too big" $ minsize < 10

      (**** Reason about sizes of f, g, and h. ****)

      val fgh_size = #size spec - 4 (* lambda + ifz + and + 1 *)
      val _ = Assert.assert "size too small" $ fgh_size >= 3
      (* ???? should never be lower *)
      val minsize =
        let val x = fgh_size div 3 in if x < minsize then x else minsize end
      val maxsize = fgh_size - (2 * minsize) (* e,g, 18 = 5 5 and 8 *)
      (* If g is size x what's the biggest h can be, assuming f is minsize? *)
      fun other_size x = fgh_size-x-minsize<commit_msg>chriiiiiist. r=burningman<commit_after>(* Specialized bonus problem solver. *)
structure Bonus =
struct
  open BV;
  infixr 0 $
  fun f $ x = f x

  fun findPairs [] = []
    | findPairs (x::L) =
    let
      fun outerLoop curThing [] curAcc = curAcc
        | outerLoop curThing (L as (x::xs)) curAcc = 
          let
            fun inner (t, acc) = if BitVec.orFills(curThing, t) then 
                (curThing, t)::acc
              else acc
            val newAcc = foldr inner curAcc L
          in
            outerLoop x xs newAcc
          end
    in
      outerLoop x L []
    end

  val minsize = 5 (* Believed minimum size of f, g, or h. *)

  fun solve 0 _ = raise Fail "Minsize became too min. We suck. :("
    | solve minsize (spec: Solver.spec) : unit =
    let
      val ops = #ops spec
      val _ = Assert.assert "not a bonus prob" $ List.exists (fn x => x = O_Bonus) ops
      val _ = Assert.assert "minsize way too big" $ minsize < 10

      (**** Reason about sizes of f, g, and h. ****)

      val fgh_size = #size spec - 4 (* lambda + ifz + and + 1 *)
      val _ = Assert.assert "size too small" $ fgh_size >= 3
      (* ???? should never be lower *)
      val minsize =
        let val x = fgh_size div 3 in if x < minsize then x else minsize end
      val maxsize = fgh_size - (2 * minsize) (* e,g, 18 = 5 5 and 8 *)
      (* If g is size x what's the biggest h can be, assuming f is minsize? *)
      fun other_size x = fgh_size-x-minsize
{'fraction_non_alphanumeric': 0.106703146374829, 'fraction_numerical': 0.010259917920656635, 'mean_word_length': 1.9104477611940298, 'pattern_counts': {'":': 0, '<': 7, '<?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': '58630', 'n_tokens_mistral': 1036, 'n_tokens_neox': 963, 'n_words': 380}