<commit_before>(ns icfp2015.problem)

(defn lcg [modulus multiplier increment]
  (fn [seed]
    (let [next-item (fn [previous-item] (mod (+ (* multiplier previous-item) increment) modulus))]
      (iterate next-item seed))))

(defn source-sequence [seed]
  (let [raw-seq (lcg (bit-shift-left 1 32) 1103515245 12345)
        truncate-bits (fn [x] (bit-and (bit-shift-right x 16) 0x7FFF))]
    (map truncate-bits (raw-seq seed))))

; a problem is just the parsed representation of the input
; { :id 0
;   :width 10
;   :height 10
;   :sourceSeeds [ 0 17 5235 ]
;   :sourceLength 100
;   :filled [ { :x 5 :y 4 } { :x 6 :y 2 } ]
;   :units [ { :members [ { :x 1 :y 2 } { :x 0 :y 5 } ]
;              :pivot { :x 0 :y 0 } } 
;            { :members [ { :x 0 :y 1 } { :x 5 :y 2 } ]
;              :pivot { :x 0 :y 1 } } ] }
;
; A game looks like this. Notice coordinate pairs are just vectors now
; { :width 10
;   :height 10
;   :problemId 0
;   :seed 17
;   :filled #{ [ 5 4 ] [ 6 2 ] }
;   :units [ { :members #{ [ 1 2 ] [ 0 5 ] }
;              :pivot [ 0 0 ] } ] }
(defn get-games
  "Returns (count (:sourceSeeds problem)) games given a problem."
  [problem]
  (let [n (:sourceLength problem)
        coord-to-vec (fn [{ :keys [x y] }] [x y])
        format-unit (fn [{ :keys [members pivot] }]<commit_msg>cjl - Fix parsing<commit_after>(ns icfp2015.problem)

(defn lcg [modulus multiplier increment]
  (fn [seed]
    (let [next-item (fn [previous-item] (mod (+ (* multiplier previous-item) increment) modulus))]
      (iterate next-item seed))))

(defn source-sequence [seed]
  (let [raw-seq (lcg (bit-shift-left 1 32) 1103515245 12345)
        truncate-bits (fn [x] (bit-and (bit-shift-right x 16) 0x7FFF))]
    (map truncate-bits (raw-seq seed))))

; a problem is just the parsed representation of the input
; { :id 0
;   :width 10
;   :height 10
;   :sourceSeeds [ 0 17 5235 ]
;   :sourceLength 100
;   :filled [ { :x 5 :y 4 } { :x 6 :y 2 } ]
;   :units [ { :members [ { :x 1 :y 2 } { :x 0 :y 5 } ]
;              :pivot { :x 0 :y 0 } } 
;            { :members [ { :x 0 :y 1 } { :x 5 :y 2 } ]
;              :pivot { :x 0 :y 1 } } ] }
;
; A game looks like this. Notice coordinate pairs are just vectors now
; { :width 10
;   :height 10
;   :problemId 0
;   :seed 17
;   :filled #{ [ 5 4 ] [ 6 2 ] }
;   :units [ { :members #{ [ 1 2 ] [ 0 5 ] }
;              :pivot [ 0 0 ] } ] }
(defn get-games
  "Returns (count (:sourceSeeds problem)) games given a problem."
  [problem]
  (let [n (:sourceLength problem)
        coord-to-vec (fn [{ :keys [x y] }] [y x])
        format-unit (fn [{ :keys [members pivot] }]
{'fraction_non_alphanumeric': 0.16794185156847743, 'fraction_numerical': 0.056618209640397855, 'mean_word_length': 2.3568677792041077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '323835', 'n_tokens_mistral': 1124, 'n_tokens_neox': 963, 'n_words': 332}