CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    1

    Question Merge lines using XOR operations bits

    Hi

    I need to do an algorithm that read a textfile have 14 Characters (Numbers 1 to 7)

    Example:

    44444444444444
    44444444444442
    14444444444444
    42444444444444
    ..ETC

    I must read each line and find lines with difference 1 or 2 characeters, in example above the first line and second line have difference
    one character I must to do a XOR in each position

    doing in first and second line

    Each line can use only 1 time
    The lines used can not to use again , then first and second line can not to used

    44444444444446

    But each row will can in maxime two symbols differents of the (1, 2 and 4)

    44444444444446 have only one symbol ( 6) , then I must to read others line to find more row with one difference

    Doing XOR between 44444444444446 and 14444444444444

    See that the number 6 in bit format is
    110 ==> 6
    and the number 4 in bit format is
    100 ==> 4

    Then 6 contain 4 then will can to do XOR in each column

    544444444444446 , Now This line have two symbols differente of the (1,2 and 4 ) , 5 and 6 then It do not need in others rows,

    but the rows used
    44444444444444
    44444444444442
    14444444444444

    Can not to used again , Someboy can to help me to do a algortihm to read each row and to do operations with bits
    what best language ?

    I know a little VB and learning Python

  2. #2
    Join Date
    Jun 2015
    Posts
    208

    Re: Merge lines using XOR operations bits

    Quote Originally Posted by muttleychess View Post
    and learning Python
    I don't quite understand what you are asking but you seem to know what you want to do and how to do it using XOR.

    It looks like Python is supporting bitwise operations and since you're learning that language why not use it? Then if you have more specific questions regarding implementation you can ask at a Python forum.

    https://wiki.python.org/moin/BitwiseOperators

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured