Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMarin Leontenko
4,400 PointsHash function - bit rolling
Could someone please solve this and explain: http://185.3.182.78/riddle/index.html
Thanks!
3 Answers
Marin Leontenko
4,400 PointsYou are right, it is a test for job application. I'm sorry if there's a policy against that on these forums. You can contact me privately for details: marin.leontenko@gmail.com
Jason Anello
Courses Plus Student 94,610 PointsIt's not a good idea to get solutions for problems like this because it puts you at a disadvantage. The company is expecting you to be able to solve this on your own. You may be in another situation where you have to solve another problem for them and not in a position to ask for help.
I would suggest that you try to work out the example in the question with pencil and paper to make sure you understand the process. Also, look up javascript's bitwise operators to make sure you understand what each one does.
Good luck!
Marin Leontenko
4,400 PointsI understand your concerns. Could you al least tell me what level of proficiency in js do i need to solve this (besides bitwise operators). I have some programming experience (Python, Java), but i'm new to javascript.
Jason Anello
Courses Plus Student 94,610 PointsI don't think you need to know much beyond the bitwise operators.
The question is telling you the steps and operations that you have to take to do a bit roll. That's not something you need to figure out. What I think this question is mostly about is translating those steps into working javascript code.
The example code shown has some errors in it because the programmer didn't correctly translate the steps into code.
If you're completely new to manipulating individual bits then I would practice the different bit operations on some small binary numbers using pencil and paper.
For example, try to figure out why
1011 & 1000 == 1000
This is just a random example and doesn't have anything to do with the problem.
Here's some js code for that example:
var a = 0b1011;
var b = 0b1000;
var result = a & b;
result.toString(2); // "1000" in binary
But I would suggest just working out some different examples on paper and not worrying about the code at first.
Here's a good MDN resource on the different bitwise operators: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators
You only need a few of these operators to solve the problem and these are mentioned in the question itself. However, if they are giving you these types of questions then you'll probably want to learn as much as you can on that page.
Marin Leontenko
4,400 PointsThanks for help :)
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Marin,
Can you give some background on what this is for?
I solved it but it seems like it's part of a test that has to do with applying for a job.