programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Devaka Cooray
• Ron McLeod
• Paul Clapham
• Liutauras Vilda
Sheriffs:
• paul wheaton
• Jeanne Boyarsky
• Tim Cooke
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Tim Moores
• Mikalai Zaikin
• Carey Brown
Bartenders:

# Chapter 4 Sierra/Bates Puzzel-y Question

Ranch Hand
Posts: 434
• Number of slices to send:
Optional 'thank-you' note:
Hello,

I'm on the Q&A part of Sierra/Bates, and for the life of me, I cannot figure out the best approach to solve a fill-in-the-blank programming:

Place the fragments into the code to produce the output 33. Note, you must use each fragment exactly once.

FRAGMENTS:
y y y y
x x
-=
*=
*=
*=
*=

Of course, they give the answer, which is

Ranch Hand
Posts: 446
1
• Number of slices to send:
Optional 'thank-you' note:
well this is a little bit difficult to guess but I think this is the best way to do this
we are given 4 compound operators and we have to use them exactly once
now given that we want output as 33 and x =7 and y = 2
we have to give just trial and error to this
33 is big as compared to 2 and 7 and hence we will use *= operator first
and also we have to use only 2 x we will use them all in this line only

this gives x = 49
now we have to reduce the answer by 16 to get 33
what do we have now?
4 y's , 2 *= and one -=
we can achieve 16 by

now y is 4

now it is 16
as we have x = 49 and y = 16
we can write

this gives 49-16 = 33

Ranch Hand
Posts: 525
• Number of slices to send:
Optional 'thank-you' note:
There is no straight forward technique for solving this kind of problem. I consider
myself lucky to have spotted how the elements might fit together in a reasonable
amount of time. But it could have taken for ever. What helped was to "fiddle" with
the given information on paper, play what-if mind games and draw pictures. There
were constraints in both the fill-in template and the cut-and-paste elements. I know
that this may not be very helpful, but it's all I have to offer.

Jim ... ...

Ranch Hand
Posts: 316
• Number of slices to send:
Optional 'thank-you' note:

May be that would help...........

I really skip such problems.

Take care
Cheers!!!

Sandra Bachan
Ranch Hand
Posts: 434
• Number of slices to send:
Optional 'thank-you' note:
Aren't all the questions in the SCJP exam supposed to be answered? Or are a number of questions on the exam that are optional to answer?

I would think this type of question needs to be left till the very end (if there is time, of course!)

Sandra Bachan
Ranch Hand
Posts: 434
• Number of slices to send:
Optional 'thank-you' note:
I just googled "Constraint Satisfaction Problems" and I'm reading up on it. Quite interesting subject....

author
Posts: 9050
21
• Number of slices to send:
Optional 'thank-you' note:
Hi Guys,

That one was a little TOO puzzle-y. We were trying to sort of emulate a drag and drop question, but none of the real D&D questions are that puzzle-y. So I'd say don't spend too much time on that particular question.

hth,

Bert

 Story like this gets better after being told a few times. Or maybe it's just a tiny ad: a bit of art, as a gift, that will fit in a stocking https://gardener-gift.com