Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Everyone is entitled to an *informed* opinion." -- Harlan Ellison


devel / comp.lang.forth / Re: SEND+MORE=MONEY

SubjectAuthor
* SEND+MORE=MONEYminf...@arcor.de
+* Re: SEND+MORE=MONEYJali Heinonen
|`* Re: SEND+MORE=MONEYJali Heinonen
| `* Re: SEND+MORE=MONEYminf...@arcor.de
|  `- Re: SEND+MORE=MONEYGerry Jackson
+- Re: SEND+MORE=MONEYMarcel Hendrix
+* Re: SEND+MORE=MONEYMarcel Hendrix
|`* Re: SEND+MORE=MONEYminf...@arcor.de
| +* Re: SEND+MORE=MONEYMarcel Hendrix
| |`- Re: SEND+MORE=MONEYminf...@arcor.de
| `* Re: SEND+MORE=MONEYAnton Ertl
|  `* Re: SEND+MORE=MONEYminf...@arcor.de
|   `- Re: SEND+MORE=MONEYminf...@arcor.de
+* Re: SEND+MORE=MONEYAnton Ertl
|+- Re: SEND+MORE=MONEYAnton Ertl
|`* Re: SEND+MORE=MONEYMarcel Hendrix
| `- Re: SEND+MORE=MONEYAnton Ertl
+* Re: SEND+MORE=MONEYPaul Rubin
|`* Re: SEND+MORE=MONEYAnton Ertl
| +* Re: SEND+MORE=MONEYJali Heinonen
| |+- Re: SEND+MORE=MONEYAnton Ertl
| |`- Re: SEND+MORE=MONEYPaul Rubin
| +* Re: SEND+MORE=MONEYminf...@arcor.de
| |`* Re: SEND+MORE=MONEYAnton Ertl
| | +- locals slowness in sf and vfx (was: SEND+MORE=MONEY)Anton Ertl
| | `* Re: SEND+MORE=MONEYnone
| |  +* Re: SEND+MORE=MONEYminf...@arcor.de
| |  |`* Re: SEND+MORE=MONEYAla'a
| |  | `* Re: SEND+MORE=MONEYMarcel Hendrix
| |  |  `* Re: SEND+MORE=MONEYAla'a
| |  |   `* Re: SEND+MORE=MONEYMarcel Hendrix
| |  |    +* Re: SEND+MORE=MONEYAla'a
| |  |    |`* Re: SEND+MORE=MONEYMarcel Hendrix
| |  |    | `* Re: SEND+MORE=MONEYMarcel Hendrix
| |  |    |  `* Re: SEND+MORE=MONEYAla'a
| |  |    |   `- Re: SEND+MORE=MONEYminf...@arcor.de
| |  |    `- Re: SEND+MORE=MONEYdxforth
| |  `- Re: SEND+MORE=MONEYAnton Ertl
| `* Re: SEND+MORE=MONEYPaul Rubin
|  `* Re: SEND+MORE=MONEYPaul Rubin
|   +* Re: SEND+MORE=MONEYminf...@arcor.de
|   |`- Re: SEND+MORE=MONEYPaul Rubin
|   +- Re: SEND+MORE=MONEYPaul Rubin
|   `* Re: SEND+MORE=MONEYAnton Ertl
|    +- Re: SEND+MORE=MONEYPaul Rubin
|    `* Re: SEND+MORE=MONEYPaul Rubin
|     `* Re: SEND+MORE=MONEYminf...@arcor.de
|      `* Re: SEND+MORE=MONEYGerry Jackson
|       +* Re: SEND+MORE=MONEYPaul Rubin
|       |+- Re: SEND+MORE=MONEYdxforth
|       |`- Re: SEND+MORE=MONEYminf...@arcor.de
|       `* Re: SEND+MORE=MONEYMarcel Hendrix
|        `* Re: SEND+MORE=MONEYminf...@arcor.de
|         +* Re: SEND+MORE=MONEYMarcel Hendrix
|         |`* Re: SEND+MORE=MONEYdxforth
|         | `- Re: SEND+MORE=MONEYMarcel Hendrix
|         `* Re: SEND+MORE=MONEYminf...@arcor.de
|          +* Re: SEND+MORE=MONEYMarcel Hendrix
|          |`* Re: SEND+MORE=MONEYHans Bezemer
|          | +* Re: SEND+MORE=MONEYminf...@arcor.de
|          | |`- Re: SEND+MORE=MONEYHans Bezemer
|          | +* Re: SEND+MORE=MONEYMarcel Hendrix
|          | |`- Re: SEND+MORE=MONEYdxforth
|          | `* Re: SEND+MORE=MONEYMarcel Hendrix
|          |  `* Re: SEND+MORE=MONEYHans Bezemer
|          |   `* Re: SEND+MORE=MONEYMarcel Hendrix
|          |    `* Re: SEND+MORE=MONEYHans Bezemer
|          |     `- Re: SEND+MORE=MONEYBrian Fox
|          `* Re: SEND+MORE=MONEYdxforth
|           +* Re: SEND+MORE=MONEYminf...@arcor.de
|           |`* Re: SEND+MORE=MONEYMarcel Hendrix
|           | +* Re: SEND+MORE=MONEYminf...@arcor.de
|           | |+- Re: SEND+MORE=MONEYMarcel Hendrix
|           | |`* Re: SEND+MORE=MONEYAnton Ertl
|           | | +* Re: SEND+MORE=MONEYminf...@arcor.de
|           | | |`- Re: SEND+MORE=MONEYHans Bezemer
|           | | `* Re: SEND+MORE=MONEYminf...@arcor.de
|           | |  `* Re: SEND+MORE=MONEYAnton Ertl
|           | |   `- Re: SEND+MORE=MONEYminf...@arcor.de
|           | +- Re: SEND+MORE=MONEYMarcel Hendrix
|           | `* Re: SEND+MORE=MONEYHans Bezemer
|           |  `* Re: SEND+MORE=MONEYMarcel Hendrix
|           |   +* Re: SEND+MORE=MONEYHans Bezemer
|           |   |`* Re: SEND+MORE=MONEYMarcel Hendrix
|           |   | `* Re: SEND+MORE=MONEYAnton Ertl
|           |   |  `- Re: SEND+MORE=MONEYMarcel Hendrix
|           |   `* Re: SEND+MORE=MONEYminf...@arcor.de
|           |    `- Re: SEND+MORE=MONEYMarcel Hendrix
|           `- Re: SEND+MORE=MONEYdxforth
+* Re: SEND+MORE=MONEYAhmed MELAHI
|`* Re: SEND+MORE=MONEYminf...@arcor.de
| `* Re: SEND+MORE=MONEYAhmed MELAHI
|  +* Re: SEND+MORE=MONEYAhmed MELAHI
|  |`- Re: SEND+MORE=MONEYAhmed MELAHI
|  `* Re: SEND+MORE=MONEYminf...@arcor.de
|   +- Re: SEND+MORE=MONEYJali Heinonen
|   +* Re: SEND+MORE=MONEYAhmed MELAHI
|   |`- Re: SEND+MORE=MONEYAhmed MELAHI
|   +* Re: SEND+MORE=MONEYAnton Ertl
|   |`* Re: SEND+MORE=MONEYminf...@arcor.de
|   | `- Re: SEND+MORE=MONEYAnton Ertl
|   +- Re: SEND+MORE=MONEYAhmed MELAHI
|   `* Re: SEND+MORE=MONEYAhmed MELAHI
`- Re: SEND+MORE=MONEYNN

Pages:12345
Re: SEND+MORE=MONEY

<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22400&group=comp.lang.forth#22400

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5b06:0:b0:3ba:f6a2:b247 with SMTP id m6-20020ac85b06000000b003baf6a2b247mr3112550qtw.92.1676326276070;
Mon, 13 Feb 2023 14:11:16 -0800 (PST)
X-Received: by 2002:a37:8e84:0:b0:706:94a4:545b with SMTP id
q126-20020a378e84000000b0070694a4545bmr2109354qkd.80.1676326275814; Mon, 13
Feb 2023 14:11:15 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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.forth
Date: Mon, 13 Feb 2023 14:11:15 -0800 (PST)
In-Reply-To: <87bklxux2b.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.157.110.94; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 87.157.110.94
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 13 Feb 2023 22:11:16 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3693
 by: minf...@arcor.de - Mon, 13 Feb 2023 22:11 UTC

Paul Rubin schrieb am Montag, 13. Februar 2023 um 21:31:27 UTC+1:
> an...@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> > However, given that your C++ solution is a lot faster and cannot
> > benefit from lazy evaluation, I expect that the potential lazy
> > evaluation advantage does not happen in this Haskell program.
>
> OK, here is my insane Forth version. Runtime with gforth-fast 0.7 about
> 1.4 seconds on same laptop as before. Same brute force algorithm. Uses
> the following highly recommended (lol) Forth techniques:
>
> - ROLL and FPICK with variable depths up to 10 deep
> - 13 local variables in one word
> - stores temporary small integer values on floating point stack
> (this works with IEEE floating point, YMMV otherwise)
> - A couple more that I have forgotten.
>
> ================================================================
>
> : 10f@>s ( copy 10 integers from fp stack to data stack :O )
> 10 0 do 9 i - fpick f>s loop ;
>
> : checkresult ( -- )
> 10f@>s { x0 x1 s e n d m o r y }
> m 0> x0 x1 > and IF
> s 1000 * e 100 * + n 10 * + d + { send }
> m 1000 * o 100 * + r 10 * + e + { more }
> m 10000 * o 1000 * + n 100 * + e 10 * + y + { money }
> send more + money = IF
> send . more . money . cr
> THEN
> THEN ;
>
> : rec ( n1 n2 ... )
> depth 0= IF
> checkresult
> ELSE
> depth { d }
> d 0 DO
> s>f RECURSE f>s d 1- ROLL
> LOOP
> THEN ;
>
> 0 1 2 3 4 5 6 7 8 9 rec bye

Kool!

Not as small but here's another permuter:

CREATE LET 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,

: EXCHANGE ( i j -- )
cells let + swap cells let +
dup @ >r swap dup @ rot ! r> swap ! ;

: LT@ ( n -- ) cells let + @ ;

: M 0 lt@ ; : O 1 lt@ ; : R 2 lt@ ; : Y 3 lt@ ;
: S 4 lt@ ; : E 5 lt@ ; : N 6 lt@ ; : D 7 lt@ ;

: S1 S 10 * E + 10 * N + 10 * D + ;
: S2 M 10 * O + 10 * R + 10 * E + ;
: S3 M 10 * O + 10 * N + 10 * E + 10 * Y + ;

: CONSTR ( -- flag )
false
M 1 <> IF EXIT THEN
s1 s2 + s3 <> IF EXIT THEN
drop true ;

: USE-PERM ( -- )
constr IF
cr ." SEND+MORE=MONEY -> " s1 . s2 . s3 .
ABORT THEN ;

\ Heap's algorithm, thanks to Gerry Jackson
: PERMUTE ( n -- ) \ n assumed > 0
1- ?dup 0= IF use-perm EXIT THEN
dup 0 DO
dup recurse
dup over 1 and negate i and exchange
LOOP
recurse ;

10 PERMUTE

Re: SEND+MORE=MONEY

<tsgfb7$2j21e$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22402&group=comp.lang.forth#22402

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: do-not-...@swldwa.uk (Gerry Jackson)
Newsgroups: comp.lang.forth
Subject: Re: SEND+MORE=MONEY
Date: Tue, 14 Feb 2023 17:11:03 +0000
Organization: A noiseless patient Spider
Lines: 119
Message-ID: <tsgfb7$2j21e$1@dont-email.me>
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 14 Feb 2023 17:11:03 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="2e17e17d27e6a6a5a71ab7c15fe892fd";
logging-data="2721838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ujBoe19ocjHVaJ3gscRmxMy/DYUwvEho="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Cancel-Lock: sha1:P2V8z/s21Mk1RQvjaKjziETEdjs=
In-Reply-To: <3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>
 by: Gerry Jackson - Tue, 14 Feb 2023 17:11 UTC

On 13/02/2023 22:11, minf...@arcor.de wrote:
> Paul Rubin schrieb am Montag, 13. Februar 2023 um 21:31:27 UTC+1:
>> an...@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>> However, given that your C++ solution is a lot faster and cannot
>>> benefit from lazy evaluation, I expect that the potential lazy
>>> evaluation advantage does not happen in this Haskell program.
>>
>> OK, here is my insane Forth version. Runtime with gforth-fast 0.7 about
>> 1.4 seconds on same laptop as before. Same brute force algorithm. Uses
>> the following highly recommended (lol) Forth techniques:
>>
>> - ROLL and FPICK with variable depths up to 10 deep
>> - 13 local variables in one word
>> - stores temporary small integer values on floating point stack
>> (this works with IEEE floating point, YMMV otherwise)
>> - A couple more that I have forgotten.
>>
>> ================================================================
>>
>> : 10f@>s ( copy 10 integers from fp stack to data stack :O )
>> 10 0 do 9 i - fpick f>s loop ;
>>
>> : checkresult ( -- )
>> 10f@>s { x0 x1 s e n d m o r y }
>> m 0> x0 x1 > and IF
>> s 1000 * e 100 * + n 10 * + d + { send }
>> m 1000 * o 100 * + r 10 * + e + { more }
>> m 10000 * o 1000 * + n 100 * + e 10 * + y + { money }
>> send more + money = IF
>> send . more . money . cr
>> THEN
>> THEN ;
>>
>> : rec ( n1 n2 ... )
>> depth 0= IF
>> checkresult
>> ELSE
>> depth { d }
>> d 0 DO
>> s>f RECURSE f>s d 1- ROLL
>> LOOP
>> THEN ;
>>
>> 0 1 2 3 4 5 6 7 8 9 rec bye
>
> Kool!
>
> Not as small but here's another permuter:
>
> CREATE LET 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,
>
> : EXCHANGE ( i j -- )
> cells let + swap cells let +
> dup @ >r swap dup @ rot ! r> swap ! ;
>
> : LT@ ( n -- ) cells let + @ ;
>
> : M 0 lt@ ; : O 1 lt@ ; : R 2 lt@ ; : Y 3 lt@ ;
> : S 4 lt@ ; : E 5 lt@ ; : N 6 lt@ ; : D 7 lt@ ;
>
> : S1 S 10 * E + 10 * N + 10 * D + ;
> : S2 M 10 * O + 10 * R + 10 * E + ;
> : S3 M 10 * O + 10 * N + 10 * E + 10 * Y + ;
>
> : CONSTR ( -- flag )
> false
> M 1 <> IF EXIT THEN
> s1 s2 + s3 <> IF EXIT THEN
> drop true ;
>
> : USE-PERM ( -- )
> constr IF
> cr ." SEND+MORE=MONEY -> " s1 . s2 . s3 .
> ABORT THEN ;
>
> \ Heap's algorithm, thanks to Gerry Jackson
> : PERMUTE ( n -- ) \ n assumed > 0
> 1- ?dup 0= IF use-perm EXIT THEN
> dup 0 DO
> dup recurse
> dup over 1 and negate i and exchange
> LOOP
> recurse ;
>
> 10 PERMUTE

ISTM that using Heap's algorithm to generate the permutations offers
more opportunities for optimisation of a solution to this problem. This
is because the algorithm generates each permutation from the previous
one by interchanging a single pair of elements. The position of the
other n-2 elements are unchanged. Therefore in the SEND + MORE = MONEY
equation only the increments/decrements for the three components of the
equation need to be calculated and applied to the result of the previous
calculation.

For example suppose digits 12345678 are allocated to SENDMORY as
SENDMORY
12345678
then
SEND MORE MONEY becomes
1234 5672 56328
suppose the next permutation is generated by exchanging digits 4 and 5
then D contributes +1 to SEND
M contributes -1000 to MORE and -10000 to MONEY
So instead of doing the entire calculation only these increments need to
be added to SEND MORE and MONEY from the previous permutation.

These increments could be pre-calculated as a power of 10 for each
letter to be multiplied by the difference in the digits changed for that
letter.

I don't know whether that's it's worth going to that much trouble.

As a wild speculation I wonder if this suggests a way of homing in on
the solution.

--
Gerry

Re: SEND+MORE=MONEY

<877cwjvqsn.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22404&group=comp.lang.forth#22404

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: SEND+MORE=MONEY
Date: Tue, 14 Feb 2023 14:13:44 -0800
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <877cwjvqsn.fsf@nightsong.com>
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com>
<2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at>
<87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>
<tsgfb7$2j21e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="c5e825cee22b173147c87b494caac3ee";
logging-data="2785501"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19a47xIzcbaaRo/QHHEmarY"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:lejOc10k1V0bNcKMPFxW5H3E2iY=
sha1:MkefGsArqe0mgNTiO8LgH/jWNXw=
 by: Paul Rubin - Tue, 14 Feb 2023 22:13 UTC

Gerry Jackson <do-not-use@swldwa.uk> writes:
> ISTM that using Heap's algorithm to generate the permutations... This
> is because the algorithm generates each permutation from the previous
> one by interchanging a single pair of elements.

I wasn't familiar with this algorithm. It sounds like a good approach,
and I will have to study it.

Re: SEND+MORE=MONEY

<tsh8q7$2lpu7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22405&group=comp.lang.forth#22405

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: SEND+MORE=MONEY
Date: Wed, 15 Feb 2023 11:25:44 +1100
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <tsh8q7$2lpu7$1@dont-email.me>
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>
<tsgfb7$2j21e$1@dont-email.me> <877cwjvqsn.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 15 Feb 2023 00:25:43 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="966dd1eafa3e9ea52c3bd7b3f2d523de";
logging-data="2811847"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qW6hxsReS3mpmNTACuE1f"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:MtV6BsUodE58drrLjuqEhSUAvD8=
Content-Language: en-GB
In-Reply-To: <877cwjvqsn.fsf@nightsong.com>
 by: dxforth - Wed, 15 Feb 2023 00:25 UTC

On 15/02/2023 9:13 am, Paul Rubin wrote:
> Gerry Jackson <do-not-use@swldwa.uk> writes:
>> ISTM that using Heap's algorithm to generate the permutations... This
>> is because the algorithm generates each permutation from the previous
>> one by interchanging a single pair of elements.
>
> I wasn't familiar with this algorithm.

Same here. Being short and simple, I've included it in my collection of
miscellaneous routines. Neat implementation.

Re: SEND+MORE=MONEY

<f5f40b64-8efc-41a8-a075-37391558a88dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22406&group=comp.lang.forth#22406

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5e52:0:b0:3bd:149:1093 with SMTP id i18-20020ac85e52000000b003bd01491093mr37298qtx.55.1676445425749;
Tue, 14 Feb 2023 23:17:05 -0800 (PST)
X-Received: by 2002:ac8:7d50:0:b0:3bb:7ae7:5e2 with SMTP id
h16-20020ac87d50000000b003bb7ae705e2mr129264qtb.51.1676445425514; Tue, 14 Feb
2023 23:17:05 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Tue, 14 Feb 2023 23:17:05 -0800 (PST)
In-Reply-To: <877cwjvqsn.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f4a:5364:1512:5a0d:6a4:a35e;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f4a:5364:1512:5a0d:6a4:a35e
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<877cwjvqsn.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f5f40b64-8efc-41a8-a075-37391558a88dn@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 15 Feb 2023 07:17:05 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1998
 by: minf...@arcor.de - Wed, 15 Feb 2023 07:17 UTC

Paul Rubin schrieb am Dienstag, 14. Februar 2023 um 23:13:47 UTC+1:
> Gerry Jackson <do-no...@swldwa.uk> writes:
> > ISTM that using Heap's algorithm to generate the permutations... This
> > is because the algorithm generates each permutation from the previous
> > one by interchanging a single pair of elements.
> I wasn't familiar with this algorithm. It sounds like a good approach,
> and I will have to study it.

Happy reading ;-)
https://sedgewick.io/wp-content/themes/sedgewick/papers/1977Permutation.pdf

Re: SEND+MORE=MONEY

<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22407&group=comp.lang.forth#22407

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:c501:0:b0:56e:bfd7:8b38 with SMTP id x1-20020a0cc501000000b0056ebfd78b38mr72594qvi.24.1676448725490;
Wed, 15 Feb 2023 00:12:05 -0800 (PST)
X-Received: by 2002:ac8:134a:0:b0:3b9:a56e:d4f9 with SMTP id
f10-20020ac8134a000000b003b9a56ed4f9mr75112qtj.5.1676448725328; Wed, 15 Feb
2023 00:12:05 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Wed, 15 Feb 2023 00:12:05 -0800 (PST)
In-Reply-To: <tsgfb7$2j21e$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=131.155.124.133; posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 131.155.124.133
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Wed, 15 Feb 2023 08:12:05 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2433
 by: Marcel Hendrix - Wed, 15 Feb 2023 08:12 UTC

On Tuesday, February 14, 2023 at 6:11:05 PM UTC+1, Gerry Jackson wrote:
> On 13/02/2023 22:11, minf...@arcor.de wrote:
> > Paul Rubin schrieb am Montag, 13. Februar 2023 um 21:31:27 UTC+1:
> >> an...@mips.complang.tuwien.ac.at (Anton Ertl) writes:
[..]
> ISTM that using Heap's algorithm to generate the permutations offers
> more opportunities for optimisation of a solution to this problem. This
> is because the algorithm generates each permutation from the previous
> one by interchanging a single pair of elements. The position of the
> other n-2 elements are unchanged. Therefore in the SEND + MORE = MONEY
> equation only the increments/decrements for the three components of the
> equation need to be calculated and applied to the result of the previous
> calculation.
[..]
This algorithm removes the random element that I mentioned in my remark on
parallellism. With no recursion overhead and no duplicated tries, that should be
quite efficient for certain types of problems. And, of course, simple to implement.

-marcel

Re: SEND+MORE=MONEY

<a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22408&group=comp.lang.forth#22408

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:93c7:0:b0:71d:8202:bc8 with SMTP id v190-20020a3793c7000000b0071d82020bc8mr44840qkd.192.1676452592287;
Wed, 15 Feb 2023 01:16:32 -0800 (PST)
X-Received: by 2002:a05:622a:94:b0:3b6:8d55:44e1 with SMTP id
o20-20020a05622a009400b003b68d5544e1mr177178qtw.305.1676452592044; Wed, 15
Feb 2023 01:16:32 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Wed, 15 Feb 2023 01:16:31 -0800 (PST)
In-Reply-To: <7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f4a:5364:1512:5a0d:6a4:a35e;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f4a:5364:1512:5a0d:6a4:a35e
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 15 Feb 2023 09:16:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2977
 by: minf...@arcor.de - Wed, 15 Feb 2023 09:16 UTC

Marcel Hendrix schrieb am Mittwoch, 15. Februar 2023 um 09:12:06 UTC+1:
> On Tuesday, February 14, 2023 at 6:11:05 PM UTC+1, Gerry Jackson wrote:
> > On 13/02/2023 22:11, minf...@arcor.de wrote:
> > > Paul Rubin schrieb am Montag, 13. Februar 2023 um 21:31:27 UTC+1:
> > >> an...@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> [..]
> > ISTM that using Heap's algorithm to generate the permutations offers
> > more opportunities for optimisation of a solution to this problem. This
> > is because the algorithm generates each permutation from the previous
> > one by interchanging a single pair of elements. The position of the
> > other n-2 elements are unchanged. Therefore in the SEND + MORE = MONEY
> > equation only the increments/decrements for the three components of the
> > equation need to be calculated and applied to the result of the previous
> > calculation.
> [..]
> This algorithm removes the random element that I mentioned in my remark on
> parallellism. With no recursion overhead and no duplicated tries, that should be
> quite efficient for certain types of problems. And, of course, simple to implement.

It seems that the most efficient non-recursive permutation algorithms require
a second control array. So in addition to swapping cells in the target array, control
array cells have to be managed as well, which eats up the promised efficiency gain.
https://www.quickperm.org/

Re: SEND+MORE=MONEY

<8a8c7ef6-3147-4b4e-a21a-b41d307d6cbdn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22413&group=comp.lang.forth#22413

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:7292:0:b0:3b8:6b09:26a0 with SMTP id v18-20020ac87292000000b003b86b0926a0mr155326qto.6.1676490336938;
Wed, 15 Feb 2023 11:45:36 -0800 (PST)
X-Received: by 2002:a0c:e349:0:b0:56e:cfe0:b925 with SMTP id
a9-20020a0ce349000000b0056ecfe0b925mr260492qvm.52.1676490336725; Wed, 15 Feb
2023 11:45:36 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Wed, 15 Feb 2023 11:45:36 -0800 (PST)
In-Reply-To: <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:64d6:9c95:4998:3e06;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:64d6:9c95:4998:3e06
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8a8c7ef6-3147-4b4e-a21a-b41d307d6cbdn@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Wed, 15 Feb 2023 19:45:36 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2070
 by: Marcel Hendrix - Wed, 15 Feb 2023 19:45 UTC

iForth64 now runs on snellius (https://servicedesk.surf.nl/wiki/display/WIKI/Snellius)
I didn't even need to recompile, just copied the binaries from my 5800X straight onto
the surf node.

FORTH> .TICKER-INFO
AMD EPYC 7F72 24-Core Processor
TICKS-GET uses os time & PROCESSOR-CLOCK 3000MHz
Do: < n TO PROCESSOR-CLOCK RECALIBRATE >
ok
FORTH> GO
Solving ... 26 microseconds elapsed, the solution is: 9567 + 1085 = 10652 ok

'Super' does not mean 'superfast' :--)

-marcel

Re: SEND+MORE=MONEY

<tsjsrk$31986$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22414&group=comp.lang.forth#22414

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: SEND+MORE=MONEY
Date: Thu, 16 Feb 2023 11:20:04 +1100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <tsjsrk$31986$1@dont-email.me>
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>
<tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com>
<a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<8a8c7ef6-3147-4b4e-a21a-b41d307d6cbdn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 16 Feb 2023 00:20:05 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cb73bf545bc6aa246386f7f851e135af";
logging-data="3187974"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FIpx6eUU8iUW1tJaKThwr"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Cancel-Lock: sha1:TTJOFuO0V7HPs89ymLh69iU4PLw=
Content-Language: en-GB
In-Reply-To: <8a8c7ef6-3147-4b4e-a21a-b41d307d6cbdn@googlegroups.com>
 by: dxforth - Thu, 16 Feb 2023 00:20 UTC

On 16/02/2023 6:45 am, Marcel Hendrix wrote:
> iForth64 now runs on snellius (https://servicedesk.surf.nl/wiki/display/WIKI/Snellius)
> I didn't even need to recompile, just copied the binaries from my 5800X straight onto
> the surf node.
>
> FORTH> .TICKER-INFO
> AMD EPYC 7F72 24-Core Processor
> TICKS-GET uses os time & PROCESSOR-CLOCK 3000MHz
> Do: < n TO PROCESSOR-CLOCK RECALIBRATE >
> ok
> FORTH> GO
> Solving ... 26 microseconds elapsed, the solution is: 9567 + 1085 = 10652 ok
>
> 'Super' does not mean 'superfast' :--)

Brain the size of a planet and you give it useless tasks to perform.

Re: SEND+MORE=MONEY

<104f1e23-9a2c-4562-95e8-4ea54a86df17n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22415&group=comp.lang.forth#22415

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:9a41:0:b0:56b:fb9d:eb75 with SMTP id q1-20020a0c9a41000000b0056bfb9deb75mr369741qvd.70.1676525082498;
Wed, 15 Feb 2023 21:24:42 -0800 (PST)
X-Received: by 2002:ac8:5bd3:0:b0:3a9:82a1:4f6 with SMTP id
b19-20020ac85bd3000000b003a982a104f6mr361167qtb.117.1676525082298; Wed, 15
Feb 2023 21:24:42 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Wed, 15 Feb 2023 21:24:42 -0800 (PST)
In-Reply-To: <tsjsrk$31986$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:64d6:9c95:4998:3e06;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:64d6:9c95:4998:3e06
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<8a8c7ef6-3147-4b4e-a21a-b41d307d6cbdn@googlegroups.com> <tsjsrk$31986$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <104f1e23-9a2c-4562-95e8-4ea54a86df17n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Thu, 16 Feb 2023 05:24:42 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1824
 by: Marcel Hendrix - Thu, 16 Feb 2023 05:24 UTC

On Thursday, February 16, 2023 at 1:20:08 AM UTC+1, dxforth wrote:
> Brain the size of a planet and you give it useless tasks to perform.

Starting Forth bottom-up.

-marcel

Re: SEND+MORE=MONEY

<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22423&group=comp.lang.forth#22423

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:aed:27cb:0:b0:3bd:dc4:82ab with SMTP id m11-20020aed27cb000000b003bd0dc482abmr470566qtg.7.1676640997422;
Fri, 17 Feb 2023 05:36:37 -0800 (PST)
X-Received: by 2002:a0c:f4c8:0:b0:537:7552:1609 with SMTP id
o8-20020a0cf4c8000000b0053775521609mr159739qvm.81.1676640997226; Fri, 17 Feb
2023 05:36:37 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Fri, 17 Feb 2023 05:36:36 -0800 (PST)
In-Reply-To: <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f4a:5358:4983:bae4:c739:3c71;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f4a:5358:4983:bae4:c739:3c71
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Fri, 17 Feb 2023 13:36:37 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3313
 by: minf...@arcor.de - Fri, 17 Feb 2023 13:36 UTC

minf...@arcor.de schrieb am Mittwoch, 15. Februar 2023 um 10:16:33 UTC+1:
> It seems that the most efficient non-recursive permutation algorithms require
> a second control array. So in addition to swapping cells in the target array, control
> array cells have to be managed as well, which eats up the promised efficiency gain.

Here's with non-recursive permutation algorithm. Quick timing showed no speed
increase significant for practical purposes. Only benefit would be less 'stress' on the
return stack.

CREATE LET 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,

: EXCHANGE ( i j -- )
cells let + swap cells let +
dup @ >r swap dup @ rot ! r> swap ! ;

: LT@ ( n -- ) cells let + @ ;

: M 0 lt@ ; : O 1 lt@ ; : R 2 lt@ ; : Y 3 lt@ ;
: S 4 lt@ ; : E 5 lt@ ; : N 6 lt@ ; : D 7 lt@ ;

: S1 S 10 * E + 10 * N + 10 * D + ;
: S2 M 10 * O + 10 * R + 10 * E + ;
: S3 M 10 * O + 10 * N + 10 * E + 10 * Y + ;

: CONSTR ( -- flag )
false
M 1 <> IF EXIT THEN
s1 s2 + s3 <> IF EXIT THEN
drop true ;

: USE-PERM ( -- )
constr IF
cr ." SEND+MORE=MONEY -> " s1 . s2 . s3 .
ABORT THEN ;

\ ----- Heap's algorithm recursive -----

: PERMUTE-R ( n -- ) \ n assumed > 0
1- ?dup 0= IF use-perm EXIT THEN
dup 0 DO
dup recurse
dup over 1 and negate i and exchange
LOOP
recurse ;

\ 10 PERMUTE-R

\ +++++ Heap's algorithm non-recursive +++++

\ control array:
CREATE CAR 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
: CA ( n -- ) cells car + ;

: PERMUTE-NR ( n -- ) \ n assumed > 0
use-perm
1 BEGIN 2dup >= WHILE
dup ca @ over <
IF dup 1 and
IF dup ca @ ELSE 0 THEN over exchange use-perm
1 swap ca +! 1
ELSE 0 over ca ! 1+
THEN
REPEAT 2drop ;

10 PERMUTE-NR

Re: SEND+MORE=MONEY

<9dcf5171-07bb-46ff-a9ca-200c9326da25n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22424&group=comp.lang.forth#22424

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2b42:b0:73b:6f11:3a6c with SMTP id dp2-20020a05620a2b4200b0073b6f113a6cmr892303qkb.4.1676653549948;
Fri, 17 Feb 2023 09:05:49 -0800 (PST)
X-Received: by 2002:a0c:f386:0:b0:537:ab77:fbe9 with SMTP id
i6-20020a0cf386000000b00537ab77fbe9mr1089867qvk.42.1676653549765; Fri, 17 Feb
2023 09:05:49 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Fri, 17 Feb 2023 09:05:49 -0800 (PST)
In-Reply-To: <ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:dd0f:426e:bfda:4940;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:dd0f:426e:bfda:4940
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9dcf5171-07bb-46ff-a9ca-200c9326da25n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Fri, 17 Feb 2023 17:05:49 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1906
 by: Marcel Hendrix - Fri, 17 Feb 2023 17:05 UTC

On Friday, February 17, 2023 at 2:36:38 PM UTC+1, minf...@arcor.de wrote:
> minf...@arcor.de schrieb am Mittwoch, 15. Februar 2023 um 10:16:33 UTC+1:
[..]
> 10 PERMUTE-NR

PERMUTE-NR is ~700x slower than my latest solution ( 14 microseconds ) :--(

-marcel

Re: SEND+MORE=MONEY

<3d36dc02-93e6-448c-82e4-eabf2703ab93n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22425&group=comp.lang.forth#22425

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:383:b0:71f:b8e9:3631 with SMTP id q3-20020a05620a038300b0071fb8e93631mr81834qkm.13.1676654946196;
Fri, 17 Feb 2023 09:29:06 -0800 (PST)
X-Received: by 2002:a0c:f4c8:0:b0:537:7552:1609 with SMTP id
o8-20020a0cf4c8000000b0053775521609mr258690qvm.81.1676654946008; Fri, 17 Feb
2023 09:29:06 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Fri, 17 Feb 2023 09:29:05 -0800 (PST)
In-Reply-To: <9dcf5171-07bb-46ff-a9ca-200c9326da25n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <9dcf5171-07bb-46ff-a9ca-200c9326da25n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3d36dc02-93e6-448c-82e4-eabf2703ab93n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Fri, 17 Feb 2023 17:29:06 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2626
 by: Hans Bezemer - Fri, 17 Feb 2023 17:29 UTC

On Friday, February 17, 2023 at 6:05:51 PM UTC+1, Marcel Hendrix wrote:
> On Friday, February 17, 2023 at 2:36:38 PM UTC+1, minf...@arcor.de wrote:
> > minf...@arcor.de schrieb am Mittwoch, 15. Februar 2023 um 10:16:33 UTC+1:
> [..]
> > 10 PERMUTE-NR
>
> PERMUTE-NR is ~700x slower than my latest solution ( 14 microseconds ) :--(

Including program development, this was even quicker:

"Me> Assume every character is actually a figure, which calculation is made here: SEND+MORE=MONEY

ChatGPT> In the SEND+MORE=MONEY puzzle, the goal is to assign each letter a digit from 0 to 9 in such a way that the resulting mathematical equation is correct. Each letter represents a distinct digit, and the leftmost digit in any number cannot be 0.

Here is one possible solution to the puzzle:

O = 0
M = 1
Y = 2
E = 5
N = 6
D = 7
R = 8
S = 9

With these assignments, the equation becomes:

9567 + 1085 = 10652

which is true."

;-) Hans Bezemer

Re: SEND+MORE=MONEY

<870a8db8-83c4-40cd-bebd-cebad5876978n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22426&group=comp.lang.forth#22426

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:270a:b0:72b:25b4:565a with SMTP id b10-20020a05620a270a00b0072b25b4565amr946144qkp.0.1676657739113;
Fri, 17 Feb 2023 10:15:39 -0800 (PST)
X-Received: by 2002:a0c:f214:0:b0:56e:a1cc:bbb3 with SMTP id
h20-20020a0cf214000000b0056ea1ccbbb3mr1031978qvk.42.1676657738901; Fri, 17
Feb 2023 10:15:38 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Fri, 17 Feb 2023 10:15:38 -0800 (PST)
In-Reply-To: <3d36dc02-93e6-448c-82e4-eabf2703ab93n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f4a:533a:fdbf:9118:5dae:b015;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f4a:533a:fdbf:9118:5dae:b015
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <9dcf5171-07bb-46ff-a9ca-200c9326da25n@googlegroups.com>
<3d36dc02-93e6-448c-82e4-eabf2703ab93n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <870a8db8-83c4-40cd-bebd-cebad5876978n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Fri, 17 Feb 2023 18:15:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3103
 by: minf...@arcor.de - Fri, 17 Feb 2023 18:15 UTC

Hans Bezemer schrieb am Freitag, 17. Februar 2023 um 18:29:07 UTC+1:
> On Friday, February 17, 2023 at 6:05:51 PM UTC+1, Marcel Hendrix wrote:
> > On Friday, February 17, 2023 at 2:36:38 PM UTC+1, minf...@arcor.de wrote:
> > > minf...@arcor.de schrieb am Mittwoch, 15. Februar 2023 um 10:16:33 UTC+1:
> > [..]
> > > 10 PERMUTE-NR
> >
> > PERMUTE-NR is ~700x slower than my latest solution ( 14 microseconds ) :--(
> Including program development, this was even quicker:
>
> "Me> Assume every character is actually a figure, which calculation is made here: SEND+MORE=MONEY
>
> ChatGPT> In the SEND+MORE=MONEY puzzle, the goal is to assign each letter a digit from 0 to 9 in such a way that the resulting mathematical equation is correct. Each letter represents a distinct digit, and the leftmost digit in any number cannot be 0.
>
> Here is one possible solution to the puzzle:
>
> O = 0
> M = 1
> Y = 2
> E = 5
> N = 6
> D = 7
> R = 8
> S = 9
>
> With these assignments, the equation becomes:
> 9567 + 1085 = 10652
> which is true."
>
> ;-) Hans Bezemer

Think of it, computers have come a long way since:

The oldest computer can be traced back to Adam and Eve.
Surprise! Surprise!
It was an apple.
But with extremely limited memory.
Just 1 byte.
Then everything crashed.

Re: SEND+MORE=MONEY

<29bd3310-a44b-48b5-941b-b69ef1b9b1can@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22427&group=comp.lang.forth#22427

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:e91a:0:b0:73b:a221:2c8e with SMTP id x26-20020ae9e91a000000b0073ba2212c8emr599950qkf.4.1676658495481;
Fri, 17 Feb 2023 10:28:15 -0800 (PST)
X-Received: by 2002:ac8:429e:0:b0:3bd:17d2:89c9 with SMTP id
o30-20020ac8429e000000b003bd17d289c9mr469201qtl.12.1676658495317; Fri, 17 Feb
2023 10:28:15 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Fri, 17 Feb 2023 10:28:14 -0800 (PST)
In-Reply-To: <870a8db8-83c4-40cd-bebd-cebad5876978n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <9dcf5171-07bb-46ff-a9ca-200c9326da25n@googlegroups.com>
<3d36dc02-93e6-448c-82e4-eabf2703ab93n@googlegroups.com> <870a8db8-83c4-40cd-bebd-cebad5876978n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <29bd3310-a44b-48b5-941b-b69ef1b9b1can@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Fri, 17 Feb 2023 18:28:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2814
 by: Hans Bezemer - Fri, 17 Feb 2023 18:28 UTC

On Friday, February 17, 2023 at 7:15:40 PM UTC+1, minf...@arcor.de wrote:
> Think of it, computers have come a long way since.

It often is way off - but sometimes it amazes me. I recently wrote a medium sized program for work.
I fed it to ChatGPT - with minimal comments. Explain it. And it returned this (a bit more, but anyways):

"The program initializes some resources, including two binary search tables "names" and "counts" to store
field values and their frequencies, respectively, and an array of dynamic strings "field-names" to store
the field names.

The main logic of the program is in a loop that reads the CSV file, extracts the field values, and counts
the frequency of each field value. The loop continues until it reaches the end of the file, and then it
prints out the results for each field value. Finally, if the "fodsfile" flag is set, the program opens a FODS
file and writes the results to it".

That's right on the money. There was more, but those were pretty spot on as well. Amazing..

Hans Bezemer

Re: SEND+MORE=MONEY

<4d8ee549-1fd4-4aed-a5aa-769ac59adfb6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22428&group=comp.lang.forth#22428

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:459e:0:b0:3b8:6816:d821 with SMTP id l30-20020ac8459e000000b003b86816d821mr264419qtn.1.1676658764206;
Fri, 17 Feb 2023 10:32:44 -0800 (PST)
X-Received: by 2002:a0c:f4c8:0:b0:537:7552:1609 with SMTP id
o8-20020a0cf4c8000000b0053775521609mr285517qvm.81.1676658764053; Fri, 17 Feb
2023 10:32:44 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Fri, 17 Feb 2023 10:32:43 -0800 (PST)
In-Reply-To: <3d36dc02-93e6-448c-82e4-eabf2703ab93n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:dd0f:426e:bfda:4940;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:dd0f:426e:bfda:4940
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <9dcf5171-07bb-46ff-a9ca-200c9326da25n@googlegroups.com>
<3d36dc02-93e6-448c-82e4-eabf2703ab93n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4d8ee549-1fd4-4aed-a5aa-769ac59adfb6n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Fri, 17 Feb 2023 18:32:44 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3609
 by: Marcel Hendrix - Fri, 17 Feb 2023 18:32 UTC

On Friday, February 17, 2023 at 6:29:07 PM UTC+1, Hans Bezemer wrote:
> On Friday, February 17, 2023 at 6:05:51 PM UTC+1, Marcel Hendrix wrote:
> > On Friday, February 17, 2023 at 2:36:38 PM UTC+1, minf...@arcor.de wrote:
> > > minf...@arcor.de schrieb am Mittwoch, 15. Februar 2023 um 10:16:33 UTC+1:
> > [..]
> > > 10 PERMUTE-NR
> >
> > PERMUTE-NR is ~700x slower than my latest solution ( 14 microseconds ) :--(
[..]
> Including program development, this was even quicker:
>
> "Me> Assume every character is actually a figure, which calculation is made here: SEND+MORE=MONEY
>
> ChatGPT> In the SEND+MORE=MONEY puzzle, the goal is to assign each letter a digit from 0 to 9
> in such a way that the resulting mathematical equation is correct. Each letter represents a distinct digit,
> and the leftmost digit in any number cannot be 0.
>
> Here is one possible solution to the puzzle:
>
> O = 0
> M = 1
> Y = 2
> E = 5
> N = 6
> D = 7
> R = 8
> S = 9
>
> With these assignments, the equation becomes:
> 9567 + 1085 = 10652
> which is true."
>
> ;-) Hans Bezemer

I also asked it that. It gave almost the same explanation and the same solution.
However, then I asked for another solution, and it gave me a wrong one, twice --
apparently it assumes the audience is not checking. In the end it did produce
a correct answer. Of course, when I said it was wrong, it quickly agreed.

It also could place the quotes to "Who is on third," and "What is the answer to
everything?" Again, it refused to defend its answers and simply agreed with
me that the answer to the latter is 46.

I thought about it backing down so quickly. Commercially it makes sense -- what
would happen if chatGPT started giving correct and unrefutable but inconvenient
answers to (e.g.) its American audience? Stock would plummet.

-marcel

Re: SEND+MORE=MONEY

<tsp7ek$3p077$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22429&group=comp.lang.forth#22429

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: SEND+MORE=MONEY
Date: Sat, 18 Feb 2023 11:51:33 +1100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <tsp7ek$3p077$1@dont-email.me>
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>
<tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com>
<a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 18 Feb 2023 00:51:32 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cf72949333e2ce7e25938a0710d5619f";
logging-data="3965159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PETwMbWQUItrVazPzd87s"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Cancel-Lock: sha1:hHazqmteMmDDFxRjxjbjGeqz6TE=
Content-Language: en-GB
In-Reply-To: <ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com>
 by: dxforth - Sat, 18 Feb 2023 00:51 UTC

On 18/02/2023 12:36 am, minf...@arcor.de wrote:
>
> Here's with non-recursive permutation algorithm. Quick timing showed no speed
> increase significant for practical purposes. Only benefit would be less 'stress' on the
> return stack.

Haven't measured it but appears to be less of an issue than the time taken
to generate the permutations which rises factorially. The latter is likely
to get you first.

Re: SEND+MORE=MONEY

<tsp8dd$3p8nn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22430&group=comp.lang.forth#22430

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: SEND+MORE=MONEY
Date: Sat, 18 Feb 2023 12:07:59 +1100
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <tsp8dd$3p8nn$1@dont-email.me>
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com>
<tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com>
<a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com>
<9dcf5171-07bb-46ff-a9ca-200c9326da25n@googlegroups.com>
<3d36dc02-93e6-448c-82e4-eabf2703ab93n@googlegroups.com>
<4d8ee549-1fd4-4aed-a5aa-769ac59adfb6n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 18 Feb 2023 01:07:58 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cf72949333e2ce7e25938a0710d5619f";
logging-data="3973879"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8Ue4nWUFQ8ISPG/ebOGAE"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Cancel-Lock: sha1:OJtQsf7BneRvvGJy3CW9c9pJnAo=
Content-Language: en-GB
In-Reply-To: <4d8ee549-1fd4-4aed-a5aa-769ac59adfb6n@googlegroups.com>
 by: dxforth - Sat, 18 Feb 2023 01:07 UTC

On 18/02/2023 5:32 am, Marcel Hendrix wrote:
>
> I thought about it backing down so quickly. Commercially it makes sense -- what
> would happen if chatGPT started giving correct and unrefutable but inconvenient
> answers to (e.g.) its American audience? Stock would plummet.

When is Forth's (our) second coming? Perhaps nobody here has invested in that :)

Re: SEND+MORE=MONEY

<125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22432&group=comp.lang.forth#22432

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:f24e:0:b0:571:471:8925 with SMTP id z14-20020a0cf24e000000b0057104718925mr249639qvl.18.1676704270172;
Fri, 17 Feb 2023 23:11:10 -0800 (PST)
X-Received: by 2002:a05:6214:18c2:b0:56f:6b7:3a7b with SMTP id
cy2-20020a05621418c200b0056f06b73a7bmr15487qvb.7.1676704269954; Fri, 17 Feb
2023 23:11:09 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Fri, 17 Feb 2023 23:11:09 -0800 (PST)
In-Reply-To: <tsp7ek$3p077$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f4a:533a:fdbf:9118:5dae:b015;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f4a:533a:fdbf:9118:5dae:b015
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <tsp7ek$3p077$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Sat, 18 Feb 2023 07:11:10 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2604
 by: minf...@arcor.de - Sat, 18 Feb 2023 07:11 UTC

dxforth schrieb am Samstag, 18. Februar 2023 um 01:51:35 UTC+1:
> On 18/02/2023 12:36 am, minf...@arcor.de wrote:
> >
> > Here's with non-recursive permutation algorithm. Quick timing showed no speed
> > increase significant for practical purposes. Only benefit would be less 'stress' on the
> > return stack.
> Haven't measured it but appears to be less of an issue than the time taken
> to generate the permutations which rises factorially. The latter is likely
> to get you first.

Brute-force permutations over the 10 decimal digits 0..9 don't rise factorially unless you
increase the base.

But principally you are right. The Magic Hexagon puzzle cannot be solved by calculating
all possible permutations over 19 positions - it would run for weeks (whereas Prolog
solves it within less than a second by working the constraints).

The point is that speed matters when you are sure a priori that there is at least one solution.

Re: SEND+MORE=MONEY

<19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22433&group=comp.lang.forth#22433

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:ab84:0:b0:56e:8aba:d9dc with SMTP id j4-20020a0cab84000000b0056e8abad9dcmr557936qvb.45.1676707174287;
Fri, 17 Feb 2023 23:59:34 -0800 (PST)
X-Received: by 2002:a0c:f58b:0:b0:56e:fbcd:9272 with SMTP id
k11-20020a0cf58b000000b0056efbcd9272mr19808qvm.12.1676707174080; Fri, 17 Feb
2023 23:59:34 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Fri, 17 Feb 2023 23:59:33 -0800 (PST)
In-Reply-To: <125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:5912:cb3b:93e6:1136;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:5912:cb3b:93e6:1136
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <tsp7ek$3p077$1@dont-email.me>
<125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sat, 18 Feb 2023 07:59:34 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2970
 by: Marcel Hendrix - Sat, 18 Feb 2023 07:59 UTC

On Saturday, February 18, 2023 at 8:11:11 AM UTC+1, minf...@arcor.de wrote:
> dxforth schrieb am Samstag, 18. Februar 2023 um 01:51:35 UTC+1:
> > On 18/02/2023 12:36 am, minf...@arcor.de wrote:
> > >
> > > Here's with non-recursive permutation algorithm. Quick timing showed no speed
> > > increase significant for practical purposes. Only benefit would be less 'stress' on the
> > > return stack.
> > Haven't measured it but appears to be less of an issue than the time taken
> > to generate the permutations which rises factorially. The latter is likely
> > to get you first.
> Brute-force permutations over the 10 decimal digits 0..9 don't rise factorially unless you
> increase the base.
>
> But principally you are right. The Magic Hexagon puzzle cannot be solved by calculating
> all possible permutations over 19 positions - it would run for weeks (whereas Prolog
> solves it within less than a second by working the constraints).
>
> The point is that speed matters when you are sure a priori that there is at least one solution.

For me, there is still some magic attached to this approach. It seems obvious
that pruning the number of paths to try would always be better than randomly
trying them all.

-marcel

Re: SEND+MORE=MONEY

<3e470581-f283-4677-822b-376eecfeabd5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22435&group=comp.lang.forth#22435

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:4197:b0:56b:ed36:ffb with SMTP id ld23-20020a056214419700b0056bed360ffbmr57453qvb.1.1676712319862;
Sat, 18 Feb 2023 01:25:19 -0800 (PST)
X-Received: by 2002:a0c:e345:0:b0:56e:cfe0:b925 with SMTP id
a5-20020a0ce345000000b0056ecfe0b925mr307809qvm.52.1676712319656; Sat, 18 Feb
2023 01:25:19 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Sat, 18 Feb 2023 01:25:19 -0800 (PST)
In-Reply-To: <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f4a:533a:fdbf:9118:5dae:b015;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f4a:533a:fdbf:9118:5dae:b015
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <tsp7ek$3p077$1@dont-email.me>
<125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com> <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3e470581-f283-4677-822b-376eecfeabd5n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Sat, 18 Feb 2023 09:25:19 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3894
 by: minf...@arcor.de - Sat, 18 Feb 2023 09:25 UTC

Marcel Hendrix schrieb am Samstag, 18. Februar 2023 um 08:59:35 UTC+1:
> On Saturday, February 18, 2023 at 8:11:11 AM UTC+1, minf...@arcor.de wrote:
> > dxforth schrieb am Samstag, 18. Februar 2023 um 01:51:35 UTC+1:
> > > On 18/02/2023 12:36 am, minf...@arcor.de wrote:
> > > >
> > > > Here's with non-recursive permutation algorithm. Quick timing showed no speed
> > > > increase significant for practical purposes. Only benefit would be less 'stress' on the
> > > > return stack.
> > > Haven't measured it but appears to be less of an issue than the time taken
> > > to generate the permutations which rises factorially. The latter is likely
> > > to get you first.
> > Brute-force permutations over the 10 decimal digits 0..9 don't rise factorially unless you
> > increase the base.
> >
> > But principally you are right. The Magic Hexagon puzzle cannot be solved by calculating
> > all possible permutations over 19 positions - it would run for weeks (whereas Prolog
> > solves it within less than a second by working the constraints).
> >
> > The point is that speed matters when you are sure a priori that there is at least one solution.
> For me, there is still some magic attached to this approach. It seems obvious
> that pruning the number of paths to try would always be better than randomly
> trying them all.
>

CLP is a truly fascinating topic, very much underrated. Sniff into the basics (see page 20ff):
https://www.cs.upc.edu/~erodri/webpage/cps/theory/cp/intro/slides.pdf

Software-wise, backtracking requires keeping complete search states in memory for each branch.
Those states comprise the (so-far pruned) domains of each variable, those are big objects.
https://en.wikipedia.org/wiki/AC-3_algorithm

There is a rather compact Python constraint solver:
https://files.pythonhosted.org/packages/37/8b/5f1bc2734ca611943e1d6733ee244238679f6410a10cd45ede55a61a8402/python-constraint-1.4.0.tar.bz2
Sources are in subfolder /constraint/__init.py__

Standard Forth would have to be tooled up too much to hope to come close to it.

Re: SEND+MORE=MONEY

<01ca0bf9-e79b-46fd-ac27-7ce9c011fb1bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22436&group=comp.lang.forth#22436

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2008:b0:71f:b89c:5ac4 with SMTP id c8-20020a05620a200800b0071fb89c5ac4mr438873qka.5.1676727800254;
Sat, 18 Feb 2023 05:43:20 -0800 (PST)
X-Received: by 2002:a0c:ae89:0:b0:56c:61:bd5d with SMTP id j9-20020a0cae89000000b0056c0061bd5dmr1234996qvd.65.1676727800060;
Sat, 18 Feb 2023 05:43:20 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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.forth
Date: Sat, 18 Feb 2023 05:43:19 -0800 (PST)
In-Reply-To: <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:5912:cb3b:93e6:1136;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:5912:cb3b:93e6:1136
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <tsp7ek$3p077$1@dont-email.me>
<125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com> <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <01ca0bf9-e79b-46fd-ac27-7ce9c011fb1bn@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sat, 18 Feb 2023 13:43:20 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3881
 by: Marcel Hendrix - Sat, 18 Feb 2023 13:43 UTC

On Saturday, February 18, 2023 at 8:59:35 AM UTC+1, Marcel Hendrix wrote:
[..]
> For me, there is still some magic attached to this approach. It seems obvious
> that pruning the number of paths to try would always be better than randomly
> trying them all.
>
> -marcel

One thing that tricked me was that the best algorithm had very little variation in the
elapsed time. That is solved: I forgot that I averaged over 1000 runs. That removes
most of the magic.

Here is a graph:

FORTH> GO:
data = [
1483 11
4711 32
2281 15
787 5
1418 10
1500 10
1218 8
194 1
2748 19
757 5
3062 20
6727 45
9049 61
996 7
139 1
5418 36
1530 10
7151 47
2122 14
6732 45
2220 15
1933 12
1448 9
526 3
353 2
9012 61
7225 49
3592 24
6518 45
351 2
253 1
3328 22
5591 37
530 3
642 4
908 6
2517 16
3824 26
1385 9
3503 23
6569 44
3014 20
494 3
2379 15
458 3
1606 11
243 2
4478 29
4999 33
362 2
3765 24
5302 37
9505 65
1267 8
1490 10
6159 41
1159 8
1787 12
3057 20
3445 23
3562 24
8708 62
1368 10
3411 24
1053 7
707 4
4901 32
51 0
1579 11
1292 8
2696 18
978 6
1026 7
3886 27
7605 50
2282 15
1088 7
2847 19
1502 10
1313 9
9272 66
3985 26
855 6
903 6
7492 50
477 3
6297 42
382 2
757 5
1498 9
4803 32
3441 23
1627 11
3508 23
7551 51
2280 16
2264 15
5765 38
560 4
43 0
]; sd = sort(data);
figure(1); clf;
plot(0.001*sd(:,1),sd(:,2),'LineWidth',2); grid on;
xlabel('\bftries [x1000]'); ylabel('\bfelapsed time [\mus]'); title('\bfSEND+MORE=MONEY in iForth')

See https://ibb.co/Brp9Hcy .

So it more or less linear in time, with a very likelyhood that it more than 10,000 tries are needed.
As shown earlier, with 1000 tries 20 useconds worst-case is almost guaranteed.

-marcel

Re: SEND+MORE=MONEY

<a2e1a162-53f2-4011-90ba-f3bf75f12b49n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22437&group=comp.lang.forth#22437

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2812:b0:72b:25b4:565c with SMTP id f18-20020a05620a281200b0072b25b4565cmr37276qkp.2.1676727889857;
Sat, 18 Feb 2023 05:44:49 -0800 (PST)
X-Received: by 2002:a0c:a914:0:b0:56e:adf1:172b with SMTP id
y20-20020a0ca914000000b0056eadf1172bmr357957qva.16.1676727889622; Sat, 18 Feb
2023 05:44:49 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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.forth
Date: Sat, 18 Feb 2023 05:44:49 -0800 (PST)
In-Reply-To: <3e470581-f283-4677-822b-376eecfeabd5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:5912:cb3b:93e6:1136;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:5912:cb3b:93e6:1136
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <tsp7ek$3p077$1@dont-email.me>
<125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com> <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
<3e470581-f283-4677-822b-376eecfeabd5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a2e1a162-53f2-4011-90ba-f3bf75f12b49n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sat, 18 Feb 2023 13:44:49 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2202
 by: Marcel Hendrix - Sat, 18 Feb 2023 13:44 UTC

On Saturday, February 18, 2023 at 10:25:20 AM UTC+1, minf...@arcor.de wrote:
> Marcel Hendrix schrieb am Samstag, 18. Februar 2023 um 08:59:35 UTC+1:
> > On Saturday, February 18, 2023 at 8:11:11 AM UTC+1, minf...@arcor.de wrote:
[..]
> Standard Forth would have to be tooled up too much to hope to come close to it.

I won't bite :--)

-marcel

Re: SEND+MORE=MONEY

<8c8c2b78-5c67-452b-9461-54d7751cd3c7n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22438&group=comp.lang.forth#22438

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:7006:0:b0:3b8:6b03:c44c with SMTP id x6-20020ac87006000000b003b86b03c44cmr515211qtm.5.1676732513210;
Sat, 18 Feb 2023 07:01:53 -0800 (PST)
X-Received: by 2002:a0c:a914:0:b0:56e:adf1:172b with SMTP id
y20-20020a0ca914000000b0056eadf1172bmr392571qva.16.1676732513007; Sat, 18 Feb
2023 07:01:53 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.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.forth
Date: Sat, 18 Feb 2023 07:01:52 -0800 (PST)
In-Reply-To: <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <tsp7ek$3p077$1@dont-email.me>
<125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com> <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8c8c2b78-5c67-452b-9461-54d7751cd3c7n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Sat, 18 Feb 2023 15:01:53 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3755
 by: Hans Bezemer - Sat, 18 Feb 2023 15:01 UTC

On Saturday, February 18, 2023 at 8:59:35 AM UTC+1, Marcel Hendrix wrote:
> For me, there is still some magic attached to this approach. It seems obvious
> that pruning the number of paths to try would always be better than randomly
> trying them all.
In essence you're right. I have my stack-optimizer discarding any diagrams which
result in datastack or returnstack underflow. However, there are plenty of sequences
that are clearly detrimental like:
DUP DROP
OVER DROP
SWAP SWAP
ROT ROT ROT
>R R>
R> >R
etc.

It makes no sense to pursue those. However, this list is not exhaustive. It would
most certainly complicate the program. And since it is a brute force program, it
eliminates only a limited number of cases - while burning up CPU time in order
to pursue them. So - how much time can you reasonably save here?

A seven word solution takes less than a second. Usually - if you need a solution
that exceeds 8 words, it's usually not going to work at all (in my experience) -
and you're better off with a solution using higher order words (like 2SWAP, 2DROP).

IMHO - always be careful when optimizing. I recently did some "optimizing" - and
while benchmarking I found out that in some cases, the "optimized" solution was
actually 10% SLOWER. So I combined the old AND the new routine in order to fix
that so in the WORST case scenario both were at least equally fast - and in the BEST
case the new one was almost twice as fast.

Lesson learned - no matter how well you think you know your own compiler, always
test your solutions and challenge your own assumptions.

Hans Bezemer

---8<---
$ pp4th -x stackopt.4th abc abcabc
- Trying a 1 word solution..
No solutions.
- Trying a 2 word solution..
No solutions.
- Trying a 3 word solution..
No solutions.
- Trying a 4 word solution..
No solutions.
- Trying a 5 word solution..
No solutions.
- Trying a 6 word solution..
No solutions.
- Trying a 7 word solution..
>r over over r@ rot rot r>
---8<---

Re: SEND+MORE=MONEY

<df0dd4e2-9f16-404f-8d50-26fbf9ead358n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22440&group=comp.lang.forth#22440

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:96d:b0:56e:af7f:95be with SMTP id do13-20020a056214096d00b0056eaf7f95bemr135104qvb.8.1676736784386;
Sat, 18 Feb 2023 08:13:04 -0800 (PST)
X-Received: by 2002:a05:620a:151c:b0:73b:a5c3:7e8b with SMTP id
i28-20020a05620a151c00b0073ba5c37e8bmr848207qkk.7.1676736784215; Sat, 18 Feb
2023 08:13:04 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.forth
Date: Sat, 18 Feb 2023 08:13:04 -0800 (PST)
In-Reply-To: <8c8c2b78-5c67-452b-9461-54d7751cd3c7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:5912:cb3b:93e6:1136;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:5912:cb3b:93e6:1136
References: <78cfcd0a-5bc4-4584-8a92-9e8005a0e306n@googlegroups.com>
<87ttzvzmmb.fsf@nightsong.com> <2023Feb9.084758@mips.complang.tuwien.ac.at>
<87pmaiztp1.fsf@nightsong.com> <87h6vuzl8v.fsf@nightsong.com>
<2023Feb10.113948@mips.complang.tuwien.ac.at> <87bklxux2b.fsf@nightsong.com>
<3f8e2c0c-f72b-41f6-ac0f-5b115cfd0530n@googlegroups.com> <tsgfb7$2j21e$1@dont-email.me>
<7dee5cf0-c8e9-4997-8eb3-54484a049523n@googlegroups.com> <a49435d0-2aed-427e-85b0-2c0df997bb2cn@googlegroups.com>
<ff70b327-2396-44bd-91c2-d0bb54dd23d6n@googlegroups.com> <tsp7ek$3p077$1@dont-email.me>
<125c1842-65f2-4a3e-8d43-9575d39e300en@googlegroups.com> <19036f44-6789-42bc-8fe7-3633a1a707a0n@googlegroups.com>
<8c8c2b78-5c67-452b-9461-54d7751cd3c7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <df0dd4e2-9f16-404f-8d50-26fbf9ead358n@googlegroups.com>
Subject: Re: SEND+MORE=MONEY
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sat, 18 Feb 2023 16:13:04 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3017
 by: Marcel Hendrix - Sat, 18 Feb 2023 16:13 UTC

On Saturday, February 18, 2023 at 4:01:54 PM UTC+1, Hans Bezemer wrote:
> On Saturday, February 18, 2023 at 8:59:35 AM UTC+1, Marcel Hendrix wrote:
[..]
> Hans Bezemer
>
> ---8<---
> $ pp4th -x stackopt.4th abc abcabc
> - Trying a 1 word solution..
> No solutions.
> - Trying a 2 word solution..
> No solutions.
> - Trying a 3 word solution..
> No solutions.
> - Trying a 4 word solution..
> No solutions.
> - Trying a 5 word solution..
> No solutions.
> - Trying a 6 word solution..
> No solutions.
> - Trying a 7 word solution..
> >r over over r@ rot rot r>
> ---8<---

: XINVERT5 PARAMS| a b c d e | e d c b a ;
: test 1 2 3 4 5 xinvert5 - - - * . ;

FORTH> see test
Flags: ANSI
$01348540 : test
$0134854A push #10 b#
$0134854C jmp .+10 ( $0124A102 ) offset NEAR
$01348551 ;
FORTH> test 10 ok

FORTH> : 3dup PARAMS| a b c | a b c a b c ;
Redefining `3dup` ok
FORTH> : test 1 2 3 3dup + - + - + . ;
Redefining `test` ok
FORTH> see test
Flags: ANSI
$013485C0 : test
$013485CA push 4 b#
$013485CC jmp .+10 ( $0124A102 ) offset NEAR
$013485D1 ;
FORTH> test 4 ok

-marcel


devel / comp.lang.forth / Re: SEND+MORE=MONEY

Pages:12345
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor