Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1234 - C (56 characters) #4

Closed
KernelEquinox opened this issue Nov 2, 2018 · 3 comments
Closed

1234 - C (56 characters) #4

KernelEquinox opened this issue Nov 2, 2018 · 3 comments

Comments

@KernelEquinox
Copy link

Here ya go~

Compiles with gcc main.c

// a=argc (1)
main(a)
{
    // b=1, c=4
    // Loop until a == 5
    for(int b=a,c=b+b<<b;a<=c;)

        // c-b<<c  ==  3<<4  ==  48 (ASCII '0')
        // Add a to print its ASCII value
        putchar(c-b<<c|a++);
}

Minimal version:

main(a){for(int b=a,c=b+b<<b;a<=c;)putchar(c-b<<c|a++);}
@ISSOtm
Copy link
Owner

ISSOtm commented Nov 3, 2018

Clever one! However, it relies on the way it's called - only one argument, which puts it in the troll category. :/

ISSOtm added a commit that referenced this issue Nov 3, 2018
As suggested in #4; sadly it relies on `argc`, although I'd love to make an exception because it's the only program I've seen so far that relies on argc being *one* :P
@KernelEquinox
Copy link
Author

KernelEquinox commented Nov 4, 2018

Here we go, updated the code to be in accordance with the rules, 61 chars total.

main()
{
    // a=1, b=1, c=4
    // Loop until a == 5
    for(int a=!!a,b=a,c=b+b<<b;a<=c;)

        // c-b<<c  ==  3<<4  ==  48 (ASCII '0')
        // Add a to print its ASCII value
        putchar(c-b<<c|a++);
}

Minimal version:

main(){for(int a=!!a,b=a,c=b+b<<b;a<=c;)putchar(c-b<<c|a++);}

@ISSOtm
Copy link
Owner

ISSOtm commented Nov 5, 2018

Purrfect.

@ISSOtm ISSOtm closed this as completed in cc9e3bd Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants