|
bfc99 发表于 2016-1-13 00:53 ![]()
暇不掩玉。
之前真没想到可以用这么少的代码来完成这个任务。大神的脑袋一定是有外挂的。
牛蛙表示不服:
with b as (
select level||'' n, decode(level, 1,111,2,1001,3,10100001,4,10010,5,111100,6,10010000,7,1100010,8,1001000,11000100) v from dual connect by level<=9
),
r(p, xp, op, i, w) as (
select n, v, 0, 0, ''
from b
union all
select p||n, decode(i, 1, v, 0)+xp, decode(i, 1, 0, v)+op, mod(i+1, 2),
case when instr(decode(i, 1, v, 0)+xp, '3')>0 then 'X' else case when instr(decode(i, 1, 0, v)+op, '3')>0 then 'O' else null end end
from r, b
where instr(r.p, n)=0
and w is null
)
select p, translate(translate('123456789', p, 'XOXOXOXOX'), '123456789', '---------'), nvl(w, 'D')
from r
where w is not null or length(p)=9;
|
|