Page 3 of 4

Posted: Mon May 17, 2010 9:53 am
by Masti6
Along with some other Challenges, I've been stuck with this one for a couple of days now, too.
I don't know the least bit of C or C++ and I ain't interested in studying them after getting more into PHP and starting to study Python (Goin' good btw xD).
So anyways, I think this test if something is true or not, because when I give X a value, it returns either True or False, and the value of X in addition because of an additional "print x" value.
But as for the answer, I have no idea how could "something of something" be formed from "True or False", if that is the case.
If it's not even close to the answer, I've no idea.
Any C -Xpert out there, please help a little bit.

Posted: Mon May 17, 2010 11:10 am
by CodeX
For this challenge you should test what the logic is true for (i.e. print them), that make the answer obvious.

Posted: Mon May 17, 2010 11:25 am
by Masti6
So I need to to test what the logic is true for, okay.
But I printed the value
"True" when != 0
"False" when 0
But I still don't get the logic for testing is X true or false.
Maybe for an age counter of some game website (i.e. battlefieldbadcompany2.com?)
age = input
if age < 18
print "Sorry, too young"
if age > 18
print "You're old enough. Enjoy!"
.... Or ?
And if even it did have the exact same purpose, I wouldn't guess the answer is "age of user".
But something of that format.
Any more hints or even the first word (as pm?) because I don't see even the slightest bit of light shining at the end of this alleyway.
At least I think so.
Could someone please remove my sunglasses?

Posted: Mon May 17, 2010 11:50 am
by CodeX
it's certainly not an age counter, also the example of

Code: Select all

if age < 18
print "Sorry, too young"
if age > 18
print "You're old enough. Enjoy!"
doesn't do the job as if your 18 it prints nothing, anyway the python equivalent of the C function

Code: Select all

bool testIt(int x) {
  return (x & (x − 1)) == 0;
}
is funnily enough

Code: Select all

def testIt(x): return (x & (x − 1)) == 0
test it and you'll see what it does

Posted: Mon May 17, 2010 3:36 pm
by Masti6
CodeX wrote:it's certainly not an age counter, also the example of

Code: Select all

if age < 18
print "Sorry, too young"
if age > 18
print "You're old enough. Enjoy!"
doesn't do the job as if your 18 it prints nothing, anyway the python equivalent of the C function

Code: Select all

bool testIt(int x) {
  return (x & (x − 1)) == 0;
}
is funnily enough

Code: Select all

def testIt(x): return (x & (x − 1)) == 0
test it and you'll see what it does
0 if 0
1 if != 0
It still isn't clear what it actually does - there are countless options.
If value = 0 return false
If value =! 0 return true
What use could such a program possibly have :?
*Sigh* Might as well give up for now and continue trying when I get all the other ones done >.<

Posted: Mon May 17, 2010 3:49 pm
by CodeX
Whatever your doing, your doing it wrong if you've got 0->false + 43 posts in two days? take it easy

Posted: Mon May 17, 2010 4:21 pm
by laz0r
Try going through from 1 to 100 and printing out the output of that program for each number, in format like:
1 - TRUE
2 - FALSE
3 - TRUE
4 - TRUE
(random True/False from a pseudorandom number generator)

You should see a pattern emerging!

Posted: Mon May 17, 2010 5:19 pm
by Masti6
Thanks lazor, that was the kind of answer I was expecting. Something that made sense xD
I've got a certain pattern of True and False from numbers all the way to 100.
I've listed all True numbers, and now I've just got to figure what the list of numbers means... Right?
If so, thanks for help!

As for CodeX's message; Isn't it better to be active on forums? Any other forums I've visited give you stars or points for posting and replying. And this one gives me the profit of hearing the other user's opinions.

Posted: Mon May 17, 2010 5:33 pm
by CodeX
Activity is good but asking 1000001 questions in short succession isn't as good as a bit of perseverance to get it sorted yourself, or last resort ask on a forum. Putting your nose to the grindstone is in my opinion a pretty good way to learn, it's the way I did which is probably why I'm not a fan of the non-stop question thing - I've got friends who do the same and it hasn't helped them, but maybe I'm being too harsh. Another thing is this forum doesn't have things allong the lines of +ve, -ve, rep and all sorts of other things at all so people don't post on here to chase tags.

don't find correct words

Posted: Sun Jul 04, 2010 8:01 pm
by SecurityCrawler
hi there,

i'm sure i know the answer but cannot find the correct words (i'm no native english speaker).

here is my soluten (i hope i do not spoil too much with that... :? )

this function just masks out all bit but one special bit and checks if this special bit is set. if it is set it returns true.

some of my tries so far:
only the .... bit is set
checks if the ... bit is set
just the ... bit is set

if i'm on the correct way, could someone please PM me the correct words?

Thanks!

Posted: Sun Jul 04, 2010 9:49 pm
by CodeX
If I recall the challenge asks for the answer in the form something of something, i.e. the answer fits in the sentence
ghandi wrote:The provided function checks that the parameter x is determiner something of something.
hopefully that will help you to get the correct answer.
determiner := a | the

Posted: Thu Feb 03, 2011 11:41 pm
by DamaTeq
i struggled at this challenge quite a while because english is not my native language. But i can give you a little hint: think of a mathematical funtion which is implemented in most programming languages.

Posted: Sun Jul 17, 2011 11:27 pm
by Nquit
Hello there,
i have been looking at this challange for houres.. not days yet.. i quite fast got the program running showing me the pattern.. now im at the part where i have to give the answer.. but i really don't know how to write the answer in the form of "something of something" because my native language is differnt from english.. if anyone can help me out a little.. with a hint in a PM.. please do then :)

Posted: Mon Jul 18, 2011 6:32 am
by bodjo
the word you are looking for was already given in a previous challenge not as an answer so i suggest you read the challenges attentively and you will find it

Posted: Wed Jun 20, 2012 6:35 pm
by zAsus
My native language is also not English...

but I think it's a great idea to execute the code
and then compare the numbers wich returns true,
they have something in common
i'ts a math term...
...u'll get it :wink:

sry for my bad english