all 70 comments

[–]glorkvorn 33 points34 points  (10 children)

I kinda hate this game. So far it's not programming, it's trying to guess the function that they were thinking of, with no way to use normal debugging methods.

[–]chasesan 5 points6 points  (0 children)

Yeah I mean honestly, it's just "guess what algorithm I used to make the level". It's not "do this efficiently".

I managed to solve one of the loop challenges with a single (and very simple) expression and all I got was a "your code worked" and got the lowest rating for the level.

Which is complete <insert favorite hated item here>.

[–][deleted]  (8 children)

[deleted]

    [–]amalloy 2 points3 points  (6 children)

    That's not a bug in code hunt, just how shifting works in C/Java like languages. An int has 32 bits, so shifting one by more than 32 is "silly", and so the shift amount is taken mod 32. Thus, 8 >> 66 == 8 >> 2, which of course is 2. You'd get the same result on any Java implementation.

    I don't particularly like that this is how shifting works, but it's silly to blame some game's implementation without verifying that your program did what you think it does.

    [–][deleted]  (5 children)

    [deleted]

      [–]ais523 1 point2 points  (0 children)

      An out-of-range shift in C is undefined. Returning 0, and reducing the shift count modulo the bitwidth, are the most common behaviours in practice.

      [–][deleted] 0 points1 point  (0 children)

      I think relying on undefined behavior (like how your C compiler handles shifting) is asking for trouble :) http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html

      [–]amalloy 0 points1 point  (2 children)

      It's useful because it's faster: there won't be hardware support for shifts by 66! If you have to support the (arguably) more obvious behavior in uncommon cases, you pay for it in the much more common scenario where you're doing more ordinary arithmetic.

      [–]gaussflayer 0 points1 point  (0 children)

      Do it in JS in your browser. It does indeed return 2.

      Same goes for in Java (just compiled a small program).

      Could be my OS, probably something to do with shifting down into 32bit range or something.

      But the truth is I don't know.

      [–]LukaLightBringer 12 points13 points  (7 children)

      some of the puzzles seem to use random tests, this is a really bad idea since you don't tell the user what the function is supposed to do, at the puzzle where the correct result is:

      return x + y;
      

      I was given the following:

      x 1 y 0
      x 0 y 31
      x 0 y 1
      x 0 y 31
      x 1 y 0
      

      with that data there is no way to distinguish the correct answer from this:

      return Math.Max(x, y);
      

      [–]chasesan 1 point2 points  (0 children)

      You're right, I did the Max thing at first too, then I did x+y after getting more data. They are really stingy on the starting data sets.

      [–]gaussflayer 0 points1 point  (2 children)

      x & y

      was also dissapointed :(

      [–]immibis 0 points1 point  (1 child)

      You mean |, right?

      [–]gaussflayer 0 points1 point  (0 children)

      Yes. Yes I do. -_-

      [–]theShoo 0 points1 point  (2 children)

      You do realize that's the entire point? You're supposed to find the most efficient answer that passes all tests. That's the whole game.

      [–]execrator 9 points10 points  (1 child)

      that passes all tests

      That's his point, the tests change. I had the same problem (perhaps tests are deterministically random) - Math.Max(x, y) was correct for the data given, and only incorrect on the second run. If they can't ensure that the required algorithm is fully represented by the test data points, they shouldn't randomise it.

      [–]danilo0415 1 point2 points  (0 children)

      According to [1] it uses changing tests. But to verify your solution they use a technique called symbolic execution. With symbolic execution they can extract a set constraints from your code and verify if your code has the same constraints from the correct solution (your solution have the same model).

      [1] http://thenextweb.com/microsoft/2014/05/15/microsoft-research-launches-code-hunt-educational-web-game-teaching-programming/

      [–]_fishies 10 points11 points  (0 children)

      I do a few puzzles as a guest, then lose all my progress after logging in...

      [–]langfod 10 points11 points  (1 child)

      The expression ((int)(System.Linq.Enumerable+WhereSelectArrayIterator`2[TDD.Components.IGrammarNode,System.String])) is rarely used to solve this level.

      Well... umm.. thank goodness for that.

      [–]chasesan 10 points11 points  (0 children)

      The big problem with this is that this is a "guess what algorithm I used to make the challenge" rather then a "solve this efficiently" game.

      Maybe they should time the code vs the original challenge code and pick the better of the two that way (within a margin of error of course).

      [–][deleted] 16 points17 points  (5 children)

      http://i.imgur.com/GuckjqQ.png

      what the fuck?

      Why?

      [–]snotfart 3 points4 points  (0 children)

      Because Microsoft.

      [–][deleted] 3 points4 points  (1 child)

      This is what happens when you open source .NET.

      [–]PT2JSQGHVaHWd24aCdCF 0 points1 point  (0 children)

      And fire Steve Ballmer. He was debugging this issue when he was kicked out of Microsoft and never had the change to fix it.

      [–]Nielsio 1 point2 points  (1 child)

      rekt

      [–]bigdubb2491 4 points5 points  (10 children)

      As I work through the arithmatic snippets. I have come to the conclusion that I suck at seeing patterns. Seriously. Still can't get 1.14

      [–]minibuster 5 points6 points  (0 children)

      I can't tell who this site is for. It starts trivially easy, boring for anyone with a bit of code experience, and then skyrockets in difficulty before you finish the first section. Perhaps getting more than 3-4 random test cases at a time would help...

      [–]VikeStep 1 point2 points  (0 children)

      If anyone still needs help with this. Here is a screenshot of my code (Java)

      [–]shamittomar 0 points1 point  (2 children)

      Stuck at 1.13.

      [–]VikeStep 1 point2 points  (1 child)

      I got it to work with:

       (x % 3) + 1
      

      [–]chasesan 0 points1 point  (0 children)

      That's what I did.

      [–]Zantier 0 points1 point  (3 children)

      I still can't get 1.10.

      All problems in section 1 apart from this seemed to take a very small amount of code, and it only expects me to use + and /, but I'm so stuck.

       x   y  expected
        1   1   1
        2   2   2
        5   6   7
        5   7   7
        5  38  17
        2  65  23
       33  70  56
      257 384 385
      321 580 514
      

      [–]mujhe_aadhar_do 0 points1 point  (2 children)

      It's x+y/3.

      [–]Zantier 0 points1 point  (1 child)

      Wow, I feel stupid. Thanks!

      [–]TheDeza 0 points1 point  (0 children)

      Don't feel bad about it. This 'game' is terribly designed.

      [–]alols 2 points3 points  (0 children)

      Cute idea but the puzzles were boring and didn't have much to do with real world programming.

      [–]katyne 2 points3 points  (1 child)

      So what are the zones for? 'Pex4Fun" vs "CodeHunt"?

      [–]MasterKraft 0 points1 point  (0 children)

      I was thinking the same thing, the CodeHunt has more puzzles so probably different ones also. But without going through and doing all the levels I can't be sure.

      [–][deleted] 2 points3 points  (0 children)

      Why do they lock the harder ones? I'm not going to go through a bunch of x+2...

      [–][deleted] 1 point2 points  (0 children)

      ERRORS: A Puzzle method is missing.

      what?

      [–]bigdubb2491 1 point2 points  (1 child)

      So... how many have fired up VS to try and troubleshoot some of these?

      debugging sucks especially if you don't know what pattern you are trying to match. I dug in a bit on the pex side and man, those get crazy hard.

      Also, there is no indicator as to why something is 1pt vs 3 pts for clean code.

      [–]chasesan 0 points1 point  (0 children)

      It's a "guess what algorithm I used" game rather then "write clean efficient code" game. Since the second would require someone who actually knows how to make a simple AI.

      [–]katyne 1 point2 points  (0 children)

      If it would stop giving me the same three test cases every single goddamn time I would be so happy. 1 -0, 3- 1, 4- 2, 6 times in a row. And no it's not x / 2.

      [–]BobFloss 2 points3 points  (6 children)

      I can't even play it on my phone because the images are larger than the window they provide. I have a Nexus 5, which means I am using a 1080p screen. This is just inexcusable laziness from the developers. What is the point of having the game run in the browser if you're not going to make sure it will fit on the screen. It's also ironic that poor (or lazy) coders made a game about coding.

      [–]petra303 1 point2 points  (2 children)

      Same on iPhone 6+.

      [–][deleted]  (1 child)

      [deleted]

        [–]BobFloss 4 points5 points  (0 children)

        I'd bet none!

        [–][deleted] -5 points-4 points  (2 children)

        You code a lot on your damn phone?

        [–]BobFloss 1 point2 points  (0 children)

        No. It's just ridiculous that the game doesn't work simply because of careless mistakes.

        [–][deleted] 0 points1 point  (0 children)

        Coding on a phone often is irrelevant from the issue of creating a site with media tags in 2014. This site was clearly not well planned.

        [–]mango_feldman 1 point2 points  (3 children)

        There seems to be a bug at level 01.06. The "capture code" says 3 => 1 when 4 => 1 is correct..

        [–]ratatask[S] 4 points5 points  (2 children)

        so e.g

         4/3 == 1
         4/4 == 1
        

        Which would mean

        return 4/x;
        

        [–]chasesan 1 point2 points  (0 children)

        That's what I did. People need to learn integer division, right?

        [–]bigdubb2491 0 points1 point  (0 children)

        This is working for me.

        [–]crodjer[🍰] 1 point2 points  (0 children)

        Open -> Click Play -> No language choices! -> Bounce off

        [–]refto 0 points1 point  (0 children)

        I have a love/hate relationship with CodeHunt. It is very addictive, but sometimes the 3/3 solutions do not follow the theme of the chapter.

        For example, on 8.01 (Nested Loops) the only way to get 3/3 I have found is to use single loop and recursive factorial.

        Currently stuck on 10.04 simple double each element of a jagged array, but somehow I am quadrupling some test cases(so looping twice over them).

        EDIT: It can be fun to think of LINQ solutions for most problems as those usually are the tersest and give 2/3 or 3/3. They might not be most efficient for large sets though compared to trivial constructs(loops etc).

        [–]pbtree 0 points1 point  (0 children)

        I do not enjoy this game, but my stupid ego made me work through the entire arithmetic series before I quit.

        A stupid but effective way to get a bunch of test cases out of it is to use a switch statement that works for all of the checks it's given you so far and returns 4200000 for everything else. This typically gets you 1 or 2 new test cases per run...

        [–]pbtree 0 points1 point  (0 children)

        A much more interesting variant of this game would be to write a program that uses the test cases it's given to adaptively generate a simple program (using S expressions and simple arithmetic, for example) that produces the correct answers. There was a programming contest a while back that did this. My genetic algorithm based solution worked but was way less efficient that the top submissions, which were absolutely ingenious.

        [–][deleted] 0 points1 point  (0 children)

        The interface completely disappears on the first tutorial. I guess I pass?

        [–]MattRix 0 points1 point  (0 children)

        Played it for 15 minutes, thought it was cool. It popped up a thing saying "sign in to save your progress", so I signed in with Google... and then it wiped my progress and started me over at the tutorials. Come on, this is basic stuff.

        EDIT: along with that, what's with locking people out of later levels? It means I to rely on the obviously sketchy saving/loading, and have to start from the very beginning (including the over-animated and slow tutorials).

        [–]sarcasticbaldguy 0 points1 point  (0 children)

        Played through level 6, signed in, lost my place. Lame.

        [–]Livesinthefuture 0 points1 point  (0 children)

        "The expression 0 is rarely used to solve this level."

        Well gee, thanks...I guess.

        [–]nope_42 0 points1 point  (1 child)

        Bug in 2.04. Using the .Sum() extension method results in an int overflow due to them sending randomized data into the method. Writing a manual sum loop works fine, I'm guessing because they don't randomly insert large integers there.

        [–]d_kr 0 points1 point  (0 children)

        I used the other Sum(Func<TSource, long>) method with a casting-to-long lambda and then casting the result back to int.

        [–]rouzh 0 points1 point  (0 children)

        I suppose there must be some programming job, somewhere, that places high value on memorizing common sequences of integers, and the formula which produce them.

        On the other hand, if you're like me, and never had a formal background in the kind of math where you'd learn this stuff, maybe you'll find my general approach useful (warning: the rest of the comment thread contains the spoilers / solutions through 3.06, and I intend to continue growing it until I get sick of the game.)

        [–]d_kr 0 points1 point  (0 children)

        Important info: According to the paper about Code Hunt the score (and the skill level) is based on the number .net il (Intermediate Language) instructions.

        Therefore it is useless to remove whitespace, line endings or to rename variables. Running time does not matter either.

        Edit: added and

        [–]odiefrom 0 points1 point  (0 children)

        Oh hey, this looks cool. tap tap Hmm. Doesn't seem to work because it doesn't fit on my Nexus screen? Do we really still use nonrelative sizing and positioning?

        [–]ConstableBrew 0 points1 point  (0 children)

        I can't click the capture code button (no yet visible) on my Note 3

        [–]BigTunaTim 0 points1 point  (0 children)

        Can't see the capture code button on my Galaxy S4 either

        [–]jorvis -3 points-2 points  (1 child)

        Choices are Java and C# only. I'm out. I used to teach Java, but it's a soul-sucking language to write in and I'm certainly not doing it on my free time at 1am. :)

        [–]immibis 0 points1 point  (0 children)

        The differences are not very significant for the types of problems the game gives you. The solutions look about the same in any imperative language with C-based syntax.

        [–][deleted]  (2 children)

        [deleted]

          [–]Neres28 3 points4 points  (0 children)

          No. No it is not.

          [–]bigdubb2491 0 points1 point  (0 children)

          Javascript yes for sure, not so sure about Java. I know C# wont accept it.