Programming 1

Put your programming skills to the test in these challenges.

Re: Programming 1

Post by dm79 on Tue Aug 10, 2010 8:43 am
([msg=43499]see Re: Programming 1[/msg])

I have not done this one yet but i think i will do it differently.

It are single words. Letters are hustled but not encoded.if you replace al letters by ascii value and then sort all the words in numerical form (acs/desc what you want). The words in the scrambled list and in the given list will appear as the same number or have the same value if you will. Then just look em up. so;

for every unscrambled word to look up and in the wordlist:
- replace all letters with ascii value
- sort(all words)
- sort(the word list)

Using arrays this would be fairly simple.

Using byte of math you could also reduce the length of the target list before the loop up:
by calculating the average of all numbers in the list you can discard the upper or lower half of the list.

Am i right or making a mistake? :roll:
dm79
New User
New User
 
Posts: 6
Joined: Fri Apr 18, 2008 3:34 pm
Blog: View Blog (0)


Re: Programming 1

Post by fashizzlepop on Tue Aug 10, 2010 10:10 am
([msg=43502]see Re: Programming 1[/msg])

Quite possibly a mistake. Plus it sounds more complicated than just plain ol' sorting. For example, a "word" that contained two '9's would be equal to a single lowercase 'r.' Of course this is a rough example.
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2303
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)


Re: Programming 1

Post by dm79 on Wed Aug 11, 2010 7:00 am
([msg=43560]see Re: Programming 1[/msg])

fashizzlepop wrote:Quite possibly a mistake. Plus it sounds more complicated than just plain ol' sorting. For example, a "word" that contained two '9's would be equal to a single lowercase 'r.' Of course this is a rough example.


You probaly right. I make it to complicated. Gona do it now so ill know in a hour.

Thanks for the reply.
dm79
New User
New User
 
Posts: 6
Joined: Fri Apr 18, 2008 3:34 pm
Blog: View Blog (0)


Re: Programming 1

Post by fashizzlepop on Wed Aug 11, 2010 8:27 pm
([msg=43586]see Re: Programming 1[/msg])

May I ask what language you plan on using? For example, in Perl, this can be done extremely easily as it has a built in "sort" command.
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2303
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)


Re: Programming 1

Post by dm79 on Fri Aug 13, 2010 2:43 pm
([msg=43670]see Re: Programming 1[/msg])

fashizzlepop wrote:May I ask what language you plan on using? For example, in Perl, this can be done extremely easily as it has a built in "sort" command.


Have done it already. Done it in visual basic :o Fast and easy. Used arrays and regular sorting of letters instead of numbers. Worked perfectly. I have a tendency to make things harder then they are:)

Thx for the input on this!
dm79
New User
New User
 
Posts: 6
Joined: Fri Apr 18, 2008 3:34 pm
Blog: View Blog (0)


Re: Programming 1

Post by fashizzlepop on Fri Aug 13, 2010 3:05 pm
([msg=43672]see Re: Programming 1[/msg])

No problem, and stay sexy. Oh wait, you are using VB? Never mind. Very NOT sexy.
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2303
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)


Re: Programming 1

Post by tremor77 on Fri Aug 13, 2010 6:42 pm
([msg=43688]see Re: Programming 1[/msg])

I have just done this in PHP, it requires a deft copy and paste manuever... but certainly doable in the time allotted.

Has anyone else done this in PHP? The following function is at the core of my solution... but not enough to be a spoiler.

Code: Select all
function characterCount($word)
{
   $counts = array();
   foreach(count_chars(strtolower($word), 1) as $char => $count)
   {
     $counts[] = (chr($char).':'.$count);
   }
   return(implode(',', $counts));
}
Image
User avatar
tremor77
Contributor
Contributor
 
Posts: 899
Joined: Wed Mar 31, 2010 12:00 pm
Location: New York
Blog: View Blog (0)


Re: Programming 1

Post by dm79 on Sat Aug 14, 2010 1:10 pm
([msg=43725]see Re: Programming 1[/msg])

fashizzlepop wrote:No problem, and stay sexy. Oh wait, you are using VB? Never mind. Very NOT sexy.


:D LOL. You got me there. Used VB instead of C++ / Perl who are much sexier. I know. I am an opportunist and I will use whatever gets the job done at minimal effort. VB was fast, forgiving with arrays/data typing and it did the trick. If speed and 100% accuracy was crucial I would have done it in C++.

And by the way: it takes milliseconds at run time to resolve the the list. Thats not a problem as well.

Keep up the grove:)
dm79
New User
New User
 
Posts: 6
Joined: Fri Apr 18, 2008 3:34 pm
Blog: View Blog (0)


Re: Programming 1

Post by fashizzlepop on Tue Aug 17, 2010 12:27 am
([msg=43835]see Re: Programming 1[/msg])

dm79 wrote:
fashizzlepop wrote:No problem, and stay sexy. Oh wait, you are using VB? Never mind. Very NOT sexy.


:D LOL. You got me there. Used VB instead of C++ / Perl who are much sexier. I know. I am an opportunist and I will use whatever gets the job done at minimal effort. VB was fast, forgiving with arrays/data typing and it did the trick. If speed and 100% accuracy was crucial I would have done it in C++.

And by the way: it takes milliseconds at run time to resolve the the list. Thats not a problem as well.

Keep up the grove:)

No worries. That's why I like Perl, it's quick and dirty AND very forgiving too.

I originally did it in PHP with a form and POST lol... Worked fine for me too.
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2303
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)


Re: Programming 1

Post by tearsstream on Mon Sep 20, 2010 4:02 am
([msg=46185]see Re: Programming 1[/msg])

I'm a complete noob but I did it with a method kind of similar to what DM79 is suggesting. Chucked the word list into Excel, split the words so that it was one letter per cell, used CODE() to get a numerical value for each letter, and took the product of each row to give me a unique number for each word.

There are a few things that you need to iron out, but I'm not going to give it all away ;)

Took me about 45 mins, which considering I haven't got a clue what I'm doing is probably about 100 times less than the rest are going to take me...

Though I'd just chuck it out there as how a non-programmer did it.
tearsstream
New User
New User
 
Posts: 1
Joined: Wed Sep 08, 2010 2:00 am
Blog: View Blog (0)


PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests