昨天看到微软出的网游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. QT:给Widget设置背景图片——设置Widget的调色板,调色板使用图片和背景色

    QT:给Widget设置背景图片 1 /*2 * set background image3 */4 QPixmap bgImages(":/images/bg.png");5 Q ...

  2. AndroidTestCase测试用法

    1.    Java代码TestCase.java 继承AndroidTestCase类 package com.test.casei; import android.test.AndroidTest ...

  3. cp | mv | rm

    linux下文件的复制.移动与删除命令为:cp,mv,rm 一.文件复制命令cp 命令格式: cp [-adfilprsu] 源文件(source) 目标文件(destination) cp [opt ...

  4. Linux学习笔记5-搭建内网Yum源

    一.安装Nginx  1.安装依赖: [root@nodeSource local]# yum install gc-devel gcc-c++ pcre-devel zlib-devel 2.解压N ...

  5. ios ViewController present不同的方向

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

  6. Lining Up(在一条直线上的最大点数目,暴力)

    Lining Up Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  7. SVG彩虹字

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  8. Android EditText 取消复制粘贴功能,取消横向全屏编辑功能(一)

    在做一些安全性的软件时候常常要考虑取消 EditText 上的复制粘贴功能以确保安全性.下面就记录了这个方法: 首先在API-11以下的版本很简单,只需要在Xml布局文件或者用代码把长按属性设置成fa ...

  9. Linux 08

    1按照视频里提出的几点要求完善使ls命令模仿windows下dir命令输出的脚本 {printf $6" "$7" \t";if (substr($1,1,1) ...

  10. 关于oracle卸载没有卸载完全的问题

    1.关闭oracle所有的服务.可以在windows的服务管理器中关闭: 2.打开注册表:regedit 打开路径: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlS ...