Let me go further a little bit. If 2b are in the group of 4. Game is basically over. If not, it may either contains 0 or 1. Let us then take 0 case first. Put group of 8 into 4/4 and compare one by one. If both are even all in group of 8 are b and then compare it with 8/8 in group of 16 and so on. If one of the 4/4 splits in group of 8 is uneven compared to the known 4a, it may contain 1 b or 2 b. Go back to the very beginning if it is 2 b. Go back to the case of 3a+1b of group of 4 if a split in group of 8 is 3a+1b. So basically it is like recursive function call all the way up to the last group of 32.
If 2 b in group of 4 and split 2/2 both are 1a+1b, then further split 1/1 must be true with 1a<>1b and and any pick from other groups must be true, either 1a=1a(from other group) or 1b<>1a(from other group). So it is done as long as group of 4 contains 2 b. For group of 4 with 0 b or 1 b will depends on recursive function call. But execution order is critical and need well designed.
solomon_007 发表于 2021-11-5 21:51
# 10 模拟SQL> with function f_dart 2 return int 3 is 4 5 type t_seg is table of int index ...
Nice to see the function returning associative array. There is optimization post recently which may apply such function to serve as index on fly. Maybe I can borrow it to create a test case and see how Oracle optimizer responds to it.
jihuyao 发表于 2021-11-7 23:20
If 2 b in group of 4 and split 2/2 both are 1a+1b, then further split 1/1 must be true with 1a1b and ...
看不懂你的推理。你还是列出所有比较结果,并且对结果给出解释,然后说根据这个结果下一步要比较什么。
2 vs 2比较结果:
平衡(可能是2a vs 2a 也可能 a+b vs a+b)
不平衡(可能是 2a vs 2b 也可能是 a+b vs 2a, 至于b比a轻还是重,此时不知道)
从上面来看,下一步分别要怎么走?
别忘了此时4个里面可能含有0,1,2个b。你不能假设2b在4个那组,一切都是未知的。
Focus on 2/2 even case which could be 4a or 2a+2b(1a+1b on both sides). Split one side only which is either 1a=1a or 1a<>1b. If 1a=1a then group of 4 has 4 a and continue to compare split 4/4 of group 8 (skip for now). If 1a<>1b then group of 4 has 2a+2b. So all other groups only have a from which picking one and compare either side of split 1/1 and if equal then it is a otherwise it is b. Do the same for the second 1/1 split to identify which one is b. Done for group of 4 containing 2a+2b and split 2/2 even. Now if split 2/2 of group 4 is uneven it implies the group of 4 has 1 b or 2 b (both b on one side). Still focus on 2 b uneven case which implies split 1/1 of both sides must be true with 1a=1a and 1b=1b (for group of 4 having only 1 b it is 1a<>1b and 1a=1a). Now picking any 2 from other groups which must 2 a and compare either side of 2/2 (uneven but both 1/1 splits are even). If even that side has 2 a and if not that side has 2 b. Done for the group of 4 in uneven case with 2 b on same side of split 2/2. As said above group of 4 with 0 or 1 b are also identified but need further process to complete (skip for now to avoid confusion with cases of 2 b in group of 4.