# [Tutor] Help needed

Suhana Vidyarthi suhanavidyarthi at gmail.com
Sat Apr 26 02:46:17 CEST 2014

```Hi,

I need help with coding for the problem below. I am new in this area, so
needed help. If anyone can help me program the below scenario, I will be
thankful.

I have this file:

1,3,5,0.03

2,3,5,5,4,0.11

3,3,5,5,4,5,8,0.04

2,5,8,7,8,0.04

3,14,10,14,13,17,13,0.04

1,14,18,0.06

4,10,13,14,13,17,13,12,13,0.04

4,11,6,11,9,11,12,11,19,0.08

3,19,20,15,20,21,20,0.24

1,21,20,0.05

3,20,21,21,16,21,22,0.27

And each line is interpreted as:

- 1,3,5,0.03  -> This line means 1 link can be down i.e. between 3—5  with
a probability of failure *0.03*
- 2,3,5,5,4,0.11 -> This line means 2 links can be down i.e. between
3--5 and 5--4 with a probability of failure *0.11* (for each link)
- 3,3,5,5,4,5,8,0.04 -> Similarly this line means 3 links can be down
i.e. between 3--5 , 5—4 and 5—8 with  a probability of failure
- 2,5,8,7,8,0.04  -> This line means 2 links can be down i.e. between
5—8 and 7—8 with probability of failure *0.04* (for each link)
- 3,14,10,14,13,17,13,0.04 -> Means 3 links can be down i.e. between
14—10, 14—13 and 17—13 with a probability of failure *0.04* (for each
- 1,14,18,0.06 -> Means 1link can be down  i.e. between 14—18 with a
probability of failure as* 0.06*
- 4,10,13,14,13,17,13,12,13,0.04 -> Means 4 links can go down i.e.
between 10—13, 14—13, 17—13 and 12—13 with a probability of failure
- 4,11,6,11,9,11,12,11,19,0.08 -> Means 4 links can go down i.e. between
11—6, 11—9, 11—12 and 11—19 with a probability of failure *0.08* (for
- 3,19,20,15,20,21,20,0.24  -> Means 3 links can go down i.e. between
19—20, 15—20 and 21—20 with a probability of failure *0.24* (for each
- 1,21,20,0.05 -> Means 1 link is down i.e. between 21—20 with a
probability of failure *0.05*
- 3,20,21,21,16,21,22,0.27 -> Means 3 links are down i.e. between 20—21,
21—16 and 21—22 with a  probability of failure as* 0.27* (for each link)

I want to create two arrays using the above file (Links array and Prob
array) that should give following output:

*Links *= { [3,5] [5,4] [5,8] [7,8] [14,10] [14,13] [17,13] [14,18] [10,13]
[14,13] [17,13] [12,13] [11,6] [11,9] [11,12] [11,19] [19,20] [15,20]
[21,20] [20,21] [21,16] [21,22] }

*Prob *= {[0.28] [0.15] [0.08] [0.04] [0.04] [0.04] [0.08] [0.04] [0.08]
[0.08] [0.08] [0.08] [0.24] [0.24] [0.34] [0.27] [0.27]}

*IMP Note*: The probabilities get added if a link is mentioned twice or
thrice. For example:  link 3—5 is repeated 3 times: in line one, it has a
probability of failure as *0.03*, in line two it is *0.11* and in line
three it is *0.04*. So the probability of failure for link 3—5 is
0.03+0.11+0.04 =* 0.28*

So the first element in Links array is [3,5] and its probability of failure
is the first element in Prob array i.e. 0.28

Can anyone help me with this please?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140425/dbe5a8dc/attachment.html>
```