'Bit Test' challenge... the strange coding.. please help me.
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.
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.
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?
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?
it's certainly not an age counter, also the example of
doesn't do the job as if your 18 it prints nothing, anyway the python equivalent of the C function
is funnily enoughtest it and you'll see what it does
Code: Select all
if age < 18
print "Sorry, too young"
if age > 18
print "You're old enough. Enjoy!"
Code: Select all
bool testIt(int x) {
return (x & (x − 1)) == 0;
}
Code: Select all
def testIt(x): return (x & (x − 1)) == 0
0 if 0CodeX wrote:it's certainly not an age counter, also the example ofdoesn't do the job as if your 18 it prints nothing, anyway the python equivalent of the C functionCode: Select all
if age < 18 print "Sorry, too young" if age > 18 print "You're old enough. Enjoy!"
is funnily enoughCode: Select all
bool testIt(int x) { return (x & (x − 1)) == 0; }
test it and you'll see what it doesCode: Select all
def testIt(x): return (x & (x − 1)) == 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 >.<
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.
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.
Last edited by Masti6 on Mon May 17, 2010 5:39 pm, edited 1 time in total.
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.
-
- Posts: 4
- Joined: Tue Feb 09, 2010 10:42 pm
don't find correct words
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!
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!
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
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