Tags: programming
Rating:
# Challenge: Golf (Programming)
---
### Solution Codes
```c
# Chars: 46
main(){for(int i=0;i<4;i++)puts("* * * * *");}
# Chars: 40
main(i){for(;i<5;i++)puts("* * * * *");}
# Chars: 39
main(i){for(;++i<6;)puts("* * * * *");}
```
#### Calculate number of characters of file
```bash
$ cat <filename>.c | sed -z '$ s/\n$//' | wc -c
```
#### Compile the program
```bash
$ gcc <filename>.c -o <output_filename>
# Result for Chars: 46
test.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
1 | main(){for(int i=0;i<4;i++)puts("* * * * *");}
| ^~~~
test.c: In function ‘main’:
test.c:1:28: warning: implicit declaration of function ‘puts’ [-Wimplicit-function-declaration]
1 | main(){for(int i=0;i<4;i++)puts("* * * * *");}
| ^~~~
test.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘puts’
+++ |+#include <stdio.h>
1 | main(){for(int i=0;i<4;i++)puts("* * * * *");}
```
#### Run the program
```bash
$ ./<output_filename>
* * * * *
* * * * *
* * * * *
* * * * *
```