Post Reply 
[VA] My 2024's very first little teaser
01-23-2024, 10:22 PM (This post was last modified: 01-23-2024 10:23 PM by Valentin Albillo.)
Post: #9
RE: [VA] My 2024's very first little teaser
.
Hi, J-F,

(01-22-2024 03:56 PM)J-F Garnier Wrote:  Here is my solution in 3 BASIC lines and 127 bytes:

20 DESTROY ALL @ OPTION BASE 1 @ DIM U(3),V(3),W(3),M(3,3) @ MAT INPUT U,V,W
40 M(1,2)=W(3) @ M(1,3)=W(2) @ M(2,1)=W(3) @ M(2,3)=W(1) @ M(3,1)=W(2) @ M(3,2)=W(1)
50 MAT V=M*V @ DISP DOT(U,V)


You will notice that there is a '*' sign, but it denotes a matrix multiplication, not an arithmetic operation, so I believe that it is allowed here.

Sorry but no, that appearance of * in MAT V=M*V isn't acceptable and renders your solution invalid. As I made it clear in the requiremens, no +, -, *, / operators are acceptable, and I made no distinction between scalar and matrix operators, matter of fact I didn't even mention scalars or matrices at all, so the requirement applies to both and the spirit of the rule is that those characters should not appear in the code listing at all, no exceptions.

The reason why the MAT prefix must appear when the variables operated upon are matrices has historical roots, as the first implementaations of BASIC already featured the MAT prefix. From Wikipedia:
    "The first version BASIC language was released on 1 May 1964. Initially, BASIC concentrated on supporting straightforward mathematical work, with matrix arithmetic support from its initial implementation [...]"

so that the interpreter would consider (LET) C=A*B to be an scalar expression while MAT C=A*B would be treated as a matrix expression. Today, the MAT prefix might be substituted by operator overload, with (e.g.) * being used for scalar real/complex variables, real/complex matrix variables, etc., as is the case with the HP-15C, where the one-and-only [x] key can multiply scalars, matrices, scalar-matrix, complex values, etc.

This means that your MAT V=M*V is using the * operator exactly as V=M*V does, only adding the MAT prefix to indicate that the operator is operating on matrices instead of on scalar values, and so explictly including that operator in your code is disallowed (also, note that the HP-71B doesn't allow a matrix variable and a scalar variable to share the same name so the interpreter could have distinguished what flavor of the operator to apply based on the name and declaration of the variables involved with no need for a MAT prefix, but this would be non-standard BASIC syntax, certainly not ANSI-compliant.)

Finally, you say above: "there is a '*' sign, but it denotes a matrix multiplication, not an arithmetic operation", which I take it to mean that matrix multiplication is a different operation than scalar multiplication. But then, nothing in the requirements specifies that you can't use 1x1 matrices, so if I left that loophole in place then nothing prevents you from declaring your variables as 1x1 matrices, having just the one, single element, and then matrix multiplication reduces to purely scalar multiplication, isn't it ?

This trick, using 1x1 matrices and using MAT C=A*B (and MAT C=A+B) renders the whole matter utterly trivial and uninteresting. And you know from experience that my challenges, mini-challenges and teasers are all but trivial and unintertesting, so believe me if I tell you that there's much more here than meets the eye. Smile

I'll post my solutions (two of them) and comments next Thursday, 25th, so you have until then to amend your solution and even improve it if you feel like it.

Thanks for your continued interest and best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] My 2024's very first little teaser - Valentin Albillo - 01-23-2024 10:22 PM



User(s) browsing this thread: 3 Guest(s)