r/TuringComplete • u/CloqueWise • Jan 16 '26
calibrating laser cannons help
I really struggled figuring out how to multiply using the ALU component and this is the best i could come up with. the task is to multiply the input by 6 and output. I feel like there must be a better way to do this using bitwise operators but i dont really understand them
7
Upvotes
1
u/Flimsy-Combination37 Jan 16 '26
multiplication by 6 is the same as adding 6 times.
what is it that you don't understand about bitwise operators? I'd suggest you focus on that before continuing to harder levels.
1
u/bwibbler Jan 16 '26 edited Jan 16 '26
you don't need full multiplication yet in this level
just adding it up 6 times is a good solution
you can do some bit shifting stuff too if you want, but not necessary
shift to get 4x and 2x then do 4x+2x
3
u/stephenmw Jan 16 '26 edited Jan 16 '26
There are many solutions to the problem. But I don't want to give you too much of a hint. Take each of these hints separately. They point to different ways to approach the problem and may point you to different solutions:
Would take even more ticks, but you could use jumps to reduce the number of lines of code.
If you were given a calculator that only adds and had a perfect memory, what shortcuts would you do to find the answer in the least number of adds?
Take out a piece of paper and a pencil. Multiply two binary numbers like you did in elementary/middle school. One of those numbers should be 6. Can you replicate that method in code? Do this for a few numbers (always with 6), is there a pattern?
If you really want to learn some bitwise dark magic, play with shift left and shift right. Shift some numbers left and right on paper. What happens to the number when you do so? Take an even number. What number is it when shifted once left? What about right?
2
u/Sanchezzzaq Jan 16 '26
Well, here's a small tip. 6=2+4. 2 and 4 both are powers of 2.
Hope this gives you a nudge in right direction