• Post Reply Bookmark Topic Watch Topic
  • New Topic
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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Chapter 4 Sierra/Bates Puzzel-y Question

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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






Please, someone help!
 
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read "Constraint Satisfaction Problems "

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

I really skip such problems.

Take care
Cheers!!!
 
Sandra Bachan
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just googled "Constraint Satisfaction Problems" and I'm reading up on it. Quite interesting subject....
 
author
Posts: 9031
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic