wu :: forums
« wu :: forums - Encoding the cipher »

Welcome, Guest. Please Login or Register.
Apr 17th, 2025, 5:59pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Grimbal, Eigenray, Icarus, SMQ, towr, william wu, ThudnBlunder)
   Encoding the cipher
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Encoding the cipher  (Read 1902 times)
mistaken_id
Junior Member
**





   


Posts: 132
Encoding the cipher  
« on: Aug 8th, 2010, 7:03pm »
Quote Quote Modify Modify

You are given a cipher decoder dictionary which has the mappings from alphabets(non-encrypted) to their encrypted forms:
 
Ex: a   -> ,,_
 b   -> ++(
 
And you are given a list of words ex: {apple , boy } Context list
 
And finally you are given the encrypted message  
 
..--__)0 (something like that)..
 
So you have to decrypt the message using cipher decoder dictionary, and the decrypted word should be one of the words in the list , if more than one word in the  list matches the decryption process, return the word with minimum number of alphabets
 
What is the efficient way to do this?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Encoding the cipher  
« Reply #1 on: Aug 9th, 2010, 1:09am »
Quote Quote Modify Modify

So, decrypted words have to be ones from the provided list?
Then I'd encrypt all the words, order them in order of "minimum number of alphabets " whatever that means. Then search for the encrypted words in the encrypted text.
You can use a hashmap to translate found encrypted words back to their plaintext version.
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: Encoding the cipher  
« Reply #2 on: Aug 9th, 2010, 1:24am »
Quote Quote Modify Modify

It is probably overkill to encode a large dictionary to find a single word.
 
I would search recursively:
Given a possible decoding of a prefix of the word:
- Check what letters match the next coded characters.
- For each letter, extend the prefix, check that a word exists with this prefix.
- If the code word is exhausted, check that the prefix exists exactly as a word.
- If only one word exists, encode it and verify that it matches the complete coded word.
- If more than one word matches, call the same procedure with the extended prefix decoding.
 
Search greedily (the longest codes first).  And among all solutions, keep the shortest one.
« Last Edit: Aug 9th, 2010, 1:31am by Grimbal » IP Logged
mistaken_id
Junior Member
**





   


Posts: 132
Re: Encoding the cipher  
« Reply #3 on: Aug 10th, 2010, 7:20pm »
Quote Quote Modify Modify

on Aug 9th, 2010, 1:24am, Grimbal wrote:
It is probably overkill to encode a large dictionary to find a single word.
 
I would search recursively:
Given a possible decoding of a prefix of the word:
- Check what letters match the next coded characters.
- For each letter, extend the prefix, check that a word exists with this prefix.
- If the code word is exhausted, check that the prefix exists exactly as a word.
- If only one word exists, encode it and verify that it matches the complete coded word.
- If more than one word matches, call the same procedure with the extended prefix decoding.
 
Search greedily (the longest codes first).  And among all solutions, keep the shortest one.

 
 
Is there a way to improve this by using dynamic programming. I tried using DP but wasn't of much help in worst case.
IP Logged
Hippo
Uberpuzzler
*****





   


Gender: male
Posts: 919
Re: Encoding the cipher  
« Reply #4 on: Aug 10th, 2010, 11:12pm »
Quote Quote Modify Modify

on Aug 9th, 2010, 1:24am, Grimbal wrote:
It is probably overkill to encode a large dictionary to find a single word.
 
I would search recursively:
Given a possible decoding of a prefix of the word:
- Check what letters match the next coded characters.
- For each letter, extend the prefix, check that a word exists with this prefix.
- If the code word is exhausted, check that the prefix exists exactly as a word.
- If only one word exists, encode it and verify that it matches the complete coded word.
- If more than one word matches, call the same procedure with the extended prefix decoding.
 
Search greedily (the longest codes first).  And among all solutions, keep the shortest one.

 
I don't think it's an overkill. Actually I am using it for unseparated morse.  
 
OK, if the question is formulated such that you have one encrypted word for which you are given set of possible words, than reading the input bounds running time from down to time any trivial algorithm requires.
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board