Programming 1

Put your programming skills to the test in these challenges.

Re: Permanent Programming 1

Post by Sepanto on Sat May 03, 2008 3:31 pm
([msg=1994]see Re: Permanent Programming 1[/msg])

I work in C, compiled under GNU C COMPILER
I wrote my input with files, so as to save time (I just copy paste the input to a file and run the program - which outputs me to a file - I copy paste it ) I have several problems -
the fprintf() function outputs me each word on it's own line - does anyone know how to make all the words comeout in the same line??
When I input the words (cpy/paste from the site) I have "# " before each word. This is what I tried for solving it, but it still gives me a bad output.
Code: Select all
void get_word(char* word)
{
int len=strlen(word),cnt=0,i,j;
char word1*;
while (!((*word<'=Z)'&&(*word=>'A')||((*word=<'z')&&(*word=>'a')))
{
cnt++;
word++;
}
word1=(char*)calloc(len-cnt+1,sizeof(char));

for (i=cnt;i<=len;i++)
word1[i-cnt]=word[i];
free(word);
word=(char*)calloc(strlen(word1)+1,sizeof(char));
strcpy(word,word1);
free (word1);
}
Sepanto
New User
New User
 
Posts: 7
Joined: Tue Apr 22, 2008 1:16 pm
Blog: View Blog (0)


Re: Permanent Programming 1

Post by lolobip on Sat May 03, 2008 4:22 pm
([msg=1996]see Re: Permanent Programming 1[/msg])

You'd be better off doing this with a higher level language with some more built in functions which would do the triming and sorting job for you, instead of going nuts with C...

I remember doing this with php / html (with an input form ) and it worked like a charm :)
lolobip
New User
New User
 
Posts: 13
Joined: Sun Apr 13, 2008 4:11 pm
Blog: View Blog (0)


Re: Permanent Programming 1

Post by Sepanto on Sun May 04, 2008 2:14 am
([msg=2044]see Re: Permanent Programming 1[/msg])

Problem is I know only c/c++ and assembly...
Sepanto
New User
New User
 
Posts: 7
Joined: Tue Apr 22, 2008 1:16 pm
Blog: View Blog (0)


Re: Permanent Programming 1

Post by sharpskater69 on Sun May 04, 2008 3:17 am
([msg=2046]see Re: Permanent Programming 1[/msg])

Sepanto: It's not a problem. It's still possible to make a cleaning function, just not as convenient as a higher level language. Read the input into lines, then discard the # and whitespace characters with an if statement. string::erase or just copy the characters into new strings without those characters or something.
sharpskater69
New User
New User
 
Posts: 34
Joined: Tue Apr 22, 2008 4:10 pm
Blog: View Blog (0)


Re: Permanent Programming 1

Post by Sepanto on Sun May 04, 2008 10:43 am
([msg=2079]see Re: Permanent Programming 1[/msg])

That's what the code I posted above is meant to do.... only it doesn't lol
Sepanto
New User
New User
 
Posts: 7
Joined: Tue Apr 22, 2008 1:16 pm
Blog: View Blog (0)


Re: Permanent Programming 1

Post by lambda0 on Sun May 04, 2008 5:47 pm
([msg=2116]see Re: Permanent Programming 1[/msg])

Sepanto wrote:That's what the code I posted above is meant to do.... only it doesn't lol


Story of my life...
User avatar
lambda0
New User
New User
 
Posts: 20
Joined: Sun May 04, 2008 7:00 am
Blog: View Blog (0)


Re: Permanent Programming 1

Post by xerox_personality on Thu May 08, 2008 9:59 pm
([msg=2145]see Re: Permanent Programming 1[/msg])

Does anyone know if there is a html version of the wordlist somewhere? I cant d/l zip files on the computer im using :(
xerox_personality
New User
New User
 
Posts: 1
Joined: Thu May 08, 2008 7:57 pm
Blog: View Blog (0)


Re: Permanent Programming 1

Post by danijelfosters on Fri May 09, 2008 12:30 am
([msg=2151]see Re: Permanent Programming 1[/msg])

Today I finnaly maded, but I haven't change anything at all, interesting, not a slight change, just done the same thing as 100 times before. 8-)

xerox_personality wrote:Does anyone know if there is a html version of the wordlist somewhere? I cant d/l zip files on the computer im using :(


Why can't U download, what are U using, OS, browser, etc ...?
danijelfosters
New User
New User
 
Posts: 5
Joined: Sun Apr 20, 2008 2:26 am
Blog: View Blog (0)


Re: Permanent Programming 1

Post by pokerhermit on Fri May 09, 2008 10:28 pm
([msg=2190]see Re: Permanent Programming 1[/msg])

funny, I am having the same problem as danijelfosters.
I'm sure I have the right words, but my formatting could be wrong. I tried commas with no spaces and no comma on the end. Tried it a few times actually. Then tried putting some spaces in. Well, it's very frustrating. I hope it just magically works one day, like it did for you.

-------------------
Edit: I woke up this morning. Ran it again without changing the script. And my answer was magically correct.
pokerhermit
New User
New User
 
Posts: 1
Joined: Fri May 09, 2008 4:03 pm
Blog: View Blog (0)


Re: Permanent Programming 1

Post by thehare on Sun May 11, 2008 8:08 pm
([msg=2281]see Re: Permanent Programming 1[/msg])

hey im just wondering can python be used to beat this challenge
and if it is can some1 pm so they can tell me wats wrong with my code
thx

:?: thehare :?:

EDIT: NVM ill try by myself :D
thehare
New User
New User
 
Posts: 8
Joined: Sun Apr 20, 2008 6:26 pm
Blog: View Blog (0)


PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron