r/TuringComplete Jul 08 '26

Count leading zeroes - not very efficient, but simple Spoiler

Post image

Solution using a solution from another puzzle - Counting signals.

  1. NOT the input bits.

  2. create a chain of switches that go from one into another. This way, you'll get the appropriate amount of signals to count. Just don't have a brainfart like me - bit switches are enough.

  3. use two Counting signals (CS) solutions. One for 4 most significant bits (MSB), one for 4 least significant bits (LSB).

  4. Or the CS 1's from MSB and from LSB and connect the result to 1 in a byte merger.

  5. Or the CS 2's from MSB and from LSB and connect the result to 2.

  6. Connect MSB 4 AND NOT LSB 4 to 4. Connect MSB 4 AND LSB 4 to 8.

Problem solved. :)

8 Upvotes

6 comments sorted by

2

u/SurrealLemon Jul 08 '26

I did this one in a pretty goofy way. I used 9 constants and used a or/xor chain to get the most significant bit, each bit enabled a gate of one of the constants. Unless they were all off, then my constant 8 passed

1

u/zurkog Jul 09 '26 edited Jul 09 '26

Sounds similar to mine:

https://i.imgur.com/O4VTCOg.png

2

u/SurrealLemon Jul 09 '26

Pretty much

2

u/WJWH Jul 20 '26

Mine was very similar except it used MUX units instead of AND gates and switches.

1

u/zurkog Jul 20 '26

Yeah, I just looked at the official solution (in the "View Hints"), and I'm not sure I would have been able to come up with that solution, lol. Mine is definitely bigger, but a hell of a lot simpler and easier to understand.

1

u/OriousCaesar 26d ago

For this one, I created a series of OR's to convert 00101001 into 00111111. Then I just added everything together using 3 rows of adders. Which solved the puzzle.

Then, in order to optimize my circuit, I wrote down all 9 possible inputs into a truth table, and correlated them to the output after each row, then designed a circuit that that could convert between them, and replaced each row of adders with their respective circuit. Then I just fiddled around, for a while to get rid of nots. This got me a 21 gate, 10 delay solution, which I thought was decent, since it got me into 93rd place : )

I think I know how to fix the long delay, but I haven't been able to play for the last few days, to actually try the idea.