hacker.org Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
'Bit Test' challenge... the strange coding.. please help me.
Goto page Previous  1, 2, 3, 4  Next
 
Reply to topic    hacker.org Forum Index » Challenges View previous topic
View next topic
'Bit Test' challenge... the strange coding.. please help me.
Author Message
Masti6



Joined: 15 May 2010
Posts: 55
Location: Finland, Nurmes

Post Reply with quote
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.
Mon May 17, 2010 9:53 am View user's profile Send private message MSN Messenger
CodeX



Joined: 17 Oct 2008
Posts: 350

Post Reply with quote
For this challenge you should test what the logic is true for (i.e. print them), that make the answer obvious.
Mon May 17, 2010 11:10 am View user's profile Send private message
Masti6



Joined: 15 May 2010
Posts: 55
Location: Finland, Nurmes

Post Reply with quote
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?
Mon May 17, 2010 11:25 am View user's profile Send private message MSN Messenger
CodeX



Joined: 17 Oct 2008
Posts: 350

Post Reply with quote
it's certainly not an age counter, also the example of
Code:
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:
bool testIt(int x) {
  return (x & (x − 1)) == 0;
}
is funnily enough
Code:
def testIt(x): return (x & (x − 1)) == 0
test it and you'll see what it does
Mon May 17, 2010 11:50 am View user's profile Send private message
Masti6



Joined: 15 May 2010
Posts: 55
Location: Finland, Nurmes

Post Reply with quote
CodeX wrote:
it's certainly not an age counter, also the example of
Code:
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:
bool testIt(int x) {
  return (x & (x − 1)) == 0;
}
is funnily enough
Code:
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 >.<
Mon May 17, 2010 3:36 pm View user's profile Send private message MSN Messenger
CodeX



Joined: 17 Oct 2008
Posts: 350

Post Reply with quote
Whatever your doing, your doing it wrong if you've got 0->false + 43 posts in two days? take it easy
Mon May 17, 2010 3:49 pm View user's profile Send private message
laz0r



Joined: 04 Feb 2010
Posts: 290
Location: Within the depths of Unix

Post Reply with quote
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!

_________________
There is no spoon.
Mon May 17, 2010 4:21 pm View user's profile Send private message
Masti6



Joined: 15 May 2010
Posts: 55
Location: Finland, Nurmes

Post Reply with quote
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.


Last edited by Masti6 on Mon May 17, 2010 5:39 pm; edited 1 time in total
Mon May 17, 2010 5:19 pm View user's profile Send private message MSN Messenger
CodeX



Joined: 17 Oct 2008
Posts: 350

Post Reply with quote
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.
Mon May 17, 2010 5:33 pm View user's profile Send private message
SecurityCrawler



Joined: 09 Feb 2010
Posts: 4

Post don't find correct words Reply with quote
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... Confused )

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!
Sun Jul 04, 2010 8:01 pm View user's profile Send private message
CodeX



Joined: 17 Oct 2008
Posts: 350

Post Reply with quote
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
Sun Jul 04, 2010 9:49 pm View user's profile Send private message
DamaTeq



Joined: 01 Feb 2011
Posts: 8

Post Reply with quote
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.
Thu Feb 03, 2011 11:41 pm View user's profile Send private message
Nquit



Joined: 15 Jul 2011
Posts: 5

Post Reply with quote
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 Smile
Sun Jul 17, 2011 11:27 pm View user's profile Send private message
bodjo



Joined: 26 Feb 2011
Posts: 37
Location: tunisia

Post Reply with quote
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
Mon Jul 18, 2011 6:32 am View user's profile Send private message
zAsus



Joined: 12 Jun 2012
Posts: 1

Post Reply with quote
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
Wed Jun 20, 2012 6:35 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    hacker.org Forum Index » Challenges All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.