text:
Golf an LZW encoder
Given an alphabet and a string, your job is to create the
Lempel–Ziv–Welch compression of the string. Your implementation can either be a function with
two parameters and a return value, or a full program that uses stdin and
stdout.
Input

The alphabet, in the form of a string, from which you will have to create
the initial dictionary: Each character should be mapped to its index in the
string, where the first index is 0. You will be expanding this dictionary as
you iterate through the algorithm.
The string to be compressed.

Output

The compressed string in the form of dictionary keys. This must be an array of
integers if you're creating a function, or printed integers separated by either
whitespace or newline (and nothing else) if you're making a full program.

Algorithm
After you have initialized the dictionary, the algorithm goes something like this:

Find the longest string W in the dictionary that matches the current input.
Emit the dictionary index for W to output and remove W from the input.
Add W followed by the next symbol in the input to the dictionary.
Repeat

Examples
"ABC", "AABAACABBA"  ==>  [0,0,1,3,2,4,5]
"be torn", "to be or not to be"  ==> [3,4,2,0,1,2,4,5,2,6,4,3,2,7,9,1]

Rules

No use of external resources
No predefined built-in functions or libraries of any kind that solves the problem for you.
Fore!

GolfScript (52 51 chars)
{[\1/\{\.{.,3$<=},-1=.2$?@@,:L)[3$<]+@L>.}do;;]}:C;

Online demo
Dissection
{  }:C;

is standard function boilerplate.
# Wrap the values we compute in an array
[
    # Stack: alphabet uncompressed-string
    # Split the alphabet from a string into an array of 1-char strings
    \1/\
    # Stack: dictionary uncompressed-string
    {
        # Stack: ... dictionary uncompressed-string-suffix
        # Find the dictionary elements which are prefixes of uncompressed-string-suffix
        \.{.,3$<=},
        # The last of them must be the longest by construction
        -1=
        # Stack: ... uncompressed-string-suffix dictionary prefix
        # Find the index of prefix in dictionary
        .2$?
        # Stack: ... uncompressed-string-suffix dictionary prefix index
        # Push index down the stack
        @@
        # Stack: ... uncompressed-string-suffix index dictionary prefix
        # Assign len(prefix) to L and append a 1-char-longer prefix to dictionary
        ,:L)[3$<]+
        # Fetch up the uncompressed-string-suffix and chop off the first L chars
        @L>
        # Stack: ... index dictionary' uncompressed-string-suffix'
        # Duplicate uncompressed-string-suffix' for the do-loop condition test
        .
    }do
    # Stack: index0 index1 ... indexN dictionary' ""
    # Pop the last two to leave just the indexes
    ;;
]

I would probably upvote this if you provided an explanation of how it works :)

Python (141 Characters)
def a(b,c,r=[]):
    if c:l,i,d=max((len(d),i,d) for i,d in enumerate(b) if c.find(d)==0)
    return a(list(b)+[c[:l+1]],c[l:],r+[i]) if c else r

Not golfed very small, but no chance of beating any of the golfscript solutions anyway.

Racket/R5RS Scheme: 359 bytes
(define(l d i)(let*((h(make-hash))(s string->list)(r(λ(x)(hash-ref h x #f)))(i(s i))(s(let l((s 0)(d(s d)))(if(null? d)s
(and(hash-set! h(car d)s)(l(+ s 1)(cdr d)))))))(let l((i(cdr i))(c(r(car i)))(o'())(s s))(if(null? i)(reverse(cons c o))
(let*((q(cons(car i)c))(n(r q)))(if n(l(cdr i) n o s)(and(hash-set! h q s)(l(cdr i)(r(car i))(cons c o)(+ s 1)))))))))

Usage:
(l "ABC" "AABAACABBA")             ; ==> (0 0 1 3 2 4 5)
(l "be torn" "to be or not to be") ; ==> (3 4 2 0 1 2 4 5 2 6 4 3 2 7 9 1)

PHP 220
implemented as a function
<? function l($d,$s){@$n=strlen;@$r=substr;$d=str_split($d);$o=[];while($s){$l=0;foreach($d as$k=>$v){$b=$n($v);if($b<=$n($s)&&!strncmp($s,$v,$b)&&$b>$l){$l=$b;$i=$k;}}$o[]=$i;$d[]=$r($s,0,$l+1);$s=$r($s,$l);}return $o;}

The spec says that if you implement a function you should return the array: printing is for implementing a program. Correcting this actually saves you 3 chars. You can also save by removing the space after <? (TBH I'm not sure if the <? is actually required - maybe ask on meta?), and replacing if(foo)if(bar)if(baz) with if(foo&&bar&&baz).

@PeterTaylor i read wrong the bit about return. thanks for the correction and tips

Perl, 188 177 156 145 137 112
sub l{($_,$s,@o)=@_;@d=split'';while($s){$s=~s/^$d[$_](.?)/push@o,$_;push@d,$&;$1/e&&last for reverse 0..$#d}@o}

i.e.
sub l {
    ($_,$s,@o)=@_;
    @d=split'';
    while($s){
        $s=~s/^$d[$_](.?)/push@o,$_;push@d,$&;$1/e
            && last for reverse 0..$#d
    }
    @o
}

Can be 109 if global @o is expected undefined or empty when entering sub. And yes, global variables are modified. Below is properly un-golfed version with lexicals.
use strict;
use warnings;

sub lzw {
    my ($alphabet, $string, @out) = @_;
    my @dict = split '', $alphabet;
    LOOP: while ($string) {
        for my $k (reverse 0..$#dict) {
            if ($string =~ s/^$dict[$k](.?)/$1/) {
                push @out, $k;
                push @dict, $&;
                next LOOP
            }
        }
        die "we shouldn't be here!\n"
    }
    return @out
}

print qq/@{[lzw("ABC", "AABAACABBA")]}\n/;
print qq/@{[lzw("be torn", "to be or not to be")]}\n/;

.
perl lzw.pl
0 0 1 3 2 4 5
3 4 2 0 1 2 4 5 2 6 4 3 2 7 9 1

PHP: 176
Just making it return a function would require one byte less. It utilizes PHP arrays ($d)as Trie trees:
<? function l($d,$s){@$S=str_split;$o=[];$d=array_flip($S($d));foreach($S($s)AS$v){if(null===$t=@$d[$c.$v]){$d[$c.$v]=count($d);$o[]=$c;$c=$d[$v];}else$c=$t;}$o[]=$c;return$o;}

Usage:
print_r(l("ABC","AABAACABBA")) ; ==> array(0, 0, 1, 3, 2, 4, 5)

SWI-Prolog, 313 244
The list of alphabet is no longer reversed. And it uses nth0 to brute force index + prefix pair.
b([],[]).
b([H|T],[[H]|R]):-b(T,R).
l(A,W,O):-b(A,B),r(B,W,O).
r(A,W,[I|T]):-m(A,W,I,E,0),append(E,R,W),(R=[N|_],!,append(E,[N],C),append(A,[C],B),r(B,R,T);T=[]).
m(A,W,I,E,N):-nth0(J,A,F),prefix(F,W),length(F,L),L>N,!,(m(A,W,I,E,L),!;I=J,E=F).

Usage:
l("be torn", "to be or not to be",O).
O = [3,4,2,0,1,2,4,5,2,6,4,3,2,7,9,1].

Old version
313 chars
Working on a reversed list of alphabet, which is convenient when I need to add new alphabet, but it is more roundabout to get the index.
This should do less work than the 244 chars version, but more code.
b([],O,O).
b([H|T],O,A):-b(T,O,[[H]|A]).
l(A,W,O):-b(A,B,[]),r(B,W,O).
r(A,W,[I|T]):-m(A,W,I,E,_),I>=0,append(E,R,W),(R=[N|_],!,append(E,[N],C),r([C|A],R,T);T=[]).
m([],_,-1,_,0).
m([H|T],W,I,E,M):-prefix(H,W),!,length(H,L),m(T,W,J,F,N),(N>L,!,M=N,I=J,E=F;M=L,length(T,D),I=D,E=H).
m([_|T],W,I,E,M):-m(T,W,I,E,M).

Wolfram Language(Mathematica), 245 bytes
Golfed version. Try it online!
f[a_,s_]:=(d=AssociationThread[Characters@a->Range[0,StringLength@a-1]];r={};i=1;c="";While[i<=StringLength@s,h=StringTake[s,{i}];n=c<>h;If[d~KeyExistsQ~n,c=n,r~AppendTo~d@c;AssociateTo[d,n->Max[Values@d]+1];c=h];i++];If[c!="",r~AppendTo~d@c];r)

Ungolfed version. Try it online!
LZWCompress[alphabet_String, input_String] := Module[
  {dict, current, next, result, i, ch},

  (* Initialize the dictionary with the alphabet *)
  dict = AssociationThread[Characters[alphabet] -> Range[0, StringLength[alphabet]-1]];
  result = {};
  current = "";
  i = 1;

  While[i <= StringLength[input],
    ch = StringTake[input, {i}];
    next = current <> ch;

    (* If the new string exists in the dictionary, update the current string *)
    If[KeyExistsQ[dict, next],
      current = next,

      (* Else, append the dictionary value of the current string to the result,
         add the new string to the dictionary, and reset the current string *)
      AppendTo[result, dict[current]];
      AssociateTo[dict, next -> Max[Values[dict]]+1];
      current = ch;
    ];

    i++;
  ];

  (* Handle the last remaining string *)
  If[current != "", AppendTo[result, dict[current]]];

  result
];

LZWCompress["ABC", "AABAACABBA"] //Print
LZWCompress["be torn", "to be or not to be"] //Print

GolfScript, 53 characters
n%~\1/\{.,,{)1$<2$?}%{)},-1=.p@.@=,:^)2$[<]+\^>.}do;;

The input must be given as two lines, first alphabet, second string to compress. The second example can be tested online.

I'm currently working on a different approach which should be shorter - unfortunately not yet finished and I'm running out of time...

Our answers look quite similar apart from the identification of the longest known prefix.

Postscript, 388 267
It's my Perl answer re-written, just for fun:
/lzw {
    10 dict begin
    /str exch def
    /alphabet exch def
    /concat
        {dup length 2 index length add string dup dup 4 index length
        5 -1 roll putinterval 0 4 -1 roll putinterval}
    def
    /push
        {1 index load dup length /_n exch def
        [exch aload pop _n 2 add -1 roll]def}
    def

    /dict [-1 alphabet length {
        1 add dup alphabet exch 1 getinterval exch
    } repeat pop] def
    [
    {
        str length 0 eq {exit} if
        dict length dup {
            1 sub dup
            dict exch get
            str exch anchorsearch
            {
                1 index
                dup length 0 ne {0 1 getinterval} if concat
                /dict exch push
                /str exch def
                exit
            } {pop} ifelse
        } repeat
    } loop
    ]

    end
} def

(ABC)(AABAACABBA) lzw
{10 string cvs print( )print} forall
(\n)print
(be torn)(to be or not to be) lzw
{10 string cvs print( )print} forall

and
gs -dBATCH -q lzw.ps
0 0 1 3 2 4 5
3 4 2 0 1 2 4 5 2 6 4 3 2 7 9 1

Procedure expects 2 strings on stack and returns an array. Not sure about quality of my Postscript, but with little help of 'binarization' (binary tokens), compression (LZW 4 bytes more efficient than Deflate) and encoding, it can be golfed to something like that:
/l<~J.+mR+f\'O00,h`aW[%a_[;,+b\+;Ei?VkM,`<7VO9Ho+MT&&IW4:>B/Jt:Fkp+9b5W"\IAS74n7,WEV`lsSZ&A6g1)4'7^,a$SAD@f9&15SkO))[/:$Z^e$4N0:?`F7fk8MV#<6.'Dr'AOkP"!5De'2kXm`>,I(@^ERI/e\Tneg#0M3_7tOQWJ$Y0n%F-#bWHFEC6hWX'hBaBu?;D~>/LZWDecode filter 500 string readstring pop cvx def

And that's 267 bytes procedure of pure ASCII code -- still not the longest of the answers :-)

Extended BrainFuck: 490 bytes
I know I won't win here, but I love compression algorithms.  It was fun writing, not too difficult and shorter than I imagined :)
{l[>>]}{k[<<]}{j&k +&l }{i]>>[-<<+>>]}{h,10-[22-[-}{g&k>>[->>]}{f>]3<[-3>+3<]}{e>+3>&l+<<&k}{d&k>[-3<+4>&l}{c 48+[-<+<+>>]<[.[-]<]10+.[-]}{a 10+<[->-[>+>>]>[+[-<+>]>+>>]5<]>[-]}{b 5<&k&f>>&g}192>&h 4<&j>>]<[-3<&k>+>&l>>+<]3<&g>>+[-<+>],10-]<[-<+>]<[->+>+<<]3>,32-[-5<&j 3>]5<&d 3>+&b 4>&h 6<&j 4>]<5<&d 4>+<&b>[-<+3>[->&e 3<&i 4<]<[->+<]4>+[-&e<<]>-[-<+>]3>&l<[-3>+4<&k<+3>&l<]3>[-3<+3>]4<&k+<[<<[-&i>-<]>[-<<[-4<+4>]4>-4<&a 4>+<&c<<[->+5>&l<+<&k 4<]>+[-<+&f 6>]>>&l<<[-<<]<<[-],10-]&a 3>&c

Usage:
$ bf ebf.bf < lzw.ebf > lzw.bf
$ bf lzw.bf <<eof
> ABC
> AABAACABBA
> eof
00
00
01
03
02
04
05

To support codes above 99 I need to add a stack structure. Doable, but since both test cases don't even use the second digit I though I'd stop here.
Here's the resulting BrainFuck code (1096):
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>,----------[----------------------[-<<<<[<<]+[>>
]>>]<[-<<<[<<]>+>[>>]>>+<]<<<[<<]>>[->>]>>+[-<+>],----------]<[-<+>]<[->+>+<<]>>
>,--------------------------------[-<<<<<[<<]+[>>]>>>]<<<<<[<<]>[-<<<+>>>>[>>]>>
>+<<<<<[<<]>]<<<[->>>+<<<]>>[<<]>>[->>]>>>>,----------[----------------------[-<
<<<<<[<<]+[>>]>>>>]<<<<<<[<<]>[-<<<+>>>>[>>]>>>>+<<<<<<[<<]>]<<<[->>>+<<<]>>[<<]
>>[->>]>[-<+>>>[->>+>>>[>>]+<<[<<]<<<]>>[-<<+>>]<<<<]<[->+<]>>>>+[->+>>>[>>]+<<[
<<]<<]>-[-<+>]>>>[>>]<[->>>+<<<<[<<]<+>>>[>>]<]>>>[-<<<+>>>]<<<<[<<]+<[<<[-]>>[-
<<+>>]>-<]>[-<<[-<<<<+>>>>]>>>>-<<<<++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-
]>>>>+<++++++++++++++++++++++++++++++++++++++++++++++++[-<+<+>>]<[.[-]<]++++++++
++.[-]<<[->+>>>>>[>>]<+<[<<]<<<<]>+[-<+>]<<<[->>>+<<<]>>>>>>]>>[>>]<<[-<<]<<[-],
----------]++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>>+++++++++++++++++++++
+++++++++++++++++++++++++++[-<+<+>>]<[.[-]<]++++++++++.[-]

Keep in mind that I have aimed for short EBF code, not BF code.
Here's the ungolfed EBF source code source code (3,5kB):
;; The data type for the lookup array
:lc the crumble for lookup array
:lv the value for this byte
:lz always zero

;; macros for lookup
;; move to open area
{to_lookup $lc(@lz)}

;; move back
{from_lookup $lz(@lc)}

{open_lookup (- &to_lookup+
                @lz &from_lookup)
}

{close_lookup &to_lookup
              $lz(-@lc)
}

;; makes a move to a higher
;; crumble and increments it
{lookup_backup
   $lc@lz
   $lc+$lz@lc
}

;; restore backup
{lookup_restore
    $lc@lz
    $lc(-$lz@lc^0+$lc@lz)
    $lz@lc
}

;; opens the lookup with the
;; index of the current register
;; and replaces it with the
;; code representing that
{lookup_value
    &open_lookup
    &to_lookup
    $lv(- &lookup_backup
          &from_lookup
          ^0+
          &to_lookup)
    &lookup_restore
    &close_lookup
}

;; We have a possible alphabet of ASCII 32-126=94 and
;; we need an empty as well *  2 slots/element = 190
190> @lz

;; The variables we use
:lec  lookup element count
:ndv  next dictionary value
:prev previos match
:cur  current index
:ax   general purpose register a

;; The trie tree data structure
:tz  the empty element
:tv  the value of this node
:tc  the crumble of this node

;; macros for the trie structure
{to_trie $tc(@tz)}

{from_trie $tz(@tc)}

;; makes a move to a higher
;; crumble and increments it
{trie_backup
   $tc@tz
   $tc+$tz@tc
}

;; restore backup
{trie_restore
    $tc@tz
    $tc(-$tz@tc^0+$tc@tz)
    $tz@tc
}

{open_trie
  ;; we take prev times lec first
  ;; we use %lz as temporary for lec
  ;; and
  $lec(-
        $lz+              ; backup lec
        $prev(-
               $ax+       ; backup prev
               &to_trie+
               &from_trie
             )
        $ax(-$prev+)      ; restore backup
      )
  $lz(-$lec+)             ; restore lec
  $cur+(-
          $ax+
          &to_trie+
          &from_trie)
  $ax-(-$cur+)
}

{trie_close &to_trie $tz(-@tc)}

;; divmod divides ^0 with ^1
;; leaving remainder in ^2
;; and quotient in ^3
;; Needs up to ^5 for working area
{divmod
  (-^1-
      [^2+^4]
      ^5[*-3+[-^1+^2]^3+^5])
}

;; First we need to fill our lookup
;; we'll use ndv
$ndv,10-
( ; while not lf
  22-
  &open_lookup
  $lec(- &to_lookup $lv+
         &from_lookup $ndv+)
  &close_lookup
  $ndv+(-$lec+)
  %ndv , 10-
)

;; Now that we have all symbols we make a copy
$lec(-$lz+)
$lz(-$lec+$ndv+)
#

$prev, 32- &lookup_value
$cur, 10-
(
  22-
  #&lookup_value
  #
  &open_trie

  ;; somehow if tv is we copy it to ax and reset prev
  ;; if prev is set we copy it to tv and
  &to_trie
  $tv(-
        &trie_backup
        &from_trie
        $ax+
        &to_trie
     )
  &trie_restore
  &from_trie
  $tz+
  $ax( $prev(-)$ax(-$prev+)$tz-)
  $tz(-
      $cur(-$lz+) ; make copy of cur
      $tc-
      $cur 10+ $prev &divmod
      $cur(-)
      $tc+
      $tv 48+(-$tz+$ax+)
      $tz[.(-)<]@cur
      10+.(-)
      $ndv(- $prev+
             &to_trie $tv+
             &from_trie
          )
      $prev+(-$ndv+)
      $lz(-$prev+)
   )
   &trie_close
   $cur(-), 10-
)
#$cur 10+ $prev &divmod
$cur(-)
$tv 48+(-$tz+$ax+)
$tz[.(-)<]@cur
10+.(-)

Ruby, 104 bytes
Only lightly golfed. Very similar to user2846289's Perl solution. I'm not sure why this straightforward challenge saw so few attempts; maybe we can revive it.
->a,s,*o{d=a.chars
(d.size-1).downto(0){(o<<_1
d<<$&
break)if s.gsub! /^#{d[_1]}(.?)/,'\1'}while s[0]
o}

Attempt This Online!


text:
Find a way to filter out swear words even if the user has escaped them
For this, imagine that the following words are really nasty cuss words:
Frag, Smeg, Felgercarb, Blatherskite, Dadgum, Fnord, Smurf, Schmit

Now, I need to filter out swear words on my website.
Normally the site will search for these words and ** them out:
I hate this s****ing cussword filter! It won't let me f***ging swear!

But people will just do this
I hate this sm.urfing  cussword filter! Good thing I can get around the fr.agging thing.

or
Holy schm1t, this web application is great!

Some more examples that I've seen are on this page:
Inversoft Profanity Filter
And then there's this: Sc***horpe Problem
Challenge: Find the shortest solution, using regular expressions, that removes the most cuss words.
Note: This is a very very relevant link: PHP chat log

It would probably be helpful to include a complete list of test cases.

You don't say how you want the Scunthorpe problem handled. Ignore it, and return Sc***horpe? Or if we should return Scunthorpe, what penalties are there for those who censor it?

s/.*// is the ultimate swearword filter. But yeah, like others have pointed out, this isn't at all a good task in its current shape: it's not very clear what the goal is and how it is scored.

...first question on Code Golf...I read the rules but yeah, I didn't phrase the question very well. I'm just really used to StackOverflow.
How can I make the question better?

@AustinBurk Just a friendly advice, post your question in the sandbox in COde Golf Meta, we will tell you how you can write your question to make it enjoyable for everyone. Edit: although I did the exact same thing when I arrived here.

This should either be a code golf or popularity contest.  Otherwise, you could maybe have the winner be the code that finds and removes the most cuss words.

I was going to do 'code golf' but there were only eight questions that used that tag so I decided not to.
I'll edit the question later. Thank you all. I need to go shovel snow though, we just got dumped on.

Code golf is actually very popular.  Most of the questions have [tag:code-golf] tags.

The shortest solution that removes the most swearwords is the one FireFly posted in a comment. I think that to save this question you need to write a spec that is sufficiently detailed that every possible test case has one correct output. Effectively, turn it into a regex-golf problem.

I just realized that that's a sed command there and that it matches everything and removes it, haha

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Shortest method to implement the Pythagorean Theorem
Who doesn't love the Pythagorean theorem \$a^2+b^2=c^2\$? Write the shortest method you can in any language that takes in value a and b and prints out The hypotenuse of this right triangle is c.  Keep c to only three decimal places.

Shortest in characters or bytes? :)

shortest in characters

The code-golf tag explicitly says "Code-golf is a competition to solve a particular problem in the fewest bytes of source code." See Scoring code golf (bytes vs. characters).

APL (54)
'The hypotenuse of this right triangle is',3⍕.5*⍨+/⎕*2

Test:
      'The hypotenuse of this right triangle is',3⍕.5*⍨+/⎕*2
⎕:
      9 10
The hypotenuse of this right triangle is 13.454

Explanation:

⎕*2: raise the values in the input to the second power
+/: take the sum
.5*⍨: raise the result to the 0.5th power
3⍕: round to 3 decimal places

This is about unbeatable

@Cruncher: I tried to encode the string but couldn't get the decoding routine small enough.

By the pigeon hole principle, I think you'd have a really hard time (maybe impossible. It has to be impossible for at least some strings) trying to compress the string. Maybe if the string had some logical pattern, but that doesn't appear to be the case. I'm interested to see the attempts you've had so far though

Correct the spelling of "hypotenuse" to save a character.

Hmm. Since all of these characters are in the range 65-122, You can encode about 4 characters into a byte(map the 65-122 into 0-63). Making your string about 32 characters shorter. The question is if you can decode those bytes back into a string in 30 chars.

Actually it may be better than that. Most chars are in 97 to 122. You can hard code the "T".

@Cruncher Huh? 4 characters per byte would mean 2 bits per character... unless you're using really big bytes :)

@JoachimIsaksson Oops. I done goofed. I was thinking that 64 is 1/4th of 256. Doesn't work like that. It's more than half of the bits. Yeah, there's no way to compress and decode it

@Cruncher: I'd have to re-encode the spaces. But I already tried something like this (packing four characters into an Unicode character) and the decoding routine was too long.

@marinus ah the spaces sound like a pain. If the string was longer it may be worth it.

@Cruncher: I'd ended up with this: 'T',⊃,/{(⎕UCS 32,96+⍳26)[1+2⊥5 4⍴(20/2)⊤⍵]}¨⎕UCS'鐄坪'. It can still be shortened a bit but obviously not by enough.

Is this a reusable method or just a one off statement?

@Cruncher: Actually, I beat it in Sclipting...

Good example of why some of us love APL!

TI-BASIC, 76 55 53 52 bytes
Input :Disp "THE HYPOTENUSE OF THIS RIGHT TRIANGLE IS
Fix 3:R▶Pr(X,Y

No, a closing parentheses is not required. Also, less bytes than that APL answer :)

Could be R▶Pr(A,B.

2 years to implement a suggestion, lol.

Destined for greatness, I guess. And I just shaved off two more bytes to beat APL!

-1 byte: Fix 3:R►Pr(X,Y

Using Input to ask for X and Y is kind of hilarious. If we allow that, should we also allow setting PolarGC before Input, so that the length of the hypotenuse is given by the one-byte R? Admittedly, with PolarGC the values of X and Y are no longer displayed when we move the cursor around, but they're still stored to the appropriate variables. (Which we would then never use, but it's the thought that counts.)

@MishaLavrov I suppose. The really funny thing would be if R was auto-calculated from the regular Input for something like Input :R

Python 2.7 - 76 Characters
print'The hypotenuse of this right triangle is %.3f'%abs(input()+1j*input())

Explanation
$$|a+bi| = \sqrt{a^2 + b^2} = c \\
\implies a^2 + b^2 = c^2$$
PJ on hypotenuse

Teacher: "Can you tell me, what is hypotenuse?"
LJ: "Hypotenuse, an easy question. If there's a high profile party last night, and you
read it in the news paper, its called High Party
News"

Sclipting, 46 characters
글坼各갠方終加감半方갾밈乘增貶껠矽녆둥긆둹댆뭴뉖멵댶넠닶눠덆둩댲걲늖덨덂건댦땡닦덬뉒걩댲밀⓶

Expects the input as two numbers (can be fractional!) separated by a space.
This is shorter than APL, despite having to use a few inconvenient tricks.
Explanation
글坼 | split at space
各 | for each...
  갠方 | to the power of two
終
加 | add
감半方 | to the power of one half
갾밈乘 | multiply by 1000
增貶 | increment, then decrement (kludge for rounding)
껠矽 | insert '.' at 4th-last character position
녆둥긆둹댆뭴뉖멵댶넠닶눠덆둩댲걲늖덨덂건댦땡닦덬뉒걩댲밀⓶ | "The hypotenuse..."

doesn't unicode make this like 92 bytes?

@Cruncher I asked yesterday up in the question comments, what counts is character count, not byte count.

dc 54
Tangents the score of the APL answer!
2^r2^+3kv[The hypotenuse of this right triangle is ]Pp

Test:
$ dc
3 4
2^r2^+3kv[The hypotenuse of this right triangle is ]Pp
The hypotenuse of this right triangle is 5.000

doesn' really work for me. dc -e '2^r2^+3kv[The hypotenuse of this right triangle is ]Pp' doesn't wait for any input, prints "dc: stack empty" 3 times and then "The hypotenuse of this right triangle is 2.000".

@Tomas it's sort of a a function; you need to put the parameters on the stack first, like I show in the test, or if you want to invoke your way, it would be dc -e '3 4 2^r2^+3kv[... where 3 and 4 are the parameters.

C, 77 or 99
77 characters if input can just be the function arguments:
f(a,b){printf("The hypotenuse of this right triangle is %.3f\n",hypot(a,b));}

99 if input must be read from stdin:
a,b;f(){scanf("%d %d",&a,&b);printf("The hypotenuse of this right triangle is %.3f\n",hypot(a,b));}

A big thanks to @Yimin Rong!

There is a hypot(a,b) which will save you three characters.

That function not compile whatever compile I use gcc tcc clang in tio...perhaps lack one #include header and in the title the precise version of the compiler

Ruby, 94 90 82 chars
p "The hypotenuse of this right triangle is %.3f"%(Math.sqrt(gets.to_i**2+gets.to_i**2))

Update (thanks for the comments):
p "The hypotenuse of this right triangle is %.3f"%(gets.to_i**2+gets.to_i**2)**0.5

You could save a few chars if you use a**0.5 instead of lengthy Math.sqrt(a). And the space after p can also be removed.

And you do not need parenthesis in %(Math...).

Powershell
Just to see if i could...
echo "The hypotenuse of this right triangle is " ([math]::round([math]::sqrt(([math]::pow(([double](Read-Host -p "A")),2) + [math]::pow(([double](Read-Host -p "B")),2))),3))

Nice work. Looks like you did this while I was busy with my own solution, which beats this by about 62 characters. For future reference, Code Golf answers are expected to be "golfed" and have their "score" included. "Golfing" means that you should make every effort to reduce the character length by using short-hand aliases, syntax tricks, and other means of stretching the language's rules. You should also remove unnecessary whitespace where possible (there's at least three spaces that can be removed from your solution). The "score", in this case, is your character count - currently 173.

I suggest reading the code golf tag wiki, various portions of the Help Center, and the Golfing Tips for PowerShell thread to get a better feel for how to write a competitive answer to code golf challenges here.

Also, I get an error with your script. "...the parameter name 'p' is ambiguous..." with regards to Read-Host.

Whispers v2, 133, 93 bytes
> Input
> Input
> "The hypotenuse of this right triangle is %.3f"
>> 1⊿2
>> 3%4
>> Output 5

Try it online!
The major part of this program is calculating the decimal point's index and truncating to 3 digits. -40 bytes from Leo!

Or you could "cheat" :) https://tio.run/##K8/ILC5ILSo2@v/fTsEzr6C0hAtBK4VkpCpkVBbkl6TmlRanKuSnKZQA1SsUZaZnlCiUFGUm5qXnpCoARVT1jNOUuOzsFAwfde03AjGMVU1AlH9pCdAsBdP//425TAE

That's a thing?!

Apparently % directly calls % from python, Jo King found this out

C++ - 90
void h(int a,int b){printf("The hypotenuse of this right triangle is %.3f\n",hypot(a,b));}

pow(a,2) when you can do a*a? I'm also not sure I understand the purpose of the floor and the +.5 and the multiply and divide by 1000

@Cruncher The floor is to set the decimal place to .3 places.  I am reworking it right now, and will include your suggestion.

There is a hypot(a,b) which will save you three characters.

@YiminRong Cool!

MATLAB 79 74
@(a,b)sprintf('The hypotenuse of this right triangle is %.3f',norm([a b]))

Python 2.7 - 80 chars
print'The hypotenuse of this right triangle is %.3f'%(input()**2+input()**2)**.5

I don't think this does 3 decimal places...?

It's my fault, I've corrected, thanks.

Perl 6 (68 74 bytes)
{printf "The hypotenuse of this right triangle is %.3f
",sqrt [+] @_ X**2}

{} declares a lambda function. [+] is sum operator, X** is cross power operator (for example, 1, 2 X+ 10, 20 gives 11, 21, 12, 22). In this case, cross power operator takes one argument, so the result has the same length as @_. @_ contains all function arguments.
If it's disallowed to have function that may take wrong number of arguments (unsafe), it's possible to replace [+] @_ X**2 with $^a**2+$^b**2, where $^a and $^b are placeholder arguments.

How would you limit to 3 decimal places?

@JoachimIsaksson: I fail at reading. Should be fixed now.

EcmaScript 6, 82 79
f=(a,b)=>"The hypotenuse of this right triangle is "+Math.hypot(a,b).toFixed(3)

Usage:
f(3, 5)
> "The hypotenuse of this right triangle is 5"

Update: Switch to Math.hypot()

Golfscript (69 67 66 65)
This would be much easier if floating point was actually supported without resorting to workarounds... :)
~'The hypotenuse of this right triangle is '@.*@.*+2-1??+.'.'?4+<

A link to test it.

why are you doing 2.!~ when 2-1 is shorter?

@McKay Good question, I always getthe difference between 2- 1and2-1` wrong, so was probably temporarily confused :) Fixed, thanks.

Javascript (97)
x=prompt;a=x(),b=x();x('The hypotenuse of this right triangle is '+Math.sqrt(a*a+b*b).toFixed(3))

.toFixed .. thank you! learned something new :)

C, 100 chars (beats the other C solution by 1!)
A ridiculously inefficient algorithm.
x;f(a,b){for(;x-a*a-b*b;x=rand());printf("The hypotenuse of this right triangle is %.3f",sqrt(x));}

Sorry, but you've written "the" instead of "this", so if you correct that it's the same length ;P

@daniero Ok, found a fix, now still one char down :)

In the Borland C compiler it would not compile...

DELPHI / PASCAL
With indent (157)
program p;
{$APPTYPE CONSOLE}
var a,b:integer;
begin
     readln(a,b);
     writeln('the hypotenuse of this right triangle is',sqrt(b*b+a*a):2:3);
end.

ah man, i had the exact same :(

to late for an edit, so again..
Edit: You can get 2 characters off by changing integer to int16 You dont have to include the first 2 lines for your answer, and you can remove whitespace. doing all that gives you 106 characters.

Python 2 (79)
def p(a,b):print'The hypotenuse of this right triangle is %.3d'%((a*a+b*b)**.5)

Dispense with math for some savings.  (a*a+b*b)**.5

Since the body of your function is a single statement, it can be on the same line as the def saving a newline and an indent.

AWK — 84 78 characters
awk '{printf"The hypotenuse of this right triangle is %.3f\n",($1^2+$2^2)^.5}'

Thanks to Wasi for suggesting ^ operator and removing ()!
e.g.
$ echo 3 4 | awk '{printf"The hypotenuse of this right triangle is %.3f\n",($1^2+$2^2)^.5}'
The hypotenuse of this right triangle is 5.000

You can golf it further {printf"The hypotenuse of this right triangle is %.3f\n",($1^2+$2^2)^.5}

C#
Method Only (114)
void H(double a, double b)
{
    Console.Write("The hypotenuse of this right triangle is {0:N3}", Math.Sqrt(a * a + b * b));
}

Complete Program (171)
using System;
class P
{
   static void H(double a, double b)
   {
     Console.Write("The hypotenuse of this right triangle is {0:N3}", Math.Sqrt(a * a + b * b));
   }
   static void Main()
   {
    H(3, 4);
   }
}

Complete Program (without using method - 141)
using System;class P{static void Main(){double a=3,b=4;Console.Write("The hypotenuse of this right triangle is {0:N3}",Math.Sqrt(a*a+b*b));}}

Heres my complete program. 141 chars...you can save a few chars using the formatstring overload of write  using System;class P{static void Main(){double a=3,b=4;Console.Write("The hypotenuse of this right triangle is {0:N3}",Math.Sqrt(aa+bb));}}

You can use string formatting in the Console.Write instead of calling ToString() to save 9 characters.

PowerShell: 111
Golfed Code
1..2|%{sv $_ (read-host)};"The hypotenuse of this right triangle is $("{0:N3}"-f[math]::sqrt($1/1*$1+$2/1*$2))"

Walkthrough
1..2|%{sv $_ (read-host)}; Gets two inputs interactively from the user, and stores them in $1 and $2. Might be able to cut some length by using arguments or pipeline inputs instead.
"The hypotenuse of this right triangle is Required text in the output, per the challenge specifications.
$(...)" Encapsulated code block will be processed as script before being included in the output.
"{0:N3}"-f Formats output from the next bit of code as a number with exactly three digits after the decimal point.
[math]::sqrt(...) Gets the square root of the encapsulated value.
$1/1*$1+$2/1*$2 Serves as our "a^2+b^2". Multiplying a number by itself is the shortest way to square it in PowerShell, but the variables need to be divided by 1 first to force them to integers. Otherwise, they are treated as text and 3*3+4*4 would be 3334444 instead of 25.

JavaScript 118 106 93
Unlike @micha's solution, mine takes in two variables via function and sends the alert of the result.
function(a,b){m=Math;c=d=>d*d,e=1e3;alert("The hypotenuse of this right triangle is "+m.round(m.sqrt(c(a)+c(b))*e)/e)}
function(a,b){e=1e3;alert("The hypotenuse of this right triangle is "+Math.round(Math.sqrt(a*a+b*b)*e)/e)}
Fat arrow functions to the rescue!
h=(a,b,e=1e3)=>"The hypotenuse of this right triangle is "+Math.round(Math.sqrt(a*a+b*b)*e)/e

Could be shorter if you inline c(). Aliasing Math doesn't save bytes in your case.

@Florent Ah, yes... one sec!

JavaScript: 83
i=prompt,'The hypotenuse of this right triangle is '+Math.hypot(i(),i()).toFixed(3)

Currently the shortest JS implementation using stdin :D
Works only on Firefox 27.0+ (EcmaScript 6)
JavaScript: 78
If we can use just two variables (as lot of scripts do here):
a=2,b=3,'The hypotenuse of this right triangle is '+Math.hypot(a,b).toFixed(3)

whoooo .. .hypot. Good catch!

dc, 55
3k?d*?d*+v[The hypotenuse of this right triangle is ]Pp

Java, 112
(Also prints out a No Such Method error, though I'm not sure if this is against the rules)
class A{static{int a=1,b=1;System.out.printf("The hypotenuse of this right triangle is %.3f",Math.hypot(a,b));}}

Java, 149
(No error)
class A{static{int a=1,b=1;System.out.printf("The hypotenuse of this right triangle is %.3f",Math.hypot(a,b));}public static void main(String[] a){}}

c64 basic v2, 60 66 bytes
0inputa,b:?"The hypotenuse of this right triangle is";sQ(a*a+b*b)

Screenshot:

How to try it.

should say "The hypotenuse of this right triangle is"

@Mayube Sad :-( +6 byte :-( Post fixed.

Jelly, 32 characters
,²S½ær3µ,“¡ÆC⁷⁺ɱSoṿȤç½?⁶Ẏtḍỵŀ»ṚK

Try it online!
There is probably a better string compression that allows me to get around needing to join with spaces but I was having trouble finding it.
Explanation:
,²S½ær3µ,“...»ṚK    Example inputs: 3, 4
,                   Pair the inputs. Result: [3, 4]
 ²                  Square them. Result: [9, 16]
  S                 Sum them. Result: 25
   ½                Get the square root of the sum. Result: 5
    ær3             Round to 3 decimal places. Result: 5
       µ            Take the result of that... Result: 5
         “...»       ...and  the compressed string Result: "The hypotenuse of this right triangle is"
        ,           And put them into a pair. Result: [5, "The hypotenuse of this right triangle is"]
              Ṛ     Reverse that. Result: ["The hypotenuse of this right triangle is", 5]
               k    Join it with spaces. Result: "The hypotenuse of this right triangle is 5.0"
                    Implicit output.

So long as only three decimal places means less than or equal to three decimal places, the output looks fine.

R, 61 76 bytes
cat("The hypotenuse of this right triangle is",round(sqrt(sum(scan()^2)),3))

cat displays its content to STDOUT.
The scan() function takes user's input from keyboard. This input exists as a vector, on which the ^2 is applied (^function is vectorized), and the sum() sums the elements of the vector. sqrt outputs the square-root, which is rounded to 3 decimal places by round(,3)
Thanks to @caird coinheringaahing for noticing that the previous answer didn't round.

Does this "Keep c to only three decimal places."?

@cairdcoinheringaahing : it does now ! Thanks !

ARBLE, 73 60 bytes
"The hypotenuse of this right triangle is %.3f"%(a^2+b^2)^.5

Try it online!

@H.PWiz I must say, for a challenge that should just be sqrt(a^2+b^2), this has a lot of unnecessary boilerplate.

OML, 57 bytes
"The hypotenuse of this right triangle is "shnhn+A6`*N3eD

Try it online!
Part 1
This simply outputs the string
"The hypotenuse of this right triangle is "s

Part 2
hnhn+A6`*N3eD
hn              take input and square it
  hn            take another input and square it
    +           add them
     A6`        push 10^6
        *       multiply the sum with that number
         N      take integer square root
          3eD   output with three places of precision
                implicit output

JavaScript, 70 bytes
(a,b)=>'The hypotenuse of the triangle is '+((a*a+b*b)**.5).toFixed(3)

The latter function rounds the number to 3 decimal places.

It would be shorter to use addition instead of a template string.

Thanks for the advice, 70 bytes now

Vyxal, 32 30 bytes
∆/`λƛ h⁼Ǐ¢Ṗλ₇ of λ× ¬ẋ Ȧ⇩ is Π

Try it Online!

30 bytes with an (undocumented) feature: string interpolation

Fig, \$36\log_{256}(96)\approx\$ 29.632 bytes
+qDFQ$XS)s2lSXreS8x%twBEZ:x@KUX"mqS*

Try it online!

Javascript, 109
A=1,B=1,s=1e3,console.log("The hypotenuse of this right triangle is " + (Math.round(Math.sqrt(A*A+B*B)*s)/s))

Fiddledee

with alert you could save 6 chars

Down to 101: A=1,B=1,s=1e3;alert("The hypotenuse of this right triangle is "+(Math.round(Math.sqrt(A*A+B*B)*s)/s))

Using suggestions from other entries so far I get it to 90:
A=1,B=1;alert("The hypotenuse of this right triangle is "+(Math.sqrt(A*A+B*B).toFixed(3)))
Even less if you leave out alert

Scala (95c)
import Math._;val x=sqrt(pow(a,2)+pow(b,2));f"The hypotenuse of this right triangle is $x%1.3g"

Java : 223
   class l {
        public static void main(String[] args) {
          new l().H(2,4);
        }
        void H(float a, float b)
    {
        System.out.printf("The hypotenuse of this right triangle is %.3f",Math.hypot(a,b));
    }
    }

I brought this to 170 by making it a one liner, changing the method to a static: class h{public static void main(String[]args){H(2,4);}static void H(float a,float b){System.out.printf("The hypotenuse of this right triangle is %.3f",Math.hypot(a,b));}}

@Michaël Demey, hah, i didnt think of that changing the function to static .

newLISP, 103 characters
(let(a 3.1 b 4)(println"The hypotenuse of this right triangle is "(round(pow(add(pow a)(pow b)).5)-3)))

The unspecified input method helps a lot... :)

Groovy : 78 Characters
a={x,y->printf"The hypotenuse of this right triangle is %.3f",Math.hypot(x,y)}

Assuming the task is just writing a method. If you need to take input parameters:
99 Characters
printf"The hypotenuse of this right triangle is %.3f",Math.hypot(args[0].toLong(),args[1].toLong())

I found two ways to it with the same length:
printf"The hypotenuse of this right triangle is %.3f",Math.sqrt(args.collect{it.toLong()**2}.sum())

F#, 78
let f a b=sqrt(a*a+b*b)|>printf"The hypotenuse of this right triangle is %.3f"

Java : 155
class A{A(int x,int y){System.out.printf("The hypotenuse of this right triangle is %.3f",Math.hypot(x,y));}public static void main(String[]s){new A(1,4);}}

You can take out the public  on the constructor saving 7

Javascript 98 characters/bytes
This is implemented as a browser alert in a function.
function p(a,b){alert('The hypotenuse of this right triangle is: '+Math.sqrt(a*a+b*b).toFixed(3))};

Fortran (90)
read(*,*)a,b;print'(a,f9.3)',"The hypotenuse of this right triangle is ",sqrt(a*a+b*b);end

Uses implicit typing so that a,b are single precision reals.

Javascript, 110 bytes
function h(a,b){return a/1==a&&b/1==b?'The hypotenuse of this right triangle is '+(a*a+b*b||0).toFixed(3):!1;}

It's a monster!!!
But it can handle NaN and invalid numbers, like text, objects, 0/0 and other invalid numbers.

Ruby 2.1+ (73 characters)
f=->a,b{puts"The hypotenuse of this right triangle is %.3f"%(a+b*1i).abs}

Prolog
h(A,B):-X is A*A+B*B, C is sqrt(X),format('The hypotenuse of this right triangle is ~3f',C).

Bash with bc, 91
No bash script yet?!

read a b
echo -n 'The hypotenuse of this right triangle is '
bc<<<"scale=3;sqrt($a^2+$b^2)"

There is no way this can win.

To save 1 character, you could use printf instead of echo -n.

Instead of bc, use dc: dc<<<"3k$a d*$b d*+vp"

Haskell, 77 characters
(\x y->print$"The hypotenuse of this right triangle is "++(show$sqrt$x^2+y^2))

Useage:
(\x y->print$"The hypotenuse of this right triangle is "++(show$sqrt$x^2+y^2)) 3.0 4.0
The hypotenuse of this right triangle is 5.0

Fortran 2008 (87 characters)
Based on the Fortran 90 solution, but now in Fortran 2008, HYPOT is an intrinsic function.
read(*,*)a,b;print'(a,f9.3)','The hypotenuse of this right triangle is ',hypot(a,b);end

J, 56 bytes
'The hypotenuse of this right triangle is '&,@":@(+&.*:)

explanation
J's "Under" verb &. is a nice fit here.  It applies a transformation, executes a verb, and then applies the reverse transformation to the result. In this case, squaring is the transformation *:, its reverse is taking the square root, and the verb in question is addition.  So we do addition "under" the square transformation.  The rest is just formatting the number and cat'ing it onto the sentence.
Try it online!

|@j. is even nicer.

@FrownyFrog that is wonderful, thanks.

Perl 5, 69 bytes
printf"The hypotenuse of this right triangle is %.3f",sqrt<>**2+<>**2

Try it online!

Tcl, 80 bytes
puts "The hypotenuse of this right triangle is [expr int(hypot($a,$b)*1e3)/1e3]"

Try it online!

I doubt that setting variables is an allowed I/O method... Nevertheless, your program does not seem to [k]eep c to only three decimal places.

@JonathanFrech: Fixed the 3 decimal places issue. About the setting variables issue, I will wait feedback from questions asker, as it seems I've seen some answers here doing the same.

05AB1E, 53 characters
"The hypotenuse of this right triangle is "|nOt₄*ï₄/«

Try it online!
I could not figure out how to compress 05AB1E strings. :(
Explanation:
"..."|nOt₄*ï₄/«

     |             Push array of inputs.
      n            Square them.
       O           Get the sum.
        t          Get the square root.
         ₄*        Multiply by 1000
           ï       Convert to integer. This rounds it.
            ₄/     Divide by 1000
"..."         «    Append it to the string.
                   Implicit print.

"The hypotenuse of this triangle is nOt 4"

compressed string version (i believe it is the most optimal compression here)
Try it online!

Petit Computer BASIC, 66 bytes
INPUT A,B?"The hypotenuse of this right triangle is ";SQR(A*A+B*B)

PTC only displays the first 3 decimal places when printing.

Jq 1.5, 80 bytes
"The hypotenuse of this right triangle is \(1e3*pow(map(.*.)|add;.5)|floor/1e3)"

Assumes input is [a,b]
Try it online at tio.run or jqplay.org

Axiom, 92 bytes
g(a,b)=="The hypotenuse of this right triangle is "((round((a^2+b^2)^.5*1.e3)/1.e3)::String)

test
(4) -> g(12, 19)
   (4)  "The hypotenuse of this right triangle is 22.472"
                                                             Type: String

APL (Dyalog), 51 bytes
'The hypotenuse of this right triangle is',3⍕|0j1⊥⎕

Try it online!
0j1⊥⎕: Convert the input into base i. e.g a b  ->  b+ai
|: Magnitude
3⍕: Round to 3 decimal places

Stax, 24 bytes
╬Z.-êû$P¿[▐Ä√#╙δdr▼▀Ö☺┐ç

Run and debug it
Unpacked, ungolfed, and commented, it looks like this.
`1/yyH\fBXNR&X+{.SC`p   print "The hypotenuse of this right triangle is "
:J+                     square and add the inputs
|Q                      square root
3j                      round to 3 places
p                       print

Run this one

JavaScript (Node.js), 76 bytes
a=>b=>'The hypotenuse of this right triangle is '+Math.hypot(a,b).toFixed(3)

Try it online!
Explanation
a => b => // the two arguments (curry method)
    `The hypotenuse of this right triangle is // write the text required
    ${Math.hypot(a,b)}` // and use JS Math.hypot function to calculate the hypotenuse.

Alternately, if the you spare me the pain of writing this text.
f=Math.hypot // is also a valid answer

Welcome to PPCG. Note, though, the requirement that the output be rounded to 3 decimal places.

Japt, 37 bytes
`T hypÇQ«e  È ght â0Ø8  `+Nx²¬x3

Try it

Husk, 41 bytes
+¨ΣŸṗ¤μe₀fı≤ṙ↔ẏ«G¹∫¨J"."msλ‰⁰i*⁰)1000√¤+□

Try it online!
With rounding being involved, I sure didn't pick the right language for the task...
+                              The concatenation of
 ¨...¨                         the compressed prefix for the output
          ms                   with the stringified elements of
            λ‰⁰   )1000        the divmod by 1000 of
                       √       the square root of
                         +     the sum of
                        ¤ □    the squares of the two arguments
                *⁰             times 1000
               i               converted to an integer
      J"."                     with a period inserted between them.

Computing the actual length of the hypotenuse only takes four bytes, rounding to three decimal places takes seventeen bytes, and adding on The hypotenuse of this right triangle is to the output takes twenty bytes. 90.244% of this answer is just formatting!

Pyth, 51 bytes
+." y¢ó³-.n?ãÜPŽýD'9¹i¾5ŠÁ«£¿9WhI‚".R@s^RJ2QJ3

Try it online!

The actual math only takes up 8 bytes.
Despite having built-in string compression capabilities, Pyth is pretty bad at compressing strings.

Jelly, 28 bytes
ÆḊær3“¡ÆC⁷⁺ɱSoṿȤç½?⁶Ẏtḍỵŀ»,K

Try it online!
How it works
ÆḊær3“¡ÆC⁷⁺ɱSoṿȤç½?⁶Ẏtḍỵŀ»,K - Main link. Takes a pair [a, b] as input
ÆḊ                           - Take the norm √(a²+b²)
  ær3                        - Round the 3 decimal places
     “¡ÆC⁷⁺ɱSoṿȤç½?⁶Ẏtḍỵŀ»   - "The hypotenuse of this right triangle is"
                          ,  - Pair the string with the norm
                           K - Insert a space between the two

Rust, 72 bytes
|a,b|print!("The hypotenuse of this right triangle is {:.3}",a.hypot(b))

Try it online!
Woohoo, rust has built-ins for this. The hypot method calculates the hypotenuse between the numbers. Instead of the usual "{}" format substitution I used "{:.3}" which forces the number to display with three decimal places.

Go, 108 bytes
import(."fmt";."math")
func f(a,b float64){Printf("The hypotenuse of the triangle is %.3f\n",Sqrt(a*a+b*b))}

Attempt This Online!

Thunno Kj, \$ 46 \log_{256}(96) \approx \$ 37.86 bytes
AO3Zu"The hypotenuse of this right triangle is

Attempt This Online!
Not having string compression really hurts in challenges like these.
Explanation
           # Implicit input
AO         # Push the hypotenuse of the inputs (yes, this is a built-in)
  3Zu      # Round to three decimal places
     "...  # Push the string
           # Flags join the stack by spaces
           # Implicit output

Thunno 2 j, 35 bytes
ÆH3ȯ‘The hypotenuse of ċṠ Ṗṇ ġḳ is

Attempt This Online!
4 bytes (ÆH3ȯ) for the main bit, and 31 bytes for the compressed string.
Explanation
ÆH3ȯ‘...  # Implicit input
ÆH        # Compute hypotenuse
  3ȯ      # Round to 3 d.p.s
    ‘...  # Push compressed string
          # Join the stack
          # Implicit output

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Shortest Program to Sort a List of numbers into Odd and Even Category
In the New Modern Times, when Charlie Chaplin encounters a computer, he is employed in the sorting Yard, as a validator to determine if the workers are correctly sorting the items. The Items in question are packets of marbles. Packets with Odd number of Marbles are stacked in the Red Basket and Packets with Even Number of Marbles are stacked in the Blue Basket.
Charlie Chaplin is supposed to punch the program that would validate if there is any anomaly in the sorting procedure. Mack Swain his immediate Boss, shares an algorithm which he needs to code.
Algorithm
L = List of Marble packets that's already sorted
L_ODD = List of packets with Odd Number of Marbles
L_EVEN = List of packets with Even Number of Marbles
Check_Digit = √(ΣL_ODD² + ΣL_EVEN²)

His Job is to determine the Check_Digit and match it with what ever value his Boss calculates.
Charlie Chaplin during his lunch hours, were able to sneak to Mack Swain's drawer and determine, that his drawer has a single card with punches on the first 46 32 columns (which means Mack was able to write a program with only 46 32 characters).
Charlie Chaplin would now need the help of all the code ninja's to write a program with as few lines as possible. He also announces a bonus of 50 points, if someone can come up with a program which is shorter than his Boss.
Summary
Given a list/array/vector of positive numbers (odd and even), you need to write a function, which would accept the array(int [])/vector<int>/list and calculate the root of the sum of the squares of the sums of odd and even numbers in the list.
The Size of the program is the size of the body of the function, i.e. excluding the size of the function signature.
Example
List = [20, 9, 4, 5, 5, 5, 15, 17, 20, 9]
Odd = [9, 5, 5, 5, 15, 17, 9]
Even = [20, 4, 20]
Check_Digit = √(ΣOdd² + ΣEven²) = 78.49203781276162

Note, the actual output might vary based on the implementation's floating point precision.
Score
Score is calculated as Σ(Characters in your Program) - 46.Score is calculated as Σ(Characters in your Program) - 32.
Apart from the regular upvoting from the community, the lowest negative score would receive an additional bonus of 50 points.
Edit

The offset that was used to calculate the Score has been changed from 46 to 32. Note, this would not affect the leader-board/ bounty eligibility or invalidate any solution.

Verdict
After a gruesome duel between the Ninjas, Mr. Chaplin received some wonderful answers. Unfortunately few of the answers tried to take undue advantage of the rule and was not very useful. He actually wanted a fair duel and answers where the logic was coded within the function signatures would eventually mean the function signature is an integral part of the solution.
Finally, Ninja FireFly was the clear winner and awarded him the bonus he well deserves.
Leaderboard (updated every day)
╒══════╤═════════════════╤══════════════╤═════════╤════════╤═══════╕
├ Rank │      Ninja      │   Dialect    │ Punches │ Scores │ Votes ┤
╞══════╪═════════════════╪══════════════╪═════════╪════════╪═══════╡
│  0   │     FireFly     │      J       │   17    │  -15   │   6   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  1   │     tmartin     │     Kona     │   22    │  -10   │   2   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  2   │ Sven Hohenstein │      R       │   24    │   -8   │   7   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  3   │    Ben Reich    │  GolfScript  │   30    │   -2   │   1   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  4   │    mollmerx     │      k       │   31    │   -1   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  5   │ David Carraher  │ Mathematica  │   31    │   -1   │   3   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  6   │     tmartin     │      Q       │   34    │   2    │   1   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  7   │     daniero     │      dc      │   35    │   3    │   1   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  8   │    psion5mx     │    Python    │   38    │   6    │   2   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  9   │       O-I       │     Ruby     │   39    │   7    │   5   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  10  │      gggg       │    Julia     │   40    │   8    │   1   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  11  │ FakeRainBrigand │  LiveScript  │   50    │   18   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  12  │    Sylwester    │    Perl5     │   50    │   18   │   2   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  13  │     daniero     │     Ruby     │   55    │   23   │   1   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  14  │    vasuakeel    │ Coffeescript │   57    │   25   │   1   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  15  │      dirkk      │    XQuery    │   63    │   31   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  16  │  crazedgremlin  │   Haskell    │   64    │   32   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  17  │   Uri Agassi    │     Ruby     │   66    │   34   │   1   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  18  │     Sumedh      │     JAVA     │   67    │   35   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  19  │      Danny      │  Javascript  │   67    │   35   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  20  │     deroby      │      c#      │   69    │   37   │   1   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  21  │  Adam Speight   │      VB      │   70    │   38   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  22  │    Andrakis     │    Erlang    │   82    │   50   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  23  │      Sp0T       │     PHP      │   85    │   53   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  24  │    brendanb     │   Clojure    │   87    │   55   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  25  │  Merin Nakarmi  │      C#      │   174   │  142   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  26  │    Boopathi     │     JAVA     │   517   │  485   │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  27  │      Noyo       │     ES6      │    ?    │   ?    │   2   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  28  │     shiona      │   Haskell    │    ?    │   ?    │   0   │
├──────┼─────────────────┼──────────────┼─────────┼────────┼───────┤
│  29  │      Vivek      │     int      │    ?    │   ?    │   0   │
└──────┴─────────────────┴──────────────┴─────────┴────────┴───────┘

Why does the lowest score need a bonus, they already won?

Moreover, the offset of 46 doesn't change anything regarding the order.

@gggg I think they mean they'll give the lowest scoring answer a +50 bounty.

@gggg: I will actually start a bounty as soon as I am allowed to. So that's what I meant by bonus.

@Howard: the lowest negative score would receive an additional bonus of 50 points. So in order to qualify for Bounty, there should be at least one answer which fairs better than 46 characters. It seems now that we already have few :-)

"Score is calculated as Σ(Characters in your Program) - 32 [...] an additional bonus of 50 points.". So it isn't code-golf, which, according to the tag, simply requires the fewest bytes of source code .

@res: If you closely observe, the lowest score, is suppose to have fewest bytes. So this still remains a code-golf.

Hm, looks like scores were never updated.. @Abhijit, did you see the entries with the score of -31? :]

@Noyo: I have added a verdict paragraph, which might answer your doubt as to why your answer was not selected as the winning solution.

Aw, rats. Here I thought the rules were there to be taken advantage of, and that cleverness would be rewarded here. ;] Still, fun question, and good job, everyone!

J, 18 17 chars - 32 = ⁻15
[:+/&.:*:2&|+//.]

(As a "function body"; has to be parenthesized or bound to a name.)
Explanation
I tried making an exploded view of what each piece does, like Tobia does in APL answers.
               +//. ]    NB. sum up partitions
           2&|           NB.   given by equality on (x mod 2)
        *:               NB. square,
   +/                    NB. sum,
     &.:                 NB. then revert the squaring (square-root)
                         NB. (f&.:g in general acts like g⁻¹(f(g(x))))
[:                       NB. (syntax to indicate composition of +/&.:*: and (2&| +//. ]))

+/&.:*: could be replaced with |@j./ making use of O-I's complex magnitude trick to save yet another two characters.
Example
   f =: [:+/&.:*:2&|+//.]
   f 20 9 4 5 5 5 15 17 20 9
78.492

ES6, (48 - 32) = 16 (1 - 32) = -31
Original version:
f=l=>(e=o=0)+l.map(x=>x%2?e+=x:o+=x)&&Math.hypot(e,o)

Entire function definition is 53 characters, body only is 48.
Updated version, taking full advantage of the problem definition and moving pretty much everything out of the body and into the signature:
f=(l,e=0,o=0,g=x=>x%2?e+=x:o+=x,c=l.map(g)&&Math.hypot(e,o))=>c

New function definition is now 63 "punches" total, but function BODY is now just ONE DAMN CHARACTER LONG. Plus it no longer corrupts the global namespace! :D
Usage:
>>> f([20, 9, 4, 5, 5, 5, 15, 17, 20, 9])
78.49203781276161

...and now I feel kinda dirty. :]

+1, I've deleted my ES6 solution since yours is way better :)

Haha, thanks. We'll see if the rules are changed once the OP sees this.. ;]

Well, it looks like the rules were indeed implicitly changed, even after an answer was accepted and the bounty awarded. Oh well! I still consider this to be the solution with the lowest score according to the rules of the challenge. :]

Actually reminds me of those c code-contests where people would do all kind of trickery in the preprocessor making a seemingly 'simple' function returning very complex stuff. The net result was off course that compiling took hours & hours (& hours) while the actual execution would return pi up to 100k numbers (or something like that) in a fraction of a second as the result was pretty much hard-coded into the binaries. Anyway, although I think we both know you were were cheating I'd say "well played sir" =P

R, (24 − 32) = −8
f=function(x)
    sum(by(x,x%%2,sum)^2)^.5

The function body consists of 24 characters.
Usage:
f(c(20, 9, 4, 5, 5, 5, 15, 17, 20, 9))
[1] 78.49204

Ergh!!! You have exactly the same solution as I just elaborated!! sqrt(sum(by(x,x%%2,sum)^2)) I only have not optimized the sqrt.... damn :-) +1 :-) PS: it is interesting how by seems to be out at first because of the shitty output format but when you run sum over it it is fixed ;-)

@Tomas In this example, by returns a one-dimensional array. One shouldn't judge the function by the result of the print.by function.

Nope, by doesn't return an array (btw, what you mean by "array"? There are none in R. You probably meant a vector), neither a vector. by returns object of class by.

@Tomas There are arrays in R. Have a look at ?array. Furthermore, is.array(by(1,1,I)) returns TRUE.

Ruby 2.1+ — (39 characters total - 7 non-body - 32 offset = 0)
Slightly different approach. I create a complex number a+b*i such that a and b are the sums of the even and odd numbers in list, respectively. Then I just take the absolute value.
f=->l{l.reduce{|s,x|s+x*1i**(x%2)}.abs}

My previous solution, which is 5 characters longer but works on 1.9.3+:
f=->l{l.reduce{|s,x|s+x*?i.to_c**(x%2)}.abs}

On a final note, if Rails + Ruby 2.1+ were allowed, we can use Array#sum to get the body down to a mere 25 characters:
l.sum{|x|x+1i**(x%2)}.abs

Very clever, I like it! This would save me a few chars in J as well.

Thanks, @FireFly. Yours is nice. Gotta learn J sometime. Cheers!

You only have to count the body of the function, I'd say 37 chars.

Thanks for the tip @steenslag. Updated. I also shaved off an additional 5 characters by using the new Complex literal shorthand. Only works in Ruby 2.1 and above, though.

Python 2.7: 45, nay: 40, nay: 38 - 32 = 6
Nothing very new here, just a combination of the complex number trick I saw in the recent Pythagoras challenge, lambda for compactness, and syntax/parenthesis minimisation:
lambda x:abs(sum(a*(1-a%2+a%2*1j)for a in x))

Update - saved a few chars. Thanks to @DSM for the trick of raising the complex component to 0/1.
lambda x:abs(sum(a*1j**(a%2)for a in x))

Ok, reading the question and recognising the 'body of the function' count rule saves another 2 chars:
def f(x):
    return abs(sum(a*1j**(a%2)for a in x))

iPython testing:
In [650]: x = [20, 9, 4, 5, 5, 5, 15, 17, 20, 9]

In [651]: print (lambda l:abs(sum(a*(1-a%2+a%2*1j)for a in l)))(x)
78.4920378128

...

In [31]: def f(x):
   ....:     return abs(sum(a*1j**(a%2)for a in x))
   ....:

In [32]: f(x)
Out[32]: 78.49203781276162

nice! it's like the problem was build exactly for abs of complex numbers

APL (27 - 46 = -19)
{.5*⍨+/2*⍨+⌿⍵×[1]z,⍪~z←2|⍵}

e.g.:
      {.5*⍨+/2*⍨+⌿⍵×[1]z,⍪~z←2|⍵} 20 9 4 5 5 5 15 17 20 9
78.49203781

Mathematica 31-32 = -1
√Tr[(Tr/@GatherBy[#,OddQ])²]//N &

GatherBy[#,OddQ] produces the even-packet, odd-packet lists.
The inner Trfinds the totals, both of which are squared and then summed (by the outer Tr).
N converts from an irrational number (the square root of an integer) to a decimal approximation.
Example
√Tr[(Tr/@GatherBy[#,OddQ])²]//N &[{9, 5, 5, 5, 15, 17, 9, 20, 4, 20}]

78.492

If f[n_]:= is not included in the count, an additional character can be saved.
    f[n_]:=
    √Tr[(Tr/@GatherBy[n,OddQ])²]//N

Example
f[{9, 5, 5, 5, 15, 17, 9, 20, 4, 20}]

78.492

Perl5 : (50 - 32 = 18)
map{$0[$_&1]+=$_}@ARGV;print sqrt$0[0]**2+$0[1]**2

+1 perhaps you may save a few chars by using say instead of print and <> instead of @ARGV (while supplying the args on the STDIN instead of on the command-line)

@Tomas Wouldn't using say require a use? switching from an argument array to <> would require an additional split/ /,.

No, say feature can be enabled from the command line. 2) I guess no split would be needed if you provide those numbers each per line.

dc 3 (35 - 32)
Using arrays, as suggested by @Tomas. This saves some of characters because I can calculate the parity of each number and use it as an index, instead of tweaking the with parity as a method of branching and putting the right values in the right registers. Also it turns out that arrays will give you a 0 even if the array/index haven't been used, so you don't have to initialize anything.
[d2%dsP;S+lP:Sz0<L]dsLx0;S2^1;S2^+v

Assumes the numbers are already on the stack, and leaves the result as the only value left when it's done.
Test:
$ dc
20 9 4 5 5 5 15 17 20 9
[d2%dsP;S+lP:Sz0<L]dsLx0;S2^1;S2^+v
p
78

dc 16 (48 - 32)
First version using registers o and e to store odd and even numbers.
0dsose[dd2%rd1+2%*lo+so*le+sez0<x]dsxxle2^lo2^+v

+1 for using dc. Ha ha sose ;-) perhaps you could get shorter result using dc array commands?

@Tomas thanks a bunch! I first dismissed the idea of using arrays for some stupid reason, but after your suggestion I tried again and they turned out to be very helpful! A register had to be used to temporarily store the parity, but overall I think this is a much more elegant solution.

You are welcome, I knew this would help :-)

Kona, 22 - 32 = -10
{(+/(+/'x@=x!2)^2)^.5}

Prolog (73 - 32 = 41)
Here we count everything after ':-' as the function body.
f([],0,0,0).
f([H|T],O,E,X):-(1 is H mod 2,f(T,S,E,_),O is H+S,!;f(T,O,S,_),E is H+S),sqrt(O*O+E*E,X).

Call function like so:
f([20, 9, 4, 5, 5, 5, 15, 17, 20, 9],_,_,X).

Julia, 40-46=-6
Implementation
function f(l)
    a=sum(l);b=sum(l[l%2 .==1]);hypot(a-b,b)
end

Output
julia> f([20, 9, 4, 5, 5, 5, 15, 17, 20, 9])
78.49203781276161

Python, 9 (55 - 46)
lambda x:sum([sum([i*(d-i%2) for i in x])**2for d in(0,1)])**0.5

Using a lambda function saves some bytes on newlines, tabs and return.
Example:
x = [20, 9, 4, 5, 5, 5, 15, 17, 20, 9]
print (lambda x:sum([sum([i*(d-i%2) for i in x])**2for d in(0,1)])**0.5)(x)
78.4920378128

Ruby, 55 - 46 = 9
f=->a{h=[0,0];a.map{|v|h[v%2]+=v};e,o=h;(e*e+o*o)**0.5}

Test:
f[[20, 9, 4, 5, 5, 5, 15, 17, 20, 9]] => 78.49203781276162`

You can use an array for h:  f=->a{h=[0,0];a.map{|v|h[v%2]+=v};e,o=h;(e*e+o*o)**0.5}

@NeilSlater doh! Thanks :)

Q, 34 - 32 = 2
{sqrt sum{x*x}(+/')(.)x(=)x mod 2}

.
q){sqrt sum{x*x}(+/')(.)x(=)x mod 2} 20 9 4 5 5 5 15 17 20 9
78.492037812761623

Ruby (66 - 32 = 34)
f=->a{o,e=a.partition(&:odd?).map{|x|x.reduce(:+)**2};(e+o)**0.5}

test:
f.([20, 9, 4, 5, 5, 5, 15, 17, 20, 9])
=> 78.49203781276162

Math.hypot *a.partition(&:odd?).map{|x|eval x*?+} shaves off a few chars

Coffeescript, (57 - 32 =25)
Implementaion
f=(a)->r=[0,0];r[e%2]+=e for e in a;[e,o]=r;(e*e+o*o)**.5

I don't know coffeescript, but i wonder if you can remove the space after the += and change 0.5 to .5

GolfScript 30
.{2%},]{{+}*}/.@\-]{2?}/+2-1??

I don't think GolfScript has much of a chance on this one!

c#: 69-32=37
double t=l.Sum(),o=l.Sum(x=>x*(x%2)),e=t-o;return Math.Sqrt(o*o+e*e);

Full code:
class Program
{
    static void Main(string[] args)
    {
        int[] list = { 20, 9, 4, 5, 5, 5, 15, 17, 20, 9 };
        Console.WriteLine(F(list));
        Console.ReadKey();
    }

    static double F(int[] l)
    {
        double t = l.Sum(),  // total sum of all elements
               o = l.Sum(x => x * (x % 2)),  // total of odd elements, if even %2 will return zero
               e = t - o; // even = total - odd
        return Math.Sqrt(o * o + e * e);
    }
}

PS: Just for fun, this works too, sadly it doesn't change the number of characters needed:
double t=l.Sum(),o=l.Sum(x=>x*(x%2));return Math.Sqrt(t*t-2*o*(t-o));

C# 174
using System;class P{static void Main(){double[] L={20,9,4,5,5,5,15,17,20,9};double O=0,E=0;foreach(int i in L){if(i%2==0)E+=i;else O+=i;}Console.Write(Math.Sqrt(E*E+O*O));}}

Readable
using System;
class P
{
  static void Main()
  {
      double[] L = { 20, 9, 4, 5, 5, 5, 15, 17, 20, 9 };
      double O = 0, E = 0;
      foreach (int i in L)
      {
        if (i % 2 == 0)
            E += i;
        else
            O += i;
      }
      Console.Write(Math.Sqrt(E * E + O * O));
   }
}

You haven't golfed this at all. We're trying to get a solution that fits on the boss's punchcard!

Why not? Explain Please.

Your code is fully indented with spaces all over. Code golf is all about getting the lowest character count. This question is tagged [tag:code-golf].

Thanks Riking. I edited it. I have fewer characters now.:)

I think the list is supposed to be provided as input, not hardcoded.

Math.Sqrt(L.GroupBy(x=>x%2).Select(x=>x.Sum()).Select(x=>x*x).Sum()); You can Console.Write on the same line, and accept the input from args as a main parameter.

Thanks Benjamin. But the Main method accepts only string as argument and we will have to convert it to double.

Matlab (44 - 46 = -2)
Function body is 44 characters:
C=mod(A,2)>0;O=(sum(A(C))^2+sum(A(~C))^2)^.5

Total function as follows:
function O = Q(A)
C=mod(A,2)>0;O=(sum(A(C))^2+sum(A(~C))^2)^.5
end

Tests of the function:
>> A = [20 9 4 5 5 5 15 17 20 9];
>> Q(A)

O =

   78.4920

ans =

   78.4920

>> B = [8 3 24 1 9 8 4 5 52];
>> Q(B)

O =

   97.6729

ans =

   97.6729

Python 2.7 - 64-46 = 18
This could be shorter using some zip magic, but for now:
(sum(s for s in x if s%2)**2+sum(s for s in x if s%2==0)**2)**.5

For completion, it turns out you can do zip magic, but it costs you more (by a few characters), so the above stands, unless someone can improve either of these:
sum(map(lambda i:sum(i)**2,zip(*[[(0,i),(i,0)][i%2]for i in x])))**.5

You don't need the [square brackets] inside the sum().

I think you could improve this significantly by working in the complex plane, e.g. abs(sum(1j**(i%2)*i for i in x)).

@DSM That is insane! I never thought of that. I can't edit that in its too much changed, but please make and answer so I can upvote it!

@DSM: I had a similar version in my mind, but yours is sleeker

Does Python accept !s%2?  That's at least an incremental change you can accept

@Charles: no, not !s%2, but that's a good idea: ~s%2 should work here.

Clojure = 87 - 46 = 41
(defn cd [v]
  (let [a apply ** #(* % %)]
    (Math/sqrt(a + (map #(** (a + (% 1)))(group-by even? v))))))

Hardly idiomatic, though.

Haskell, 64C - 46 = 18
c x=sqrt$fromIntegral$s(f odd x)^2+s(f even x)^2
f=filter
s=sum

Not too difficult to read. Example run:
*Main> c [1..10]
39.05124837953327

PHP 85-32=53
$a=$b=0;foreach($x as $q){if(($q%2)==0)$a=$a+$q;else$b=$b+$q;}echo sqrt($a*$a+$b*$b);
This is the best i'ld come up being a newbie. I'm sure there must be some shorter versions as well.
EDIT:
A reduced version of the code could be:
foreach($x as$q)($q%2)?$a=$a+$q:$b=$b+$q;echo sqrt($a*$a+$b*$b);

This version only has 64 (21 less than the original answer) chars.
Said so, 64-32=32

Did it independently, got 58 base: foreach($l as$m)$m%2?$o+=$m:$e+=$m;echo sqrt($o*$o+$e*$e);

int e=0,o=0;for(int i :n){if(i%2==0)e+=i;else o+=i;}System.out.println(Math.sqrt(e*e+o*o));
Actual method in java code
public static void checkDigit(int[] n)
{
    int e=0,o=0;for(int i :n){if(i%2==0)e+=i;else o+=i;}System.out.println(Math.sqrt(e*e+o*o));
}

Test Class

public class Sint
{
    public static void main(String[] args)
    {
        if(args == null || args.length == 0)
            args = "20 9 4 5 5 5 15 17 20 9".split(" ");
        int[] n = null;
        try
        {
            n = new int[args.length];
            for(int i=0; i<args.length; i++)
                n[i] = Integer.parseInt(args[i]);
            System.out.print("int array is: ");
            for(int dd : n) System.out.print(dd+", ");
            System.out.print("\n");
            checkDigit(n);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void checkDigit(int[] n)
    {
        int e=0,o=0;for(int i :n){if(i%2==0)e+=i;else o+=i;}System.out.println(Math.sqrt(e*e+o*o));
    }
}

LiveScript 50 (or 1 if you're flexible)
The 1 character solution is r where the function signature is this:
fun = (a,o=(sum a.filter odd),e=(sum a.filter even),r=(e*e+o*o)**0.5) ->

But I think that's a technicality.
Actual answer:
o=sum a.filter odd
e=sum a.filter even
(e*e+o*o)^0.5

Is it really a technicality, though? ;] http://codegolf.stackexchange.com/a/20396/8856

k (31-32 = -1)
sqrt{+/b*b:+/'(.)x@=(_a)=a:x%2}

Example run:
  sqrt{+/b*b:+/'(.)x@=(_a)=a:x%2} 20 9 4 5 5 5 15 17 20 9
78.492037812761623

Erlang: 82C - 32 = 50
fun(L)->F={lists,sum},O=[X||X<-L,X rem 2>0],E=F(L--O),math:sqrt(F(O)*F(O)+E*E)end.

Erlang isn't great for this. Most shortcuts end up being more characters (tuples etc.)
The only real things of note:

{lists,sum} is a function reference to lists:sum and can be called
Even numbers are calculated by subtracting -- (list subtract) the odd numbers list from the full list

Can call using:
fun(L)->F={lists,sum},O=[X||X<-L,X rem 2>0],E=F(L--O),math:sqrt(F(O)*F(O)+E*E)end([20,9,4,5,5,5,15,17,20,9]).

Output: 78.49203781276162

VB.net (81c - 11c = 70) - 32 = 38
Via liberal usage of the term Write a function
Function(n)Math.Sqrt(n.Sum(Function(x)x Mod 2=0)^2+n.Sum(Function(x)x Mod 2=1)^2)

XQuery, (63 - 32 = 31)
Implementation
declare default function namespace 'http://www.w3.org/2005/xpath-functions/math';
declare function local:f($s) {
  sqrt(pow(fn:sum($s[. mod 2=0]),2)+pow(fn:sum($s[. mod 2=1]),2))
};

Output
local:f((20, 9, 4, 5, 5, 5, 15, 17, 20, 9))

BaseX was used as XQuery processor.

Haskell
57 - 32 = 25
Straight optimization of crazedgremlins answer:
c x=sqrt$read$show$sum(odd%x)^2+sum(even%x)^2
(%)=filter

Optimizations:

read$show is shorter than fromIntegral - 3 chars
s=sum\n and two s's has total length of 8 chars, two sum's is just 6 chars. - 2 chars
making filter into operator does away with need of whitespace - 2 chars

I also tried adding more stuff to the operator, but it ended up being just as long:
c x=sqrt$read$show$odd%x+even%x
(%)=(((^2).sum).).filter

C (68-32 = 36)
float f(int *a, int c)
{int s[2]={0};while(c--)s[a[c]%2]+=a[c];return sqrt(*s**s+s[1]*s[1]);}

In action:
#include <stdio.h>
#include <math.h>

float f(int *a, int c)
{int s[2]={0};while(c--)s[a[c]%2]+=a[c];return sqrt(*s**s+s[1]*s[1]);}

int main(void)
{
    printf("%f\n", f((int[]){20, 9, 4, 5, 5, 5, 15, 17, 20, 9}, 10));
    return 0;
}

ised (10 characters - 32) = -22
ASCII:
@={@+E$1@+O$1}

UTF8:
@={ΣE$1ΣO$1}

The variable $1 must contain the array. Example invocation from shell:
ised --l - '@={ΣE$1ΣO$1}' <<<"20, 9, 4, 5, 5, 5, 15, 17, 20, 9"

Example invocation in interactive mode:
ised> @1{20, 9, 4, 5, 5, 5, 15, 17, 20, 9}
20 9 4 5 5 5 15 17 20 9
ised> @={ΣE$1ΣO$1}
78.492

Explanation: operators O and E extract odd and even elements of the array. The operator @+ or Σ sums the array. @= returns the length of the given vector.
If you want a function, it's even shorter. Saving a function:
ised> @2{: @={ΣExΣOx} :}

The function body is only 10 characters long. The rest is the function declaration ({: :}) and storage of the function handle into memory slot 2 (@2). Invocation
ised> $2::{20 9 4 5 5 5 15 17 20 9}

Link to software: http://ised.sourceforge.net/

Tcl, 60 bytes (bonuses not included yet)
proc C L {lmap c $L {incr [expr $c%2] $c}
expr hypot($0,$1)}

Try it online!

Factor + math.unicode, 43 - 32 = 11
[ [ odd? ] partition [ Σ sq ] bi@ + sqrt ]

Try it online!

Jelly, 10 bytes - 32 = score -22
ḟḂƇ,ḂƇ§²S½

Try it online!

Javascript 67-32=35
function r(a){k=j=0;a.map(function z(i){i%2?j+=i:k+=i});return Math.sqrt(k*k+j*j)}

Doesn't seem like there is an easy way of spliting the array into even's and odd's without defining another function :(
console.log(r([20, 9, 4, 5, 5, 5, 15, 17, 20, 9]));
78.49203781276162

JAVA: 67-32=35
inside function(int[] a) :
int x=0,y=0;
for(int i:a)
{
if(i%2==0)
x+=i;
else y+=i;
}
Math.hypot(x,y);

C'mon guys atleast tell why you've down-voted the answer.
Its a working code.

I didn't downvote. But why i*i? I also get 1108.9891793881488 when I run your code with the sample input.

I thought we need to square them first,then add them.....ΣEven² is actually (ΣEven)², while I took it as Σ(Even²). but I should've checked with sample input earlier.
Thanks @Danny.

If you're trying to make the code small, you can skip the curly braces and keep everything on one line.

JAVA 517 bytes
 public class Link
    {
        public static void main(String[] args)
        {
            int[]a={20, 9, 4, 5, 5, 5, 15, 17, 20, 9};
            int []b=new int[10];
            int[]c=new int[10];
            int j=0,k=0,l=0,m=0;
            for(int i=0;i<a.length;i++)
            {
                if(a[i]%2==0)
                {
                    b[j]=a[i];
                    j++;
                }
                else
                {
                    c[k]=a[i];
                    k++;
                }
            }
            for(int i=0;i<j;i++)
            {
                l=l+b[i];
            }
            l=l*l;
            for(int i=0;i<k;i++)
            {
                m=m+c[i];
            }
            m=m*m;
            l=l+m;
            double t=Math.sqrt(l);
            System.out.print(t);
        }

    }

Vyxal ḋ, 7 bytes - 32 = score -25
⁽∷ġṠ²∑√

Try it Online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Is an email is Spam or Ham?
Challenge
Given an email in plain text format, including headers, decide if the email is either spam or ham, and output SPAM or HAM respectively.  The emails will be given below. Your code must be able to correctly identify all of the samples, but should be general enough to work on any email.
Scoring
This is a code golf, so shortest code wins.
Restrictions
Do not:

Rely on message length
Rely on particular senders, recipients, dates, or subjects

Data
Spam
Subject:   favorable offer
From:   "Simon Nicolas" uopt@pictishbeast.net
Date:   Sun, August 28, 2005 0:00
To:   "UK resident"

Hello! I am Simon Nicolas, a general manager of international company IFSD Inc. (
http://www.ifsd-company.com ) and I have a favorable offer for you.

Now it is a little about our company. We are engaged the organization of plans of
reception of payments for private persons and the companies. Our services

are demanded by those who has requirement to accept remittances from clients in
other countries.

Our company conducts wide international activity; we work with the organizations and
private persons from the various countries worldwide. Our activity

constantly extends, we enter new services, we expand staff of employees we open
representations of the company in the territory of the various countries.

In connection with constant expansion of our international activity we feel
necessity of new employees in the territories of the various countries. Now we

have announced a set of employees on a post "the Regional Financial Manager".

Working on this post, our colleagues produce work with the bank transfers and the
checks. Our clients are private persons and the companies of the

different countries and for simplification of remittances we use our Regional
Financial managers.

The functions of the Regional Financial Manager:

-reception of bank payments on a bank account

The scheme of work is those: the Regional Financial Manager receives money resources
and informs us on this. We in turn at once enroll the necessary sum on

the account of our client. It allows you to save a lot of time - now the client does
not need to wait for reception of money from abroad. As such scheme

allows you to save money. From the sum of each transaction lead through you our
company pays 5 %.

The basic requirements:

-age of 21-60 years

-access to the Internet, e-mail

-opportunity to work not less than 3 hours per day

It is your really favorably chance to earn!

Start to work right now! For the beginning with us you need to fill works only
labour agreement

---

Best regards,

Simon Nicolas.

http://www.ifsd-company.com

Spam
From: "Met Investment Fund" nclpbruehue@dancy.com
To: "UK competitor"
Subject: Job offer from http://www.metinvf.com
Date: Sat, 19 Mar 2005 00:10:07 +0000

Vacancies

We have some vacancies right now, here they are:

Financial manager:

JOB DESCRIPTION

Requirements:

Resident of the United Kingdom
Knowledge of Microsoft Word and Microsoft Excel;
Home Computer with e-mail account and ability to check your e-mail box at least
twice a day;
1-3 hours free during the week;
Be fast in decisions;
To manage MIF financial affairs through the provision of efficient and effective
financial
systems and support;
To ensure that the financial affairs are conducted in compliance with current
legislative
requirements and in line with requirements set by DCAL, DFP and DCMS;
To ensure adherence to all internal and external audit requirements;
To recieve MIF payments and our sub-companies payments and send them directly to our
investors;
To co-ordinate and control the completion of all necessary payments to our clients
(through
our site's member zone);
Have a university degree;
UK Bank account (for wire transfers from our company and our clients);

All offers here:
http://www.metinvf.com/careers.html

Ham
From: "Tony McAdams" <tony@mcadams.com>
To: "Bobby" <bobby@mcadams.com>
Subject: Bobby, check out this job posting
Date: Sun, 30 May 2005 03:50:02 +0000

Hey Bob,

I heard you were looking for work, so I figured I'd pass along this job
offer.  A friend of mine works for Webdings Inc., and he mentioned they
are hiring.

Their site is: http://www.webdings.com

Anyways, how's the new apartment?  Get everything moved in alright? We
should be by Tuesday with some food and a house warming present. If Tuesday
doesn't work, we can drop by any time during the week.

Unfortunately Sparky won't be able to make it, she's not really feeling
all that well. The vet called and said they'd have to keep her for
observation for at least a week. Bummer.

Anyways, I hope to hear back from you soon Bob, everyone here misses you a
lot!

Talk to you soon,
Tony

Ham
Subject:   Quote Selection
From:   "Simon Nicolas" simonsays@gmail.com
Date:   Mon, January 2, 2005 20:01
To:   "undisclosed-recipients"

Hello class,

Before next week's lecture, I need you all to read "His Last Bow" by
Doyle.  Pay particular attention to the following paragraphs:

    From that day they were seen no more in England. Some six
    months afterwards the Marquess of Montalva and Signor Rulli,
    his secretary, were both murdered in their rooms at the Hotel
    Escurial at Madrid. The crime was ascribed to Nihilism, and
    the murderers were never arrested. Inspector Baynes visited
    us at Baker Street with a printed description of the dark face of
    the secretary, and of the masterful features, the magnetic
    black eyes, and the tufted brows of his master. We could not
    doubt that justice, if belated, had come at last.
    "A chaotic case, my dear Watson," said Holmes over an evening
    pipe. "It will not be possible for you to present in that compact
    form which is dear to your heart. It covers two continents,
    concerns two groups of mysterious persons, and is further
    complicated by the highly respectable presence of our friend,
    Scott Eccles, whose inclusion shows me that the deceased Garcia
    had a scheming mind and a well-developed instinct of self preservation.
    It is remarkable only for the fact that amid a perfect
    jungle of possibilities we, with our worthy collaborator, the
    inspector, have kept our close hold on the essentials and so
    been guided along the crooked and winding path. Is there any
    point which is not quite clear to you?"

Thank you,
Simon

Are there any objective (I know, overused word her) criteria for the program? As the question stands now, anything from a lame program to a real spam detecter would do.

@tomsmeding I'm not really sure how to make it more objective besides giving a bigger sample set. Any suggestions?

J (40)
This program has a 100% success rate on the given samples.
echo>(+./(3#1)E.LF=1!:1[3){'HAM';'SPAM'

How does it work?
It checks if the mail contains three or more newlines in a row, and if so, classifies it as spam. For the test set, this holds. (Interestingly enough, from a cursory glance at my spam folder, this also holds for quite a lot of real spam.)

I'm not familiar with the syntax, but perhaps you could save a character by looking for 1- instead?

Befunge 98 - 34
~a-!2*1-+:2`98+*j"SP"8j@,k3"MA"<H'

This is a translation of marinus's answer; it checks for 3 or more newlines in a row.


text:
Rotate simple ASCII art
This is similar to a previous question on this site, but with much simpler rules, so we should get much shorter results (in bytes):

Input:  ASCII art with only two possible characters: space and '#'.
Output: Input sequence rotated 90 degrees counter-clockwise.

Winner is answer with least number of bytes including length of language name.

Any special reason for the "including length of language name"?

@Victor - to encourage users of non esoteric languages to compete as well.

Are input lines equal length (padded with spaces if necessary)?

@nbubis Don't think that this is really such a incentive.

@Victor - yes you're right :( how do you suggest penalizing esoterics without specifying languages?

@nbubis By asking problems that are very hard or impossible to solve in esoteric languages. Very few esoteric languages features graphics, animations, networking and mouse or touchscreen input, so this could be a way to do it.

Why try to penalise esoteric languages in the first place? If your goal is to encourage other languages, focus on encouraging other languages effectively rather than penalising esoterics ineffectively. StackExchange even has a built-in method to encourage a particular type of answer: the bounty.

So, say, JavaScript (a normal, non-esoteric language) has a higher penalty than APL or J or K, and the same penalty as GolfScript? Not sure how that "encourages non esoteric languages" at all...

nbubis I understand you, because the esoteric languages can be demotivating, but we should try to find better criteria for handling that

K, 1+1
+

.
k)+("# # #";" # # ";"#####")
"# #"
" ##"
"# #"
" ##"
"# #"

I don't know k, but I count k ) + and than the matrix, thats 3 characters right? And than you need to add the K as one character. So the total is 4, not 1

The k) is just a prompt, like >>> in a python interpreter. It doesn't need to be there at all

GolfScript (10 chars + 10)
n/zip-1%n*

Online demo
Note: as Tomas correctly observed in the comments, I'm assuming that the input is rectangular. This seems reasonable, because it is explicitly stated in the specification of the question which this one aims to simplify.

You are assuming that all the lines are of the same length, which was not specified in the rules. I think you can still post your solution but the limitation should be stated in the asnwer.

MATLAB - 14
rot90(a)

Where 'a' is the input art, in matrix form.
8 characters in the code, 6 in the name. 8 + 6 = 14.

J, 16+1 characters
|.|:[;._2[1!:1[3

Usage (first 3 lines of # is the input, the rest is the output):
   |.|:[;._2[1!:1[3
# # #
 # #
#####
# #
 ##
# #
 ##
# #

Explanation:
1!:1[3 take multi-line input from the keyboard
[ used as a separator
[;._2 chop the string into lines
|: transpose
|. reverse
12 characters to take an process the input, and 4 characters to complete the task.

Python 3.X 56-Chars
print('\n'.join(map(''.join,zip(*input().split('\n')))))

Demo
>>> print '\n'.join(map(''.join,zip(*raw_input().split('\n'))))
# # #
 # #
#####
# #
 ##
# #
 ##
# #
# ## # #
 ## # #
# ######
 ##
# #

A bit late, but aren't you supposed to add 6 chars because "Python" has six letters?

R, 4+1
t(a)

Where 'a' is the input art, in matrix form. Language is Cran R, function to transform/rotate a martix is t.

The score is 5: 4 + 1 (the length of R)

Ruby 56
s=[*$<];s[0].size.downto(1){|i|puts s.map{|l|l[i-1]}*''}

I think there's a syntax error somewhere.

@nbubis All lines must be of the same length (padded with spaces). Also an updated version of Ruby is probably required.

Perl, 44 chars
$/=$i--;$_=<>;say/(.).{$i}$/gmwhile!++$i||$1

Assuming all rows have equal length.

J (4+1)
|:|.

Expected input as a string matrix. Usage:
   a=: >'# # #';' # #';'#####'
   a
# # #
 # #
#####
   |:|.a
# #
##
# #
##
# #

Basically a duplicate of http://codegolf.stackexchange.com/a/20157/20356

Bash (144 + 4) (131 + 4)
Assumes input is in a file with newlines to delimit end of row.
Assumes each row has the same number of characters.
Assumes first argument is path to file.
t=`sed 's/\(.\)/\1\t/g' $1` n=$(expr $(head -n1 $1|wc -c) \- 1);for i in $(seq 1 $n);do echo "$t"|cut -f$i|tac|tr -d '\n';echo;done

Un-golfed:
t=$(sed 's/\(.\)/\1\t/g' $1) # Add a tab after every character.
n=$(expr $(head -n 1 $1 | wc -c) \- 1) # Count the number of characters in a row.
for i in $(seq 1 $n); do # For each row.
    echo "$t"|cut -f "$i" |tac|tr -d '\n' # Cut the i^th column, print, reverse and delete newline.
    echo # Finished processing i^th row. Emit newline.
done

JavaScript (ES6), 83

f=(s,o=[],a='')=>/./.test(s)?f(s.replace(/^./gm,x=>(a=x+a)&&''),[...o,a]):o.join`\n`

G.onclick=g=>X.innerHTML=f(X.innerHTML)
textarea{
  height:100px;
  line-height:7px;
}
<button id=G>Rotate</button>
<textarea id=X>
#
# #
#   #
#     #
#       #
#         #
#       #
#     #
#   #
# #
#
</textarea>