IBM MTM 2019: Part Three – Challenge #02


This time we’re playing a slots game, no, not in a casino. That’s gambling! Gambling is bad! We’re programming our own version, well… fixing someone else’s version of slots.

I would like to remind you that I’m not allowed to give the correct solution to part 3 its challenges. I will however guide you a bit through the process and show you what my results are.

REXX Language Syntax

IBM Master the Mainframe Part Three – Challenge #02
So we need to execute a few commands before we can start this challenge. In our Z#####.REXX we need to make a new member using the primary command s slots. When editing that new member we need to copy ‘zos.mtm2019.public.rexx(slots)’ into it.
Let’s save and execute by going back and executing the line command ex next to the member name.
I got the following, there’s obviously something wrong in the code. I can already spot the mistake in the first screenshot, look for fruit.f.

Modify SLOTS REXX code enabling FRUIT.? variable to contain a fruit value

So let’s go back and read what IBM has to say. The scripts starts a do loop at line 20. At line 24, 26 and 28 the VIEW.# variable get sets to a random fruit name value. BUT there seems to be a problem at line 28. This line requires a modification. Once we fix it, we need to execute it again.

Pick the odd one out, fix it and execute. Let me do that.

The third fruit now shows correctly! Nice!

Modify SLOTS REXX code to acknowledge a win

Hmm… there still seems to be an issue when you win a game of slots. The error is caused by line 73, we need to fix that, our intern misspelled something. Damn you Brian! Let’s investigate the issue.

So, this again is a game of spot the odd one out. But there’s only one to compare the other one to. High chance of failure and high chance of success. Love it! Fix line 73 please 😉 Let me fix it and execute it again.

Two hours later I finally won a game. But I don’t really know the correct 5 digit safe box key. Time to review the code! Type end to exit the code.

Review SLOTS REXX code to determine the 5 digit safe deposit box key

Time to get our minds dirty. We must read the code in order to win this thing!

Ok we need to take a look at line 63 to 78. The key is 2001. Then we have an array n with 6 numbers in it. After that there’s a loop that iterates of the array n. When the current iteration is either 1 or 2 then it skips the iterations? Assuming iterate is the same as continue in JavaScript or PHP. Then, otherwise, it just add the current index of the array to key.

I know what to do. Time to get the calculator. I got the number, do you? If you’re desperate, take a look at line 81 😉

Do like the screenshot above and let’s see if we get the right output.

View p3.output member #02 for winnings deposited

I have censored the number, but my winnings are deposited!

Did you win?

Are you also a millionaire? I am! Time to buy that mainframe I always wanted, IBM, expect a call soon!

22 thoughts on “IBM MTM 2019: Part Three – Challenge #02

  1. Hi! I got the answer, (and the desired output), but I do not understand the hint on line 81. How does (what is says) relate to the number?

      1. Thanks a lot for the screenshot Scotty, as I was finally able to put two and two together and complete this challenge. Much appreciated!

        1. Basically change line 81.
          Then run the program, until you get all three matching.
          Once you get all three matching, you get the number.
          You will then have put the number and click enter.
          If you did all the previous direction correctly, then you’ll get output.

  2. On line ??: I changed redacted by Kevin
    On line ??: I changed redacted by Kevin

    Is there any other lines I need to edit?
    Do I need to type a certain character to run the program correctly?
    (after typing ex on SLOTS)

    1. Hi Mig

      Yes, you need to win the slots game and then enter the correct number. To execute REXX you indeed need to execute using the ‘ex’ line command.

      Kind regards,
      – Kevin

  3. Hi Kevin,
    I feel we are cheating a little, because we know this from last year challenge 😉
    Maybe next year they will change this challenge step!

    1. Hi Georges

      I honestly was afraid it was the same challenge, but they had a different approach, good! This challenge was also much soon than last year 🙂

      Kind regards

Leave a Reply to kevindurant Cancel reply

Your email address will not be published. Name, email and website not required.