Incrementing combinations - brain teaser



IBM's Command List programming language & Restructured Extended Executor

Incrementing combinations - brain teaser

Postby yodish » Thu Mar 21, 2013 6:28 am

Hopefully someone can give me an efficient way to try every possible version of a dataset's low level qualifier: ex) 079083 or 079 08 3

That is: 079 (the julian date) - 08 (the hour) - 3 (the minutes, the second digit is truncated)

I need to loop through every combination as efficiently as possible.
That would be 366 possible julian dates (accounting for a leap year), 23 possible hours, and 5 possible minutes.


Thanks for any help!
yodish
 
Posts: 22
Joined: Thu Oct 25, 2012 3:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: Incrementing combinations - brain teaser

 

Re: Incrementing combinations - brain teaser

Postby prino » Thu Mar 21, 2013 2:38 pm

Are you a troll?

What the flucking hell is wrong with three nested loops?

Moderators, please close this thread, before more time is wasted on trivialities!
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 536
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 21 times

Re: Incrementing combinations - brain teaser

Postby Robert Sample » Thu Mar 21, 2013 5:48 pm

1. Unless you are using Unix System Services, 079083 cannot be a data set low-level qualifier. Every level of a data set name must start with a letter in z/OS.
2. Which 10-minute segment are you ignoring? The first digit of the minutes can be 0, 1, 2, 3, 4, or 5 -- which is 6 possible values yet you only want 5 you tell us.
3. Since a z/OS machine runs millions of instructions per second (depending upon the language used, it could be hundreds of millions), and you do not have a solution yet, WHY ARE YOU CONCERNED ABOUT EFFICIENCY? The only time you should EVER worry about efficiency on a mainframe is if (1) the code is in production, and (2) there is documented evidence that the code cannot execute within the appropriate time available.
4. As has been pointed out, simple nested loops will solve your problem effectively.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Incrementing combinations - brain teaser

Postby steve-myers » Thu Mar 21, 2013 5:56 pm

The other problem is this.

If your are using the generated suffix to test if a data set matches the suffix, it makes essentially no difference how "efficient" your process to create the suffix is: the test to determine if there is a matching data set will take thousands of times longer. A better solution might be to get a list of all data sets, which can be done quite efficiently, then test if the data sets in the list match a possible valid suffix.
steve-myers
Global moderator
 
Posts: 1885
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: Incrementing combinations - brain teaser

Postby yodish » Thu Mar 21, 2013 5:56 pm

Thanks,

No, I don't think i'm a troll. Sorry to anger you prino, but i'm guessing it's fair to assume you have a lot to be angry about.

I do appreciate the response Robert Sample, i've basically worked out the program; it's a little more complex than my post makes it seem; but I wanted to start with the basic structure.
yodish
 
Posts: 22
Joined: Thu Oct 25, 2012 3:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: Incrementing combinations - brain teaser

Postby enrico-sorichetti » Thu Mar 21, 2013 6:01 pm

No, I don't think i'm a troll. Sorry to anger you prino, but i'm guessing it's fair to assume you have a lot to be angry about.

only about stupid questions like this one, and unfortunately it means getting angry quite a lot :geek:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Incrementing combinations - brain teaser

Postby Ed Goodman » Thu Mar 21, 2013 7:43 pm

Any reason why you don't want to just grab the list from the catalog? An IDCAMS listcat command can generate the entire list of cataloged datasets in much less time.

Even if they aren't cataloged, you can use the same function with a volume number to get the list on a particular pack.

Even if they are on tape, you can get a batch job to list the contents of the tape management system.

I went to the hardware store last Saturday to get the parts to install a faucet. I had everything laid out like what I needed and the plumbing section girl took one look and said "You're making this WAY harder than you need to." Then she showed me the single piece that was manufactured to do the exact job I needed done. It was a good reminder that Ed Goodman from Columbus Ohio was not the first person in the entire world of plumbing to have this requirement.
Ed Goodman
 
Posts: 342
Joined: Thu Feb 24, 2011 12:05 am
Has thanked: 3 times
Been thanked: 17 times


Return to CLIST & REXX