Programming 1

Put your programming skills to the test in these challenges.

Re: Programming 1

Post by Learning_Noob on Sun Jan 05, 2014 11:39 pm
([msg=78757]see Re: Programming 1[/msg])

Still working as of 1/5/2014; the sorted tip was very helpful for python

For any other python users out there, i'm curious why EOF (during stdin) can seldom hang on eclipse > pydev > for windows. Seems rather daunting as i was hoping to run one window rather than having to fumble windows. The only thing i could dig up on google may relate to deliminators on reading each string? E.g. EOF in an interactive session would need to follow the enter key (or so i've read for py 2.7)?

Definitely a great warmup after being absent for a while, looking forward to the next challenge
New User
New User
Posts: 2
Joined: Sun Apr 15, 2012 8:30 pm
Blog: View Blog (0)

Re: Programming 1

Post by Bl4ckPh0enix on Sun Feb 16, 2014 9:34 am
([msg=79505]see Re: Programming 1[/msg])

I passed the whole last night thinking.
So i did it in python, and my algorithm steps where those:

  • Create a words.txt file where i would paste the provided list of scrabbled words

  • Grab each line from wordlist.txt and append it in a wordlist array, same with words.txt and words array . Before appending lines in those arrays, remove \n\t\r characters and spaces (because pasting the list from hts to the words.txt could be messy)
  • For each element of words array, scan the wordlist array and: if the scrabbled word is of the same length as the unscrabbled word
  • Then for each element (character) of the scrabbled word if it exists in the unscrabbled word DELETE the character from the position in which it was found in the unscrabbled word and now get back to the loop with the new (without the deleted character) unscrabbled word
  • When this new unscrabbled word is equal to a zero length string ( == '' ) you can be sure that you got the right word

I dont know if there is any case in which those steps could return a false answer.

but i am almost sure that this is not the only solution and i would like it if any of you could post or pm me other ideas.

-- Sun Feb 16, 2014 5:29 pm --

Second solution!
It's a bit more mathematical...
It's based on the uniqueness of the factorisation of an integer into product of prime numbers.
New User
New User
Posts: 3
Joined: Sun Aug 04, 2013 7:22 pm
Blog: View Blog (0)


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests