Live data from Hacker News

C implementation of Tic-Tac-Toe in a single call to printf

github.com

31–40 of 85 posts

Re: C implementation of Tic-Tac-Toe in a single call to printf

#31
post #28

> in a single call to printf > while(*d) printf(fmt, arg) How's that a single call ?

> How's that a single call syntactically it is. But it's not a very clear description. So how would you describe that single call location getting executed in a loop so everybody understands what is really meant? A single line of code is worse.

"a call to printf in a while loop"

Re: C implementation of Tic-Tac-Toe in a single call to printf

#32
post #11

I am afraid that the author has disqualified himself by publishing the source code before the judging of IOCCC 2020 is over. See catch 22 in the rules: "The judges STRONGLY prefer to not know who is submitting entries to the IOCCC."[1] Even the winners are asked not to publish the code until it is available on the IOCCC web site.[2] [1] https://ioccc.org/2020/rules.txt [2] Personal communication

It is true that publishing the source code this early is risky, but submitting the code that has been already published is not prohibited by its own. My winning entry (2012/kang [1]) was in fact published independently and was even on HN [2]. I'm pretty sure that this is not the only occurrence, having seen some winning entries trending on Twitter before the public announcement.

[1] https://www.ioccc.org/2012/kang/

[2] https://news.ycombinator.com/item?id=2748402

Re: C implementation of Tic-Tac-Toe in a single call to printf

#34
post #16

Earlier quoted context omitted.

Hence advanced bait. printf() is called in a while loop, so it is hardly a single call.

I don’t want to jump on the title hate bandwagon - what the author has done is definitely creative and clever and this discussion detracts from it - but it also uses scanf.

Where?

    int main() {
        while(*d) printf(fmt, arg);
    }

Re: C implementation of Tic-Tac-Toe in a single call to printf

#35
Oddly enough I find that the #define macro soup detracts from the performance here. I was rather unimpressed at first because obfuscating C code by just #define'ing a bunch of code is a trivial and rather uninteresting way to write unreadable code. Of course you can make any arbitrary code look like a printf call with enough macros!

But it's actually a lot more clever than that.

I feel like this would be a lot more impressive if it was written in simple and clear C since then you'd see that there really isn't any tic-tac-toe logic being explicitly implemented the way you'd expect.

Re: C implementation of Tic-Tac-Toe in a single call to printf

#36

Earlier quoted context omitted.

I don’t want to jump on the title hate bandwagon - what the author has done is definitely creative and clever and this discussion detracts from it - but it also uses scanf.

Where? int main() { while(*d) printf(fmt, arg); }

On line 57: https://github.com/carlini/printf-tac-toe/blob/master/printt...

Re: C implementation of Tic-Tac-Toe in a single call to printf

#37

This is just crazy and I love it From a description on the author's website[1] of a Doom clone written in 13k of JavaScript. > Until recently all content on this website was research, and while writing papers can be fun, sometimes you just need to blow off a little steam. I think more companies should allow for their employees to have some plain old fun with no strings attached on a regular basis. [1] https://nichola…

>with no strings attached

What about char arrays?

Re: C implementation of Tic-Tac-Toe in a single call to printf

#39

This is just crazy and I love it From a description on the author's website[1] of a Doom clone written in 13k of JavaScript. > Until recently all content on this website was research, and while writing papers can be fun, sometimes you just need to blow off a little steam. I think more companies should allow for their employees to have some plain old fun with no strings attached on a regular basis. [1] https://nichola…

>I think more companies should allow for their employees to have some plain old fun with no strings attached on a regular basis. Maybe we could call this additional 'holiday pay' or a longer 'weekend' and mandate it through law so that everyone benefits.

a law would be government overreach, but the idea is solid and the results tangibles; should be within the realm of a union regulations, if we ever manage to get one going.

Re: C implementation of Tic-Tac-Toe in a single call to printf

#40
post #36

Earlier quoted context omitted.

Where? int main() { while(*d) printf(fmt, arg); }

On line 57: https://github.com/carlini/printf-tac-toe/blob/master/printt...

Ah, well spotted, thanks. I didn't think it was fair to call the title click bait just because it used a while loop to drive the calls to printf, but also including a scanf call is definitely not in the same spirit.
Post reply on HN