Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Dyalog APL , (削除) 22 (削除ここまで)(削除) 21 (削除ここまで) 15 bytes

Dyalog APL , (削除) 22 (削除ここまで)(削除) 21 (削除ここまで) 15 bytes

.5∘(×ばつ.*⍨)⍣⎕

Takes (a,b) as right argument, and prompts for n:

(

×ばつ dot product of 0.5 and the right argument

, followed by

×ばつ.*⍨ "dot power" of the right argument and 0.5*

)⍣⎕ applied numeric-prompt times.

* "dot power" is like dot product, but using multiplication and power instead of plus and multiplication, as follows:

n
A ×ばつ.*⍨ B is BiA = B1AB2A
i=1

-3 bytes thanks to ngn.


Old version:

{((+/÷≢)×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘

#Dyalog APL , (削除) 22 (削除ここまで)(削除) 21 (削除ここまで) 15 bytes

.5∘(×ばつ.*⍨)⍣⎕

Takes (a,b) as right argument, and prompts for n:

(

×ばつ dot product of 0.5 and the right argument

, followed by

×ばつ.*⍨ "dot power" of the right argument and 0.5*

)⍣⎕ applied numeric-prompt times.

* "dot power" is like dot product, but using multiplication and power instead of plus and multiplication, as follows:

n
A ×ばつ.*⍨ B is BiA = B1AB2A
i=1

-3 bytes thanks to ngn.


Old version:

{((+/÷≢)×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘

Dyalog APL , (削除) 22 (削除ここまで)(削除) 21 (削除ここまで) 15 bytes

.5∘(×ばつ.*⍨)⍣⎕

Takes (a,b) as right argument, and prompts for n:

(

×ばつ dot product of 0.5 and the right argument

, followed by

×ばつ.*⍨ "dot power" of the right argument and 0.5*

)⍣⎕ applied numeric-prompt times.

* "dot power" is like dot product, but using multiplication and power instead of plus and multiplication, as follows:

n
A ×ばつ.*⍨ B is BiA = B1AB2A
i=1

-3 bytes thanks to ngn.


Old version:

{((+/÷≢)×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘
-6
Source Link
Adám
  • 31.8k
  • 4
  • 131
  • 292

#Dyalog APL, (削除) 22 (削除ここまで) 21(削除) 21 (削除ここまで) 15 bytes {(

.5∘(×ばつ.*⍨)⍣⎕

Takes (+/÷≢a,b) as right argument, and prompts for n:

(

×ばつ dot product of 0.×ばつ/)⍣⍺⊢⍵}5 and the right argument

, followed by

×ばつ.*⍨ "dot power" of the right argument and 0.5*

)⍣⎕ applied numeric-prompt times.

* "dot power" is like dot product, but using multiplication and power instead of plus and multiplication, as follows:

n
A ×ばつ.*⍨ B is BiA = B1AB2A
i=1

-3 bytes thanks to ngn.


Old version:

{((+/÷≢)×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘

#Dyalog APL, (削除) 22 (削除ここまで) 21 bytes {((+/÷≢),.×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘

#Dyalog APL, (削除) 22 (削除ここまで) (削除) 21 (削除ここまで) 15 bytes

.5∘(×ばつ.*⍨)⍣⎕

Takes (a,b) as right argument, and prompts for n:

(

×ばつ dot product of 0.5 and the right argument

, followed by

×ばつ.*⍨ "dot power" of the right argument and 0.5*

)⍣⎕ applied numeric-prompt times.

* "dot power" is like dot product, but using multiplication and power instead of plus and multiplication, as follows:

n
A ×ばつ.*⍨ B is BiA = B1AB2A
i=1

-3 bytes thanks to ngn.


Old version:

{((+/÷≢)×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘
added 30 characters in body
Source Link
Adám
  • 31.8k
  • 4
  • 131
  • 292

APL, (削除) 22 (削除ここまで) 21 bytes

{((+/÷≢)×ばつ/)⍣⍺⊢⍵}

#Dyalog APL , (削除) 22 (削除ここまで) 21 bytes {((+/÷≢)×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘

APL, (削除) 22 (削除ここまで) 21 bytes

{((+/÷≢)×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘

#Dyalog APL , (削除) 22 (削除ここまで) 21 bytes {((+/÷≢)×ばつ/)⍣⍺⊢⍵}

Takes n as left argument and a b as right argument.

⊢⍵ On the RightArg
(...)⍣⍺ recalculate LeftArg times
(+/÷≢) sum divided by tally
, followed by
×ばつ/ the square root of the product.

All the test cases:

 f←{((×ばつ+/)×ばつ/)⍣⍺⊢⍵}
 0 1 2 5 10 10 f ̈ (24 6)(24 6)(24 6)(24 6)(100 50)(1,2*.5)
┌────┬─────┬────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│24 6│15 12│13.5 13.41640786│13.45817148 13.45817148│72.83955155 72.83955155│1.198140235 1.198140235│
└────┴─────┴────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘
Saved one char by not assuming arg len
Source Link
Adám
  • 31.8k
  • 4
  • 131
  • 292
Loading
Source Link
Adám
  • 31.8k
  • 4
  • 131
  • 292
Loading

AltStyle によって変換されたページ (->オリジナル) /