473,811 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1108

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
2647
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 < b simply means that b < a can't be set, also it must be a != b. >And with three objects a < b , b < c means a < c > >I studied Quick Union Find algorithms a bit and if I understood them >correctly, once the user gives the input setting the...
2
3177
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 frame sorting technique used in buffer. 3.C program to implement MLMA Collision free protocol.
4
3711
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 http://www.simonshepherd.supanet.com/source.htm#new_ansi Specifically I don;t know how to handle a C-long block and perform the
10
2285
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 i=0;i<=tlength-1;i++)///tlength is the length of the string to encrypt { ctext+=x+i;/////x is a random number and ctext is a char*
3
2045
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 In Advance to all....................... With Regards,
1
3849
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 In Advance to all....................... With Regards,
1
1204
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 In Advance to all....................... With Regards,
9
7837
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 chess position has around 30 moves, it would mean every node of the tree would have 30 branches (on average), which in turn themselves would average about 30 branches each. I can think of a variety of ways of implementing this, including a series...
2
2248
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 the companies with the persons according to the gale shapley algorithm. /----match.h--------------------------------------------------------------/ #include <iostream> #include<vector> using namespace std; /*------Declarations------*/
0
9728
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.