What's so bad if anyone who has completed the challenge is posting his code, m!nus?
Absolutely no reason to be pissed
Well I don't have my code here right now on this machine but I can tell you it's MUCH more longer so I have obviously done the thing way too complicated. And that's the reason why I think it's a good think to see some code of others in the "Challenges Solved" forum, because it's nice to learn something and see what I can do better in the future.
If we all think we are the best and the code of the others is shitty, posting in this part of the forum is senseless anyway.
just programming it straight bit for bit with no tricks at all you get 54 instructions which is 29 instructions shorter than Lukas's code and easier to understand, but that's really nothing to get excited about -- a bit different to the tricky program for the smallest mouse with only 21 instructions ...
I have no problems to publish the xor solution here, but I don't know the policy of this forum -- so may one of the moderators may put a comment on this. I think it's better to discuss the results on "real code" than gloating about it only with instruction lengths or so.
Although I am not a moderator, I think it's quite good to discuss the result, including the code, and that is the role of this "Challenges Solved" forum. But, as m!nus says, just showing the code is a bit pointless.
And we must take care not to spoil other challenges. For example, we should not show the answer to the "Mod" challenge which is also valid to the "Fast Mod" challenge, in the "Mod" thread. Of course, showing it in the "Fast Mod" thread is ok. It's applicable not only to the code itself but also to the underlying thoughts and ideas of the code.
Some of us, including me, are taking better care not to spoil the possibilities of future challenges. That's why we're sometimes refering to only the length of the code.
I agree with tails.
And I think we should also cherish the "hacker" term. Hacker works alone. Don't reduce it to "script kiddie". Discussing the challenges and their solutions is fine but code sharing is a bit overkill, I think. And the crowd here is probably not the one that would give you a nice "peer review" anyway. So I am second to m!nus here as well - "and you call this your code ?"
I think careful posting and discussion of code is really valuable. The discussion with therethinker and tails in the quinine- and mighty-quine-threads is a good example .. you see other ideas and get inspiration for your own code. Meanwhile, the quinine-thread is also an example for the danger of posting code: In part, it spoils mighty-quine. But hey... mighty quine arose from this thread, so this again shows the value of discussing code.
I totally disagree with this sentiment, but I don't really want to argue about it.
I agree with you gfoot, a hacker doesn't have to work alone, teamwork doesn't make him less of a hacker, plus if you work together with someone else you can exchange ideas that the other one maybe would have never come up with.
p.s. i wanna do quine but i'm too lazy to do spiral bits
m!nus wrote:i wanna do quine but i'm too lazy to do spiral bits
Oh, Spiral Bits is fun! Really! One of the challenges where there are many possible approaches and you can get really creative (unless you are doing it by hand ).
the_impaler wrote:I agree with tails.
And I think we should also cherish the "hacker" term. Hacker works alone. Don't reduce it to "script kiddie".
I disagree, violently so. Script kiddies work alone. Hackers most of all want to understand and learn, and both of those are much easier when talking to others to compare idead (and impossible without that beyond a certain point).
In a way I think it's a shame that we can't freely share solutions and algorithms with everyone here, because while the competion of finding them yourself is a great motivator, it also reduces or completely eliminates the possibility to learn from others.
Thanks to lukas for posting his code! I completely agree with theStack. No code is pointless if it solved the challenge! I'd like to see other solutions in the "Solved" forum even if there's no comment at all!
In the forum very often people say it's great to learn from the challenges. But you don't learn just by dealing with a problem... you also learn by dealing with other peoples work. Don't be greedy! Share your code (the only one exception: spoilers to another challenge)! You'll never need it in a real life environment, so why keep it secret?
It uses the modulo code from the previous challenge, works with any positive numbers and is only limited by HackVM internal integer definition.
Obviously it's not the shortest one so I encourage again everybody to post (and discuss) their solutions!
A)
0: move 1 to M[2] /* in M[2] is used as counter */
1: while (a != 0 || b != 0) {
2.0: if (a % 2 != b % 2) {
2.1 M[3] += M[2] /* in M[3] the result is saved*/
}
3.0: a /= 2
3.1: b /= 2
3.2: M[2] *= 2
}
4: print M[3]
B)
0: 12>
1: 0<0:(Quantity_Instructions_until_4)? 0<1:(Quantity_Instructions_until_2.0)? 1<0:(Quantity_Instructions_until_4)?
2.0: 0<0<2/2*-1<1<2/2*-:(Quantity_Instructions_until_3.0)?
2.1 3<2<+3>
3.0: 0<2/0>
3.1: 1<2/1>
3.2: 2<2*2>
3.3: (Negative_Quantity_Instructions_until_1)g /* this is necessary to replace while in number A) 1: */
4: 3<p
C)
12>0<0:89*0d?0<1:25*?1<0:69*0d?0<0<2/2*-1<1<2/2*-:7?3<2<+3>0<2/0>1<2/1>2<2*2>099*1+-g3<p