楼主: newkid

[每日一题] puzzleup 2018

[复制链接]
论坛徽章:
8
玉兔
日期:2015-11-16 10:18:00铁扇公主
日期:2015-10-27 21:47:42九尾狐狸
日期:2015-12-11 22:31:15
191#
发表于 2018-10-25 12:22 | 只看该作者



ITPUB的网站不时中风,充分证明了oracle的没落,用户水平就是最好的证明


使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
192#
 楼主| 发表于 2018-10-25 22:29 | 只看该作者
solomon_007 发表于 2018-10-25 09:55
3个对,如果不讲顺序,那除以 3!= 6 就可以了。

12480/6=2080

我的写法:
with f as (select level fid from dual connect by level<=4) -- 家庭编号
,c as ( ---- 所有团队组合
select father.fid||mother.fid||child.fid||gender c
      ,power(2,father.fid+12)+power(2,mother.fid+8)+power(2,child.fid+4*(gender-1)) bits
  from f father,f mother,f child,(select level gender from dual connect by level<=2)
where father.fid not in (mother.fid,child.fid) and mother.fid<>child.fid
)
select COUNT(*) as cnt -----三个团队组合
  from c c1,c c2,c c3
where c1.bits<c2.bits and c2.bits<c3.bits
and bitand(c1.bits,c2.bits)=0 and bitand(c1.bits,c3.bits)=0 and bitand(c2.bits,c3.bits)=0;

再送你一个章,想要哪个?

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
193#
 楼主| 发表于 2018-10-25 22:32 | 只看该作者
lugionline 发表于 2018-10-25 12:22
ITPUB的网站不时中风,充分证明了oracle的没落,用户水平就是最好的证明

老炮们都玩自媒体去了,技术论坛没落不只是itpub,全球都一样。你能找出一个繁荣的技术论坛来?
我现在的愿望就是将来itpub安乐死的时候能整理一下帖子,做张纪念光盘。说实话能坚持到现在已经是奇迹了,投资人看来很有情怀。

使用道具 举报

回复
论坛徽章:
548
生肖徽章2007版:猴
日期:2008-05-16 11:28:59生肖徽章2007版:马
日期:2008-10-08 17:01:01SQL大赛参与纪念
日期:2011-04-13 12:08:17授权会员
日期:2011-06-17 16:14:53ITPUB元老
日期:2011-06-21 11:47:01ITPUB官方微博粉丝徽章
日期:2011-07-01 09:45:27ITPUB十周年纪念徽章
日期:2011-09-27 16:30:472012新春纪念徽章
日期:2012-01-04 11:51:222012新春纪念徽章
日期:2020-11-30 22:13:24海蓝宝石
日期:2012-02-20 19:24:27
194#
发表于 2018-10-26 09:40 | 只看该作者
newkid 发表于 2018-10-25 22:29
我的写法:
with f as (select level fid from dual connect by level

你的“秀才”最多,就送这个吧;如果不能转,就随便送个能转的

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
195#
 楼主| 发表于 2018-10-26 22:34 | 只看该作者
秀才不能转,我就给了个“山治”。

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
196#
 楼主| 发表于 2018-10-26 22:44 | 只看该作者
本帖最后由 newkid 于 2018-10-26 23:08 编辑

在做第三题的时候加菲猫提到了 SYS_GUID()比DBMS_RANDOM.VALUE更慢。

我在WINDOWS 7笔记本上测试确实如此:版本12.2
select count(sys_connect_by_path(p||c,','))
   from (select chr(64+level) p
           from dual
          connect by level<=11
        )
       ,(select level c from dual connect by level<=3)
connect by level<=5 and p>=prior p and prior sys_guid() is not null;

COUNT(SYS_CONNECT_BY_PATH(P||C,','))
------------------------------------
                              819159

Elapsed: 00:00:20.85

select count(sys_connect_by_path(p||c,','))
   from (select chr(64+level) p
           from dual
          connect by level<=11
        )
       ,(select level c from dual connect by level<=3)
connect by level<=5 and p>=prior p and prior dbms_random.value is not null;

COUNT(SYS_CONNECT_BY_PATH(P||C,','))
------------------------------------
                              819159

Elapsed: 00:00:02.89

但是,到了 LINUX上面就反过来了:版本12.1
select count(sys_connect_by_path(p||c,','))
   from (select chr(64+level) p
           from dual
          connect by level<=11
        )
       ,(select level c from dual connect by level<=3)
connect by level<=5 and p>=prior p and prior dbms_random.value is not null;

COUNT(SYS_CONNECT_BY_PATH(P||C,','))
------------------------------------
                              819159

Elapsed: 00:00:10.54

select count(sys_connect_by_path(p||c,','))
   from (select chr(64+level) p
           from dual
          connect by level<=11
        )
       ,(select level c from dual connect by level<=3)
connect by level<=5 and p>=prior p and prior sys_guid() is not null;

COUNT(SYS_CONNECT_BY_PATH(P||C,','))
------------------------------------
                              819159
Elapsed: 00:00:03.04

使用道具 举报

回复
论坛徽章:
548
生肖徽章2007版:猴
日期:2008-05-16 11:28:59生肖徽章2007版:马
日期:2008-10-08 17:01:01SQL大赛参与纪念
日期:2011-04-13 12:08:17授权会员
日期:2011-06-17 16:14:53ITPUB元老
日期:2011-06-21 11:47:01ITPUB官方微博粉丝徽章
日期:2011-07-01 09:45:27ITPUB十周年纪念徽章
日期:2011-09-27 16:30:472012新春纪念徽章
日期:2012-01-04 11:51:222012新春纪念徽章
日期:2020-11-30 22:13:24海蓝宝石
日期:2012-02-20 19:24:27
197#
发表于 2018-10-28 12:44 | 只看该作者
newkid 发表于 2018-10-26 22:44
在做第三题的时候加菲猫提到了 SYS_GUID()比DBMS_RANDOM.VALUE更慢。

我在WINDOWS 7笔记本上测试确实如 ...

新发现,奇怪的现象;这后面还得根据平台,用不同的方法!

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
198#
 楼主| 发表于 2018-10-31 22:19 | 只看该作者
#14:
DIFFERENT DIGITS

A number has distinct digits and each of its digits is larger than the letter count of the digit on its left. What is the largest such integer?

The letter count of a number is defined as the number of letters in English spelling of that number.

一个数的每位各不相同,并且每位数字都大于其左侧数字的字母数。这样的整数最大是多少?

数字的字母数定义为该数字的英文拼写字母数。

使用道具 举报

回复
论坛徽章:
548
生肖徽章2007版:猴
日期:2008-05-16 11:28:59生肖徽章2007版:马
日期:2008-10-08 17:01:01SQL大赛参与纪念
日期:2011-04-13 12:08:17授权会员
日期:2011-06-17 16:14:53ITPUB元老
日期:2011-06-21 11:47:01ITPUB官方微博粉丝徽章
日期:2011-07-01 09:45:27ITPUB十周年纪念徽章
日期:2011-09-27 16:30:472012新春纪念徽章
日期:2012-01-04 11:51:222012新春纪念徽章
日期:2020-11-30 22:13:24海蓝宝石
日期:2012-02-20 19:24:27
199#
发表于 2018-10-31 23:04 | 只看该作者
# 14

好像太简单了。。。

SQL>
SQL> with t as (
  2  select 0 n, 'zero' letter
  3    from dual
  4  union all
  5  select n, to_char(to_date(n, 'j'), 'jsp')
  6    from (select level n from dual connect by level < 10)
  7  ),
  8  s (lvl,n_list,n_last) as (select 1,cast(n as varchar2(10)),n
  9                             from t
10                            where n > 0
11                            union all
12                           select lvl + 1,
13                                  s.n_list||t.n,
14                                  t.n
15                             from s,t
16                            where instr(s.n_list,t.n)=0
17                              and t.n > (select length(letter)
18                                           from t
19                                          where n = s.n_last)
20                            )
21  select max(to_number(n_list)) from s
22  /
MAX(TO_NUMBER(N_LIST))
----------------------
               3987645

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
200#
 楼主| 发表于 2018-11-1 01:09 | 只看该作者
奇怪,这个CONNECT BY只能出来三层,是bug还是我哪里写错了?

with t as (SELECT level n,length(to_char(to_date(level, 'j'), 'jsp')) c from dual connect by level<10)
select replace(sys_connect_by_path(n,','),',')
  from t
where connect_by_isleaf=1
connect by nocycle n>prior c
;

你很严密地加上了0, 其实0不可能放在开头,也不可能放在中间,所以可以排除。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表