Help with Assignment

I have a problem given to me. It's just to create a hello world program. But, I can only use 45 characters at most. what the. So how do I do it?
So what's your best attempt so far?
65 characters.
1
2
#include<iostream>
int main(){std::cout<<"Hello World";return 0;}
You can't.
1
2
#include<iostream>
int main(){std::cout<<"Hello World";}

is already 55 characters if you remove the return statement.

I'm sorry, but you were assigned a horrible garbage assignment and should really be thinking about the quality education you're receiving. A hello world program in Python is already 20 characters. In C++, you have to include libraries to print and define a main function (which will obviously reach over 45 characters).
I guess it depends on how many rules you're willing to break, and which language you choose.

1
2
3
4
5
6
7
8
9
$ cat main.c
#include<stdio.h>
main(){puts("hello world");}
$ gcc main.c
main.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main(){puts("hello world");}
 ^
$ ./a.out 
hello world


These types of problems (aka magic tricks) are fun diversions when you're feeling bored, but teach you nothing about how to write programs properly.

@salem_c, If you count newlines, that's 47! So it depends on whether newlines count, too. But you could break yet another rule and leave out the header, resulting in 29 characters (counting the newline).

 
main(){puts("hello world");}

Last edited on
This compiles:
1
2
#include<stdio.h>
main(){puts("hello world");}

But its 46 characters. So...
damn
Where did you get this task from?

- Clueless college professor?
- Clueless archaic TurboC orientated website?
@fiji885, Its not a garbage assignment, it's a problem from RI (a school in Singapore). If it was garbage, they wouldn't assign it and plus, there have been 379 people who completed it!
@salem_c From a auto judging auto grading site called mrjudge. The website is dunjudge.me.
Yeah, it is a very bad assignment.

salem c:
These types of problems (aka magic tricks) are fun diversions when you're feeling bored, but teach you nothing about how to write programs properly.

which I couldn't have said better myself.

Bulbasheen:

This compiles:
1
2
#include<stdio.h>
main(){puts("hello world");}


But its 46 characters. So...
damn


This isn't even C++ anymore. If you can use C, it'll work, but as dutch has mentioned, you'll have to break a rule.

So yes, this assignment is pretty useless since it doesn't really teach you how to do anything useful.
I know.
But I still need to complete it

Edit: This is a golf problem. Still a bad one though.
Last edited on
Bulbasheen wrote:
This compiles:
1
2
#include<stdio.h>
main(){puts("hello world");}

But its 46 characters. So...
damn

Bulbasheen, just use the C++ header (<cstdio> instead of <stdio.h>) and you can save one character.
Woah.
Thanks it worked!
Now I can do a better and more interesting problem.
Topic archived. No new replies allowed.