Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Pattern Decoder

Pattern Decoder

Scheduled Pinned Locked Moved Algorithms
algorithmsregexhelp
30 Posts 10 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H hdsouza1

    I need to figure out the formula/pattern/algorithm needed to convert the number on the left into a checksum on the right. Here are a few examples 6789542137 ; 53426 7274707623 ; 13890 7608909976 ; 21097 7866018419 ; 46204 8185833863 ; 59982 8052724826 ; 68535 Please help Thanks

    C Offline
    C Offline
    Cosmic Egg
    wrote on last edited by
    #13

    This question reminds me of the hollywood movie "Beautiful Mind".

    1 Reply Last reply
    0
    • C Cosmic Egg

      why is it assumed that f(n) = 0 for all other n

      7 Offline
      7 Offline
      73Zeppelin
      wrote on last edited by
      #14

      Because based on the finite sample population he posted, it is a valid assumption.

      "If only God would give me some clear sign! Like making a large deposit in my name in a Swiss bank."

      C 1 Reply Last reply
      0
      • 7 73Zeppelin

        Because based on the finite sample population he posted, it is a valid assumption.

        "If only God would give me some clear sign! Like making a large deposit in my name in a Swiss bank."

        C Offline
        C Offline
        Cosmic Egg
        wrote on last edited by
        #15

        But he has just given you few samples of input and output of a function. all the remaining output cannot be assumed to be zero what you are saying is this: if i say f(100) = 10 f(81) = 9 f(64) = 8 f(49) = 7 f(36) = 6 f(25) = 5 here its a simple example in which output is just square root of input now based on your assumption f(n) = 0, does that mean square root of all remaining numbers are zero

        C 7 2 Replies Last reply
        0
        • C Cosmic Egg

          But he has just given you few samples of input and output of a function. all the remaining output cannot be assumed to be zero what you are saying is this: if i say f(100) = 10 f(81) = 9 f(64) = 8 f(49) = 7 f(36) = 6 f(25) = 5 here its a simple example in which output is just square root of input now based on your assumption f(n) = 0, does that mean square root of all remaining numbers are zero

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #16

          f(100) = 10
          f(81) = 9
          f(64) = 8
          f(49) = 7
          f(36) = 6
          f(25) = 5

          f(n) = 0 for all other n values

          It is a perfect legal (and admittely beautiful) function. It satisfies all your requirements until you don't specify the 'square root' one. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          C 1 Reply Last reply
          0
          • C Cosmic Egg

            But he has just given you few samples of input and output of a function. all the remaining output cannot be assumed to be zero what you are saying is this: if i say f(100) = 10 f(81) = 9 f(64) = 8 f(49) = 7 f(36) = 6 f(25) = 5 here its a simple example in which output is just square root of input now based on your assumption f(n) = 0, does that mean square root of all remaining numbers are zero

            7 Offline
            7 Offline
            73Zeppelin
            wrote on last edited by
            #17

            He provides a finite sample of 6 data points. The function he provided describes them perfectly. If the sample size is 6, then all others must be zero. There's nothing wrong with it and it's a perfect fit to the data.

            "If only God would give me some clear sign! Like making a large deposit in my name in a Swiss bank."

            C R 2 Replies Last reply
            0
            • 7 73Zeppelin

              He provides a finite sample of 6 data points. The function he provided describes them perfectly. If the sample size is 6, then all others must be zero. There's nothing wrong with it and it's a perfect fit to the data.

              "If only God would give me some clear sign! Like making a large deposit in my name in a Swiss bank."

              C Offline
              C Offline
              Cosmic Egg
              wrote on last edited by
              #18

              he never says the sample size is 6 he just gave you 6 to you because he cannot go on posting all samples

              7 1 Reply Last reply
              0
              • C CPallini

                f(100) = 10
                f(81) = 9
                f(64) = 8
                f(49) = 7
                f(36) = 6
                f(25) = 5

                f(n) = 0 for all other n values

                It is a perfect legal (and admittely beautiful) function. It satisfies all your requirements until you don't specify the 'square root' one. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                C Offline
                C Offline
                Cosmic Egg
                wrote on last edited by
                #19

                okay you can take any other example....this was just to prove the point....

                C 1 Reply Last reply
                0
                • C Cosmic Egg

                  he never says the sample size is 6 he just gave you 6 to you because he cannot go on posting all samples

                  7 Offline
                  7 Offline
                  73Zeppelin
                  wrote on last edited by
                  #20

                  Cosmic Egg wrote:

                  he never says the sample size is 6 he just gave you 6 to you because he cannot go on posting all samples

                  ...and the function fits the finite sample. The function fits the observed data: any other (unknown) points are irrelevant and can therefore be set to zero. Adding additional points will change the function, obviously, so that if f(7) were defined, then setting f(n>7) = 0 would fit the new data.

                  "If only God would give me some clear sign! Like making a large deposit in my name in a Swiss bank."

                  1 Reply Last reply
                  0
                  • C Cosmic Egg

                    okay you can take any other example....this was just to prove the point....

                    C Offline
                    C Offline
                    CPallini
                    wrote on last edited by
                    #21

                    You didn't prove the point and without further requirements the OP's request is pointless. :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    1 Reply Last reply
                    0
                    • S shrewdlin
                      1. x and y is variable 2) yes, it means x to the power of 5 yan can use your data to make six equation for example: a * 6789542137 ^ 6 + b * 6789542137 ^ 5 + c * 6789542137 ^ 4 + d * 6789542137 ^3 + d * 6789542137 ^ 2 + f * 6789542137 = 53426 (this is the first one, you can do the other) six equation to solve six variable can you calculate the a、b、c、d、e、f then use the known a、b、c、d、e、f to rebuild the equation the data is very big you can use maple software for you!!!good luck!!
                      H Offline
                      H Offline
                      hdsouza1
                      wrote on last edited by
                      #22

                      Hi Shrewdlin, Thanks for the detailed explanation. I guess I will have to buy the maple software. before I buy I was wondering how you got to this formula. Did you run the numbers through some program of yours to get this formula Thanks

                      C D 2 Replies Last reply
                      0
                      • H hdsouza1

                        Hi Shrewdlin, Thanks for the detailed explanation. I guess I will have to buy the maple software. before I buy I was wondering how you got to this formula. Did you run the numbers through some program of yours to get this formula Thanks

                        C Offline
                        C Offline
                        cp9876
                        wrote on last edited by
                        #23

                        You can solve it in a spreadsheet, for the theory see Polynomial Interpolation[^], but unless you know that the answer you are looking for is a polynomial it is almost certainly wrong. A 5th order polynomial can be fitted to your data: a * x ^ 5 + b * x ^ 4 + c * x ^3 + d * x ^ 2 + e * x ^ 1 + f = y but so can a 6th a * x ^ 6 + b * x ^ 4 + c * x ^3 + d * x ^ 2 + e * x ^ 1 + f = y a 7th a * x ^ 7 + b * x ^ 4 + c * x ^3 + d * x ^ 2 + e * x ^ 1 + f = y or a different 7th a * x ^ 7 + b * x ^ 6 + c * x ^3 + d * x ^ 2 + e * x ^ 1 + f = y or a Fourier series a * sin(x) + b * sin(2*x) + c * sin(3*x) + d * sin(4*x) + e * sin(5*x) + f = y or basically a linear combination of any collection of 6 functions (some collections of 6 functions will fail, but most will succeed). There are also a wide range of possible solutions that don't fall into these categories. So unless you can state why any of the above solutions should or shouldn't be the one you are looking for, you don't know enough about the problem to solve it.

                        Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

                        1 Reply Last reply
                        0
                        • 7 73Zeppelin

                          He provides a finite sample of 6 data points. The function he provided describes them perfectly. If the sample size is 6, then all others must be zero. There's nothing wrong with it and it's a perfect fit to the data.

                          "If only God would give me some clear sign! Like making a large deposit in my name in a Swiss bank."

                          R Offline
                          R Offline
                          Roger Wright
                          wrote on last edited by
                          #24

                          73Zeppelin wrote:

                          If the sample size is 6, then all others must be zero

                          That's extraordinarily poor logic. There are six known values; that's no reason to extrapolate all other values to zero. It just means we only know 6 of them; unless a pattern can be derived from the known samples, we know nothing about the other possible values.

                          "A Journey of a Thousand Rest Stops Begins with a Single Movement"

                          7 1 Reply Last reply
                          0
                          • H hdsouza1

                            I need to figure out the formula/pattern/algorithm needed to convert the number on the left into a checksum on the right. Here are a few examples 6789542137 ; 53426 7274707623 ; 13890 7608909976 ; 21097 7866018419 ; 46204 8185833863 ; 59982 8052724826 ; 68535 Please help Thanks

                            R Offline
                            R Offline
                            Roger Wright
                            wrote on last edited by
                            #25

                            You call the right-hand value a checksum. Why not assume that's what it really is? Checksums are performed on blocks of data, usually of a fixed size, in bit-wise fashion. That is, each character is loaded into a shift register, then the bits are shifted out and summed. Checksums originated with serial data communications, wherein a block of data was shifted out to the communications media and the bits summed as it was transmitted. The total of the checksum was tacked on to the end of each message and sent. At the receiving end the message was serially loaded into a register while the bits were summed. The total value of the sum was then compared to the last block of data sent, which was the checksum calculated by the sender. If they matched, the message was assumed good; if not, a NACK was returned to the sender, and the sender retransmitted. Convert your data into binary - an 8-bit character is probably acceptable, unless you assume Unicode was used. Pad the higher-order bits with zeroes and sum the bits. Convert the result back into decimal and look for the checksum. This method may take a while, as checksums were used on fixed block sizes and you don't know what size was used. Note, too, that this only applies to text data. Real numbers encoded using IEEE standards or other methods may convert differently. Without a lot more information about the problem domain it's impossible to suggest anything short of brute force decryption.

                            "A Journey of a Thousand Rest Stops Begins with a Single Movement"

                            H 1 Reply Last reply
                            0
                            • R Roger Wright

                              You call the right-hand value a checksum. Why not assume that's what it really is? Checksums are performed on blocks of data, usually of a fixed size, in bit-wise fashion. That is, each character is loaded into a shift register, then the bits are shifted out and summed. Checksums originated with serial data communications, wherein a block of data was shifted out to the communications media and the bits summed as it was transmitted. The total of the checksum was tacked on to the end of each message and sent. At the receiving end the message was serially loaded into a register while the bits were summed. The total value of the sum was then compared to the last block of data sent, which was the checksum calculated by the sender. If they matched, the message was assumed good; if not, a NACK was returned to the sender, and the sender retransmitted. Convert your data into binary - an 8-bit character is probably acceptable, unless you assume Unicode was used. Pad the higher-order bits with zeroes and sum the bits. Convert the result back into decimal and look for the checksum. This method may take a while, as checksums were used on fixed block sizes and you don't know what size was used. Note, too, that this only applies to text data. Real numbers encoded using IEEE standards or other methods may convert differently. Without a lot more information about the problem domain it's impossible to suggest anything short of brute force decryption.

                              "A Journey of a Thousand Rest Stops Begins with a Single Movement"

                              H Offline
                              H Offline
                              hdsouza1
                              wrote on last edited by
                              #26

                              Hi Roger, Thanks for your response. 1)Can you give me an example of "Convert your data into binary...." . Is it similar to this http://www.easycalculation.com/decimal-converter.php 2) Also what is a good methord of brute force decryption Thanks

                              R K 2 Replies Last reply
                              0
                              • H hdsouza1

                                Hi Roger, Thanks for your response. 1)Can you give me an example of "Convert your data into binary...." . Is it similar to this http://www.easycalculation.com/decimal-converter.php 2) Also what is a good methord of brute force decryption Thanks

                                R Offline
                                R Offline
                                Roger Wright
                                wrote on last edited by
                                #27

                                1. It depends on the data type. If ASCII, a 6 would become 00100100; if straight binary, 6 = 00000110. It might also be that the entire number is one encoded value, which a straight decimal to binary converter will give you. That's why I say the problem is not well enough defined to solve easily. If the source is text data, the ASCII format is likely, if it's a simple device using an 8-bit processor that is producing this data, the 8-bit straight binary is possible. If it's something else, like stolen launch codes for Italy's secret intercontinental wine bottle launch system, then the whole number might be a single value that needs to be converted. There's no way to tell from the question. 2. If I knew how to do that I'd be making a whole lot more money cracking financial data streams for the IRS. Read a book on encrytion/decrytion methods and pick one. Bruce Schneier's Applied Cryptography is a good introduction.

                                "A Journey of a Thousand Rest Stops Begins with a Single Movement"

                                1 Reply Last reply
                                0
                                • R Roger Wright

                                  73Zeppelin wrote:

                                  If the sample size is 6, then all others must be zero

                                  That's extraordinarily poor logic. There are six known values; that's no reason to extrapolate all other values to zero. It just means we only know 6 of them; unless a pattern can be derived from the known samples, we know nothing about the other possible values.

                                  "A Journey of a Thousand Rest Stops Begins with a Single Movement"

                                  7 Offline
                                  7 Offline
                                  73Zeppelin
                                  wrote on last edited by
                                  #28

                                  Roger Wright wrote:

                                  That's extraordinarily poor logic. There are six known values; that's no reason to extrapolate all other values to zero. It just means we only know 6 of them; unless a pattern can be derived from the known samples, we know nothing about the other possible values.

                                  It's a discretization of the available data. If he's trying to fit six observations of the sample population, then setting the remaining data to zero is completely acceptable. That's not to say we assume the rest of the data is zero, but that we are fitting only to the points that we know.

                                  1 Reply Last reply
                                  0
                                  • H hdsouza1

                                    Hi Shrewdlin, Thanks for the detailed explanation. I guess I will have to buy the maple software. before I buy I was wondering how you got to this formula. Did you run the numbers through some program of yours to get this formula Thanks

                                    D Offline
                                    D Offline
                                    darrellp
                                    wrote on last edited by
                                    #29

                                    Wait! Don't buy Maple! You need to tell us something about what you expect out of this "decoder". If you just want any function that will match up at these points, sure, the polynomial will work but it will go crazy outside of these points. I'm assuming you're trying to "reproduce" some other function which spat out these values, in which case the polynomial is pretty much guaranteed to be the wrong thing. On the other hand, if you're just looking for a rule that takes on those values, you can use the function which takes on those specific values at those specific points and is zero everywhere else. It's about as likely as the polynomial and you don't have to buy Maple to compute it. In general, if you are trying to reproduce the function that somebody else carefully chose to produce these values you're probably out of luck. There are an infinite number of functions that will do that. If you're looking for any function at all, then either take the one I mentioned above or explain whatever other details you've got that keep that one from working. You see these sort of questions in "brainteasers" where you have a chance of solving them, but if this was designed to prevent cracking, you're not likely to chance across the right answer.

                                    1 Reply Last reply
                                    0
                                    • H hdsouza1

                                      Hi Roger, Thanks for your response. 1)Can you give me an example of "Convert your data into binary...." . Is it similar to this http://www.easycalculation.com/decimal-converter.php 2) Also what is a good methord of brute force decryption Thanks

                                      K Offline
                                      K Offline
                                      Kalegley
                                      wrote on last edited by
                                      #30

                                      Hi Roger, Thanks for your response. There are simple techniques to convert binary to decimal http://www.acalculator.com/binary-decimal-hexadecimal-converter.html Thanks !!

                                      1 Reply Last reply
                                      0
                                      Reply
                                      • Reply as topic
                                      Log in to reply
                                      • Oldest to Newest
                                      • Newest to Oldest
                                      • Most Votes


                                      • Login

                                      • Don't have an account? Register

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • World
                                      • Users
                                      • Groups