昨天看到微软出的网游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)——沉迷娱乐的我的更多相关文章

  1. WCF服务调用超时错误:套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的。本地套接字超时是“00:05:30”(已解决)

    问题: 线上正式环境调用WCF服务正常,但是每次使用本地测试环境调用WCF服务时长就是出现:套接字连接已中止.这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的.本地套接字超 ...

  2. 2016 Google code jam 答案

    二,RoundC import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundE ...

  3. code::blocks(版本10.05) 配置opencv2.4.3

    (1)首先下载opencv2.4.3, 解压缩到D:下: (2)配置code::blocks, 具体操作如下: 第一步, 配置compiler, 操作步骤为Settings  -> Compil ...

  4. code::blocks(版本号10.05) 配置opencv2.4.3

    (1)首先下载opencv2.4.3, 解压缩到D:下: (2)配置code::blocks, 详细操作例如以下: 第一步, 配置compiler, 操作步骤为Settings  -> Comp ...

  5. 出现“安全时间戳无效,因为其创建时间(“2013-10-30T14:42:07.861Z”)是将来的时间。当前时间为“2013-10-30T14:36:23.988Z”,允许的时钟偏差是“00:05:00””的原因

    具体原因是服务器的时间和本地的时间不能超过5分钟,超过5分钟了.只要修改你本地机器的时间,和服务器相差的时间不能超过5分钟,就可以了. 根本原因是windows 系统域认证要求的,所有都一样.

  6. Matlab实现Butterworth滤波器 分类: 图像处理 2014-06-02 00:05 527人阅读 评论(0) 收藏

    下面是用Matlab实现的Butterworth高通.低通滤波器. clc;clear all;close all; I=imread('cameraman.tif'); subplot(3,2,1) ...

  7. [leetcode.com]算法题目 - Gray Code

    The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...

  8. 微软云 azure 数据迁移之oracle11g dataguard

    背景,将本地的oracle数据迁移到微软云azure云上面的oracleserver. 1.复制本地的rman备份集到微软云azure的oracleserver上 scp -r -P56922 201 ...

  9. 2015微软创新杯Imaginecup正在进行参赛(报名截止日期2014年12月31日本23:59)

    CSDN高校俱乐部与微软官方合作,2015微软创新杯大赛中国区官网落户CSDN高校俱乐部:http://student.csdn.net/mcs/imaginecup2015 在微软官方设置创新杯中国 ...

随机推荐

  1. Excel导入到DataTable

    1.前台代码 <asp:FileUpload ID="fupFiles" runat="server" /> <asp:Button ID=& ...

  2. 整理幾種常見PCB表面處理的優缺點

    這只是一篇整理文,而且我個人僅從事過後段的電路板組裝,而未從事過電路板製程,所以有些見解純粹只是個人看法,如果有些不一樣的聲音或錯誤也歡迎留言討論. 隨著時代的演進,科技的進步,環保的要求,電子業也隨 ...

  3. C#正则表达式匹配任意字符

    原文:C#正则表达式匹配任意字符 不得不说正则很强大,尤其在字符串搜索上 匹配任意字符,包括汉字,换行符: [\s\S]*. 版权声明:本文为博主原创文章,未经博主允许不得转载.

  4. Linux 备份工具

     Linux 备份工具 GNU 的传统备份工具  GNU tar — http://www.gnu.org/software/tar/ GNU cpio — http://www.gnu.org/so ...

  5. 从Linux终端管理进程:10个你必须知道的命令

    从Linux终端管理进程:10个你必须知道的命令 Linux终端有一系列有用的命令.它们可以显示正在运行的进程.杀死进程和改变进程的优先级.本文列举了一些经典传统的命令和一些有用新颖的命令.本文提到的 ...

  6. PF_RING packet overwrites

    最近在用 PF_RING 抓包过程中,发现个灵异的现象,高流量丢包时, 经常会出现正在处理的包的内容被覆盖.开始,怀疑是不是自己程序有地方越界写了,后来发现,如果自己拷贝一份,然后处理拷贝的那份,永远 ...

  7. Node中npm 安装问题

    首先,我们的npm包无所谓安全性,所以不要使用性能和效率更慢的https,转而使用http,相关命令如下: 1.关闭npm的https   npm config set strict-ssl fals ...

  8. stl入门--reverse函数

    #include<iostream> #include<algorithm>          using namespace std; int main() {     ch ...

  9. thecorner.com.cn - Customer Care

    thecorner.com.cn - Customer Care 所有主题 帮助 关于我们 thecorner.com 是通过专业的"迷你商店"形式荟萃最新男士.女士精选时尚商品和 ...

  10. ios ViewController present不同的方向

    First ViewController CATransition *transition = [CATransition animation]; transition.duration = 0.3; ...