Help with exercise!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viddiG
    New Member
    • Apr 2010
    • 1

    Help with exercise!!!

    I'm a first year computer science student.
    I have been given an exercise and have no clue where to start.
    Tried using count functions but have can't get the output that I need!
    Any help would be greatly appreciated!!!
    Thanks
    Vid

    input:

    0 0 0 0 1 0 1 0
    0 0 1 0 0 1 0 1
    1 0 0 0 1 0 0 1
    1 0 0 0 1 1 0 1
    1 1 0 0 0 1 1 0
    0 1 1 0 1 0 0 1
    1 1 1 0 0 1 0 0
    0 1 0 1 1 0 1 0
    0 1 1 1
    0 0 1 0
    1 0 0 1
    0 1 0 0
    0 1 1 0
    1 0 1 0
    0 0 0 0
    1 0 0 0
    0 1 1
    1 0 0
    1 0 0
    END

    output:

    0: 4 6
    1: 2 5 7
    2: 0 4 7
    3: 0 4 5 7
    4: 0 1 5 6
    5: 1 2 4 7
    6: 0 1 2 5
    7: 1 3 4 6
    0: 1 2 3
    1: 2
    2: 0 3
    3: 1
    0: 1 2
    1: 0 2
    2:
    3: 0
    0: 1 2
    1: 0
    2: 0


    Basically, the program is supposed to give the position of the 1's for each line.
    I have tried using a mix of count, def and pop functions but nothing is going my way.
    Any help would be greatly appreciated!
  • YarrOfDoom
    Recognized Expert Top Contributor
    • Aug 2007
    • 1243

    #2
    Maybe a look trough here will give you some ideas.

    Comment

    Working...