Page 1 of 1

Incrementing combinations - brain teaser

PostPosted: Thu Mar 21, 2013 6:28 am
by yodish
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!

Re: Incrementing combinations - brain teaser

PostPosted: Thu Mar 21, 2013 2:38 pm
by prino
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!

Re: Incrementing combinations - brain teaser

PostPosted: Thu Mar 21, 2013 5:48 pm
by Robert Sample
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.

Re: Incrementing combinations - brain teaser

PostPosted: Thu Mar 21, 2013 5:56 pm
by steve-myers
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.

Re: Incrementing combinations - brain teaser

PostPosted: Thu Mar 21, 2013 5:56 pm
by yodish
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.

Re: Incrementing combinations - brain teaser

PostPosted: Thu Mar 21, 2013 6:01 pm
by enrico-sorichetti
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:

Re: Incrementing combinations - brain teaser

PostPosted: Thu Mar 21, 2013 7:43 pm
by Ed Goodman
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.