Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Chapter 4 Sierra/Bates Puzzel-y Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Chapter 4 Sierra/Bates Puzzel-y Question" Watch "Chapter 4 Sierra/Bates Puzzel-y Question" New topic

Chapter 4 Sierra/Bates Puzzel-y Question

Sandra Bachan
Ranch Hand

Joined: Feb 18, 2010
Posts: 434

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.

y y y y
x x

Of course, they give the answer, which is

Please, someone help!

Marriage Made in Heaven
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446

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

SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
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 ... ...

Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Read "Constraint Satisfaction Problems "

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

I really skip such problems.

Take care

SCJP 6.0 96%

(Connecting the Dots ....)
Sandra Bachan
Ranch Hand

Joined: Feb 18, 2010
Posts: 434
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

Joined: Feb 18, 2010
Posts: 434
I just googled "Constraint Satisfaction Problems" and I'm reading up on it. Quite interesting subject....
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
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.



Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Chapter 4 Sierra/Bates Puzzel-y Question
It's not a secret anymore!