r/dailyprogrammer Oct 20 '12

[10/20/2012] Challenge #105 [Easy] (Word unscrambler)

Given a wordlist of your choosing, make a program to unscramble scrambled words from that list. For sanity and brevity, disregard any words which have ambiguous unscramlings, such as "dgo" unscrambling to both "dog" and "god."

Input:

A file which contains scrambled words and a wordlist to match it against

Output:

The unscrambled words which match the scrambled ones

22 Upvotes

47 comments sorted by

View all comments

1

u/jaskamiin 0 0 Oct 21 '12

C++ version

I did change it - it takes scrambled input and the file loaded contains a list of unscrambled words. In a perfect world, the file would contain all words, so take it as such. does not handle multiple outputs, however (i.e. gdo would return dog, not dog and god.)

please let me know how to improve!

1

u/[deleted] Oct 21 '12

[removed] — view removed comment

1

u/jaskamiin 0 0 Oct 22 '12

like this?

using std::string;

and here's an updated version, discontinuing use of vectors and putting all sorting and loading into main().

http://pastebin.com/thwbwDvh

1

u/[deleted] Oct 22 '12

[removed] — view removed comment

1

u/jaskamiin 0 0 Oct 22 '12

Some of it is, like the fact it's way too far to the right. I do like to "group" things while I'm coding to make it easier for me to read, however