exupero's blog
RSSApps

Automating stack algorithm searches

(def factor-highest-power-of-10
  (reify RewriteRule
    (length [_] 2)
    (replacement [_ [x op]]
      (when (and (number? x) ('#{* /} op))
        (let [p (Math/floor (Math/log10 x))
              [d] (->> (range p 0 -1)
                    (map #(Math/pow 10 %))
                    (filter #(zero? (mod x %))))]
          [(clojure.core// x d) op d op])))))
(def merge-constants
  (let [math-ops '{+ +
                   - -
                   * clojure.core/*
                   / clojure.core//}]
    (reify RewriteRule
      (length [_] 3)
      (replacement [_ [a b c]]
        (cond
          (and (number? a) (number? b) (math-ops c))
          , (let [f (eval (math-ops c))]
              [(f a b)])
          (and (number? a) (= 'dup b) (math-ops c))
          , (let [f (eval (math-ops c))]
              [(f a a)]))))))
(def simplifications
  [factor-highest-power-of-10
   merge-constants
   (pattern '[?x * ?x /] [])
   (pattern '[?x / ?x *] [])
   (pattern '[?x ?x /] [1])
   (pattern '[?x * *] '[* ?x *])
   (pattern '[1 *] [])
   (pattern '[1 /] [])
   (pattern '[9 *] '[dup 10 / - 10 *])
   (pattern '[25 * *] '[100 * 4 /])
   (pattern '[5 *] '[10 * 2 /])])
(def rewrite-rules
  [factor
   expand
   factor-gcd
   (pattern '[?x * ?y *] '[?y * ?x *])
   (pattern '[?x / ?y *] '[?y * ?x /])
   (pattern '[?x * ?y /] '[?y / ?x *])
   (pattern '[?x ?y * *] '[?y ?x * *])
   (pattern '[?x ?y ?z * +] '[?x ?y * ?x ?z * +])
   (pattern '[?x ?y + *] '[dup [?x *] dip ?y * +])
   (pattern '[?x ?x] '[?x dup])])
(defn difficulty [stack ops]
  {:length (length-difficulty ops)
   :nesting (nesting-difficulty ops)
   :stack-size (stack-size-difficulty stack ops)
   :multiplier-and-divisor (multiplier-and-divisor-difficulty stack ops)})
(defn rewrite [ops rule]
  (let [len (length rule)]
    (sequence
      (comp
        (map-indexed
          (fn [i ops-window]
            [i (replacement rule ops-window)]))
        (filter second)
        (map (fn [[i r]]
               (splice ops i (+ i len) r))))
      (partition len 1 ops))))
(defn simplify [ops]
  (rewrites ops simplifications))
(defn search [ops depth]
  (loop [opss [ops]
         depth depth
         res #{ops}]
    (if (pos? depth)
      (let [opss' (mapcat (fn [ops]
                            (mapcat #(simplify (rewrite ops %)) rewrite-rules))
                          opss)]
        (recur opss' (dec depth) (into res opss')))
      res)))
(sort-by first
  (mapv
    (juxt #(reduce + (vals (difficulty [1] (eval %))))
          #(difficulty [1] (eval %))
          identity)
    (search '[3600 *] 5)))
([8
  {:length 2, :nesting 0, :stack-size 2, :multiplier-and-divisor 4}
  [3600 *]]
 [11
  {:length 4, :nesting 0, :stack-size 3, :multiplier-and-divisor 4}
  [1800 2 * *]]
 [11
  {:length 4, :nesting 0, :stack-size 3, :multiplier-and-divisor 4}
  [3000 600 + *]]
 [13
  {:length 6, :nesting 0, :stack-size 3, :multiplier-and-divisor 4}
  [1000 800 + 2 * *]]
 [15
  {:length 4, :nesting 0, :stack-size 3, :multiplier-and-divisor 8}
  [2 1800 * *]]
 [16
  {:length 6, :nesting 0, :stack-size 3, :multiplier-and-divisor 7}
  [2 2 * 900 * *]]
 [16
  {:length 6, :nesting 0, :stack-size 3, :multiplier-and-divisor 7}
  [5 1 + 600 * *]]
 [16
  {:length 6, :nesting 0, :stack-size 3, :multiplier-and-divisor 7}
  [2 dup * 900 * *]]
 [16
  {:length 6, :nesting 0, :stack-size 3, :multiplier-and-divisor 7}
  [2 900 * 2 * *]]
 [17
  {:length 6, :nesting 0, :stack-size 4, :multiplier-and-divisor 7}
  [3000 2 300 * + *]]
 [17
  {:length 6, :nesting 0, :stack-size 3, :multiplier-and-divisor 8}
  [2 1500 * 600 + *]]
 [18
  {:length 8, :nesting 0, :stack-size 3, :multiplier-and-divisor 7}
  [2 500 * 800 + 2 * *]]
 [18
  {:length 6, :nesting 0, :stack-size 4, :multiplier-and-divisor 8}
  [2 1000 800 + * *]]
 [18
  {:length 8, :nesting 0, :stack-size 3, :multiplier-and-divisor 7}
  [5 4 + 2 * 200 * *]]
 [18
  {:length 8, :nesting 0, :stack-size 3, :multiplier-and-divisor 7}
  [5 4 + 200 * 2 * *]]
 [18
  {:length 6, :nesting 0, :stack-size 4, :multiplier-and-divisor 8}
  [2 900 2 * * *]]
 [19
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 7}
  [2 450 2 * * 2 * *]]
 [19
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 7}
  [1000 2 400 * + 2 * *]]
 [19
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 7}
  [5 1 + 300 2 * * *]]
 [19
  {:length 7, :nesting 2, :stack-size 3, :multiplier-and-divisor 7}
  [dup [3000 *] dip 600 * +]]
 [20
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 7}
  [3000 2 150 2 * * + *]]
 [20
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 8}
  [2 750 2 * * 600 + *]]
 [20
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 8}
  [2 1000 500 + * 600 + *]]
 [21
  {:length 6, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 2 900 * * *]]
 [21
  {:length 6, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 dup 900 * * *]]
 [21
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 7}
  [5 4 + 2 100 * * 2 * *]]
 [21
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 7}
  [5 2 2 * + 200 * 2 * *]]
 [21
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 9}
  [3000 2 * 3000 300 * + *]]
 [22
  {:length 9, :nesting 2, :stack-size 4, :multiplier-and-divisor 7}
  [2 dup [1000 *] dip 800 * + *]]
 [22
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 8}
  [2 700 50 + 2 * * 600 + *]]
 [22
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 10}
  [2 2 * 2 450 * * *]]
 [22
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 10}
  [5 1 + 2 300 * * *]]
 [22
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 10}
  [2 2 450 * * 2 * *]]
 [22
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 7}
  [3000 2 100 50 + 2 * * + *]]
 [22
  {:length 9, :nesting 2, :stack-size 4, :multiplier-and-divisor 7}
  [dup [3000 *] dip 300 2 * * +]]
 [22
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 10}
  [2 dup 450 * * 2 * *]]
 [23
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 9}
  [1000 2 * 1000 400 * + 2 * *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 2 500 * 800 + * *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 1500 * 2 300 * + *]]
 [23
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 10}
  [3000 2 2 150 * * + *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 2 2 * 450 * * *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 2 450 * 2 * * *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 dup 750 * * 600 + *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 5 4 + 200 * * *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 dup 500 * 800 + * *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 2 750 * * 600 + *]]
 [23
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 10}
  [3000 2 dup 150 * * + *]]
 [23
  {:length 8, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 dup 450 * 2 * * *]]
 [24
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 10}
  [2 500 * 2 400 * + 2 * *]]
 [24
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 10}
  [2 2 250 * * 800 + 2 * *]]
 [24
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 10}
  [5 1 + 2 150 * 2 * * *]]
 [24
  {:length 11, :nesting 2, :stack-size 4, :multiplier-and-divisor 7}
  [2 dup [1000 *] dip 500 * + 600 + *]]
 [24
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 9}
  [3000 2 2 75 * 2 * * + *]]
 [24
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 1000 2 400 * + * *]]
 [24
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 2 450 2 * * * *]]
 [24
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 dup 450 2 * * * *]]
 [24
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 9}
  [3000 2 * 3000 150 2 * * + *]]
 [25
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 2 375 * 2 * * 600 + *]]
 [25
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 750 2 * * 2 300 * + *]]
 [25
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 2 1 + 500 * * 600 + *]]
 [25
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 10}
  [5 1 + 2 150 2 * * * *]]
 [25
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 1000 500 + * 2 300 * + *]]
 [25
  {:length 11, :nesting 2, :stack-size 5, :multiplier-and-divisor 7}
  [2 dup [1000 *] dip 400 2 * * + *]]
 [25
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 dup 500 * 500 + * 600 + *]]
 [25
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 dup 1 + 500 * * 600 + *]]
 [25
  {:length 9, :nesting 2, :stack-size 4, :multiplier-and-divisor 10}
  [dup [3000 *] dip 2 300 * * +]]
 [25
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 11}
  [2 2 500 * 500 + * 600 + *]]
 [25
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 10}
  [2 2 400 50 + * * 2 * *]]
 [25
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 10}
  [1000 2 2 200 * * + 2 * *]]
 [26
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 10}
  [3000 2 2 75 2 * * * + *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 2 250 2 * * 800 + * *]]
 [26
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 10}
  [3000 2 2 100 50 + * * + *]]
 [26
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 10}
  [3000 2 dup 100 50 + * * + *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 5 4 + 100 2 * * * *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 5 4 + 2 100 * * * *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 5 2 dup * + 200 * * *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 2 375 2 * * * 600 + *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 1500 * 2 150 2 * * + *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 2 400 50 + * 2 * * *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 1000 2 250 * + * 600 + *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 2 400 50 + 2 * * * *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 5 2 2 * + 200 * * *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 2 700 50 + * * 600 + *]]
 [26
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 dup 700 50 + * * 600 + *]]
 [27
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 12}
  [3000 2 * 3000 2 150 * * + *]]
 [27
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 13}
  [3000 2 * 2 300 * 1500 * + *]]
 [27
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 2 450 * * * *]]
 [27
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 13}
  [2 2 * 1500 * 3000 300 * + *]]
 [27
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 13}
  [2 1500 * 2 * 3000 300 * + *]]
 [27
  {:length 11, :nesting 2, :stack-size 4, :multiplier-and-divisor 10}
  [dup [3000 *] dip 2 150 * 2 * * +]]
 [27
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 dup dup 450 * * * *]]
 [27
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 dup 2 450 * * * *]]
 [27
  {:length 8, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 dup 450 * * * *]]
 [27
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 13}
  [3000 2 * 2 1500 * 300 * + *]]
 [27
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 11}
  [2 1000 2 200 2 * * + * *]]
 [28
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 5 2 2 * + 2 100 * * * *]]
 [28
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 14}
  [2 2 750 * * 2 300 * + *]]
 [28
  {:length 10, :nesting 0, :stack-size 4, :multiplier-and-divisor 14}
  [2 dup 750 * * 2 300 * + *]]
 [28
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 13}
  [5 1 + 2 2 150 * * * *]]
 [28
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 13}
  [5 1 + 2 dup 150 * * * *]]
 [28
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 13}
  [2 2 2 225 * * * 2 * *]]
 [28
  {:length 11, :nesting 2, :stack-size 5, :multiplier-and-divisor 10}
  [dup [3000 *] dip 2 150 2 * * * +]]
 [28
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 12}
  [3000 2 2 2 75 * * * + *]]
 [28
  {:length 11, :nesting 2, :stack-size 5, :multiplier-and-divisor 10}
  [2 dup [1000 *] dip 2 400 * * + *]]
 [28
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 12}
  [3000 2 dup 2 75 * * * + *]]
 [28
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 11}
  [2 5 2 * 5 2 * + 200 * * *]]
 [28
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 12}
  [3000 2 2 dup 75 * * * + *]]
 [29
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 11}
  [2 1000 2 200 50 + * + * 600 + *]]
 [29
  {:length 13, :nesting 2, :stack-size 4, :multiplier-and-divisor 10}
  [2 dup [1000 *] dip 500 * + 2 300 * + *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 2 375 * * * 600 + *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 1500 * 2 2 150 * * + *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 dup 500 * 2 400 * + * *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 dup 375 * * * 600 + *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 2 225 * 2 * * * *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 dup 250 * * 800 + * *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 2 225 * * 2 * * *]]
 [29
  {:length 12, :nesting 0, :stack-size 4, :multiplier-and-divisor 13}
  [2 1000 500 + * 2 * 3000 300 * + *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 500 * 2 400 * + * *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 dup 2 375 * * * 600 + *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 1500 * 2 dup 150 * * + *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 dup 2 250 * * 800 + * *]]
 [29
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 2 250 * * 800 + * *]]
 [30
  {:length 13, :nesting 2, :stack-size 5, :multiplier-and-divisor 10}
  [2 dup [1000 *] dip 2 250 * * + 600 + *]]
 [30
  {:length 13, :nesting 2, :stack-size 6, :multiplier-and-divisor 9}
  [3000 2 2 dup [100 *] dip 50 * + * + *]]
 [30
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 13}
  [2 2 14 1 + 50 * * * 600 + *]]
 [30
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 dup 2 400 50 + * * * *]]
 [30
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 12}
  [3000 2 2 2 1 + 50 * * * + *]]
 [30
  {:length 12, :nesting 0, :stack-size 4, :multiplier-and-divisor 14}
  [2 2 500 * 500 + * 2 300 * + *]]
 [30
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 1000 2 dup 200 * * + * *]]
 [30
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 12}
  [3000 2 2 2 50 * 50 + * * + *]]
 [30
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 2 2 400 50 + * * * *]]
 [30
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 13}
  [3000 2 * 2 1000 500 + * 300 * + *]]
 [30
  {:length 12, :nesting 0, :stack-size 4, :multiplier-and-divisor 14}
  [2 2 1 + 500 * * 2 300 * + *]]
 [30
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 2 dup 400 50 + * * * *]]
 [30
  {:length 10, :nesting 0, :stack-size 5, :multiplier-and-divisor 15}
  [2 1000 2 * 1000 400 * + * *]]
 [30
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 12}
  [3000 2 * 3000 2 100 50 + * * + *]]
 [30
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 2 2 225 2 * * * * *]]
 [30
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 1000 2 2 200 * * + * *]]
 [31
  {:length 11, :nesting 2, :stack-size 5, :multiplier-and-divisor 13}
  [dup [3000 *] dip 2 dup 150 * * * +]]
 [31
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 2 350 * 50 + * * 600 + *]]
 [31
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 13}
  [2 5 4 + 2 2 50 * * * * *]]
 [31
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 1 + 2 250 * * * 600 + *]]
 [31
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 1000 500 + * 2 2 150 * * + *]]
 [31
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 500 * 2 250 * + * 600 + *]]
 [31
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 2 250 * * 500 + * 600 + *]]
 [31
  {:length 11, :nesting 2, :stack-size 5, :multiplier-and-divisor 13}
  [dup [3000 *] dip 2 2 150 * * * +]]
 [31
  {:length 12, :nesting 0, :stack-size 7, :multiplier-and-divisor 12}
  [3000 2 2 100 2 25 * + * * + *]]
 [31
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 2 700 50 + * * 2 300 * + *]]
 [31
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 13}
  [5 1 + 2 2 100 50 + * * * *]]
 [31
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 14}
  [2 1000 2 250 * + * 2 300 * + *]]
 [31
  {:length 12, :nesting 0, :stack-size 7, :multiplier-and-divisor 12}
  [3000 2 2 2 70 5 + * * * + *]]
 [31
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 13}
  [2 2 700 2 25 * + * * 600 + *]]
 [32
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 15}
  [2 1000 2 * 1000 250 * + * 600 + *]]
 [32
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 2 2 200 50 + * * 800 + * *]]
 [32
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [3000 2 * 3000 2 2 75 * * * + *]]
 [32
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 1000 2 2 125 * * + * 600 + *]]
 [32
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 2 2 300 75 + * * * 600 + *]]
 [32
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 14}
  [2 1500 * 2 2 100 50 + * * + *]]
 [32
  {:length 12, :nesting 0, :stack-size 4, :multiplier-and-divisor 16}
  [2 2 750 * * 2 * 3000 300 * + *]]
 [33
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 17}
  [2 dup 2 2 225 * * * * *]]
 [33
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 15}
  [5 1 + 2 2 2 75 * * * * *]]
 [33
  {:length 12, :nesting 0, :stack-size 7, :multiplier-and-divisor 14}
  [3000 2 2 2 3 25 * * * * + *]]
 [33
  {:length 12, :nesting 0, :stack-size 4, :multiplier-and-divisor 17}
  [2 1500 * 2 * 2 1500 * 300 * + *]]
 [33
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 17}
  [2 2 dup 2 225 * * * * *]]
 [33
  {:length 13, :nesting 2, :stack-size 5, :multiplier-and-divisor 13}
  [2 2 dup [700 *] dip 50 * + * 600 + *]]
 [33
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 16}
  [2 1500 * 2 * 3000 2 150 * * + *]]
 [33
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 16}
  [3000 2 * 2 2 750 * * 300 * + *]]
 [33
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 16}
  [3000 2 * 2 1500 * 2 150 * * + *]]
 [33
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 17}
  [2 2 2 2 225 * * * * *]]
 [33
  {:length 10, :nesting 0, :stack-size 6, :multiplier-and-divisor 17}
  [2 2 2 dup 225 * * * * *]]
 [33
  {:length 12, :nesting 0, :stack-size 7, :multiplier-and-divisor 14}
  [2 1000 2 2 2 100 * * * + * *]]
 [34
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 17}
  [2 2 750 * * 2 2 150 * * + *]]
 [34
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 17}
  [2 2 2 250 * * 2 400 * + * *]]
 [34
  {:length 13, :nesting 2, :stack-size 6, :multiplier-and-divisor 13}
  [2 dup [1000 *] dip 2 2 200 * * * + *]]
 [34
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 17}
  [2 2 2 375 * * * 2 300 * + *]]
 [34
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 16}
  [2 1500 * 2 2 2 75 * * * + *]]
 [34
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 16}
  [2 2 2 8 1 + 50 * * * * *]]
 [34
  {:length 13, :nesting 2, :stack-size 6, :multiplier-and-divisor 13}
  [dup [3000 *] dip 2 2 100 50 + * * * +]]
 [35
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 17}
  [2 2 2 3 125 * * * * 600 + *]]
 [35
  {:length 12, :nesting 0, :stack-size 7, :multiplier-and-divisor 16}
  [2 2 2 400 2 25 * + * * * *]]
 [35
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 18}
  [2 2 500 * 2 * 1000 400 * + * *]]
 [35
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 17}
  [2 2 2 2 200 * 50 + * * * *]]
 [35
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 17}
  [2 2 2 2 125 * * * 800 + * *]]
 [35
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 17}
  [2 2 500 * 2 2 200 * * + * *]]
 [35
  {:length 12, :nesting 0, :stack-size 5, :multiplier-and-divisor 18}
  [2 1000 2 * 2 500 * 400 * + * *]]
 [36
  {:length 12, :nesting 0, :stack-size 7, :multiplier-and-divisor 17}
  [2 2 2 2 200 25 + * * * * *]]
 [36
  {:length 12, :nesting 0, :stack-size 6, :multiplier-and-divisor 18}
  [2 1000 2 * 1000 2 200 * * + * *]]
 [36
  {:length 13, :nesting 2, :stack-size 6, :multiplier-and-divisor 15}
  [dup [3000 *] dip 2 2 2 75 * * * * +]]
 [37
  {:length 13, :nesting 2, :stack-size 6, :multiplier-and-divisor 16}
  [2 2 2 dup [400 *] dip 50 * + * * *]]
 [38
  {:length 12, :nesting 0, :stack-size 7, :multiplier-and-divisor 19}
  [2 2 2 2 3 75 * * * * * *]])