楼主: newkid

[每日一题] puzzleup 2018

[复制链接]
论坛徽章:
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
211#
 楼主| 发表于 2018-11-7 23:30 | 只看该作者
#15

TIME DIFFERENCES

17 May 1989 - 23:46 (17/05/89 - 23:46) can be numerically written as 1705892346, where each digit from 0 to 9 is used exactly once. What is the minimum numerical difference between two different time information having this property.

Note: 24-hour format is used therefore the time part is between 00:00 and 23:59.         


1989年5月17日 - 23:46(17/05/89 - 23:46)可以用数字写成1705892346,其中0到9之间的每个数字恰好只使用一次。具有这种属性的两个不同时间信息之间的最小数值差异是多少?

注意:使用24小时格式,因此时间部分在00:00和23:59之间。

-------------
这题的答案应该就是把最后两位数字颠倒一下。

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
212#
发表于 2018-11-8 06:38 来自手机 | 只看该作者
答案不跨天?

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
213#
发表于 2018-11-8 06:39 来自手机 | 只看该作者
数字把日写在年前,不可能跨天

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
214#
发表于 2018-11-8 06:41 来自手机 | 只看该作者
本帖最后由 〇〇 于 2018-11-8 07:46 编辑

10秒减01秒最小?
21-12
32-23
43-34
54-45
都一样

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
215#
发表于 2018-11-8 07:43 | 只看该作者
newkid 发表于 2018-11-2 22:17
这也能扯上“用PLSQL的”?你的逻辑太强大。

我看了一下MMA的识别,竟然把0认成9,这识别出来的程序还 ...

训练不足

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
216#
发表于 2018-11-8 08:45 | 只看该作者
本帖最后由 〇〇 于 2018-11-8 09:57 编辑

alter session set nls_date_format ='mmddyyhh24mi';

with t as (select to_char(date'2018-11-08'+ interval '1' MINUTE * (level-1),'hhmi') d from dual connect by level<24*60),
a as(select t.d from t where not exists(select 1 from (select level-1 l from dual connect by level<=10) where instr(d,l,1,2)>0 ))
select min(a.d-a1.d) from a,a a1 where a.d>a1.d and translate('a'||a.d,'a'||a1.d,'a')='a';

9

使用道具 举报

回复
论坛徽章:
8
玉兔
日期:2015-11-16 10:18:00铁扇公主
日期:2015-10-27 21:47:42九尾狐狸
日期:2015-12-11 22:31:15
217#
发表于 2018-11-8 10:03 来自手机 | 只看该作者
这也能叫puzzle? 题目中1705892346 稍微变异一下1706892345, 1706892354,咱用mma的根本就不写代码

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
218#
发表于 2018-11-8 10:44 | 只看该作者
lugionline 发表于 2018-11-8 10:03
这也能叫puzzle? 题目中1705892346 稍微变异一下1706892345, 1706892354,咱用mma的根本就不写代码

改成最大的呢

使用道具 举报

回复
论坛徽章:
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
219#
发表于 2018-11-8 11:13 | 只看该作者
# 15
好吧,你们都口算,我还是暴力一把吧

SQL> with t as (select level -1 n from dual connect by level <=100),
  2       d as (select lpad(n,2,'0') dd from t where n between 1 and 31 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  3       m as (select lpad(n,2,'0') mm from t where n between 1 and 12 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  4       y as (select lpad(n,2,'0') yy from t where n between 0 and 99 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  5       h as (select lpad(n,2,'0') hh from t where n between 0 and 23 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  6       i as (select lpad(n,2,'0') mi from t where n between 0 and 59 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  7       s (time_num) as (
  8          select dd||mm||yy||hh||mi time_num
  9            from d,m,y,h,i
10           where instr(dd,substr(mm,1,1))=0 and instr(dd,substr(mm,2,1))=0
11             and instr(dd||mm,substr(yy,1,1))=0 and instr(dd||mm,substr(yy,2,1))=0
12             and instr(dd||mm||yy,substr(hh,1,1))=0 and instr(dd||mm||yy,substr(hh,2,1))=0
13             and instr(dd||mm||yy||hh,substr(mi,1,1))=0 and instr(dd||mm||yy||hh,substr(mi,2,1))=0
14       )
15  select min(abs(a.time_num - b.time_num))
16    from s a,s b
17   where a.time_num <> b.time_num
18  /
MIN(ABS(A.TIME_NUM-B.TIME_NUM)
------------------------------
                             9

使用道具 举报

回复
论坛徽章:
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
220#
发表于 2018-11-8 11:15 | 只看该作者

SQL> with t as (select level -1 n from dual connect by level <=100),
  2       d as (select lpad(n,2,'0') dd from t where n between 1 and 31 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  3       m as (select lpad(n,2,'0') mm from t where n between 1 and 12 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  4       y as (select lpad(n,2,'0') yy from t where n between 0 and 99 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  5       h as (select lpad(n,2,'0') hh from t where n between 0 and 23 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  6       i as (select lpad(n,2,'0') mi from t where n between 0 and 59 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
  7       s (time_num) as (
  8          select dd||mm||yy||hh||mi time_num
  9            from d,m,y,h,i
10           where instr(dd,substr(mm,1,1))=0 and instr(dd,substr(mm,2,1))=0
11             and instr(dd||mm,substr(yy,1,1))=0 and instr(dd||mm,substr(yy,2,1))=0
12             and instr(dd||mm||yy,substr(hh,1,1))=0 and instr(dd||mm||yy,substr(hh,2,1))=0
13             and instr(dd||mm||yy||hh,substr(mi,1,1))=0 and instr(dd||mm||yy||hh,substr(mi,2,1))=0
14       )
15  select min(abs(a.time_num - b.time_num)),max(abs(a.time_num - b.time_num))
16    from s a,s b
17   where a.time_num <> b.time_num
18  /
MIN(ABS(A.TIME_NUM-B.TIME_NUM) MAX(ABS(A.TIME_NUM-B.TIME_NUM)
------------------------------ ------------------------------
                             9                     1501979184

使用道具 举报

回复

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

本版积分规则 发表回复

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