SHENZHEN I/O

SHENZHEN I/O

26 个评价
DIVISIBILITY BY THREE
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
更新日期
5.131 KB
2017 年 4 月 2 日 上午 6:56
2017 年 5 月 28 日 上午 9:40
3 项改动说明 ( 查看 )

订阅以下载
DIVISIBILITY BY THREE

描述
23 条留言
praneeth.kolichala 2024 年 5 月 23 日 上午 12: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 2023 年 7 月 28 日 下午 2:04 
Alternative high power version in 3 / 3651 / 7
Verdammte Heinz 2023 年 7 月 28 日 下午 1:57 
First attempt 7 / 737 / 14
s7eph4n 2023 年 4 月 6 日 上午 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 2023 年 3 月 29 日 下午 4:06 
?
Cocoa 2022 年 8 月 30 日 下午 11: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 2021 年 10 月 19 日 上午 9:49 
Got a 3/3756/7 ... I guess I'm not a power guy ¯\_(ツ)_/¯
Dan 2019 年 11 月 18 日 上午 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 2018 年 10 月 2 日 上午 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 2018 年 7 月 18 日 下午 10: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.