Mini Kanren and the Da Vinci Quest, part II
Today the second symbol puzzle in the Da Vinci Quest was revealed. The puzzle was of the same type as described in Mini Kanren and the Da Vinci Quest - the only twist was that the board was enlarged to 5x5. The modified program for the puzzle, I got, is:
(define distinct
(lambda (x1 x2 x3 x4 x5)
(let ([xs (list x1 x2 x3 x4 x5)])
(all
(membero 'omega xs)
(membero 'blade xs)
(membero 'gcross xs)
(membero 'fleur xs)
(membero 'cross xs)))))
(run* (b)
(fresh ( x1 x2 x3 x4 x5
x6 x7 x8 x9 x10
x11 x12 x13 x14 x15
x16 x17 x18 x19 x20
x21 x22 x23 x24 x25)
(alli
; the board consists of fields fields
(== b (list (list x1 x2 x3 x4 x5)
(list x6 x7 x8 x9 x10)
(list x11 x12 x13 x14 x15)
(list x16 x17 x18 x19 x20)
(list x21 x22 x23 x24 x25)))
; known symbols
(== b (list (list x1 'gcross x3 'fleur x5)
(list x6 x7 'cross 'blade x10)
(list x11 'omega x13 x14 'cross)
(list x16 x17 'fleur x19 x20)
(list x21 'cross x23 x24 x25)))
; symbols in rows are distinct
(distinct x1 x2 x3 x4 x5)
(distinct x6 x7 x8 x9 x10)
(distinct x11 x12 x13 x14 x15)
(distinct x16 x17 x18 x19 x20)
(distinct x21 x22 x23 x24 x25)
; symbols in columns are distinct
(distinct x1 x6 x11 x16 x21)
(distinct x2 x7 x12 x17 x22)
(distinct x3 x8 x13 x18 x23)
(distinct x4 x9 x14 x19 x24)
(distinct x5 x10 x15 x20 x25)
; symbols in each colored area are distinct
(distinct x1 x2 x7 x12 x13)
(distinct x3 x8 x4 x5 x10)
(distinct x6 x11 x16 x21 x22)
(distinct x17 x18 x19 x23 x24))))
0 Comments:
Post a Comment
<< Home