Skip to content

Instantly share code, notes, and snippets.

@newjam
Created February 7, 2019 03:38
Show Gist options
  • Save newjam/d4b35c013c56f44400d573afb3ae3819 to your computer and use it in GitHub Desktop.
Save newjam/d4b35c013c56f44400d573afb3ae3819 to your computer and use it in GitHub Desktop.
; https://leetcode.com/problems/3sum-closest/
(declare-const a Int)
(declare-const b Int)
(declare-const c Int)
(assert (or (= a -1) (= a 2) (= a 1) (= a -4)))
(assert (or (= b -1) (= b 2) (= b 1) (= b -4)))
(assert (or (= c -1) (= c 2) (= c 1) (= c -4)))
(assert (< a b))
(assert (< b c))
(declare-const target Int)
(assert (= target 1))
(declare-const total Int)
(assert (= total (+ a b c)))
(minimize (abs (- target total)))
(check-sat)
(get-model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment