| Bytes | Lang | Time | Link |
|---|---|---|---|
| 038 | Zsh | 241221T095826Z | roblogic |
| 087 | brainfuck | 241220T135333Z | WeirdGly |
| 050 | Python 3 | 241205T205028Z | Fmbalbue |
| 034 | AWK | 241206T184421Z | xrs |
| 028 | R | 241205T142306Z | Eonema |
| 027 | R | 241205T133445Z | pajonk |
| 008 | APL+WIN | 241205T101702Z | Graham |
| 007 | Charcoal | 241205T105326Z | Neil |
| 046 | PowerShell | 241205T104828Z | user3141 |
| 002 | 05AB1E | 241205T102119Z | Kevin Cr |
| 042 | JavaScript Node.js | 241205T094207Z | l4m2 |
| 005 | APL Dyalog 20.0 | 241205T093817Z | Adá |
| 010 | Vyxal 3 | 241205T094007Z | Themooni |
Zsh, 38 bytes
for m ({1..$4})bc<<<"$1*$m^2+$m*$2+$3"
Similar to my previous solution. M, N, C, V are passed as arguments $1 $2 $3 $4.
brainfuck, 87 bytes
+>>,>>,>,>,[-<<[-<+>>+<]<[->+<]<[-<+<[-<+>>>>+<<<]<[->+<]>>>]<[->+<]<++>>>[->>+<<]>>.>]
Well, since I already made a program for the first part of this challenge, I might as well try to do the second one. Obviously, like the previous answer, this only works with integers and input/output is done in binary (non-competing answer). This code is a bit longer than the previous one because it requires at least one multiplication. However, this is still something Brainfuck can manage, since: $$y \times x^2 = y \times (1 + 3 + 5 + \cdots) = y \times 1 + y \times 3 + y \times 5 + \cdots$$
So the only thing that's required is to use an accumulator starting with 1, calculate the product between the accumulator and M, add to C, and finally increment the accumulator by 2 after each loop. Here's a quick explanation of the code:
+>>,>>,>,>, set up (tempAcc=0 Acc=1 tempM=0 M tempSum=0 N C V)
[ while V != 0:
-<<[-<+>>+<]<[->+<] same as part 1
<[-<+< while M != 0:
[-<+>>>>+<<<]<[->+<] tempSum = Acc * M
>>>]<[->+<]<++> add 2 to Acc
>>[->>+<<]>>.>] add tempSum to C; print(C)
I think that's pretty much it, since the third part would be way harder to do with Brainfuck.
Python 3, 52, 50 bytes
lambda M,N,C,V:[M*A*A+N*A+C for A in range(1,V+1)]
Thanks to Unrelated String for saving 2 bytes.
APL+WIN, 17 8 bytes
Thanks to Adam for a saving of 9 bytes.
Prompts for a vector of coefficients matching the order of the polynomial followed by the number of points.
(⍳⎕)⊥¨⊂⎕
Charcoal, 7 bytes
IEθ↨⊕ιη
Try it online! Link is to verbose version of code. Takes input in JSON format as V and a list of M, N, C. Explanation:
θ Input `V`
E Map over implicit range
η Input list `M, N, C`
↨ Evaluate polynomial
ι Current value
⊕ Incremented
I Cast to string
Implicitly print
PowerShell, 46 bytes
iex('1..{3}|%{{{0}*$_*$_+{1}*$_+{2}}}'-f$args)
Basically the same solution as in the earlier post: it's shorter to use the-f format operator to generate a string that is than invoked (iex) as PowerShell command, than to write out the loop directly.
05AB1E, 2 bytes
Lβ
This challenge made me realize a golf on my answer for the previous challenge, so both are now exactly the same.
Two loose inputs in the order and format \$V\$ and \$[M,N,C]\$.
Try it online or verify all test cases. (Test cases taken from @Adám's APL answer.)
Explanation:
L # Push a list in the range [1, first (implicit) input V]
β # Convert the second (implicit) input-triplet [M,N,C] from a base-v list to
# base-10 integers for each v in the [1,V]-ranged list
# (after which this list is output implicitly)
JavaScript (Node.js), 42 bytes
(m,n,c)=>g=v=>v?[...g(v-1),m*v*v+n*v+c]:[]
Linear solution is 1 bytes longer:
(m,n,c)=>g=v=>v?[c+=n+=m,...g(v-1,n+=m)]:[]
APL (Dyalog 20.0), 5 bytes
Anonymous tacit infix function, taking V as left argument and [M,N,C] as right argument.
⍪⍤⍳⍛⊥
Try it online! (emulation due to old TIO version)
…⍛⊥ evaluate in mixed-base, but first pre-process the left argument as follows:
…⍤⍳ expanding to the indices 1…V, and then:
⍪ transform into a column vector (matches up the entire [M,N,C] with each of 1…V)
Vyxal 3, 10 bytes
ɾ:²?×$?×++
taking heavy inspiration from pacman's answer on the previous post
ɾ:²?×$?×++
ɾ # range 1..V
: # duplicate the range
²?× # square and multiply by M
$?× # fetch other copy of the range and multiply by N
+ # add MX²+NX
+ # add C
# implicit output
💎
Created with the help of Luminespire.