facebook puzzle submission failure
I tried submitting the first facebook puzzle to the facebook bot, but i got a reply that my code never compiled. I wrote the code in c (linux gcc compiler) and sent it via gmail. I didn't understand what they exactl开发者_开发百科y wanted me to send, so i sent the .c file and the linux executable file. Have I sent the right files or should i create some other file for the bot to do it's work?
Since the bot never gives accurate reasons why the code never worked, please check if my logic was alright. Here is the code:
#include<stdio.h>
int main(int argc, char *argv[])
{
freopen(argv[1], "r", stdin);
int n;
scanf("%d", &n);
for(int i=1;i<=n;++i)
{
if((i%3==0)&&(i%5==0))
{
printf("Hop\n");
}
else if(i%3==0)
{
printf("Hoppity\n");
}
else if(i%5==0)
{
printf("Hophop\n");
}
}
return 0;
}
Thanks :)
You'll need to attach a makefile that compiles the executable to the same name as the assignment, and adding +x chmod doesn't hurt. You then attach both your makefile and c source (you can optionally archive it if you want).
Also, I haven't checked recently, but the bot also has problems with most email services with the exception of hotmail. So you'll need to open a hotmail account and use that to send it to the bot.
(I would post links, but I can't find the original discussions I found the info above). You can see the Puzzle Master discussions for general info about the facebook puzzle challenge stuff.
Granted, it is annoying that the email lacks details about what went wrong.
Makefiles
Here's an example Makefile for the facebook puzzle challenge from David Eisenstat:
# If you copy and paste this Makefile, change the eight space indent to a tab.
hoppity: hoppity.c Makefile
$(CC) -std=gnu99 -O2 -o $@ $< -lm
The basics of a makefile is in "goal: dependencies" followed by commands to execute (prefixed by a tab). There are plenty of resources online about makefiles (since I'm no guru about makefiles). Like this one for example.
Then, if you want to test the compilation cycle yourself (assuming you have make and a c compiler), invoke make
in the command line (after cd-ing to the directory where the makefile is located).
So how do i create a make file? I'm new to linux c programming. Thanks :) – Jay 18 mins ago
Just copy and paste the example Makefile into a file called "Makefile" in the same directory as your source code. Then at the command line type "make", and the code will be compiled (or not, pending errors).
I got the puzzle submitted successfully. It did work with gmail but it didn't work with live mail. I never got a reply when I used live mail.
makefile contents:
hoppity: hoppity.c makefile
gcc -std=c99 -o hoppity hoppity.c
Thanks everyone :)
精彩评论