SHENZHEN I/O

SHENZHEN I/O

DIVISIBILITY BY THREE
23 kommentarer
praneeth.kolichala 23. maj 2024 kl. 0:59 
Low power version: 11 / 420 / 7
Idea: this relies on a lot of random coincidences that work out. The idea is, if the input is 10a+b (ignore 100 for now), then compute 15a+b by using `dgt 1` and `mul 5` to get `5a` and adding the original input again. Use 15a+b as the address inside a ROM.

If we reduce this mod 14, we get a+b. Thus, the data of the ROM can tell is if a+b is a multiple of 3. Unfortunately, sums in the range 0-4 could correspond to 0-4 or 14-18.

The way we can fix this is as follows: if the sum mod 14 is 0-4, then we should add 14 if and only if the original input was >= 50. If the input is < 50, then the max digit sum is 4 + 9 = 13, so there will never be overflow. If it is >= 50, then the digit sum is at least 5, so a result of 0-4 indicates overflow mod 14. Since the threshold (50) is exactly the threshold that the logic gates use to distinguish 0 and 1, we can fix the 14-18 issue using only logic gates (in particular, zero lines of code and zero extra power!).
Verdammte Heinz 28. juli 2023 kl. 14:04 
Alternative high power version in 3 / 3651 / 7
Verdammte Heinz 28. juli 2023 kl. 13:57 
First attempt 7 / 737 / 14
s7eph4n 6. apr. 2023 kl. 6:28 
I had another go on this problem, optimizing for power. Building on Z903 idea of a 0-39 lookup table, but removed the loop and got it down to a 7/ 451 /10. Unfortunately the code didn't fit into a MC4000 anymore, so I had to use the more expensive MC6000.
FoxClass 29. mar. 2023 kl. 16:06 
?
Cocoa 30. aug. 2022 kl. 23:12 
Firstly I calculated the sum of every digit, using too many dgt and dst instructions, and got 7/634/11.

Then I realized a + b = 10a + b - 9a , finally solved in 5/498/9.
s7eph4n 19. okt. 2021 kl. 9:49 
Got a 3/3756/7 ... I guess I'm not a power guy ¯\_(ツ)_/¯
Dan 18. nov. 2019 kl. 9:21 
My best so far is 5 / 498 / 9.
Digital root calculation similar to @ebik's approach + lookup table

https://i.imgur.com/BdbYVmf.png
ebik 2. okt. 2018 kl. 11:26 
@Z903 you can reduce inputs to 0, 10, 20, ... 180 instead by multiplying last digit by 9 (= 10 - 1) and adding input then you get 5/480/9 https://imgur.com/MBGL6w3
Z903 18. juli 2018 kl. 22:16 
5/540/9 https://i.imgur.com/Yv0ZmMZ.png Reduced inputs down to 0-39 then modular arithmic on LUT comparing value to reduced value.
ipg 10. jan. 2018 kl. 4:53 
Did manage to reduce the power slightly at more cost and lines to 9/480/11 but just a cheap trick (well, expensive trick) on top of @AJMansfield's idea
ipg 9. jan. 2018 kl. 2:38 
@AJMansfield Brilliant wish I'd thought of your approach. Did implement it and match your results but can't take any credit. I am more proud of my alternative which just uses one component with only 683 cost, 5/683/14.
AJMansfield 2. dec. 2017 kl. 11:30 
Been doing some more reading, and there should be a way to do this with the Chinese Remainder Theorem and similar math as well, I think.
AJMansfield 11. nov. 2017 kl. 17:07 
@flarn2006 yes that's the whole reason I had to map it to 0-14, so I could use it as the address for a ROM without any collisions.
Sparkette 24. okt. 2017 kl. 18:09 
@AJMansfield: Nice, did you use the ROM chip for the lookup table? Cause if not you could probably save some cost by doing that.
AJMansfield 14. okt. 2017 kl. 16:37 
This is a very fun puzzle though, since there are several possible approaches to this problem beyond just a subtraction spin-loop. Probably the coolest one is computing the digital root or decomposing in base 3. I think there might also be another method related to discrete logarithms although I'm not sure.
AJMansfield 14. okt. 2017 kl. 15:54 
7 / 506 / 10. How I did it:

I used repeated conditional subtraction with an optimized gap sequence to get the input in the range 0-13, then used that as an address in a lookup table.
slow down cadet 9. okt. 2017 kl. 13:57 
You can get a very easy solution (lowest cost and lowest lines) by simply implementing basic division, but getting lowest power solution is quite difficult. It's a fun challenge! I can't get better than 1.1K power right now..
censorship = death :( 8. okt. 2017 kl. 20:18 
zero is divisable by anything because there will never be a remainder. it will always be zero unless it's 0/0 and then that's not allowed.
patrickfeltes 19. aug. 2017 kl. 16:30 
0 is divisible by 3. By the definition of divisibilty, a number x is divisible by y if x = y*z for some integer z. In the case of 0 and 3, 0 = 3 * 0. Thus, 0 is divisible by 3.
Gkatsos 20. juli 2017 kl. 11:19 
Really fun, but 0 is not devisible by 3 :/
xot 12. juli 2017 kl. 18:23 
Nice. This uses simple I/O but the information panel says XBus.
bremdob 9. juli 2017 kl. 5:55 
A fun problem that has a very easy solution if you break down division, but otherwise, could be quite complicated and inefficient