Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

84%
+9 −0
Challenges Evaluate a single variable polynomial equation

APL (Dyalog Unicode), 11 3 1 byte ⊥ Try it online! Anyone who can golf this further gets a cookie! Function submission which takes reversed coefficients as right argument and $x$ as left ar...

posted 4y ago by Razetime‭  ·  edited 4y ago by Razetime‭

Answer
#5: Post edited by user avatar Razetime‭ · 2020-11-15T05:58:24Z (about 4 years ago)
-2 bytes
  • # [APL (Dyalog Unicode)], <sup><del>11</del></sup> 3 bytes
  • <!-- language-all: lang-apl -->
  • ∘⌽
  • [Try it online!][TIO-khik693b]
  • [APL (Dyalog Unicode)]: https://www.dyalog.com/
  • [TIO-khik693b]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/x91LX3UMeNRz97/aUD@o96@R13Nj3rXPOrdcmi98aO2iUCVwUHOQDLEwzP4v6GFkUKagoahJpcJmNYx0uQy0DMFsY30TEE8QwjPUM9AxwiIjYHYRM9AEwA "APL (Dyalog Unicode) – Try It Online"
  • Function submission which takes coefficients as right argument and \$x\$ as left argument.
  • -8 bytes from dzaima and rak1507([APL Orchard](https://chat.stackexchange.com/transcript/message/56155063#56155063)).
  • Uses a simple decode.
  • # [APL (Dyalog Unicode)], <sup><del>11</del></sup> <sup><del>3</del></sup> 1 byte
  • <!-- language-all: lang-apl -->
  • [Try it online!][TIO-khiphjoa]
  • [APL (Dyalog Unicode)]: https://www.dyalog.com/
  • [TIO-khiphjoa]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/x91Lf2fBmQ96u171NX8qHfNo94th9YbP2qbCFQTHOQMJEM8PIP/G1oYKaQpPOrZq2GoyWUCY@oYaXIZ6JlCuUZ6piABQ7iAoZ6BjhEQGwOxiZ6BJgA "APL (Dyalog Unicode) – Try It Online"
  • Anyone who can golf this further gets a cookie!
  • Function submission which takes reversed coefficients as right argument and \$x\$ as left argument.
  • -8 bytes from dzaima and rak1507([APL Orchard](https://chat.stackexchange.com/transcript/message/56155063#56155063)).
  • -2 bytes from Adám‭.
  • Uses a mixed base conversion.
#4: Post edited by user avatar Razetime‭ · 2020-11-15T03:39:53Z (about 4 years ago)
  • # [APL (Dyalog Unicode)], <strike><sup>11</strike></sup> 3 bytes
  • <!-- language-all: lang-apl -->
  • ⊥∘⌽
  • [Try it online!][TIO-khik693b]
  • [APL (Dyalog Unicode)]: https://www.dyalog.com/
  • [TIO-khik693b]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/x91LX3UMeNRz97/aUD@o96@R13Nj3rXPOrdcmi98aO2iUCVwUHOQDLEwzP4v6GFkUKagoahJpcJmNYx0uQy0DMFsY30TEE8QwjPUM9AxwiIjYHYRM9AEwA "APL (Dyalog Unicode) – Try It Online"
  • Function submission which takes coefficients as right argument and \$x\$ as left argument.
  • -8 bytes from dzaima and rak1507([APL Orchard](https://chat.stackexchange.com/transcript/message/56155063#56155063)).
  • Uses a simple decode.
  • # [APL (Dyalog Unicode)], <sup><del>11</del></sup> 3 bytes
  • <!-- language-all: lang-apl -->
  • ⊥∘⌽
  • [Try it online!][TIO-khik693b]
  • [APL (Dyalog Unicode)]: https://www.dyalog.com/
  • [TIO-khik693b]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/x91LX3UMeNRz97/aUD@o96@R13Nj3rXPOrdcmi98aO2iUCVwUHOQDLEwzP4v6GFkUKagoahJpcJmNYx0uQy0DMFsY30TEE8QwjPUM9AxwiIjYHYRM9AEwA "APL (Dyalog Unicode) – Try It Online"
  • Function submission which takes coefficients as right argument and \$x\$ as left argument.
  • -8 bytes from dzaima and rak1507([APL Orchard](https://chat.stackexchange.com/transcript/message/56155063#56155063)).
  • Uses a simple decode.
#3: Post edited by user avatar Razetime‭ · 2020-11-15T03:33:54Z (about 4 years ago)
-8 bytes
  • # [APL (Dyalog Unicode)], 11 [bytes](https://github.com/abrudz/SBCS)
  • <!-- language-all: lang-apl -->
  • {+/⍺×⍵*⍳≢⍺}
  • [Try it online!][TIO-khh92dss]
  • [APL (Dyalog Unicode)]: https://www.dyalog.com/
  • [TIO-khh92dss]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/6u19R/17jo8/VHvVq1HvZsfdS4Ccmv/pwElH/X2PepqftS75lHvlkPrjR@1TQRqCw5yBpIhHp7B/zUMNRXSFAwtjLg0DHWMQGwTLg0jPVMI20DPFCiuZ6CjYAQijEGEiZ4BWIueKQA "APL (Dyalog Unicode) – Try It Online"
  • Function submission which takes coefficients as left argument and \$x\$ as right argument.
  • Assumes `⎕IO←0` (0-indexing)
  • ## Explanation
  • ```
  • {+/⍺×⍵*⍳≢⍺}
  • ≢⍺ length of the coefficients
  • ⍳ range 0..length-1
  • ⍵* x to the power of each of those
  • ⍺× multiply that by the coefficients
  • +/ and fold the list by addition(sum it)
  • # [APL (Dyalog Unicode)], <strike><sup>11</strike></sup> 3 bytes
  • <!-- language-all: lang-apl -->
  • ⊥∘⌽
  • [Try it online!][TIO-khik693b]
  • [APL (Dyalog Unicode)]: https://www.dyalog.com/
  • [TIO-khik693b]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/x91LX3UMeNRz97/aUD@o96@R13Nj3rXPOrdcmi98aO2iUCVwUHOQDLEwzP4v6GFkUKagoahJpcJmNYx0uQy0DMFsY30TEE8QwjPUM9AxwiIjYHYRM9AEwA "APL (Dyalog Unicode) – Try It Online"
  • Function submission which takes coefficients as right argument and \$x\$ as left argument.
  • -8 bytes from dzaima and rak1507([APL Orchard](https://chat.stackexchange.com/transcript/message/56155063#56155063)).
  • Uses a simple decode.
#2: Post edited by user avatar Razetime‭ · 2020-11-14T14:43:34Z (about 4 years ago)
  • # [APL (Dyalog Unicode)], 22 [bytes](https://github.com/abrudz/SBCS)
  • <!-- language-all: lang-apl -->
  • {+/⍺×⍵*⍳≢⍺}
  • [Try it online!][TIO-khh92dss]
  • [APL (Dyalog Unicode)]: https://www.dyalog.com/
  • [TIO-khh92dss]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/6u19R/17jo8/VHvVq1HvZsfdS4Ccmv/pwElH/X2PepqftS75lHvlkPrjR@1TQRqCw5yBpIhHp7B/zUMNRXSFAwtjLg0DHWMQGwTLg0jPVMI20DPFCiuZ6CjYAQijEGEiZ4BWIueKQA "APL (Dyalog Unicode) – Try It Online"
  • Function submission which takes coefficients as left argument and \$x\$ as right argument.
  • Assumes `⎕IO←0` (0-indexing)
  • ## Explanation
  • ```
  • {+/⍺×⍵*⍳≢⍺}
  • ≢⍺ length of the coefficients
  • ⍳ range 0..length-1
  • ⍵* x to the power of each of those
  • ⍺× multiply that by the coefficients
  • +/ and fold the list by addition(sum it)
  • # [APL (Dyalog Unicode)], 11 [bytes](https://github.com/abrudz/SBCS)
  • <!-- language-all: lang-apl -->
  • {+/⍺×⍵*⍳≢⍺}
  • [Try it online!][TIO-khh92dss]
  • [APL (Dyalog Unicode)]: https://www.dyalog.com/
  • [TIO-khh92dss]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/6u19R/17jo8/VHvVq1HvZsfdS4Ccmv/pwElH/X2PepqftS75lHvlkPrjR@1TQRqCw5yBpIhHp7B/zUMNRXSFAwtjLg0DHWMQGwTLg0jPVMI20DPFCiuZ6CjYAQijEGEiZ4BWIueKQA "APL (Dyalog Unicode) – Try It Online"
  • Function submission which takes coefficients as left argument and \$x\$ as right argument.
  • Assumes `⎕IO←0` (0-indexing)
  • ## Explanation
  • ```
  • {+/⍺×⍵*⍳≢⍺}
  • ≢⍺ length of the coefficients
  • ⍳ range 0..length-1
  • ⍵* x to the power of each of those
  • ⍺× multiply that by the coefficients
  • +/ and fold the list by addition(sum it)
#1: Initial revision by user avatar Razetime‭ · 2020-11-14T05:32:20Z (about 4 years ago)
# [APL (Dyalog Unicode)], 22 [bytes](https://github.com/abrudz/SBCS)

<!-- language-all: lang-apl -->

    {+/⍺×⍵*⍳≢⍺}

[Try it online!][TIO-khh92dss]

[APL (Dyalog Unicode)]: https://www.dyalog.com/
[TIO-khh92dss]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/6u19R/17jo8/VHvVq1HvZsfdS4Ccmv/pwElH/X2PepqftS75lHvlkPrjR@1TQRqCw5yBpIhHp7B/zUMNRXSFAwtjLg0DHWMQGwTLg0jPVMI20DPFCiuZ6CjYAQijEGEiZ4BWIueKQA "APL (Dyalog Unicode) – Try It Online"

Function submission which takes coefficients as left argument and \$x\$ as right argument.

Assumes `⎕IO←0` (0-indexing)

## Explanation
```
{+/⍺×⍵*⍳≢⍺}
        ≢⍺  length of the coefficients
       ⍳     range 0..length-1
     ⍵*      x to the power of each of those
   ⍺×        multiply that by the coefficients
 +/          and fold the list by addition(sum it)