Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Inputs Output
- 1 1 1 1
- 3 4 5 1.25
- 42 42 3.14 ≈ 6.9476
- 14 6 12 1.575
- 6 12 14 1.575
- 0.5 0.6 0.7 ≈ 1.09375
- S_Ḥ⁸÷P
- Implicit argument [a, b, c].
- S Take the sum, a+b+c or 2*s
- Ḥ Take the double, [2*a, 2*b, 2*c].
- _ Vectorized subtract, giving us [2*(s-a), 2*(s-b), 2*(s-c)].
- ⁸÷ Vectorized divide the initial left argument, the input [a, b, c],
- by [2*(s-a), 2*(s-b), 2*(s-c)].
- P Take the product giving us the aspect ratio, abc/8(s-a)(s-b)(s-c).
- SH_÷@HP
- S÷_2Pİ
- S÷_2Pİ Main link. Argument: [a, b, c]
- S Sum; compute 2s := a + b + c.
- ÷ Divide; yield [2s ÷ a, 2s ÷ b, 2s ÷ c].
- _2 Subtract 2; yield [2s ÷ a - 2, 2s ÷ b - 2, 2s ÷ c - 2].
- P Product; yield (2s ÷ a - 2)(2s ÷ b - 2)(2s ÷ c - 2).
- İ Invert; yield 1 ÷ (2s ÷ a - 2)(2s ÷ b - 2)(2s ÷ c - 2).
- a=>b=>c=>a*b*c/(b+c-a)/(a+c-b)/(a+b-c)
- tsGE-/p
- t % Take input implicitly. Duplicate
- % STACK: [3 4 5], [3 4 5]
- s % Sum of array
- % STACK: [3 4 5], 12
- G % Push input again
- % STACK: [3 4 5], 12, [3 4 5]
- E % Multiply by 2, element-wise
- % STACK: [3 4 5], 12, [6 8 10]
- - % Subtract, element-wise
- % STACK: [3 4 5], [6 4 2]
- / % Divide, element-wise
- % STACK: [0.5 1 2.5]
- p % Product of array. Implicitly display
- % STACK: 1.25
- O¹·-¹/P
- O # sum input
- ¹ # push input again
- · # multiply by 2
- - # subtract from sum
- ¹/ # divide by input
- P # product
- x=scan();prod(x/(sum(x)-2*x))
- (a#b)c=a*b*c/(b+c-a)/(a+c-b)/(a+b-c)
- p=product
- f v=p v/p((sum v-).(2*)<$>v)
- @(v)prod(v./(sum(v)-2*v))
- sum(v) = 3+4+5 = 12
- sum(v)-2*v = 12 - 2*[3,4,5] = 12 - [6,8,10] = [6,4,2]
- v./(sum(v)-2*v)) = [3,4,5] ./ [6,4,2] = [0.5,1,2.5]
- prod(v./(sum(v)-2*v)) = 0.5 * 1 * 2.5 = 1.25
- 1##&@@(#/(Tr@#-2#))&
- fun a b c->a*.b*.c/.(b+.c-.a)/.(a+.c-.b)/.(a+.b-.c)
- @@@prod[#0#1#2/1- +#1#0#2/1- +#2#0#1/1- +#2#1#0]
- (((@@@prod[#0#1#2/1* * - +#1#0#2- +#2#0#1- +#2#1#0])3)4)5
- (a,b,c)=>product([a,b,c,1/(b+c-a),1/(a+c-b),1/(a+b-c)])
- ;Σ♀/♂¬πì
- Implicit input [a, b, c].
- ; Duplicate [a, b, c].
- Σ sum() to get twice the semiperimeter, 2*s.
- ♀/ Vectorized divide 2*s by [a, b, c] to get [2*s/a, 2*s/b, 2*s/c].
- ♂¬ Vectorized subtract 2 to get [2*s/a-2, 2*s/b-2, 2*s/c-2].
- π Get the product of the above to get 8*(s/a-1)*(s/b-1)*(s/c-1).
- This is the same as 8(s-a)(s-b)(s-c)/abc.
- ì Invert to get the aspect ratio, abc/8(s-a)(s-b)(s-c).
- Implicit return.
- (a,b,c)->a*b*c/(b+c-a)/(a-b+c)/(a+b-c)
- public class Pcg101234 {
- interface F {
- double f(double a, double b, double c);
- }
- public static void main(String[] args) {
- F f = (a,b,c)->a*b*c/(b+c-a)/(a-b+c)/(a+b-c);
- System.out.println(f.f(1,1,1));
- System.out.println(f.f(3,4,5));
- System.out.println(f.f(42,42,3.14));
- System.out.println(f.f(14,6,12));
- System.out.println(f.f(6,12,14));
- System.out.println(f.f(0.5,0.6,0.7));
- }
- }
- 1.0
- 1.25
- 6.947606226693615
- 1.575
- 1.575
- 1.09375
- p%/*-)/+i
- 2%
- print(
- 1 / fold(
- multiply,
- fold(add, i) / i - 2
- )
- )
- print(1 / product(sum(i) / i - 2))
- Os/ÍPz
- 5k?dsa?dsb?dsc++2/sslalblc**lsla-lslb-lslc-8***/p
- 5k # Set the output precision to 5 digits after the decimal
- ?dsa # Prompt for first input value on first line, duplicate it, and then store it in register `a`
- ?dsb # Prompt for second input, duplicate it, and store it in register `b`
- ?dsc # Prompt for third input, duplicate it, and store it in register `c`
- ++2/ss # Sum up the 3 values on the main stack, then divide sum by 2 and store the result in register `s`
- lalblc** # Copy all three values from registers `a`,`b`,`c` onto the main stack, find their product, and push result to top of main stack
- lsla- # Copy value from register `s` onto main stack, subtract register `a`'s value from it, and push result to main stack
- lslb- # Copy value from register `s` onto main stack, subtract register `b`'s value from it, and push result to main stack
- lslc- # Copy value from register `s` onto main stack, subtract register `c`'s value from it, and push result to main stack
- 8*** # Find the product of the top three values and 8 and then push the result to main stack
- /p # Divide the second to top value (a*b*c) by the top of stack value (8*(s-a)*(s-b)*(s-c)), push the result to the main stack, and then output the result to STDOUT
- prod(Ans)/prod(sum(Ans)-2Ans
- ->a,b,c{a*b*c/(b+c -a)/(a+c -b)/(a+b -c)}
- def f(x,y,z):s=x+y+z;return 1/((s/x-2)*(s/y-2)*(s/z-2))
- : p 3 fpick ;
- : T p p p ;
- : f 0 s>f T f- f+ f- T f+ f- f* T f- f- f* 1/f f* f* f* ;
- 3 fpick takes the 3rd element (0-indexed) and pushes a copy
- Used to copy parameters on the stack over another number 'x' ( a b c x -> a b c x a b c )
- : f3p 3 fpick 3 fpick 3 fpick ;
- : f define a function f
- 0 s>f f3p f- f+ f- push a zero, copy params, compute 0-(a+b-c)
- the zero allows me to copy (I need an 'x' to jump over)
- f3p f+ f- f* copy params and compute -(b+c-a), multiply by previous result
- the negatives miraculously cancel
- f3p f- f- f* copy and compute (a+c-b), multiply by previous result
- 1/f f* f* f* ; take the reciprocal and multiply by a*b*c
- the result is left on the floating point stack
- @*$1/@*{@+$1-2.*$1}
- Π$1/Π{Σ$1-2.*$1}
- Function r(a,b,c)
- s=(a+b+c)/2:r=(a*b*c)/(8*(s-a)*(s-b)*(s-c))
- End Function
- void ar(double a,double b,double c)=>Console.Write(a*b*c/(b+c-a)/(a+c-b)/(a+b-c));
- ar(42, 42, 3.14);
- 1QFQsR/tt)B/
- {(*/x)%8*/-x-+/x%2}
- a,b,c=...print(a*b*c/(b+c-a)/(a+c-b)/(a+b-c))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement