Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"Any excuse will serve a tyrant." -- Aesop


devel / comp.lang.prolog / Autum Challenge: Short Deadfish Numbers

SubjectAuthor
* Autum Challenge: Short Deadfish NumbersMild Shock
`- Autum Challenge: Short Deadfish NumbersMild Shock

1
Autum Challenge: Short Deadfish Numbers

<26896d7c-9e07-4fcc-8bcf-927fa7775031n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=2833&group=comp.lang.prolog#2833

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:7f09:0:b0:40f:df11:8c07 with SMTP id f9-20020ac87f09000000b0040fdf118c07mr47511qtk.1.1696447341970;
Wed, 04 Oct 2023 12:22:21 -0700 (PDT)
X-Received: by 2002:a4a:4f42:0:b0:57b:3840:4c85 with SMTP id
c63-20020a4a4f42000000b0057b38404c85mr1069522oob.1.1696447341674; Wed, 04 Oct
2023 12:22:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Wed, 4 Oct 2023 12:22:21 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <26896d7c-9e07-4fcc-8bcf-927fa7775031n@googlegroups.com>
Subject: Autum Challenge: Short Deadfish Numbers
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Wed, 04 Oct 2023 19:22:21 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1728
 by: Mild Shock - Wed, 4 Oct 2023 19:22 UTC

Solve this problem:

Deadfish is one of the best known non Turing-complete programming languages. It has only one accumulator (which starts at 0) to store
data, and only four commands:

i - Increment the accumulator
s - Square the accumulator
d - Decrement the accumulator
o - Output the accumulator

Create a program that will input a number and output Deadfish
code to display the number. It must work for any integer from 0 to 255.

https://codegolf.stackexchange.com/questions/40124/short-deadfish-numbers/

Twist, don't write the solution in Prolog. But in your favorite Prolog
with your favorite state extension. For example Mecury states via
(!)/1 or some other Prolog language extension that helps

dealing with state.

Re: Autum Challenge: Short Deadfish Numbers

<8bc6ee04-7329-4aaf-b7e6-96435d24a913n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=2837&group=comp.lang.prolog#2837

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:ac8:7d10:0:b0:406:94da:5abd with SMTP id g16-20020ac87d10000000b0040694da5abdmr233732qtb.12.1696891941572;
Mon, 09 Oct 2023 15:52:21 -0700 (PDT)
X-Received: by 2002:a05:6870:3a01:b0:1d6:3381:dfea with SMTP id
du1-20020a0568703a0100b001d63381dfeamr6217791oab.1.1696891941342; Mon, 09 Oct
2023 15:52:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Mon, 9 Oct 2023 15:52:21 -0700 (PDT)
In-Reply-To: <26896d7c-9e07-4fcc-8bcf-927fa7775031n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.57.50.239; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r
NNTP-Posting-Host: 77.57.50.239
References: <26896d7c-9e07-4fcc-8bcf-927fa7775031n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8bc6ee04-7329-4aaf-b7e6-96435d24a913n@googlegroups.com>
Subject: Re: Autum Challenge: Short Deadfish Numbers
From: bursejan@gmail.com (Mild Shock)
Injection-Date: Mon, 09 Oct 2023 22:52:21 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2700
 by: Mild Shock - Mon, 9 Oct 2023 22:52 UTC

Naive solution with CLP(FD), and without "o" operator.
Why would one use CLP(FD) ? Well you can easily experiment
with forward search and backward search:

/* forward search, first the op/3 and then recursive */
deadfish_(X0, X) -->
{ ops(Op, X0, X1) },
[Op],
deadfish_(X1, X).

/* backward search, first recursive and then op/3 */
deadfish2_(X0, X) -->
[Op],
deadfish2_(X1, X),
{ ops(Op, X0, X1) }.

Which one is faster? Try yourself:

/* GNU Prolog, 1.5.0 */
?- between(1,90,N), once(deadfish(N,_)), fail; true.
(11703 ms) yes

?- between(1,90,N), once(deadfish2(N,_)), fail; true.
(219 ms) yes

But still waiting for more solutions that use tabling!

Mild Shock schrieb am Mittwoch, 4. Oktober 2023 um 21:22:23 UTC+2:
> Solve this problem:
>
> Deadfish is one of the best known non Turing-complete programming languages. It has only one accumulator (which starts at 0) to store
> data, and only four commands:
>
> i - Increment the accumulator
> s - Square the accumulator
> d - Decrement the accumulator
> o - Output the accumulator
>
> Create a program that will input a number and output Deadfish
> code to display the number. It must work for any integer from 0 to 255.
>
> https://codegolf.stackexchange.com/questions/40124/short-deadfish-numbers/
>
> Twist, don't write the solution in Prolog. But in your favorite Prolog
> with your favorite state extension. For example Mecury states via
> (!)/1 or some other Prolog language extension that helps
>
> dealing with state.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor