want all numbers from 1-1000 that contain 3 and 4 in a list

Discussion in 'Lounge' started by samsome, Mar 16, 2022.

  1. samsome

    samsome Guest

    SOLVED: i did it till 100 and then it just repeats by adding 100 to each excel cell its fine thanks

    want all numbers from 1-1000 that contain numbers 3 and 4 in a list

    is there a way to do this, in excel or anywhere

    i just need them in a list

    so it would start as

    3
    4
    13
    14
    23
    24
    30
    31
    32
    etc
     
    Last edited by a moderator: Mar 16, 2022
  2.  
  3. BEAT16

    BEAT16 Audiosexual

    Joined:
    May 24, 2012
    Messages:
    9,082
    Likes Received:
    6,997

    Attached Files:

  4. samsome

    samsome Guest

  5. BEAT16

    BEAT16 Audiosexual

    Joined:
    May 24, 2012
    Messages:
    9,082
    Likes Received:
    6,997
    Delete the numbers you don't need !
     
  6. samsome

    samsome Guest

    i thought it was gonna work by deleting but...

    the thing is....

    as long the number contains 3 and 4 i want the whole number included in my list...so deleting other numbers won't work

    this is the pattern i am looking for to understand what i mean....so even 1,2,5,6,7,8,9,0 is ok as long 3 and 4 is included

    3
    4
    13
    14
    23
    24
    30
    31
    32
    33
    34
     
  7. BEAT16

    BEAT16 Audiosexual

    Joined:
    May 24, 2012
    Messages:
    9,082
    Likes Received:
    6,997
    What should it be or in other words what the hell are you up to ?
     
  8. samsome

    samsome Guest

    thanks Beat16 its fine i did it till 100 and then it just repeats by adding 100 to each excel cell its fine thanks!
     
  9. stopped

    stopped Producer

    Joined:
    Mar 22, 2016
    Messages:
    343
    Likes Received:
    106
    regex is 0% fun so it is hard to find other people to formulate regex searches for you, but this is a great opportunity to learn a little regex
     
  10. Plainview

    Plainview Rock Star

    Joined:
    Mar 9, 2020
    Messages:
    468
    Likes Received:
    480
    the laziest way I could think of
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int i;
        
        for (i = 1; i < 1000; ++i)
        {
            if (((i % 10) / 1) == 3 || ((i % 100) / 10) == 3 || ((i % 1000) / 100) == 3 )
            {
                printf("%d \n", i);
            }
    
            else if (((i % 10) / 1) == 4 || ((i % 100) / 10) == 4 || ((i % 1000) / 100) == 4)
            {
                printf("%d \n", i);
            }
            else
            {
            }
        }
        getchar();
        return 0;
    }
    
    upload_2022-3-16_17-37-5.png
     
    • Winner Winner x 4
    • Like Like x 3
    • Love it! Love it! x 2
    • List
  11. Ozmosis

    Ozmosis Producer

    Joined:
    Sep 12, 2011
    Messages:
    177
    Likes Received:
    80
    i. Create a new excel spreadsheet, select A1 and type number 1
    ii Next Select Fill/Series/Columns and Linear enter step value start 1 and end 1000
    Now you should have 1-1000 listed down the page, next...
    iii select column A to highlight the column and then select Sort & Filter/Filter.
    iv In A1 you should now see an arrow, click to open the menu and in the number filters search type 3 and copy all and paste to a new column. After this you can do the same for number 4, there will of course be some duplicates... so..
    v Delete the original column now you should have the results for all numbers containing 3 and 4
    vi Select the DATA tab, and then select remove duplicates...
    vii Now you can copy the list to where ever you need it.

    You could probably do this using formula, but without scratching my head too much this is the easy way!!

    Hope this helps :)

    EDIT - While writing my post Plainview also replied, so if you are a total geek like he is you can also use cmd line as he has shown hahaha 1337.
     
  12. vairish

    vairish Noisemaker

    Joined:
    Nov 18, 2011
    Messages:
    3
    Likes Received:
    3
    Quick and easy way to do it in Python:

    Code:
    for number in range(1000):
        if '3' in str(number) or '4' in str(number):
            print(number)
    
    The output is in the attached text file
     
    • Like Like x 3
    • Winner Winner x 3
    • List

    Attached Files:

  13. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,986
    Likes Received:
    3,859
    Location:
    Europe
    Way to go! Good oldie C :wink:
    Python vs pretty much anything else is almost cheating lol. Well done too :wink:

    Now... ahem... assembly version please? :rofl:
     
    Last edited: Mar 16, 2022
  14. lukehh

    lukehh Audiosexual

    Joined:
    Jun 22, 2012
    Messages:
    1,043
    Likes Received:
    592
    So, now it is solved.
    What the hell do you need that list for? :winker:
     
    Last edited by a moderator: Mar 16, 2022
  15. clone

    clone Audiosexual

    Joined:
    Feb 5, 2021
    Messages:
    6,135
    Likes Received:
    2,622
    the actual laziest way would have been in Excel. Conditional Format text containing 3 and 4, filter by color. copy visible.

    Would take under a minute :)
     
  16. fiction

    fiction Audiosexual

    Joined:
    Jun 21, 2011
    Messages:
    1,893
    Likes Received:
    688
    Very easy under MacOS or Linux:
    seq 1 1 1000 |grep "[34]"

    What it does: Count from 1 to 1000 by 1 and show all lines that contain at least "3" or "4" at any position.
     
    Last edited: Mar 16, 2022
    • Like Like x 3
    • Winner Winner x 1
    • List
  17. SineWave

    SineWave Audiosexual

    Joined:
    Sep 4, 2011
    Messages:
    4,315
    Likes Received:
    3,417
    Location:
    Where the sun doesn't shine.
    Yeah, pretty smart and easy to do. I would also add > list.txt after " so that you get a "list.txt" text file with those numbers in your home folder or wherever you started the console from. No need to copy them by hand. :wink:
     
Loading...
Loading...