473,395 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Need help implementing an algorithm in python

I would appreciate any help I can get in finding a solution to the
following problem:

================================================== ================

Below is a diagram:
http://www.muchographiks.com/algo.jpg

THE PROBLEM

Lets say we have 4 terms (purple represents the terms). Some terms in
these 4 terms combine to to make keywords (if we get the words in these
sub-terms they should equal to the keywords (e.g. terms ['kaiser
chiefs', 'i predict a riot', 'album'] combined make keywords ['kaiser',
'chiefs', 'i', 'predict', 'a', 'riot', 'album']). There will be terms
leftover sometimes, not all terms are used.

POSSIBLE ANSWER?

How it searches for the answer is by combining terms from top to
bottom, then checking to see if the keywords match the combined terms.

We start by with 1 combination (combine two terms). In the diagram, it
shows, t1 (term 1) combining with t2 then t3 then t4 (this is the red
line). If it can't find a match, it continues. It shows t2 combining
with t3 then t4 (dark green). If it can't find a match, it continues.
It shows t3 combining with t4 (light green). If by then it can't find a
match, we do the following:

Now the above example was just 1 combination. It gets more complicated
because we are going to have to keep increasing the number of
combinations by 1 to find a match. We are going to keep doing this
until combinations >= len(keywords). So now its two combinations. t1
will combine with t2 and t3. Check if its a match. If not continue. t1
will combine with t3 and t4. check if its a match. t2 will combine with
t3 and t4. t3 and t4 can't combine by themselves because they are only
two terms so we skip them (we already did 2 term combinations). After
this if theres no match we do 3 combinations... all the way until
combinations >= len(keywords).

================================================== ================

Here is what I have gotten so far:
http://pastebin.com/450352

I know exactly what to do its just I have no way of translating the
thought into programming code. If anybody can help at all I would
greatly appreciate it.

Thanks.

Dec 6 '05 #1
5 1085

ech0 wrote:
I would appreciate any help I can get in finding a solution to the
following problem:

================================================== ================

Below is a diagram:
http://www.muchographiks.com/algo.jpg

THE PROBLEM

Lets say we have 4 terms (purple represents the terms). Some terms in
these 4 terms combine to to make keywords (if we get the words in these
sub-terms they should equal to the keywords (e.g. terms ['kaiser
chiefs', 'i predict a riot', 'album'] combined make keywords ['kaiser',
'chiefs', 'i', 'predict', 'a', 'riot', 'album']). There will be terms
leftover sometimes, not all terms are used.

POSSIBLE ANSWER?

How it searches for the answer is by combining terms from top to
bottom, then checking to see if the keywords match the combined terms.

We start by with 1 combination (combine two terms). In the diagram, it
shows, t1 (term 1) combining with t2 then t3 then t4 (this is the red
line). If it can't find a match, it continues. It shows t2 combining
with t3 then t4 (dark green). If it can't find a match, it continues.
It shows t3 combining with t4 (light green). If by then it can't find a
match, we do the following:

Now the above example was just 1 combination. It gets more complicated
because we are going to have to keep increasing the number of
combinations by 1 to find a match. We are going to keep doing this
until combinations >= len(keywords). So now its two combinations. t1
will combine with t2 and t3. Check if its a match. If not continue. t1
will combine with t3 and t4. check if its a match. t2 will combine with
t3 and t4. t3 and t4 can't combine by themselves because they are only
two terms so we skip them (we already did 2 term combinations). After
this if theres no match we do 3 combinations... all the way until
combinations >= len(keywords).

================================================== ================

Here is what I have gotten so far:
http://pastebin.com/450352

I know exactly what to do its just I have no way of translating the
thought into programming code. If anybody can help at all I would
greatly appreciate it.

Thanks.


Be honest, is this a take-home final ?

Dec 6 '05 #2
I'm still in highschool. This is no homework. This is a personal
project for me. I would normally do it myself but this one is just too
complex, thats why I'm asking for help.

Dec 6 '05 #3
Just to point out... I came up with the algorithm. Which is why I can
explain it so well. But implementing it into code is one well of a task.

Dec 6 '05 #4
wow. nevermind. i figured it out.

Dec 6 '05 #5
ech0 wrote:
wow. nevermind. i figured it out.

I hope that you will share it with those of us who haven't figured it
out yet.

Colin W.
Dec 6 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: aredo3604gif | last post by:
On Sun, 10 Apr 2005 19:46:32 GMT, aredo3604gif@yahoo.com wrote: >The user can dynamically enter and change the rule connection between >objects. The rule is a "<" and so given two objects: >a <...
2
by: prash | last post by:
Hi everybody, I would like to request all the members to help me find the source code for the following : 1.C program for error detecting code: CRC-CCITT and CRC -32. 2.c Program for...
4
by: Kinsley Turner | last post by:
Hey-ho, I'm getting a bit out of my depth porting the 'tiny encryption algorithm' from C to python. Ref: http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm...
10
by: Nemok | last post by:
Hi, I am trying to write an additive encryption algorithm in C++ that will encrypt a text by adding a random numer to each character in a string. The code looks similar to this: for(int...
3
by: Charleees | last post by:
Hi all, I need C# code for Implementing MD5 Algorithm.. Hope all would have heard of MD5 Algorith... Does any one have the C# coding for that Algorithm.. please Send... ITs URgent..... Thanks...
1
by: Charles | last post by:
Hi all, I need C# code for Implementing MD5 Algorithm.. Hope all would have heard of MD5 Algorith... Does any one have the C# coding for that Algorithm.. please Send... ITs URgent..... Thanks...
1
by: Charles | last post by:
Hi all, I need C# code for Implementing MD5 Algorithm.. Hope all would have heard of MD5 Algorith... Does any one have the C# coding for that Algorithm.. please Send... ITs URgent..... Thanks...
9
by: raylopez99 | last post by:
What's the best way of implementing a multi-node tree in C++? What I'm trying to do is traverse a tree of possible chess moves given an intial position (at the root of the tree). Since every...
2
nabh4u
by: nabh4u | last post by:
hi, i need some help with progamming..i have a program which has to implement gale shapley's algorithm. i have 2 preference lists one is for companies and the other is for persons. i have to match...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.