This may end up being a total failure. I hope it does not :P

So it is a puzzle for programmers (actually, 2 puzzles).

The first puzzle will be used as filter and solving it will give you access to 3 bundle GAs (no CV requirement) and the second puzzle.
The second puzzle will be a group puzzle (shared answers) with questions related to different programming languages, and solving it will give you access to 1 bundle and 1 no bundle GA (great game IMHO).

I'm not sure how many programmers are here in SG, neither how many enjoy solving puzzles, so I made it a group puzzle to avoid having no solvers. If it turns out to be too easy, there is always time for a future harder puzzle :D

Please post all the second puzzle questions/thoughts/shared breakthroughs in this thread and not in the GAs :D

Without further ado, the puzzle.

I hope you enjoy it.

Countdown

EDIT: Added languages poll: poll
EDIT2: It seems I forgot about the most used lang according to the poll. My apologies to the java coders U_U
EDIT3: It would we nice if the solvers post here the code used to solve it (for those questions where the answer is not the code itself) :D

9 years ago*

Comment has been collapsed.

JavaBump.

9 years ago
Permalink

Comment has been collapsed.

I've done no programming that has to do with the internet, just some basic ADA programming at the university (mandatory programming class), which I was quite good at, for a noob! Got the highest possible score at the final exam.

I'll give this a go and see what happens. Messed around and got the perhaps comical "cannot get some" message, poor server :D

9 years ago
Permalink

Comment has been collapsed.

Trying some random answers will start the hint coundown I guess, and the hint may give you some tools to solve it :D

9 years ago
Permalink

Comment has been collapsed.

Too easy, didn't even wrote a line of code :P

9 years ago
Permalink

Comment has been collapsed.

Seriously, Brainfuck? That's hilarious.

9 years ago
Permalink

Comment has been collapsed.

I wasn't the first to solve #4 but I did this in the console

< window.words = $("body strong").text().split(' ');
< $.each(window.words, function( index, value ){ if( value.length == 7) { window.count++;}});
< window.count;

445

9 years ago
Permalink

Comment has been collapsed.

Oh, boy, forgot about the "alignment" on the CSS one, lol...

So, regarding the C# one, I can't understand the relationship between the numbers and the output necessary? Anyone? Am I making sense?

9 years ago
Permalink

Comment has been collapsed.

It's a simple modulus. I have a working solution but ITH doesn't seem to like the variable names that I'm using; is there a way to somehow generalize them in C#?

9 years ago
Permalink

Comment has been collapsed.

Not really, I don't know C#. I was going to try and research a way to do that. I'm not really sure what a modulus is... :/

9 years ago
Permalink

Comment has been collapsed.

9 years ago
Permalink

Comment has been collapsed.

Ooh... Ok, language barrier. :P Thanks. :)

9 years ago
Permalink

Comment has been collapsed.

Ok, it's solved. It was probably the variable names... Thanks! Hi five! o/

9 years ago
Permalink

Comment has been collapsed.

I tried both e,f (next available alphabetically) and x,y; must have been the spaces within the statement. In any case, solved now!

9 years ago
Permalink

Comment has been collapsed.

I forgot to mention the variable names, my bad!

9 years ago
Permalink

Comment has been collapsed.

Java & C.

9 years ago
Permalink

Comment has been collapsed.

bah SQL question was already done by the time I got there :(

9 years ago
Permalink

Comment has been collapsed.

never touched ruby before now, think i have the answer but it wont take, I tested @ repl.it and get the right output.

Am I close?

>  m1
undefined local variable or method `m1' for #<Context:0x00000000b63d70>
(repl):1:in `initialize'
>   m2
undefined local variable or method `m2' for #<Context:0x00000000b63d70>
(repl):1:in `initialize'
>   [:m1, :m2].each do |m| 
.. eval "def #{m}; puts :#{m}; end" 
.. end
=> [:m1, :m2]
>   m1
m1
=> nil
>   m2
m2
=> nil
9 years ago
Permalink

Comment has been collapsed.

Tried to remove the unnecessary spaces, to no avail.

9 years ago
Permalink

Comment has been collapsed.

That's a completely valid answer. I prefer to avoid eval because it is usually seen as a security risk and a bad practice, but if no one can come up with the actual answer I'll add it as valid.
Basically, you need to dynamically define methods without using eval.

9 years ago
Permalink

Comment has been collapsed.

Well for never touching Ruby you are really making me research :) . I did come up with another way that works, with no eval, but also wont accept

self.class.send(:define_method,m){puts m}

closer?

9 years ago
Permalink

Comment has been collapsed.

Working from where you started, I got to the answer, but gorok got it first!

9 years ago
Permalink

Comment has been collapsed.

Ahh I was close, but looks like REPL.it doesn't work like the real IRB because define_method(m){puts m} fails for me.

ohh well learned a lot :)

9 years ago
Permalink

Comment has been collapsed.

I had to try several online compilers till I found one that worked.

9 years ago
Permalink

Comment has been collapsed.

Finally I found the correct shortest code. Damn annoying when half of the online ruby compilers tell me they don't know define_method, and one that doesn't complain about the method doesn't let me write []{}.

Once I finally found a useful compiler I finally was able to work on a solution. Probably would have been easier if I actually had real Ruby practice instead of just doing a short tutorial a few months ago.

9 years ago
Permalink

Comment has been collapsed.

I work with Ruby so I didn't use an online REPL (for the other ones I used this) and instead used pry. I'll keep this in mind for the next puzzle :D

9 years ago
Permalink

Comment has been collapsed.

After some searching I found this. I then used it for C too since I had it open already.

I also tried the one you used, but for some strange reason I am not able to enter [,],{ and } there (maybe cause I'm not using an English keyboard layout?). Copy&paste also doesn't work there, so I had to find something else.

9 years ago
Permalink

Comment has been collapsed.

Q7, where do we go from here?

void fun(char**a,char*b,char*c){strcpy(c,*a);strcat(c,b);}

9 years ago*
Permalink

Comment has been collapsed.

C noob here, I was pretty close but don't really know how to pass references around

void fun(char &a,char b,char &c){strcpy(c,a);strcat(c,b);}

9 years ago
Permalink

Comment has been collapsed.

That code/syntax would be C++, C simply does not support references.

9 years ago
Permalink

Comment has been collapsed.

I was trying with

void fun(char**a,char*b,char*c){sprintf(c,"%s%s",*a,b);}

but no luck either.

9 years ago*
Permalink

Comment has been collapsed.

The "printing" is already in the provided code, so I guess this is not the way. :/

9 years ago
Permalink

Comment has been collapsed.

sprintf doesn't print. It outputs the result to the string passed as first parameter using a printf like format.

9 years ago
Permalink

Comment has been collapsed.

Oh, my bad, didn't read it properly. :/

9 years ago
Permalink

Comment has been collapsed.

I tried something very similar. Code works but it is not the correct answer either.
void fun(char**a,char*b,char*c){strcpy(c,*a);strcat(c,b);}

9 years ago*
Permalink

Comment has been collapsed.

Try using this character ` to make a code comment.

9 years ago
Permalink

Comment has been collapsed.

Thanks, couldn't figure out why it wasn't working. Was the wrong character. :)

9 years ago
Permalink

Comment has been collapsed.

Ok, mine was printing some garbage. Changing the first strcat to strcpy solves that, making it like yours is now. Also, removed some additional spaces to make it exactly like yours.

Where can we go from there?

9 years ago
Permalink

Comment has been collapsed.

There must be a different string function that can do this. Maybe it is possible in one line instead of two.

9 years ago
Permalink

Comment has been collapsed.

Not sure...

void fun(char**a,char*b,char*c){strcat(strcpy(c,*a),b);}

Less legible, but a little shorter. :P not right either.

9 years ago
Permalink

Comment has been collapsed.

I just came up with the same thing :)

Now I'm wondering what else to try.

9 years ago
Permalink

Comment has been collapsed.

void fun(char**a,char*b,char*c){memcpy(c,*a,5);memcpy(c+5,b,10);}
This also works but it is not the right answer.

9 years ago
Permalink

Comment has been collapsed.

Thanks for reminding me that c+5 can be used as starting position for copies :)

void fun(char**a,char*b,char*c){strcpy(c,*a);strcpy(c+5,b);}
9 years ago
Permalink

Comment has been collapsed.

We did it! :)

9 years ago
Permalink

Comment has been collapsed.

So that ended being the "correct" answer. I find that very bad code, since it's assuming the length of a is 5. A function shouldn't assume something like that.

9 years ago
Permalink

Comment has been collapsed.

Yeah, makes it more specific, less generic. :/

9 years ago
Permalink

Comment has been collapsed.

That and c + strlen(a) (or c) were the initial solutions.

9 years ago
Permalink

Comment has been collapsed.

That (your first comment) was one of the answers I was looking for (the other one being two strcpy (the one that gorok found 3 seconds before this comment lol xD)), but for some reason it wasn't listed as solution. Just added it! Sorry for the inconveniences.

9 years ago
Permalink

Comment has been collapsed.

Hi I am trying the first puzzle but cant seem to get the formatting correct, i am fairly certain i have the correct post request...

any pointers?

$.post("ur'",{var:data});

9 years ago
Permalink

Comment has been collapsed.

the answer is in the returned data from the post

9 years ago
Permalink

Comment has been collapsed.

Thanks OpNop;
its still not accepting it... i paste the code starting with $.post(); in the textbox with the check button.. am i doing something wrong?

will an alert suffice like so:

function(data,status){
alert("Data: " + data + "\nStatus: " + status);
}

dont want to post my soln here without spoiling it for everyone...

9 years ago
Permalink

Comment has been collapsed.

You need to do the actual POST yourself to "http://ithpuzzle.herokuapp.com/some/url", when you do it, you will get a message back from the server to paste as the answer.

so to clarify, the correct answer is NOT how to POST, but the data you get back from the POST

9 years ago
Permalink

Comment has been collapsed.

ohhhhh....

got it working

Thanks a bunch!!

9 years ago
Permalink

Comment has been collapsed.

when you enter into a puzzle and you realize that everyone knows more than you and the puzzle is about programming...

View attached image.
9 years ago
Permalink

Comment has been collapsed.

wow, can't believe I figured out the GLSL one. Just started messing around @ https://www.shadertoy.com and looking for math functions and boom found it

9 years ago
Permalink

Comment has been collapsed.

Good thing you solved that, cause I doubt I would have gotten that.

9 years ago
Permalink

Comment has been collapsed.

Thanks for the fun puzzles! It looks like there is quite a bit of interest in this type of puzzle, given that the solution came many hours before the hints were revealed.

9 years ago
Permalink

Comment has been collapsed.

Bump for solved, if solved is the right word - the second puzzle was done before I got there!

9 years ago
Permalink

Comment has been collapsed.

Damn, too late to solve anything in part two... I pretty much only do java, given the choice... but I have used quite a few other ones as well...

9 years ago
Permalink

Comment has been collapsed.

Aww, it seems I arrived late. It seems it was fun, though. Thanks!

9 years ago
Permalink

Comment has been collapsed.

I was too late for Co-op but it looks like it was fun. Bump!

9 years ago
Permalink

Comment has been collapsed.

Ok ok I took the hint T_t

9 years ago
Permalink

Comment has been collapsed.

Have a shy bump from a non-programmer.

Got the first one right though - the second one was already done - but the questions and answers made for an interesting read. Thank you for the puzzles :D

9 years ago
Permalink

Comment has been collapsed.

BUMP for the nice puzzle :) (though it seems I'm quite late)

9 years ago
Permalink

Comment has been collapsed.

ooooh coooolllll~~~~ i'm gonna do one like this someday too! may i copy your idea??? xP

9 years ago
Permalink

Comment has been collapsed.

Way too late for the coop, but thanks and have a bump

9 years ago
Permalink

Comment has been collapsed.

Late as always

9 years ago
Permalink

Comment has been collapsed.

Try again ;)

P.S.

BASIC ftw =3

View attached image.
9 years ago
Permalink

Comment has been collapsed.

Closed 9 years ago by akhanubis.