Programming 1

Put your programming skills to the test in these challenges.

Re: Programming 1

Post by Valparaiso on Mon Mar 01, 2010 1:27 pm
([msg=35943]see Re: Programming 1[/msg])

faazshift wrote:This community is about showing you your resources and sharing knowledge. Its not about giving the answers, but helping you to figure out the answer (or an answer) on your own. Basically community-assisted self-help.

But surely, in the context of a complex programming challenge (in this instance: finding the correct anagram) there is no singular "answer". There are multiple answers, some better than others. That brings me to my original point: collectively, it's likely that we have at least 1 "very good" solution to this problem. This means that, in my opinion, we will have a large number of solutions that are "worse". I'm convinced that almost (if not) all of these "worse" solutions will never be improved upon, simply because very few people will have the motivation to improve something which works good enough. Therefore, by not sharing, it's likely that very few of us will in fact learn anything new.

Your blog post seems to suggest that re-inventing something will automatically make it better, which is in my opinion a semantic misconception about "re-invention". By sharing solutions rather than forcing everyone to re-invent the same thing, we're infinitely more likely to reach a better solution more quickly. If history teaches us anything, it's that a large number of modern day technologies (and evolution as a whole) were not re-invented, they were stolen and improved upon (telephone, radio, ...). Also, your arguments are in complete disregard of time and effort. In an ideal world, theoretically speaking, you're right. Unfortunately, in the real world, all things considered, your "every man for himself" way of thinking will achieve very little and waste a lot.

I realise I'm not going to win any hearts and minds having this discussion, and it may not be the point of this community to share at all, so I'll happily drop it and move on :)
Valparaiso
New User
New User
 
Posts: 4
Joined: Sat Feb 27, 2010 5:51 pm
Blog: View Blog (0)


Re: Programming 1

Post by thefeedinghand on Wed Mar 03, 2010 2:57 pm
([msg=36039]see Re: Programming 1[/msg])

so I just finished my program (in C) and I must say that..... there's not enough time for writing and copy-pasting the words!, I always run out of time, especially because for some reason I can't copy the scrambled words from the page to my program, it just shows a "^V" , there should be an additional 10 seconds...
thefeedinghand
New User
New User
 
Posts: 7
Joined: Wed Aug 05, 2009 6:14 pm
Blog: View Blog (0)


Re: Programming 1

Post by orwell84 on Wed Mar 03, 2010 3:19 pm
([msg=36040]see Re: Programming 1[/msg])

thefeedinghand wrote:so I just finished my program (in C) and I must say that..... there's not enough time for writing and copy-pasting the words!, I always run out of time, especially because for some reason I can't copy the scrambled words from the page to my program, it just shows a "^V" , there should be an additional 10 seconds...

Try right-clicking and choosing the "paste" option. On my computer (ubuntu) you can just right-click and press 'p'
Or you could find out how to access the web page. I'm pretty sure that's what you're meant to find out how to do.
Mens et manus.
User avatar
orwell84
Poster
Poster
 
Posts: 112
Joined: Fri Feb 20, 2009 8:20 pm
Blog: View Blog (0)


Re: Programming 1

Post by thefeedinghand on Wed Mar 03, 2010 3:31 pm
([msg=36041]see Re: Programming 1[/msg])

nevermind I just got it, had to input real fast the words lol, took a few tries, it feels very rewarding :D, especially since it took me like 2 weeks to get this done in C, I'm sure it would've been way easier in other language.

Here's my method (please delete if it's considered a spoiler)
I alphabetically sorted every letter in each string from the wordlist (using the bubble sort LOL) and stored it in a different variable from the one I used to store the list words ,sorted the input words too, then I just used the string comparison function and made it write the string to a textfile whenever the strings matched, so I just had to paste what the text file had directly to the page, and that's it :mrgreen:
thefeedinghand
New User
New User
 
Posts: 7
Joined: Wed Aug 05, 2009 6:14 pm
Blog: View Blog (0)


Re: Programming 1

Post by amainejr on Wed May 05, 2010 6:01 pm
([msg=38385]see Re: Programming 1[/msg])

Is it okay to post code for help? I've got 2 functions i'm questioning and need an eye to see if they can spot my error. I'm having problems stopping my program from continuing a recursion. I can't tell if it is in my condition statement or in the recursion itself. The functions do most of the work, so I feel like it'd be a spoiler if I posted them. The code is in Java. If you can help, shoot me a pm or your e-mail. I don't want the answer, I just want you to look at my code and tell me where my problem is.

-- Sat May 08, 2010 12:37 am --

NVM Got it. I'd still like to ask how do you break from a recursive method in Java, without going through every permutation?
amainejr
New User
New User
 
Posts: 1
Joined: Wed Apr 14, 2010 4:19 pm
Blog: View Blog (0)


Re: Programming 1

Post by msbachman on Wed May 12, 2010 7:54 pm
([msg=38610]see Re: Programming 1[/msg])

I finally did that sum bitch in C.

The end result was not as pretty as I had hoped but it worked just the same.

I'll try to be as specific as I feel I can be without giving away spoilers of how I did it. How I did it was as follows:

two files, one for the scrambled data, one for the list.

If you know php, you'll use code similar to that for opening up two file streams for fgets.

You'll use nested loops for comparing the output of a certain sorting function. If that comparison is a certain value, you'll output the value as a match in the specified format.

Likely, there are better ways of doing this, but since in the grand scheme of things I'm no C expert, this was an effective route for me.

All in all, getting this challenge done was a huge accomplishment for me. I stuck to my guns in C and this was about my fifth time of attempting the challenge seriously. I just gave up when I encountered a road block. My last bit of advice for anyone trying it in C is to stick with it; I learned a ton in the process of coding this and am grateful for the often frustrating experience as a whole.
"I'm going to get into your sister. I'm going to get my hands on your daughter."
~Gatito
User avatar
msbachman
Contributor
Contributor
 
Posts: 685
Joined: Mon Jan 12, 2009 10:22 pm
Location: In the sky lol
Blog: View Blog (0)


Re: Programming 1

Post by Arameus on Fri May 28, 2010 2:38 pm
([msg=39215]see Re: Programming 1[/msg])

if you are doing this in Python you do NOT need to compare each letter in a word one by one. Use the sorted() function instead.

For example:

>>>sorted('bcd') == sorted('cdb')
True
Arameus
New User
New User
 
Posts: 36
Joined: Mon Feb 01, 2010 6:53 pm
Location: Ballston Spa, NY
Blog: View Blog (0)


Re: Programming 1

Post by LCWare on Sat May 29, 2010 3:45 am
([msg=39247]see Re: Programming 1[/msg])

I see alot of complicated methods and ideas just to solve this challenge.
I see alot people getting stuck on the symantics of the term programing or programing languages
Once I created my solution... it took only 2 seconds or less to find the matches and submit the data

I see alot of people sifting or sorting the chars in each word and comparing them...
there is a much better method mentioned in one of the extbasic challenges

Also a way to insert the data into the form is in the Basic challenges

The combination of the two allowed to solve this like makin a cake.
I actually didn't see the need for fancy string searchs and comparasions

This is one lanuage, at is not unlike c but the only difference is that it doesn't get compiled...
probably hence why people are looking overly extravagant solutions in compile-time based lanuages...

These are my hints for those still stuck... the solutions are already here for those that have done basic and extbasic...
what more is needed?
LCWare
New User
New User
 
Posts: 2
Joined: Mon May 24, 2010 12:02 am
Blog: View Blog (0)


Re: Programming 1

Post by vaporware on Wed Jun 02, 2010 8:03 pm
([msg=39429]see Re: Programming 1[/msg])

Just solved this one today.

I used a C++ program that read lines from a cracklist file (copied, pasted, and saved by hand by me), filtered the input to just the characters, passed the array of chars onto a function that counted the occurrence of each letter, number, colon, or parenthesis, loaded the wordlist line by line, did the same for each word (counted each occurrence of each type of character) and compared with the cracklist counts. If they matched the while function was broken and it spat out the wordlist word plus a comma and continued for all ten cracklist words.

This seems like such a tedious method, I really know little about C/C++ and i'm sure there's a more efficient way. Worked in the end though.
"As I did 20 years ago, I still fervently believe that the only way to make software secure, reliable, and fast is to make it small. Fight Features."

-Andrew S. Tanenbaum (Author of MINIX)
vaporware
New User
New User
 
Posts: 7
Joined: Wed Jun 02, 2010 1:37 pm
Blog: View Blog (0)


Re: Programming 1

Post by themagicpickle on Wed Jun 16, 2010 5:47 pm
([msg=40192]see Re: Programming 1[/msg])

I just finished this after starting writing it last night. I wrote the program in C++, and I'm sure this isn't the easiest way to do it, but it's what made sense to me.

I read in all the possible words from wordlist.txt, and saved it in a queue (of strings, modeled by list). I also read in the scrambled words from a text file (scrambled.txt) that I copy and pasted them to each time I tried to complete the challenge. Time usually wasn't a factor, except the computer I'm doing it on takes a while to switch windows sometimes. I used getline() to get the words from scrambled.txt (after I wrote a function to throw out the #s and the spaces), and I sorted the characters in each word before adding it to a queue. I then sorted each word in the wordlist and just looped through until I found the one that matched. The problem I had was figuring out how to output that word unscrambled. I fixed it by copying the (unscrambled) wordlist, and just sorting one of them. Then each time I popped or pushed one of them, I did the same to the other. I used q.front() to check for equality, then outputted p.front() to get the corresponding word.

It took me a while, but I was also unfamiliar with C++. My school uses a modified version of it that is better for teaching theory, and it's a lot easier to program with it, but I thought I should try using a language that's actually used in the "real" world. If anyone's got any tips I'd love to hear them.
themagicpickle
New User
New User
 
Posts: 3
Joined: Tue Jun 08, 2010 12:25 am
Blog: View Blog (0)


PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests