微软Code Hunt答案(00-05)——沉迷娱乐的我
昨天看到微软出的网游Code Hunt。o(∩_∩)o...哈哈,还不好好玩一吧,个人感觉不是一个模块比一个模块难的,Code Hunt是按功能划分。所以不要怕自己做不来。由于不同人特长不一样。
像ACM都是分工合作的啦。废话不多。我们来总结一下前01-04的答案。希望对大家有帮助,纯属娱乐。还有非常多能够优化的地方,欢迎一起来讨论!
注:语言C# 网页地址:https://www.codehunt.com/
转载请著明:http://blog.csdn.net/grublinux/article/details/26380131
注:澄清一些误会,以下的答案不是所有三星。
有一些是还有优化余地的,为了免得误会我把能优化的题目用红色标注。
然后假设大家提供了自己更加完美的答案,我会陆续更新上来,而且标注作者。谢谢大家。玩的开心!
chapter 00
00.02
using System;
public class Program {
public static int Puzzle(int x) {
return x+1;
}
}
00.03
using System;
public class Program {
public static int Puzzle(int x) {
return 2*x;
}
}
00.04
public class Program {
public static int Puzzle(int x, int y) {
return x+y;
}
}
chapter 01
01.01
using System;
public class Program {
public static int Puzzle(int x) {
return (-1)*x;
}
}
01.02
using System;
public class Program {
public static int Puzzle(int x) {
return x-2;
}
}
01.03
using System;
public class Program {
public static int Puzzle(int x) {
return x*x;
}
}
01.04
using System;
public class Program {
public static int Puzzle(int x) {
return 3*x;
}
}
01.05
using System;
public class Program {
public static int Puzzle(int x) {
return x/3;
}
}
01.06
using System;
public class Program {
public static int Puzzle(int x) {
return 4/x;
}
}
01.07
using System;
public class Program {
public static int Puzzle(int x, int y) {
return x-y;
}
}
01.08
using System;
public class Program {
public static int Puzzle(int x, int y) {
return x+2*y;
}
}
01.09
using System;
public class Program {
public static int Puzzle(int x, int y) {
return x*y;
}
}
01.10
public class Program {
public static int Puzzle(int x, int y) {
return x + y / 3;
}
}
01.11
using System;
public class Program {
public static int Puzzle(int x, int y) {
return (Math.Abs(x)>=Math.Abs(y)&&y!=0)?x/y:0;
}
}
01.12
using System;
public class Program {
public static int Puzzle(int x) {
return x%3;
}
}
01.13
using System;
public class Program {
public static int Puzzle(int x) {
return x%3+1;
}
}
01.14
using System;
public class Program {
public static int Puzzle(int x) {
return 10%x;
}
}
01.15
using System;
public class Program {
public static int Puzzle(int x, int y, int z) {
return (x+y+z)/3;
}
}
chapter 02
02.01
using System;
using System.Linq;
public class Program {
public static int[] Puzzle(int n) {
return Enumerable.Range(0, n).ToArray();
}
}
02.02
using System;
using System.Linq;
public class Program {
public static int[] Puzzle(int n) {
return Enumerable.Range(0, n).Select(x => x * n).ToArray();
}
}
02.03
using System;
using System.Linq;
public class Program {
public static int[] Puzzle(int n) {
return Enumerable.Range(0, n).Select(x => x * x).ToArray();
}
}
02.04
using System;
using System.Linq;
public class Program {
public static int Puzzle(int[] v) {
return (int)v.Sum(i => (long)i);
}
}
Thanks For test4153(2 floor)
02.05
using System;
public class Program {
public static int Puzzle(int n) {
return (n-1)*(n)*(2*n-1)/6;
}
}
return Enumerable.Range(0,n).Sum(i=>i*i); Thanks For test4153(3 floor)
02.06
using System;
using System.Linq;
public class Program {
public static int Puzzle(string s) {
return s.Length - s.Replace("a", "").Length;
}
}
return s.Sum(a=>a=='a'?
1:0); Thanks
For lgl404149074(5
floor)
02.07
using System;
using System.Linq;
public class Program {
public static int Puzzle(string s, char x) {
return s.Length - s.Replace(""+x, "").Length;
}
}
chapter 03
03.01
using System;
public class Program {
public static int Puzzle(int a, int x) {
return x<=0 ? 1 : a*Puzzle(a, x-1);
}
}
Thanks For lgl404149074(5
floor)
03.02
using System;
public class Program {
public static int Puzzle(int i) {
return (i == 0)? 1: i * Puzzle(i-1);
}
}
03.03
using System;
public class Program {
public static int Puzzle(int lowerBound, int upperBound) {
int product = 1;
for (int i = lowerBound; i <= upperBound; ++i) {
product *= i;
}
return product;
}
}
return Enumerable.Range(lowerBound,upperBound-lowerBound+1).Aggregate(1,(sum,num)=>sum*num);
Thanks For TrotylYu
03.04
using System;
public class Program {
public static int Puzzle(int n) {
return (n <= 0)? 0: (n+1) / 2 * ((n + 1) / 2 - 1);
}
}
03.05
using System;
public class Program {
public static int Puzzle(int n) {
return n*(n+1)*(n+2)/6;
}
}
03.06
using System;
using System.Linq;
public class Program {
public static string Puzzle(string word) {
return string.Join(" ", (new string('_', word.Length)).AsEnumerable());
}
}
return String.Join(" ",new String('_',word.Length).ToArray());
Thanks For TrotylYu
03.07
using System;
using System.Linq;
public class Program {
public static string Puzzle(string s) {
return string.Join("",
s.Select(
c => (char)((c > 117)? (c - 21): (c + 5))
)
);
}
}
03.08
using System;
public class Program {
public static int Puzzle(int x) {
string s = "";
s += x;
return s.Length;
}
}
return x.ToString().Length;
Thanks For TrotylYu
chapter 04
04.01
using System;
public class Program {
public static bool Puzzle(bool x, bool y) {
return x || y;
}
}
04.02
using System;
public class Program {
public static bool Puzzle(bool x, bool y) {
return x && y;
}
}
04.03
using System;
public class Program {
public static bool Puzzle(int x) {
return x<50;
}
}
04.04
using System;
public class Program {
public static bool Puzzle(int x, int y) {
return x<y;
}
}
04.05
using System;
public class Program {
public static int Puzzle(int i) {
return (i == 0)? 0: Math.Abs(i)/i;
}
}
04.06
using System;
public class Program {
public static bool Puzzle(int i, int j) {
return false;
}
}
04.07
using System;
public class Program {
public static int Puzzle(int i) {
return (i < 100)?
2: 3;
}
}
04.08
using System;
public class Program {
public static string Puzzle(int i) {
return (i % 2 == 0)? "even": "odd";
}
}
04.09
using System;
public class Program {
public static string Puzzle(int i) {
return ((i % 5 == 0)?
"": "not a ") + "multiple of 5";
}
}
04.10
using System;
public class Program {
public static string Puzzle(int i, int x) {
return ((i % x == 0)? "": "not a ") + ("multiple of " + x);
}
}
04.11
using System;
public class Program {
public static string Puzzle(int i, int j, int k) {
if (i / (double)j == j / (double)k && (i!=j)) return "yes!";
return "no";;
}
}
04.12
using System;
public class Program {
public static int Puzzle(int i) {
if (i < 8) return 0;
if (i < 15) return 7;
return 21;
}
}
return i>14?21:((i-1)/7)*7; Thanks
For brown_cat(11
floor)
chapter 05
05.01
using System;
public class Program {
public static string Puzzle(string s) {
int l = s.Length;
return l<4?"short":l<8?
"average":l<15?"long":"super long";
}
}
Thanks For lgl404149074(5
floor)
05.02
using System;
public class Program {
public static string Puzzle(int i) {
return (i % 1111 == 0) ?
"fancy year" : "not a fancy year";
}
}
Thanks For lgl404149074(5
floor)
05.03
using System;
public class Program {
public static bool Puzzle(int a, int b, int c) {
return (Math.Pow(Math.Min(a,b),2)==(Math.Max(a,b)+c)*(Math.Abs(c-Math.Max(a,b))))?true:false;
}
}
05.04
using System;
public class Program {
public static int Puzzle(int x, int y) {
return Math.Abs(x)+Math.Abs(y);
}
}
05.05
using System;
public class Program {
public static bool Puzzle(int i, int j) {
return i*i==j?true:false;
}
}
Thanks For lgl404149074(5
floor)
微软Code Hunt答案(00-05)——沉迷娱乐的我的更多相关文章
- WCF服务调用超时错误:套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的。本地套接字超时是“00:05:30”(已解决)
问题: 线上正式环境调用WCF服务正常,但是每次使用本地测试环境调用WCF服务时长就是出现:套接字连接已中止.这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的.本地套接字超 ...
- 2016 Google code jam 答案
二,RoundC import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundE ...
- code::blocks(版本10.05) 配置opencv2.4.3
(1)首先下载opencv2.4.3, 解压缩到D:下: (2)配置code::blocks, 具体操作如下: 第一步, 配置compiler, 操作步骤为Settings -> Compil ...
- code::blocks(版本号10.05) 配置opencv2.4.3
(1)首先下载opencv2.4.3, 解压缩到D:下: (2)配置code::blocks, 详细操作例如以下: 第一步, 配置compiler, 操作步骤为Settings -> Comp ...
- 出现“安全时间戳无效,因为其创建时间(“2013-10-30T14:42:07.861Z”)是将来的时间。当前时间为“2013-10-30T14:36:23.988Z”,允许的时钟偏差是“00:05:00””的原因
具体原因是服务器的时间和本地的时间不能超过5分钟,超过5分钟了.只要修改你本地机器的时间,和服务器相差的时间不能超过5分钟,就可以了. 根本原因是windows 系统域认证要求的,所有都一样.
- Matlab实现Butterworth滤波器 分类: 图像处理 2014-06-02 00:05 527人阅读 评论(0) 收藏
下面是用Matlab实现的Butterworth高通.低通滤波器. clc;clear all;close all; I=imread('cameraman.tif'); subplot(3,2,1) ...
- [leetcode.com]算法题目 - Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...
- 微软云 azure 数据迁移之oracle11g dataguard
背景,将本地的oracle数据迁移到微软云azure云上面的oracleserver. 1.复制本地的rman备份集到微软云azure的oracleserver上 scp -r -P56922 201 ...
- 2015微软创新杯Imaginecup正在进行参赛(报名截止日期2014年12月31日本23:59)
CSDN高校俱乐部与微软官方合作,2015微软创新杯大赛中国区官网落户CSDN高校俱乐部:http://student.csdn.net/mcs/imaginecup2015 在微软官方设置创新杯中国 ...
随机推荐
- 从sample来学习Java堆(转)
1)Java堆 所有对象的实例分配都在Java堆上分配内存,堆大小由-Xmx和-Xms来调节,sample如下所示: public class HeapOOM { static class OOMOb ...
- C# 导出 excel 复杂格式 html导出
/// <summary> /// 夜班津贴统计导出 /// </summary> public void ExportOtStat(string data) { var in ...
- Quartz框架的使用
专用词汇:scheduler:任务调度器trigger:触发器,用于定义任务调度时间规则job:任务,即被调度的任务misfire:错过的,指本来应该被执行但实际没有被执行的任务调度 Quartz核心 ...
- hdu 5199 Gunner(STL之map,水)
Problem Description Long long ago, there is a gunner whose name is Jack. He likes to go hunting very ...
- [转!]jQuey中的return false作用是什么
jQuey中的return false作用是什么: 在众多的语句中都有return false的使用,当然对于熟悉它的开发者来说,当然是知根知底,知道此语句的作用,当然也就知道在什么时候使用此语句,不 ...
- 模块化的JavaScript
我们再一次被计算机的名词,概念笼罩. backbone.emberjs.spinejs.batmanjs 等MVC框架侵袭而来. CommonJS.AMD.NodeJS.RequireJS.SeaJS ...
- Android(一)
Android Activity TextView,Button 1.在fragment_main.xml文件中直接添加控件 2.在MainActivity.java文件中添加TextView控件 在 ...
- Error in invoking target 'agent nmhs' of makefile
安装Oracle11g报错:Error in invoking target 'agent nmhs' of makefile 解决方法:cd $ORACLE_HOME/sysman/libvi i ...
- GetRect:通过提供点和宽度返回对应矩形RECT
RECT GetRect(int x,int y,int width,int height); 描述:通过提供点和宽度返回对应矩形RECT 返回:矩形结构RECT 参数: x:X轴坐标 y:Y轴坐标 ...
- CentOS快捷键总结
* 打开主菜单 = Alt + F1 * 运行 = Alt + F2 * 显示桌面 = Ctrl + Alt + d * 最小化当前窗口 = Alt + F9 * 最大化当前窗口 = Alt + F1 ...