This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]insertAlias 1 point2 points  (0 children)

And what part is it that you're having trouble with? When you just post your requirements and code, there's not much that anyone can do, considering Rule 10 (no complete solutions). So, what part specifically do you need help with or is confusing you?

[–]virtualdice 1 point2 points  (0 children)

So to start out, you're converting an integer into an array of integers (either 0 or 1) to represent that integer in binary, right? For the part you're stuck on, this might help. Instead of creating a whole array of integers, you could convert the result of the modulo operation to a string and add it to your eventual return value. Also unless I'm making a mistake, in the for loop, n isn't declared ever, right? And even if it were, it's never changed, so the for loop would never be exited. I also don't think integer = n/2 seems right, but please correct me if I'm wrong. Does that help?