Hello everybody !
I have two list, they are, S1=['A','B','C','D','E'], and
S2=['F','G','H','I','J'], but i have to compare both in this way:
A vs J
A vs I, B vs J
A vs H, B vs I, C vs J
A vs G, B vs H, C vs I, D vs J
A vs F, B vs G, C vs H, D vs I, E vs J
B vs F, C vs G, D vs H, E vs I
C vs F, D vs G, E vs H
D vs F, E vs G
E vs F
Perhaps, you should understand better in this way:
A
J
A B
I J
A B C
H I J
A B C D
G H I J
A B C D E
F G H I J
B C D E
F G H I
C D E
F G H
D E
F G
E
F
Could someone give me any idea how to compare(or print) both list in
this way ??? Thanks a lot !!!
jDSL 6 1246
jairodsl wrote:
Hello everybody !
I have two list, they are, S1=['A','B','C','D','E'], and
S2=['F','G','H','I','J'], but i have to compare both in this way:
A vs J
A vs I, B vs J
A vs H, B vs I, C vs J
A vs G, B vs H, C vs I, D vs J
A vs F, B vs G, C vs H, D vs I, E vs J
B vs F, C vs G, D vs H, E vs I
C vs F, D vs G, E vs H
D vs F, E vs G
E vs F
Perhaps, you should understand better in this way:
A
J
A B
I J
A B C
H I J
A B C D
G H I J
A B C D E
F G H I J
B C D E
F G H I
C D E
F G H
D E
F G
E
F
Could someone give me any idea how to compare(or print) both list in
this way ??? Thanks a lot !!!
jDSL
for i in xrange(1, len(S1)+1):
print S1[0:i]
print S2[-i:]
print
Am I really the first person to respond to this?
On Feb 12, 8:03 pm, "jairodsl" <jairo...@gmail.comwrote:
Hello everybody !
I have two list, they are, S1=['A','B','C','D','E'], and
S2=['F','G','H','I','J'], but i have to compare both in this way:
A vs J
A vs I, B vs J
A vs H, B vs I, C vs J
A vs G, B vs H, C vs I, D vs J
A vs F, B vs G, C vs H, D vs I, E vs J
B vs F, C vs G, D vs H, E vs I
C vs F, D vs G, E vs H
D vs F, E vs G
E vs F
(snipped)
Could someone give me any idea how to compare(or print) both list in
this way ??? Thanks a lot !!!
jDSL
s1 = [ 'A', 'B', 'C', 'D', 'E' ]
s2 = [ 'F', 'G', 'H', 'I', 'J' ]
s3 = []
for count in xrange( len(s1) + len(s2) - 1 ):
try:
operand = s2.pop()
except IndexError:
operand = None
except:
raise
s3.insert(0,operand)
print [ t for t in zip(s1, s3) if t[1] is not None ]
--
Hope this helps,
Steven
En Tue, 13 Feb 2007 01:03:07 -0300, jairodsl <ja******@gmail.comescribió:
I have two list, they are, S1=['A','B','C','D','E'], and
S2=['F','G','H','I','J'], but i have to compare both in this way:
A vs J
A vs I, B vs J
A vs H, B vs I, C vs J
A vs G, B vs H, C vs I, D vs J
A vs F, B vs G, C vs H, D vs I, E vs J
B vs F, C vs G, D vs H, E vs I
C vs F, D vs G, E vs H
D vs F, E vs G
E vs F
And what to do after comparing each pair?
Anyway, this would be one general approach: First, forget about the lists.
Use numbers instead of letters (0 to 4), and try to generate the pairs of
numbers needed. Once your program can generate the right number pairs, use
those numbers as indexes into the lists.
--
Gabriel Genellina
James Stroud wrote:
jairodsl wrote:
>Hello everybody !
I have two list, they are, S1=['A','B','C','D','E'], and S2=['F','G','H','I','J'], but i have to compare both in this way:
A vs J A vs I, B vs J A vs H, B vs I, C vs J A vs G, B vs H, C vs I, D vs J A vs F, B vs G, C vs H, D vs I, E vs J B vs F, C vs G, D vs H, E vs I C vs F, D vs G, E vs H D vs F, E vs G E vs F
Perhaps, you should understand better in this way:
A J
A B I J
A B C H I J
A B C D G H I J
A B C D E F G H I J
B C D E F G H I
C D E F G H
D E F G
E F
Could someone give me any idea how to compare(or print) both list in this way ??? Thanks a lot !!!
jDSL
for i in xrange(1, len(S1)+1):
print S1[0:i]
print S2[-i:]
print
Am I really the first person to respond to this?
I didn't scroll far enough down.
On Feb 13, 5:03 am, "jairodsl" <jairo...@gmail.comwrote:
Hello everybody !
I have two list, they are, S1=['A','B','C','D','E'], and
S2=['F','G','H','I','J'], but i have to compare both in this way:
A vs J
A vs I, B vs J
A vs H, B vs I, C vs J
A vs G, B vs H, C vs I, D vs J
A vs F, B vs G, C vs H, D vs I, E vs J
B vs F, C vs G, D vs H, E vs I
C vs F, D vs G, E vs H
D vs F, E vs G
E vs F
Could someone give me any idea how to compare(or print) both list in
this way ??? Thanks a lot !!!
jDSL
def interleave( X, Y ):
for i in range(1, len(Y)+1):
yield zip(X, Y[-i:])
for j in range(1, len(X)):
yield zip(X[j:], Y)
x = ['A', 'B', 'C', 'D', 'E']
y = ['F', 'G', 'H', 'I', 'J']
for seq in interleave(x, y):
print seq
[('A', 'J')]
[('A', 'I'), ('B', 'J')]
[('A', 'H'), ('B', 'I'), ('C', 'J')]
[('A', 'G'), ('B', 'H'), ('C', 'I'), ('D', 'J')]
[('A', 'F'), ('B', 'G'), ('C', 'H'), ('D', 'I'), ('E', 'J')]
[('B', 'F'), ('C', 'G'), ('D', 'H'), ('E', 'I')]
[('C', 'F'), ('D', 'G'), ('E', 'H')]
[('D', 'F'), ('E', 'G')]
[('E', 'F')]
Regards
Gerard
On Feb 13, 4:30 am, "Gerard Flanagan" <grflana...@yahoo.co.ukwrote:
On Feb 13, 5:03 am, "jairodsl" <jairo...@gmail.comwrote:
Hello everybody !
I have two list, they are, S1=['A','B','C','D','E'], and
S2=['F','G','H','I','J'], but i have to compare both in this way:
A vs J
A vs I, B vs J
A vs H, B vs I, C vs J
A vs G, B vs H, C vs I, D vs J
A vs F, B vs G, C vs H, D vs I, E vs J
B vs F, C vs G, D vs H, E vs I
C vs F, D vs G, E vs H
D vs F, E vs G
E vs F
Could someone give me any idea how to compare(or print) both list in
this way ??? Thanks a lot !!!
jDSL
def interleave( X, Y ):
for i in range(1, len(Y)+1):
yield zip(X, Y[-i:])
for j in range(1, len(X)):
yield zip(X[j:], Y)
x = ['A', 'B', 'C', 'D', 'E']
y = ['F', 'G', 'H', 'I', 'J']
for seq in interleave(x, y):
print seq
[('A', 'J')]
[('A', 'I'), ('B', 'J')]
[('A', 'H'), ('B', 'I'), ('C', 'J')]
[('A', 'G'), ('B', 'H'), ('C', 'I'), ('D', 'J')]
[('A', 'F'), ('B', 'G'), ('C', 'H'), ('D', 'I'), ('E', 'J')]
[('B', 'F'), ('C', 'G'), ('D', 'H'), ('E', 'I')]
[('C', 'F'), ('D', 'G'), ('E', 'H')]
[('D', 'F'), ('E', 'G')]
[('E', 'F')]
Regards
Gerard
Thank you very much for all your answers.
jDSL This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: MrCoder |
last post by:
Hey guys, my first post on here so I'll just say "Hello everbody!"
Ok heres my question for you lot.
Is there a faster way to compare 1 byte array to another?
This is my current code
//...
|
by: Megan |
last post by:
Hi everybody-
I'm helping a friend with a music database. She has an old one and is
creating a new one. She wants to compare records and fields in the old
database with records and fields in the...
|
by: Vincent |
last post by:
has any one seen a program to compare mdbs'. I have ran into a few of
them, but none seem to really do that job.
Basically what I need to do is, take 2 access mdb's and check the
differences...
|
by: geronimo_me |
last post by:
Hi,
I am atempting to compare part of a field with the whole of another
field in access. Is this possible?
Basically I have 2 tables with the following info:
Table1
Field1 = MR.
|
by: Russ Green |
last post by:
How does this:
public TimeSpan Timeout
{
get { return timeout; }
set
{
timeout = value;
if(timeout < licenseTimeout)
licenseTimeout = timeout;
}
|
by: Linda |
last post by:
Hi,
Is there a way to do a "text" (rather than "binary") compareison with
the "like" operator, without changing the global "Option Compare"
setting? I don't want to risk breaking many, many...
|
by: Mark A |
last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP
11).
Using the SAMPLE database, tables EMP and EMLOYEE.
In the followng stored procedure, 2 NULL columns (COMM) are...
|
by: antani |
last post by:
I need to implement a function with a argument that is a compare
function.
This compare function must be several for every necessity.
For example , I would like a compare function to analyze...
|
by: neha_chhatre |
last post by:
can anybody tell me how to compare two float values
say for example
t and check are two variables declared float how to compare t and
check
please help me as soon as possible
|
by: Lambda |
last post by:
I defined a class:
class inverted_index
{
private:
std::map<std::string, std::vector<size_t index;
public:
std::vector<size_tintersect(const std::vector<std::string>&);
};
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |