Code Hunt BOF 2016初体验
来源:互联网 发布:金林钣金展开软件下载 编辑:程序博客网 时间:2024/06/06 09:45
这两天刚报名参加了微软的编程之美挑战赛,试了下Code Hunt,相比普通的CodeHunt zone来说还是非常有难度的。
地址:https://www.codehunt.com/
00
00.01
return -9 + x*11;
00.02
return x^y;
00.03
int i=0,j=0,res=0;;for(i=0;i<p.length;i++){ res+= p[i][0] * (int)Math.pow(x,p[i][1]);}return res;
00.04卡住了很久,后来穷举看了很多的测试用例,最后找出来的,Orz
return Math.abs(x)>=Math.abs(y);
00.05 逗逼题
return a[a.length -2];
00.06
String res = ""; for(int i= s.length()-1;i>=0;i--) res += s.charAt(i); return res+s;
01
01.01
int[] res = new int[n]; for(int i=0;i<n && i<a.length;i++) res[i] = a[i]; return res;
01.02
if(i==0) return '0'; return i>0 ? '+' : '-';
01.03
return !(a&b);
01.04 绝对值排序问题
int i,temp,j; for (i = 1; i < a.length; i++) { temp = a[i]; for (j = i - 1; j >= 0 && Math.abs(a[j]) > Math.abs(temp); j--) a[j + 1] = a[j]; a[j+1] = temp; } return a;
01.05 字符串反转
String res=""; for(int i=s.length()-1;i>=0;i--) res += s.charAt(i); return res;
01.06 就这么简单,被带跑到素数判断以后推倒重来的结果
return n%4==0 ? true : false;
02
02.01 大小写反转
String res=""; char tmp; for(int i=0;i<s.length();i++) { tmp = s.charAt(i); if(tmp>='A' && tmp <='Z') tmp = (char)((int)tmp+32); else if(tmp>='a' && tmp<='z') tmp = (char)((int)tmp-32); res +=tmp; } return res;
02.02 字符串中字母个数总和
int sum=0; for(int i=0;i<a.length;i++) sum+=a[i].length(); return sum;
02.03
int []res = new int[a.length-1]; for(int i =0;i<res.length;i++) res[i]=a[i+1]-a[i]; return res;
02.04 列方程解参数
return (int)(x + Math.pow(x,2)*3)/2;
02.05 特殊情况,全为空格时
String []ss = s.trim().split(" "); if(i>=ss.length) return null; else if(ss.length==1 && ss[0].equals("")) return null; return ss[i];
02.06 TF 找规律就好
return !(x & !y) || z;
03
03.01 替换字符简化过程
String res =""; s = s.replace("\t","#"); int i,j,k; for(i=0;i<s.length();i++) { if(s.charAt(i)=='#') { k = (n-res.length()%n); for(j=0;j<k;j++) res +=" "; } else res+=s.charAt(i); } return res;
03.02 邮箱正确性判断,但是不可以用正则,下面的是勉强通过,性能不好的代码
int aPos = s.indexOf("@", 1); if (aPos < 0 || aPos == s.length()-1) return false; if (s.indexOf("@", aPos + 1) > 0) return false; int bPos = s.indexOf(".", aPos + 2); if (bPos < 0 || bPos == s.length()-1 || s.indexOf("..")==s.length()-1) return false; return true;
正则写法,在Eclipse下面好用,但是在Hunt平台上,全返回true,不知道为嘛。
String regex="\\w+@[\\w\\.]+\\.[\\w\\.]+"; return s.matches(regex);
03.03 斐波那契数组,可怜我自己,还用方程解
return (n/3==0) ? n : Puzzle(n-1) + Puzzle(n-2);
03.04
for(int i=0;i<a.length;i++) a[i] = a[i]/c; return a;
03.05 进制转换
String res = ""; if(n==0) return "0"; while(n>0) { res = n%b + res; n = n/b; } return res;
03.06 没做出来,心塞
1 0
- Code Hunt BOF 2016初体验
- Code Hunt (Microsoft Research)
- Code Hunt Sector02
- code hunt JAVA01
- code hunt JAVA02
- CSDN CODE 初体验
- Code Hunt SECTOR 02 LOOPS
- EF Code First 初体验
- EF Code First 初体验
- Visual Studio Code初体验
- 程序员的游戏——Code Hunt
- Code Hunt 第一章算术篇答案
- Code Hunt 第二篇 循环片答案
- 一个程序员的游戏 Code Hunt
- code hunt 题解一 (java 版)
- code hunt 题解二(java版)
- code hunt 题解三 (java版)
- code hunt 题解四(java 版)
- nyoj 722 数独
- MVC框架初步
- iOS项目上传到AppStore步骤流程
- iOS修改系统音量
- eclipse使用教程系列之三:导入maven项目转换web项目并打包编译图文详解
- Code Hunt BOF 2016初体验
- iOS每日一记-----如何写好简历 。。。。
- 怎样让您的系统也有“数据透视表”功能?
- 删除已经配置的类库和移除CocoaPods
- @property atomic与nonatomic readonly
- 大数据安全规范
- 缺少各种framework会报的错误
- Xcode 之自己编译静态库
- [剑指offer]重建二叉树