47 lines
1.4 KiB
Text
47 lines
1.4 KiB
Text
[([Int] -> Bool)] predicates
|
||
predicates [+]= st -> st.len == 12
|
||
predicates [+]= st -> sum(st[(len)-6 ..]) == 3
|
||
predicates [+]= st -> sum(st[(1..).step(2)]) == 2
|
||
predicates [+]= st -> I st[4] {(st[5] [&] st[6])} E 1
|
||
predicates [+]= st -> sum(st[1.<4]) == 0
|
||
predicates [+]= st -> sum(st[(0..).step(2)]) == 4
|
||
predicates [+]= st -> sum(st[1.<3]) == 1
|
||
predicates [+]= st -> I st[6] {(st[4] [&] st[5])} E 1
|
||
predicates [+]= st -> sum(st[0.<6]) == 3
|
||
predicates [+]= st -> (st[10] [&] st[11])
|
||
predicates [+]= st -> sum(st[6.<9]) == 1
|
||
predicates [+]= st -> sum(st[0.<11]) == 4
|
||
|
||
F to_str(b)
|
||
R (0.<12).filter(i -> @b[i]).map(i -> i + 1).join(‘ ’)
|
||
|
||
print(‘Exact hits:’)
|
||
L(n) 0 .< (1 << 12)
|
||
V bools = [0] * 12
|
||
L(i) 12
|
||
I n [&] (1 << (11 - i)) != 0
|
||
bools[i] = 1
|
||
|
||
L(predicate) predicates
|
||
I Int(predicate(bools)) != bools[L.index]
|
||
L.break
|
||
L.was_no_break
|
||
print(‘ ’to_str(bools))
|
||
|
||
print("\nNear misses:")
|
||
L(n) 0 .< (1 << 12)
|
||
V bools = [0] * 12
|
||
L(i) 12
|
||
I n [&] (1 << (11 - i)) != 0
|
||
bools[i] = 1
|
||
|
||
V count = 0
|
||
L(predicate) predicates
|
||
I Int(predicate(bools)) == bools[L.index]
|
||
count++
|
||
I count == 11
|
||
L(predicate) predicates
|
||
V i = L.index
|
||
I Int(predicate(bools)) != bools[i]
|
||
print(f:‘ (Fails at statement {i + 1:2}) {to_str(bools)}’)
|
||
L.break
|