473,326 Members | 2,133 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,326 software developers and data experts.

Incorrect results for the given input data

440 256MB
I have the Scenario where the data is lying in this format in the file

Input is :

El N1 N2 N3 N4
E1 1 2 6 5
E2 2 3 7 6
E3 3 4 8 7
E4 5 6 10 9
E5 6 7 11 10
E6 7 8 12 11
Expand|Select|Wrap|Line Numbers
  1.  
  2.     9------------10--------------11-----------12
  3.     |    |    |    |        
  4.     |   E4    |  E5    |  E6    |
  5.     5--------------6--------------7--------------8
  6.     |      |    |    |        
  7.     |   E1    |  E2    |   E3    |
  8.     1-------------2---------------3--------------4
  9.  
Output Should be (the common shared points) :

2:E1,E2
3:E2,E3
5:E1,E4
6:E1,E2,E4,E5
7:E2,E5,E3,E6
7:E3,E6

I have written the piece of code ,where it is giving wrong results.Could anybody help me in correcting it.
Expand|Select|Wrap|Line Numbers
  1. def FindCommonPoints():
  2.     dict1= {E1:[1,2,6,5],E2:[2,3,7,6],E3:[3,4,8,7],E4:[5,6,10,9],E5:[6,7,11,10],E6:[7,8,12,11]}
  3.  
  4.     nlist =[]    
  5.  
  6.     list1El = []
  7.     list1El = dict1.keys()
  8.     NSharedEldict=()
  9.     ElID=0
  10.     count = 6
  11.     nSharedEl =0
  12.     NSharedEldict ={}  
  13.  
  14.     nSharedElList =[]
  15.     boundaryNode = []
  16.     listElem=[]
  17.     SharedElemlist = []
  18.  
  19.     for i in range(0, count):
  20.         ElID = list1El[i]
  21.         nlist = dict1.get(ElID)
  22.  
  23.         for n in range(0,4):
  24.             nID = nlist [n]
  25.  
  26.             for k in range(i+1,count):
  27.                 nlist 2 = dict1.get(list1Els[k])
  28.  
  29.                 SharedElemlist ElID 
  30.                 for m in range(0,4):
  31.  
  32.                     if( nID == nlist [m] ):
  33.                         SharedElemlist (list1Els[k])
  34.                         NSharedEldict nID = SharedElemlist 
  35.  
  36.             SharedElemlist = []
  37.  
  38.  
  39.     print NodeSharedElementdict      
  40.  
  41. if __name__ == "__main__":
  42.     print "Hello"
  43.     FindCommonPoints()
  44.  
Thanks in advance
PSB
Mar 3 '07 #1
8 1367
bartonc
6,596 Expert 4TB
I have the Scenario where the data is lying in this format in the file

Input is :

El N1 N2 N3 N4
E1 1 2 6 5
E2 2 3 7 6
E3 3 4 8 7
E4 5 6 10 9
E5 6 7 11 10
E6 7 8 12 11
Expand|Select|Wrap|Line Numbers
  1.  
  2.     9------------10--------------11-----------12
  3.     |    |    |    |        
  4.     |   E4    |  E5    |  E6    |
  5.     5--------------6--------------7--------------8
  6.     |      |    |    |        
  7.     |   E1    |  E2    |   E3    |
  8.     1-------------2---------------3--------------4
  9.  
Output Should be (the common shared points) :

2:E1,E2
3:E2,E3
5:E1,E4
6:E1,E2,E4,E5
7:E2,E5,E3,E6
7:E3,E6

I have written the piece of code ,where it is giving wrong results.Could anybody help me in correcting it.
Expand|Select|Wrap|Line Numbers
  1. def FindCommonPoints():
  2.     dict1= {E1:[1,2,6,5],E2:[2,3,7,6],E3:[3,4,8,7],E4:[5,6,10,9],E5:[6,7,11,10],E6:[7,8,12,11]}
  3.  
  4.     nlist =[]    
  5.  
  6.     list1El = []
  7.     list1El = dict1.keys()
  8.     NSharedEldict=()
  9.     ElID=0
  10.     count = 6
  11.     nSharedEl =0
  12.     NSharedEldict ={}  
  13.  
  14.     nSharedElList =[]
  15.     boundaryNode = []
  16.     listElem=[]
  17.     SharedElemlist = []
  18.  
  19.     for i in range(0, count):
  20.         ElID = list1El[i]
  21.         nlist = dict1.get(ElID)
  22.  
  23.         for n in range(0,4):
  24.             nID = nlist [n]
  25.  
  26.             for k in range(i+1,count):
  27.                 nlist 2 = dict1.get(list1Els[k])
  28.  
  29.                 SharedElemlist ElID 
  30.                 for m in range(0,4):
  31.  
  32.                     if( nID == nlist [m] ):
  33.                         SharedElemlist (list1Els[k])
  34.                         NSharedEldict nID = SharedElemlist 
  35.  
  36.             SharedElemlist = []
  37.  
  38.  
  39.     print NodeSharedElementdict      
  40.  
  41. if __name__ == "__main__":
  42.     print "Hello"
  43.     FindCommonPoints()
  44.  
Thanks in advance
PSB
Expand|Select|Wrap|Line Numbers
  1.             SharedElemlist = [] # cleaner to empty the list first
  2.  
  3.                         SharedElemlist.append(list1Els[k])
  4.                     NSharedEldict[nID] = SharedElemlist  # store it outside the loop
  5.  
Mar 3 '07 #2
psbasha
440 256MB
Sorry the earlier code was errorneous.This is the right code.

----------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. def FindCommonPoints():
  2.     dict1= {"E1":[1,2,6,5],"E2":[2,3,7,6],"E3":[3,4,8,7],"E4":[5,6,10,9],"E5":[6,7,11,10],"E6":[7,8,12,11]}
  3.  
  4.     nlist =[]    
  5.  
  6.     list1El = []
  7.     list1El = dict1.keys()
  8.     NSharedEldict=()
  9.     ElID=0
  10.     count = 6
  11.     nSharedEl =0
  12.     NSharedEldict ={}  
  13.  
  14.     nSharedElList =[]
  15.     boundaryNode = []
  16.     listElem=[]
  17.     SharedElemlist = []
  18.  
  19.     for i in range(0, count):
  20.         ElID = list1El[i]
  21.         nlist = dict1.get(ElID)
  22.  
  23.         for n in range(0,4):
  24.             nID = nlist [n]
  25.  
  26.             for k in range(i+1,count):
  27.                 nlist2 = dict1.get(list1El[k])
  28.  
  29.                 SharedElemlist.append(ElID )
  30.                 for m in range(0,4):
  31.  
  32.                     if( nID == nlist [m] ):
  33.                         SharedElemlist.append(list1El[k])
  34.                         NSharedEldict [nID] = SharedElemlist 
  35.  
  36.             SharedElemlist = []
  37.  
  38.  
  39.     print NSharedEldict      
  40.  
  41. if __name__ == "__main__":
  42.     print "Hello"
  43.     FindCommonPoints()
--------------------------------------------------------------------------------------

Could you please help me ,after which loops I have to add these piece of code,so that I can get the correct Output.

Thanks in advance
PSB
Mar 3 '07 #3
bartonc
6,596 Expert 4TB
Sorry the earlier code was errorneous.This is the right code.
.....<snip> Thanks in advance
PSB
When posting could, you need to put in the code tags. Please read the "POSTING GUIDELINES" on the right hand side of this page in order to learn how to do this. Thank you.
Mar 3 '07 #4
psbasha
440 256MB
could you please help me in finding the code tags.I searched for it,I didnot find it.

Thanks
PSB
Mar 4 '07 #5
ghostdog74
511 Expert 256MB
could you please help me in finding the code tags.I searched for it,I didnot find it.

Thanks
PSB
when you do a reply, you can see on the toolbar, (if that's called) a "#" symbol. that's the CODE tag. If not,on the right hand side, there's a REPLY GUIDELINES that shows you how.
Mar 4 '07 #6
psbasha
440 256MB
Expand|Select|Wrap|Line Numbers
  1. def FindCommonPoints():
  2.     dict1= {"E1":[1,2,6,5],"E2":[2,3,7,6],"E3":[3,4,8,7],"E4":[5,6,10,9],"E5":[6,7,11,10],"E6":[7,8,12,11]}
  3.  
  4.     nlist =[]    
  5.  
  6.     list1El = []
  7.     list1El = dict1.keys()
  8.     NSharedEldict=()
  9.     ElID=0
  10.     count = 6
  11.     nSharedEl =0
  12.     NSharedEldict ={}  
  13.  
  14.     nSharedElList =[]
  15.     boundaryNode = []
  16.     listElem=[]
  17.     SharedElemlist = []
  18.  
  19.     for i in range(0, count):
  20.         ElID = list1El[i]
  21.         nlist = dict1.get(ElID)
  22.  
  23.         for n in range(0,4):
  24.             nID = nlist [n]
  25.  
  26.             for k in range(i+1,count):
  27.                 nlist2 = dict1.get(list1El[k])
  28.  
  29.                 SharedElemlist.append(ElID )
  30.                 for m in range(0,4):
  31.  
  32.                     if( nID == nlist [m] ):
  33.                         SharedElemlist.append(list1El[k])
  34.                         NSharedEldict [nID] = SharedElemlist 
  35.  
  36.             SharedElemlist = []
  37.  
  38.  
  39.     print NSharedEldict      
  40.  
  41. if __name__ == "__main__":
  42.     print "Hello"
  43.     FindCommonPoints()
  44.  
  45. :
Mar 4 '07 #7
psbasha
440 256MB
Expand|Select|Wrap|Line Numbers
  1. def FindCommonPoints():
  2.     dict1= {"E1":[1,2,6,5],"E2":[2,3,7,6],"E3":[3,4,8,7],"E4":[5,6,10,9],"E5":[6,7,11,10],"E6":[7,8,12,11]}
  3.  
  4.     nlist =[]    
  5.  
  6.     list1El = []
  7.     list1El = dict1.keys()
  8.     NSharedEldict=()
  9.     ElID=0
  10.     count = 6
  11.     nSharedEl =0
  12.     NSharedEldict ={}  
  13.  
  14.     nSharedElList =[]
  15.     boundaryNode = []
  16.     listElem=[]
  17.     SharedElemlist = []
  18.  
  19.     for i in range(0, count):
  20.         ElID = list1El[i]
  21.         nlist = dict1.get(ElID)
  22.  
  23.         for n in range(0,4):
  24.             nID = nlist [n]
  25.  
  26.             for k in range(i+1,count):
  27.                 nlist2 = dict1.get(list1El[k])
  28.  
  29.                 SharedElemlist.append(ElID )
  30.                 for m in range(0,4):
  31.  
  32.                     if( nID == nlist [m] ):
  33.                         SharedElemlist.append(list1El[k])
  34.                         NSharedEldict [nID] = SharedElemlist 
  35.  
  36.             SharedElemlist = []
  37.  
  38.  
  39.     print NSharedEldict      
  40.  
  41. if __name__ == "__main__":
  42.     print "Hello"
  43.     FindCommonPoints()
  44.  
  45. :
Could you please help me in getting the corrected output from the above piece of code.


Thanks in advance
PSB
Mar 4 '07 #8
psbasha
440 256MB
I have fixed this problem.

Thanks
PSB
Mar 5 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could....
13
by: NM | last post by:
Sometimes ago I was having a problem in linking between C++ and Fortran program. That was solved (using input from this newsgroup) using the Fortran keyword "sequence" with the derived types (to...
11
by: Mark Findlay | last post by:
Hello Experts! I am attempting to use the OleDbCommand.ExecuteScaler() function within my ASP.NET C# web page to perform a simple validation, but receive the following error: "Incorrect...
2
by: Linda Wienholt | last post by:
I have two usercontrols on the home page of my website. They are intermitently sending incorrect HTML to the browser, which results in a textbox being rendered with the wrong width. Either both...
2
by: Pasquale | last post by:
I am using the query below for a multi event registration confirmation page. Any one of these events can have individuals and/or teams, which also then can have different categories of individuals...
11
by: RipperT | last post by:
Don't know if this group covers web apps, but here goes. In VS 2005, I am trying to get variables to hold thier values during postback from the server. I convert a text box's user-keyed value to an...
20
by: Francine.Neary | last post by:
I am learning C, having fun with strings & pointers at the moment! The following program is my solution to an exercise to take an input, strip the first word, and output the rest. It works fine...
1
by: `Zidane Tribal | last post by:
it would appear that using the command 'crc("data")' from the String::CRC returns incorrect results (although, they are at least consistently incorrect). for example, this script..... ...
12
by: colin | last post by:
Hi, Ive got a difference in results depending on wether I run my app in the debugger, or run it seperatly (or with <ctrl-f5>) the results in the debugger seem to be more correct, although the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
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 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.