Article View: comp.lang.c
Article #1203Re: BizFuss (was Re: Taming The Switch-Statement)
From: bartc
Date: Sat, 31 Oct 2026 12:21
Date: Sat, 31 Oct 2026 12:21
79 lines
4189 bytes
4189 bytes
On 31/10/2026 10:39, Rosario19 wrote:
> On Fri, 30 Oct 2026 11:47:59 +0000, bartc wrote:
>
>> That output becomes:
>>
>> 167 is not divisible by any of (2,3,5,7)
>> 168 is divisible by 2
>> 168 is divisible by 3
>> 168 is divisible by 7
>> 169 is not divisible by any of (2,3,5,7)
>>
>> Sizes (with hard tabs and no comments):
>>
>> Your Python: 340 characters
>> Mine: 222 (as above; scripting)
>> C: 393 (not shown; not elegant)
>> Mine: 314 (not shown; systems lang)
>
> The APL one is 80 characters
That's not quite right:
* You're using 2,3,7 not 2,3,5,7, which would add 2 characters
* You're doing 20 iterations not 200 (adds 1 more character!)
* You missed out 'any of ' (adds 6 characters, however your output seems
to have unnecessary space so perhaps that can be trimmed)
> Is more long the string to write that the code to execute...
The point about the version I posted is that it does the correct task
but much cleanly than Python, which had lots of unnecessary
complications. So anyone could follow it.
But I modified my version to be compact, and it looks like this:
f:=(2,3,5,7)
for n to 20 do
d::=()
for x in f when n rem x=0 do d&:=x od
?n,(d|"is divisible by"|"is not divisible by"),(d|d|f)
od
This is 134 characters (131 without those indents). It suffers from
named symbols such as 'rem' needing 5 characters rather than 1.
Note that your APL (with '5' added), because it uses Unicode, takes up
105 bytes; my version is still 131/134 bytes while still just about
being understandable.
That's pretty good even if a big chunk of the APL (38 characters/bytes)
is those strings.
It would be interesting if somebody were to post a version in code-golf C.
(The output from my version here is this, but it can vary provided the
same info is displayed:)
1 is not divisible by (2,3,5,7)
2 is divisible by (2)
3 is divisible by (3)
4 is divisible by (2)
5 is divisible by (5)
6 is divisible by (2,3)
7 is divisible by (7)
8 is divisible by (2)
9 is divisible by (3)
10 is divisible by (2,5)
11 is not divisible by (2,3,5,7)
12 is divisible by (2,3)
13 is not divisible by (2,3,5,7)
14 is divisible by (2,7)
15 is divisible by (3,5)
16 is divisible by (2)
17 is not divisible by (2,3,5,7)
18 is divisible by (2,3)
19 is not divisible by (2,3,5,7)
20 is divisible by (2,5)
Technical Details
Message-ID:
<11c4mfp$13b6a$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11ba02r$3pl5h$1@dont-email.me> <11bnfpm$i84l$1@dont-email.me> <11bng23$iblc$1@dont-email.me> <11bngj1$ifj5$1@dont-email.me> <11bnnbg$l7i1$1@dont-email.me> <11bntk0$nsbo$1@dont-email.me> <11bnvbq$olbj$1@dont-email.me> <11bo02r$otr5$1@dont-email.me> <11bo0ul$pbso$1@dont-email.me> <11bo1bc$phlr$1@dont-email.me> <tft5elp1q2ns7rhfp3rod862ks5ip3p0ms@4ax.com> <11c1kee$2lqi$2@dont-email.me> <11c205f$73k2$1@dont-email.me> <t8hbelloceeupncsjjl41ah7jd4vv2gms3@4ax.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: bartc <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: BizFuss (was Re: Taming The Switch-Statement) Date: Sat, 31 Oct 2026 12:21:13 +0000 Organization: A noiseless patient Spider Lines: 79 Message-ID: <11c4mfp$13b6a$1@dont-email.me> References: <119qf6l$2rmg3$1@dont-email.me> <11ba02r$3pl5h$1@dont-email.me> <11bnfpm$i84l$1@dont-email.me> <11bng23$iblc$1@dont-email.me> <11bngj1$ifj5$1@dont-email.me> <11bnnbg$l7i1$1@dont-email.me> <11bntk0$nsbo$1@dont-email.me> <11bnvbq$olbj$1@dont-email.me> <11bo02r$otr5$1@dont-email.me> <11bo0ul$pbso$1@dont-email.me> <11bo1bc$phlr$1@dont-email.me> <tft5elp1q2ns7rhfp3rod862ks5ip3p0ms@4ax.com> <11c1kee$2lqi$2@dont-email.me> <11c205f$73k2$1@dont-email.me> <t8hbelloceeupncsjjl41ah7jd4vv2gms3@4ax.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 31 Oct 2026 12:21:13 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1158346"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xhrbPFvXYzjDxhHKkiipv"; posting-host="e68c21d34812d47967f764b98d287209" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:e/ssVfLcevtpzYmaq4oNMvMzqK8= sha256:A0JZsZsqoN/VgM48XMOH3f5sT8SZZSgb38WoLamzoqY= sha1:bTP5HJI5Rmyhg+sw98Xz94rOYCo= sha256:L5vQtike2orwU0M+azAiO92Sst4/03qYbD2CBBEABNA= In-Reply-To: <t8hbelloceeupncsjjl41ah7jd4vv2gms3@4ax.com> Content-Language: en-GB