How to compare consecutive groups of numbers in arrays

Hi
I require to place the solution into a 1D array.
I need to compare two arrays and save the same numbers that are in both arrays but also save groups of numbers that may be in only one of the two arrays being compared.
In the example l have not been able to place all consecutive groups of numbers 8,9,10,11,12 into a 1D array.
In the example l need to filter out the zeros and the number four.
The numbers in both arrays are always in descending order however may not be in the order of index number of array. That is 15 = 15 index number
A consecutive group of numbers in this example is a group that increase by a value of 1. E.g.. 8,9,0,22,23,24 are two consecutive groups of numbers.
Thank  you
Solved!
Go to Solution.
Attachments:
Compare numbers and consecutive numbers in arrays.vi ‏17 KB

Hi Lynn
I did have a look at the consecutive array solution. I have looked and looked l thought l knew how it worked but after a number of separate evaluations with other code l have failed. I am just glad it works. With the consecutive array solution l tried today my own code but l lost either the first number of the last number of a consecutive group of numbers.
I may have confused you but in doing so you have provided a real different view which l am very grateful. You have viewed the consecutive number problem as just a single 1D array problem. By doing this you have opened my eyes to another way to do the job and a way to handle this type of data. However l am also comparing two arrays. For example l have to pick up say two equal values in two columns that the consecutive array does not detect and then correctly locate a value in the final array if the value is not in the final array.
What l have not told you is also l have to be able to identify groups of numbers in two 1D arrays. E.g... Array 1 has 1,2,9,10 next array has 9,10 the final array ends up 9,10 when l would like 0,9,10. When viewing numbers by rows later on l can then detect with a array length vi the length of the 1,2 groups of numbers over a large number of columns. If 9,10 jumps to the front it becomes a wrong length. This is actually my main problem which has caused me a large amount of extra programming. I have gone back to basics to see what l can do differently and you have provided the first clue with the consecutive array. I placed it in my main program today and it filtered a lot variable data which l could not remove without losing real data. The main data lost in your solution was the say 17 number in two columns which in an image is a horizontal line. I know what l have just provided you in this paragraph is all new information but it provides a background as to what l am up to. I am getting pixel data from a 2D array and comparing +1 index 1D array with a normal array. This way l can view the data of the next column to see if there is a pattern. I am actually trying to program an array as how humans view objects in images.
I will have another go at integrating your solution next week
Regards
Michael

Similar Messages

  • How  to compare previouse value in pl/sql array

    DECLARE
    CURSOR stg_raw_cur IS
    SELECT RAW_STG_ID,
    DEVICE_CD,
    MODEL_VERSION,
    PLATFORM_CD,
    PROFILE_COOKIE,
    LOCATION_CD,
    SAMPLE_RATE,
    EVENT_TYPE_CD,
    to_char(to_date(to_date(substr(EVENT_DATE_TIME,1,8),'yyyymmdd')-1 ||
    'T' ||
    substr(EVENT_DATE_TIME,10,8)
    || 'Z','DD-MON-RR"T"HH24:MI:SS"Z"'), 'YYYYMMDDYY"T"HH24:MI:SS"Z"' ) EVENT_DATE_TIME,
    EVENT_SPECIFIC,
    BATCH_ID,
    DWH_ARVL_DT,
    DWH_ARVL_DT_ID,
    DWH_CREATE_DT from dwh_stg.stg_raw where batch_id >= 200
    order by batch_id asc;
    TYPE stgrawarr IS TABLE OF stg_raw_cur%ROWTYPE;
    stg_raw_rec stgrawarr;
    l_batch_id NUMBER :=0 ;
    v_ctr NUMBER :=0;
    l_temp_batch_id number :=0;
    BEGIN
    OPEN stg_raw_cur;
    LOOP
    FETCH stg_raw_cur BULK COLLECT INTO stg_raw_rec LIMIT 100;
    EXIT
    WHEN stg_raw_cur%NOTFOUND;
    END LOOP;
    CLOSE stg_raw_cur;
    for i in stg_raw_rec.first..stg_raw_rec.last
    loop
    dbms_output.put_line('batch id is '|| stg_raw_rec(i).batch_id );
    IF l_batch_id != stg_raw_rec(i).batch_id
    then
    dbms_output.put_line('Different');
    end if;
    l_temp_batch_id := stg_raw_rec(i).batch_id;
    commit;
    end loop;
    END;
    I want to compare previous value of stg_raw_rec(i).batch_id if differnet then increament the value
    else leave the same.
    thanks.

    Try this,
    FOR i IN stg_raw_rec.FIRST .. stg_raw_rec.LAST
       LOOP
          IF l_temp_batch_id != stg_raw_rec (i).batch_id
          THEN
             --increment
             l_temp_batch_id := l_temp_batch_id + 1;
          END IF;
           DBMS_OUTPUT.PUT_LINE ('batch id is ' || stg_raw_rec (i).batch_id||' unique batch id is '||l_temp_batch_id);
        --  DBMS_OUTPUT.PUT_LINE ('batch id is ' || stg_raw_rec (i).batch_id);
        --  IF l_batch_id != stg_raw_rec (i).batch_id
        --  THEN
        --    DBMS_OUTPUT.PUT_LINE ('Different');
        --  END IF;
          l_temp_batch_id := stg_raw_rec (i).batch_id;
          COMMIT;
       END LOOP;

  • How can I rank a group of numbers in a array or list

    Now I have a group of numbers :13, 4, 5, 10.
    I need a java algorithm to rank those numbers, the result will be like 4,1,2,3 after ranking.
    suppose there are same numbers in the source, for example: 13, 4, 4, 5, 6
    the result will be like 4, 1, 1, 2, 3 after ranking.
    Thank you for any help!

    Another alternative is to make a class which has two attributes
    1. number value
    2. rank
    make this class implement comparable so you sort it anyway you like. Below is a very close example of what you are looking for, just need to replace frequency with rank
    class ComparbleExample{
        private final String[] possibleNumbers = {"one", "two", "three"};
        private String[] inputNumbers = {"one", "two", "three", "one", "one", "four", "three"};
        private Number[] numbers;
        public ComparbleExample(){
            numbers = new Number[possibleNumbers.length];
            populateNumberArrayList();
            System.out.println("\n\nPrinting Unsorted Array");
            print();
            ArrayList<Integer> d;
            Arrays.sort(numbers);
            System.out.println("\n\nPrinting Sorted Array");
            print();
        public void populateNumberArrayList(){
            int frequency;
            for(int i = 0;i<numbers.length;i++){
                frequency = getFrequency(possibleNumbers);
    numbers[i] = new Number(possibleNumbers[i],frequency);
    public int getFrequency(String number){
    int frequency = 0;
    for(int i=0;i<inputNumbers.length;i++){
    if(number.equals(inputNumbers[i])){
    frequency++;
    return frequency;
    public void print(){
    for(int i = 0;i<numbers.length;i++){
    System.out.println(numbers[i]);
    public static void main(String[] args){
    new ComparbleExample();
    class Number implements Comparable{
    private int frequency;
    private String number;
    public Number(String number){
    this(number, -1);
    public Number(String number, int frequency){
    this.number = number;
    this.frequency = frequency;
    public String getNumber() {
    return number;
    public int getFrequency() {
    return frequency;
    public void setFrequency(int frequency) {
    this.frequency = frequency;
    public void setNumber(String number) {
    this.number = number;
    public int compareTo(Object o) {
    Number n = (Number)o;
    if(frequency < n.getFrequency()){
    return 1;
    }else if(frequency > n.getFrequency()){
    return -1;
    }else{
    return 0;
    @Override
    public String toString() {
    return this.number +", "+ this.frequency;

  • Two questions:  how do Skype and iChat compare for group video?  quality, reliability, cost, etc are important.  2) Is my MobileMe ID what I need to use in the window in making an iChat buddy?  It only says AIM above the window, online tutorial differs.

    Two questions:  1) How do Skype and iChat compare for group video?  Quality, reliability, cost, etc are important.  2) Is my MobileMe ID what I need to input in the window in making an iChat buddy?  It only says AIM above the window, online tutorial differs, saying MobileMe, AIM, GoogleTalk (Jabber) all work. Thnx

    Hi,
    IChat uses better Video Compression than Skype does.
    On a top flight Mac you can send a 640 X 480 pixel frame up to 30 frames a sec.
    Skype can't match this.
    iChat in Video is Peer to Peer. (you can actually Log out of the Buddy list)
    Skype seems to borrow something from everyone's bandwidth to make connections.
    What do you mean by Business account Tracking ?
    iChat Adds (or can add) the First Name, Last Name of your Buddies and create an Address Book Entry
    Whether you mark those cards connected with a  company is up to you.
    (I have heard of issues with earlier version of iChat and the Address Book that "saw" the Company Name as the part of the Name and linking several Screen Names to the one name
    Audio on a Mac using Skype tend to be the same as the streaming needs are less.
    However you have to rely on any PCs audio abilities from PCs which may not be to the same standard.
    Mac to PCs in iChat and AIM can be difficult though.  (It should work but it rarely as simple as Plug and go)
    Skype may suit your needs better on ocassions.
    9:11 PM      Thursday; May 5, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.7)
    , Mac OS X (10.6.7),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How to create a group on the iPhone 4S?

    How to create a group on the iPhone 4S?

    yes  By using this group will it use the cell phone numbers?

  • How to compare records in singe internal table

    Hi Folks,
    iam having 3 records in my first itab( T_FINAL) with fields
    material no,  descrip ,  mat type and  group.
    and 16 records in second itab(T_MVKE ) with fields
    mat no ,  distri.chanel  and division
    now I want to fetch the records from T_MVKE  by comparing the records in
    T_FINAL .my requirement is to check the given mat no. in sales org.2000,2100.  if yes then i have to consider 2000 only, if it is in only 2100 then consider 2100 only . is it is in 2000 only then consider 2100 only
    my code is
    LOOP AT T_FINAL.
        READ TABLE T_MVKE WITH KEY MATNR = T_FINAL-MATNR.
       IF SY-SUBRC = 0.
       ON CHANGE OF T_MVKE-MATNR OR T_MVKE-VKORG.
    IF T_MVKE-VKORG = '2000' and SY-TABIX > 1.
          CONCATENATE '2000' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
    ELSEIF T_MVKE-VKORG = '2000' AND SY-TABIX = 1.
         CONCATENATE '2000' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
    ELSE.
        CONCATENATE '2100' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
        ENDIF.
    this logic fails ,. could tell me how to compare values in single itab?
    Thanks
    neha

    Hi ,
    if i've understand you correctly , try that:
    LOOP AT t_final.
      AT NEW matnr.
        CLEAR: v_2000, v_2100.
    *1) 2000
        READ TABLE  t_mvke    WITH KEY matnr = t_final-matnr
                                       vkorg = 2000.
        IF sy-subrc = 0.
          v_2000 = 'X'.
        ENDIF.
    *2) 2100
        READ TABLE  t_mvke    WITH KEY matnr = t_final-matnr
                                       vkorg = 2100.
        IF sy-subrc = 0.
          v_2100 = 'X'.
        ENDIF.
    *compare
        IF v_2000 = 'X' AND  v_2100 = 'X'.
    *read 2000 only
        ELSEIF v_2000 = ' '  AND v_2100 = ' '.
    *nothing found
        ELSE.
    *all other combinations
    *read 2100 only
        ENDIF.
      ENDAT.
    ENDLOOP.
    regards Andreas

  • Vendor Master Management - How to make 'Corporate Group' field an autoupdat

    Vendor Master Management - How to make 'Corporate Group' field an automatically updated field
    Frnz,
    I am doing a Spend Analysis and thereby restructring some aspects of SAP and business processes. One of the intiatives is to leverage the 'Corporate Group' field in Vendor Master for getting the consolidated spend visibility at the corporate group level of vendors. So far this field wasn't been used to effect. I can update it manually, but the question remains is how do I do with the change management of the corporate group of large vendor base in the scenario of everhappening Mergers and Acquisitions. Are there any alternatives anybody can suggest ? (Like linking D&B numbers etc)
    Thanks in advance for your suggestions..

    Hi Shiv,
    Let me elaborate the purpose of using this field. I want to have a consolidated spend visibility across a corporate group which has multiple vendor codes. Its difficult everytime to group the spends of these vendors manually especially when the number of vendors are too high. Also sometimes the names of vendor companies may not indicate that these are from same corporate group but in fact they could be. In order to have the reports generated on corporate groups, I must maintain this field in vendor master or a Z table. But the problem here is, it should be possible to update this field as and when there are any mergers or acquisitions at vendor side and the corporate group of a particular vendor gets changed due to this. So this has to be effected in vendor master or Z-table automatically. I do know that there are certain agencies like Dunn & Brad (DNB) which provide possibly the details on corporate group of a company but its not fully effective for Indian Vendors as its not mandatory on them to have DNB number & also its a disconnected process and I was looking to connect it seamlessly to Corporate Group field so that I need not bother to update these things manually everytime. I also wanted to explore various possibilities of doing this.
    I hope I have spelled it out correctly.

  • How to Compare 2 internal table data...

    Hi Experts,
    i ve 2 internal tables, both contains NRIC numbers...
    now i want to compare whether the both table data is same or not?
    i tried like
    if itab1[] = itab2[].
    but its not working...
    how 2 compare both tables are having matching data r not?
    Thanks in Advance,
    sudeer.

    Hi Vijay,
    thanks for ur replay...
    i ve done same thing what u ve given, but its not working........
    but both tables having same data....no doubt on that...
    my require ment is i ve contants in both tables..
    i want 2 check if both should have same no of records and contant also should be same...

  • Column of consecutive integers in Numbers

    How do I enter a function that generates a row of consecutive integers in Numbers?

    Hi irrascible,
    Another way is to insert the first 2 values of a series, then select the starting cells and drag by the Fill Handle.
    This is in Numbers '09 (it works in Numbers 3.2 but the Fill Handle is a yellow dot in the centre right side of the selection).
    Regards,
    Ian.

  • How to create a group calendar?

    Hello,
    i am sorry but this is one more question on wiki-group-calendars.
    *In short:*
    I am not able to create a group calendar with the wiki frontend. the calendar that is created with a wiki is owned by the admin of the wiki. So it is always a personal calendar that cannot be shared in iCal.
    LONG:
    I want to create a group calendar that is viewed and edited through iCal.app and the web service. Apple´s "wiki deployment" guide says on page 57:
    +"The web calendar allows you to easily schedule events for yourself or your group. ...+
    +There are *two types of web calendars: personal and group*. You can send and receive event invitations through the personal calendar but not through the group calendar. Also, *while anyone in a group can create or edit events in a group calendar*, you can edit only events in your own personal calendar or event invitations you send to other people.+
    +The web calendar uses iCal Server to store events and invitations. ..."+
    But there is not mentioned how to create a group calendar. The calendar created with the wiki web-frontend belongs to the admin of that particular wiki. This is why the calendar data ist stored in folder named with the UUID of the wiki admin. Also the alias "http://server.fqdn:8008/principals/groups/mygroupname/" which i provided in iCal turns into ..._uids_UUID-of-the-wiki-admin and only the wiki-admin can access this calendar in iCal.app.
    My research on this topic reveals that there were in issue that should be resolved in 10.6.4 (that is running on our Server). So, again, how to create a group calendar?
    Thanks, Philipp.
    10.6.4 OSX Server
    10.6.x Clients

    farmer tan wrote:
    you need to go to the wiki page and add the wiki's there and then in the setting of the wiki is where you set permissions and services such as calendar, blog, and podcast you can also set all permissions for the wiki in the settings tab
    fyi none of my groups were available unless i logged into the wiki as the Directory Admin not Server Admin
    migrated from 10.5.7 to 10.6
    Message was edited by: farmer tan
    Could you be more specific farmer tan, please?
    You said "you need to go to the wiki page and add the wiki's there...." What is the "wiki page" you mention? Is that some place I go to via the browser or the Server Admin tool?
    I went to http://ical.mysite.com/ical/ and logged in as the Directory Administrator but didn't see anything resembling what you described.
    Thanks in advance for any help you can provide.

  • How do I access group calendars on 10.8 server from a calendar client?

    Hi,
    I have a brand new installation of 10.8.2 . I installed the server app and started Calendar, Contacts, DNS, File Sharing, Mail, Open Directory and the Wiki services. I created a group with some users in it. I also created a group wiki and enabled the calendar for that wiki. The user group has r/w access to the wiki. The web interface to the wiki works from a client 10.8.2 client system. I can edit the group calendar through the web interface. I created an account in the Calendar application that connects to the server and shows the users' calendar. I altered the server path to /principals/__uids__/wiki-GROUPNAME/.
    The calendar shown is still that for the user and not the one of the group. Hence my question: how do I access group calendars on a 10.8 server from the calendar application on a client?

    yrmomsadic wrote:
    Forgot to mention, you can techinically force it to work, but iCal breaks it for some unknow reason, taking it back to the users account after a day or two.  The best work around has been to create a new user, named the group name, and then allow delegates to access the calendar.  This however screws things up with the iphone calendar, as it didn't/doesn't handle delegates.  Again, hoping Apple comes to their senses on this.
    You can still delegated calendars on iOS, but the setup is a little tricky.  You have to add an entirely new calendar account, and enter the full ugly url with the users uuid.  It would be so nice if iOS just supported CalDav delegation.

  • Hey How Do I Get Group Message On The IPhone 4s because some reason it doesn't want to show . First i did is setting then messages  it only show imessage and message count )HELP)

    ey How Do I Get Group Message On The IPhone 4s because some reason it doesn't want to show . First i did is setting then messages  it only show imessage and message count )HELP)

    At the bottom of the page Settings > Messages you should have a section headed "SMS/MMS" Turn MMS messaging on then you can turn group message on.

  • How do I restore Groups to Contacts from time machine?

    How do I restore groups to Contacts using time machine?  I somehow managed to duplicate many groups and contacts in Contacts, so I deleted everything and tried to restore them using time machine backup  from a few days before.  It restored all my contacts, but none of my groups.  If you select a group and click restore it will restore all the contacts in the group, but not the group itself.  I had many groups with many contacts in each and would really prefer not to do this manually.  I can see the groups in the time machine backup, but cannot figure out how to restore them.  I know from researching online that with Address Books and previous operating systems you could go to ~Library/Applications Support/AddressBook  and restore the whole file, but either this operating systems hides the necessary files or Contacts is set up differently than AddressBook was.  I am using OS 10.9.5 and Contacts version 8.0 on a MacbookPro 13 inch mid 2010.

    Here is what I have tried:
    1. Finder>Go>(Option)Library>Address Book(highlighted)with files showing in right column. Opened Time Machine and Address Book folder is there. Tried to go back to several previous dates from several months ago. None will highlight in order for the Restore button to light up.
    2. Finder>Mac HD (under Devices)>(Option)Library>Address Book (same as above). Again, cannot go anywhere back in time to highlight a date for Restore button to light up.
    Note: I was able to use Time Machine to restore my Contacts with no problem. However, they are All Contacts only and did not restore my Groups. I do know how to make groups again and highlight and drag them back, but wanted to see if there was a way to restore the groups. I will post another question as to why my Time Machine won't let me restore the Address Book as well as the Contacts. Thank you for your time and patience.

  • How to find user group from tcode

    Hi Experts,
    I have custom tcode from this i found report name as AQIDSYSTQV000001SD_RR_03======
    I am unable to find Queryname in SQ01 from this.
    When i saw some of the forums i  understood that IDSYST is the user group for my query but i am unable to trace such user group in SQ01.
    Please guide me how to find user group for my report
    Thanks&Regards,
    narasimha.

    Hi ,
    I found in table AQGQSTRUC but i didnt find the specified query
    Previously 401 client is there but at present it is not there .How can you justify it that it is 401 client.
    As 401 client data is moved to someother client is it the problem why i am not able to find query??
    Thanks&Regards,
    narasimha.
    Edited by: narasimha02 on Dec 7, 2010 9:54 AM

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

Maybe you are looking for

  • How to scan  my macbook pro virus

    how to scan my macbook pro virus

  • Dreamweaver CC crashes when switching from code view to design view

    I am experiencing a recent problem with a file I am currently working. When I switch from code view to design view Dreamweaver crashes and requests a shut down. Other files seem to work without a problem. This particular files has 3 cascading EdgeAni

  • Help in setting up video for final cut pro 7

    my objective is to create a stop motion video for weddings and the dimensions are 1440 x 1080. this corresponds to the 640 x 480 ntsc video which can be played via the regular projectors. my question is when i import jpg images into the sequence, it

  • PIXMA922 issue with no paper message

    Printer keeps giving a "no paper" message about upper tray when lower tray is full and is from where I need to print. Is there a way to override the message? Will it always be doing this or can I select the paper tray at when selecting "print"?

  • IPhoto is re-syncing every time.

    Hello Folks, Every time I sync in iTunes, All iphotos (photos) are re-syncing every time. Also in my iPhoto folder the *iPod Photo Cache* always starts a new Cache. Specs: Fifth Generation iPod (iPod with video) Mac OSX 10.5.1 and 10.4.11 iTunes 7.6