做了个数据结构,b是20种待猜的,t是每次猜的4个,如果返回否用not exists可以排除一部分,如果返回是,就在剩下的中再换4个数来猜
with b(n,s) as(values
(1,[1,2,3,4]),
(2,[2,3,4,5]),
(3,[6,7,8,9]),
(4,[7,8,9,10]),
(5,[11,12,13,14]),
(6,[12,13,14,15]),
(7,[16,17,18,19]),
(8,[17,18,19,20]),
(9,[21,22,23,24]),
(10,[22,23,24,25]),
(11,[1,6,11,16]),
(12,[6,11,16,21]),
(13,[2,7,12,17]),
(14,[7,12,17,22]),
(15,[3,8,13,18]),
(16,[8,13,18,23]),
(17,[4,9,14,19]),
(18,[9,14,19,24]),
(19,[5,10,15,20]),
(20,[10,15,20,25])
),
t(x) as (values([1,6,7,8])),
t1 as (select unnest(x)i from t)
select * from b where not exists(select 1 from t1 where i in (select unnest(s)));
n s
-- ----------------
2 [2, 3, 4, 5]
5 [11, 12, 13, 14]
6 [12, 13, 14, 15]
7 [16, 17, 18, 19]
8 [17, 18, 19, 20]
9 [21, 22, 23, 24]
10 [22, 23, 24, 25]
17 [4, 9, 14, 19]
18 [9, 14, 19, 24]
19 [5, 10, 15, 20]
20 [10, 15, 20, 25] |