[Question]
  [
We live in a wonderful age of technology where we can have beautifully detailed 8K screens on our TVs, and even 2K displays on our phones for our mobile browsing pleasure. We've come a long way in recent years in terms of screen technology. 
One of the products of this is a term that was made popular by Apple, *Retina*. This is referring to the [pixel density](https://en.wikipedia.org/wiki/Pixel_density) of the display in question being so high, that at a viewing distance of 10-12 inches away, individual pixels cannot be easily picked out. 
Steve Jobs said that the pixel density where this occurs is right around **300 pixels per inch**, and they started employing pixel densities in this range on their devices with the *Retina* buzzword used for advertising.
Pixel density can be calculated by the following formula:
![D=sqrt(w^2+h^2)/d](https://i.stack.imgur.com/G9tBC.gif)
Where `d` is the diagonal of the screen in inches, `w` is the number of pixels on the horizontal axis, and `h` is the number of pixels on the vertical axis.
# Your Task
For this task, you'll be using the *Retina* standard to decide what products are worth buying. Being the modern consumer that you are, when you shop for devices you want to make sure that you're getting a good product, not some device from the 90s! As such, you want to build a *program or function* that takes the screen width, height and diagonal length as **input or function parameters**, and tells you whether the particular screen qualifies as a retina screen (`D > 300`) by *printing to the screen or returning*. 
Due to your contempt for non-Retina devices, your *program or function* will output `Retina!` when the device qualifies, and `Trash!` when it does not.
You may assume that all of the numbers will be greater than 0. Pixel values for width and height will always be whole numbers. Screen size may be interpreted in any way, as long as it supports decimals. The input may be in any order you choose, and may also be on up to 3 separate lines.
# Example I/O
```
1920 1080 4.95   -> Retina!
2560 1440 5.96   -> Retina!
1920 1080 10.5   -> Trash!
10 10 0.04       -> Retina!
4096 2160 19(.0) -> Trash!
8192 4320 100.00 -> Trash!
3000 1500 11.18  -> Retina!
180 240 1(.0)    -> Trash!
```
---
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the fewest number of bytes wins.
---
Here's a Stuck solution, a stack based programming language I'm making:
```
r;`;/300>"Retina!""Trash!"?
```
  
[Answer]
# [Retina](https://github.com/mbuettner/retina), ~~530~~ ~~220~~ ~~210~~ ~~202~~ ~~201~~ ~~193~~ ~~191~~ ~~187~~ 185 (184) bytes
*Credits to randomra for saving 3 bytes!* (And paving the way for a couple more.)
```
+`\.(\d)(.+)( .+)
$1.$2_$3_
\b
#
+`(\d*)#((((((((((9)|8)|7)|6)|5)|4)|3)|2)|1)|\w)
$1$1$1$1$1$1$1$1$1$1$3$4$5$6$7$8$9$10$11#
\d
11
(?=(1*)\1)[^.]
$1
^(1+)\.\1{90000}1+
Retina!
1.+
Trash!
```
For byte-counting purposes, each line goes in a separate file, but you can run the above code as is from a single file by invoking Retina with the `-s` flag.
This expects the density first (which *must* contain a decimal point, even if it's a trailing one), followed by width and height, i.e. `d w h`.
This is a *bit* slow. I wouldn't try most of the given test cases, because it will run for ages. However, you can check that it works correctly with the test cases
```
19. 4096 2160     -> Trash!
1. 180 240        -> Trash!
1. 181 240        -> Retina!
1. 180 241        -> Retina!
0.04 10 10        -> Retina!
```
Basically, after multiplying all numbers through to make the density an integer, you don't want the width and height to have more than 4 digits.
While this is slow, it is completely exact... there are no floating point issues or anything like that. All arithmetic is using (unary) integers.
In principle, I could shave off one more byte: the `^` can be omitted, but it will make `Trash!` test cases horribly slow due to excessive amounts of backtracking.
## Explanation
First, let's rearrange the inequality to avoid floating point operations:
```
√(w2 + h2) / d > 300
√(w2 + h2) > 300 d
w2 + h2 > 90000 d2
```
We can also notice that this is invariant under multiplying `w`, `h` and `d` by the same number `x`:
```
w2 + h2 > 90000 d2
(x w)2 + (x h)2 > 90000 (x d)2
x2 (w2 + h2) > 90000 x2 d2
w2 + h2 > 90000 d2
```
There are several ways to square a unary number, but we'll be making use of the identity
```
n2 = Σi=1..2n ⌊i/2⌋
```
This gives us a way to solve the problem using only integer arithmetic (representing integers in unary). 
Let's go through the code. Each pair of lines is a regex substitution.
```
+`\.(\d)(.+)( .+)
$1.$2_$3_
```
This repeatedly moves the decimal point in the density to the right while multiplying width and height by 10 (the `x` above). This is to ensure that all numbers are integers. Instead of appending zeroes, I'm appending `_`, which I'll be treating as zero later on. (This is a golfing trick, because otherwise I'd need to write `...${3}0` to avoid ambiguity with `$30`.) The `+` in front of the regex tells Retina to repeat this substitution until the result stops changing (which is the case when the pattern no longer matches).
```
\b
#
```
We're preparing the three numbers for conversion to unary now. In principle, we need a marker (the `#`) in front of each number, but it's shorter to add one to the end of each number as well, which won't affect the conversion step.
```
+`(\d*)#((((((((((9)|8)|7)|6)|5)|4)|3)|2)|1)|\w)
$1$1$1$1$1$1$1$1$1$1$3$4$5$6$7$8$9$10$11#
```
This is the conversion to unary, using a trick that [has been developed by dan1111](https://codegolf.stackexchange.com/a/47571/8478). Essentially I'm translating each digit to a rep-digit of itself, while multiplying the existing digits by 10 (moving the `#` marker to the right in the process). This binary representation will be quite a jumble of different digits, but the total number will be equal to the value of the original integer. Note the `\w` at the end - normally this is just `0`, but we want to treat `_` as zero as well (which is considered a word character in regex).
```
\d
11
```
We turn each digit into two `1`s, thereby a) ensuring all digits are the same (which will be necessary later) and b) doubling each of the numbers.
```
(?=(1*)\1)[^.]
$1
```
This does two things: it squares all numbers (or rather half of each number, by computing a sum over `2n`), and adds the resulting squares of the width and the height. Notice that `[^.]` matches `1`s, `#` markers and spaces. If it's a `#` or a space, the lookahead won't capture anything, which means all of those are simply removed, i.e. the results for the width and height are concatenated/added. The decimal point `.` remains to separate the result for `d` from those. If `[^.]` matches a `1` instead, then the lookahead ensures that we capture half of the `1`s after it (rounded down) in group `1`. This computes the sum I mentioned above, which will then yield the square of the original number.
```
^(1+)\.\1{90000}1+
Retina!
```
The string is now `d2` (in unary), then `.`, then `w2 + h2` (in unary). We want to know if the first unary number times `90000` is shorter than the second. We can easily do this multiplication using a capturing group and `{n}` repetition syntax. We use `1+` (instead of `1*`) afterwards to ensure that the second number is actually *greater* than that and not just equal. If so, we replace all of that by `Retina!`.
```
1.+
Trash!
```
If the second number wasn't big enough, then the previous step won't have changed anything and the string will still start with a `1`. If that's the case, we just replace the entire string by `Trash!` and are done.
[Answer]
## Python, 49
```
lambda w,h,d:"RTertaisnha!!"[w*w+h*h<=9e4*d*d::2]
```
Uses string interleaving.
It turned out shorter to square both sides than to use the complex norm.
```
w*w+h*h<=9e4*d*d
abs(w+1j*h)<=300*d
```
[Answer]
# CJam, ~~30 29~~ 27 bytes
```
q~mh300/<"Retina""Trash"?'!
```
Requires input to be in form of `diagonal width height`
*UPDATE: 1 byte saved thanks to Dennis!*
[Try it online here](http://cjam.aditsu.net/#code=q~mh300%2F%3C%22Retina%22%22Trash%22%3F'!&input=9.96%202560%201440%20)
[Answer]
# [Retina](https://github.com/mbuettner/retina), 312 bytes
```
(\d+) (\d+) (\d+)(?:\.(\d+))?
a$1bc$2dj300ke$3fg$4h9iiiiiiiii8iiiiiiii7iiiiiii6iiiiii5iiiii4iiii3iii2ii1i0
+`(b.*)(d.*)fg(\d)
0$10$2$4fg
+`(a|c|e|j)(\d)(\d*)(i*)((?:b|d|f|k).*h.*\2(i*))
$1$3$4$4$4$4$4$4$4$4$4$4$6$5
g`(i+)
Q$1R$1
+`Q(i+)Ri
$1Q$1R
+`(j(i*).*e)i(.*f)
$1$3$2
a(i*).*c(i*).*f\1\2.*
Trash!
.*0
Retina!
```
This does take quite a while to run, but it seems to work.
Probably could be golfed a lot more...
## Explanation:
```
(\d+) (\d+) (\d+)(?:\.(\d+))?
a$1bc$2dj300ke$3fg$4h9iiiiiiiii8iiiiiiii7iiiiiii6iiiiii5iiiii4iiii3iii2ii1i0
```
Add tags to make the string more convenient to parse, and add some junk to make it easier to convert to base 1, and add a 300 to multiply by later
```
+`(b.*)(d.*)fg(\d)
0$10$2$4fg
```
Append `0`s to the width and height, while appending the decimal part of the diagonal to the integer part. When this is done, the diagonal will be an integer, and the width and height will be multiplied by however many `10`s were necessary.
```
+`(a|c|e|j)(\d)(\d*)(i*)((?:b|d|f|k).*h.*\2(i*))
$1$3$4$4$4$4$4$4$4$4$4$4$6$5
```
Convert all numbers to base 1, using the lookup-table I appended in the first step
```
g`(i+)
Q$1R$1
```
Prepare to square all of the numbers
```
+`Q(i+)Ri
$1Q$1R
```
Square each number
```
+`(j(i*).*e)i(.*f)
$1$3$2
```
Multiply the square of the diagonal by the square of the 300 we inserted in the first step
```
a(i*).*c(i*).*f\1\2.*
Trash!
```
If the width appended to the height fits in the product we just computed, the pixel density is too low, and it's Trash!
```
.*0
Retina!
```
Otherwise, it's Retina!
[Answer]
# APL, ~~40~~ 36 bytes
Saved 4 bytes thanks to Dennis!
```
{(9E4×⍵*2)<+/⍺*2:'Retina!'⋄'Trash!'}
```
This creates an unnamed dyadic function that takes the first two arguments on the left and the third on the right. It checks whether the sum of the squares of the left values is greater than 300^2 times the square of the right one. Output is printed accordingly.
You can [try it online](http://tryapl.org/?a=4096%202160%7B%289E4%D7%u2375*2%29%3C+/%u237A*2%3A%27Retina%21%27%u22C4%27Trash%21%27%7D19&run)!
[Answer]
# TI-BASIC, 43
Takes width and height through the homescreen as a two-element list, and diagonal through Input.
```
Input D
If 300D>√(sum(Ans²
Then
Disp "Retina!
Else
"Trash!
```
TI-BASIC's two-byte lowercase letters add 7 bytes (`i`, being the imaginary unit, is one byte) cause it to be quite uncompetitive. Thankfully, `!` is also one byte because it represents the factorial function.
[Answer]
# JavaScript ES6, 49 bytes
```
(w,h,d)=>Math.hypot(w,h)/d>300?'Retina!':'Trash!'
```
I hate that JavaScript has such long math operators. But even if there was a `Math.pythagorean` this would be shorter.
[Answer]
## Excel, 44 bytes
Type your inputs in these cells.
* A1 = Width in pixels
* B1 = Height in pixels
* C1 = Diagonal in inches
And this formula gives your result:
```
=IF((300*C1)^2<A1^2+B1^2,"Retina!","Trash!")
```
[Answer]
# Prolog, 51 bytes
```
a(W,H,D,R):-9e4*D*D<W*W+H*H,R="Retina!";R="Trash!".
```
Running `a(8192,4320,100.0,R).` outputs: `R = "Trash!" .`
Edit: Thanks to @PaulButcher for correcting an edge case and golfing one byte.
[Answer]
# Pyth - 27 bytes
Uses ternary operator and `abs` to calculate pythagorean.
```
?>c.avzQ300"Retina!""Trash!
```
Takes input in two lines, first line `width, height`, second line `diag`.
The rules were relaxed so rolling back.
[Try it online here](http://pyth.herokuapp.com/?code=%3F%3Ec.avzQ300%22Retina!%22%22Trash!&input=1920%2C%201080%0A4.95&debug=0).
[Answer]
## JavaScript (ES6), 45 bytes
```
f=(w,h,d)=>w*w+h*h>d*d*9e4?'Retina!':'Trash!'
```
## CoffeeScript, 47 bytes
No ternary operator, but there is exponentiation (which doesn't help in the latest attempt).
```
f=(w,h,d)->w*w+h*h>d*d*9e4&&'Retina!'||'Trash!'
# Previous attempt
f=(w,h,d)->(w*w+h*h)**.5/d>300&&'Retina!'||'Trash!'
```
[Answer]
# [O](http://o.readthedocs.org/), ~~40~~ 37 bytes
```
jjjrmd\/'īu>{"Retina!"p}{"Trash!"p}?
```
A lot of bytes for the input formatting :\
[Try it online](http://o-lang.herokuapp.com/link/code=jjjrmd%5C%2F%27%C4%ABu%3E%7B%22Retina!%22p%7D%7B%22Trash!%22p%7D%3F&input=1920%0A1080%0A4.95)
[Answer]
# Pure Bash (no bc/other external commands), ~~138~~ ~~136~~ ~~135~~ ~~82~~ 83 bytes
```
a=${3#*.}
d=${a//?/0}
r=(Trash Retina)
echo ${r[$1$d**2+$2$d**2>90000*${3/./}**2]}!
```
I decided to try doing it in pure bash. I've probably made a few obvious inefficiencies as this is my first time code golfing, but I am VERY familiar with bash and have had fun in the past trying to write things that don't use any external commands (ie pure bash).
~~The printf statement is the most annoying. Anyone got any better ideas for padding numbers with zeroes?~~
EDIT: Saved two bytes, turns out printf will take an empty argument for zero. Saved another byte, turns out I'd previously miscounted and just assigning the output of printf to a variable is smaller than using -v.
EDIT2: Thanks to Digital Trauma in the comments, this is now down much more significantly. Tricks: using bash's regex support to replace the string of digits with zeroes instead of counting it then printing that number of zeroes (seems obvious when I put it like that...), storing the strings in a bash array to save an echo, and taking into account a slight change in rules that means you can end all input numbers in .0.
EDIT3: Added a byte to fix bug introduced by Digital Trauma's suggested modification.
[Answer]
# dc, 41 bytes
```
[[Retina!]pq]sr?d*rd*+vr/300<r[Trash!]p
```
Requires args to be input in `d, w, h` order - I hope this is OK.
### Test output:
```
$ for t in \
> "4.95 1920 1080" \
> "5.96 2560 1440" \
> "10.5 1920 1080" \
> "0.04 10 10" \
> "19 4096 2160" \
> "100.00 8192 4320" \
> "11.18 3000 1500" ; do \
> echo $t | dc -e'9k[[Retina!]pq]sr?d*rd*+vr/300<r[Trash!]p'
> done
Retina!
Retina!
Trash!
Retina!
Trash!
Trash!
Retina!
$ 
```
[Answer]
# Julia, ~~46~~ ~~45~~ 42 bytes
```
f(w,h,d)=w^2+h^2>9e4d^2?"Retina!":"Trash!"
```
This creates a function that accepts three numeric values and returns a string.
It's a direct implementation of the formula, just rearranged a bit. Both sides of the inequality were multiplied by `d` then squared.
[Answer]
# R, ~~59~~ 55 Bytes
As an unnamed function now
```
function(h,w,d)if(h^2+w^2>9e4*d^2)'Retina!'else'Trash!'
```
Very simple implementation, that eliminates the need for the index references.
**Previous**
```
cat(if((n=scan()^2)[1]+n[2]>9e4*n[3])'Retina!'else'Trash!')
```
Fairly simple, get the input from scan into a vector (single line, space separated or multi-line). Square the vector. Do the calculation and cat the result.
[Answer]
# MATLAB - ~~49~~ 45 bytes
```
c={'Trash!','Retina!'};c{(w*w+h*h>9e4*d*d)+1}
```
I first had to declare a cell array which contains `Trash!` and `Retina!` which are stored in locations 1 and 2 in the cell array. Next, I use the observation observed by many to rearrange the equation so that you are checking for the condition only using integer arithmetic. I represented 90000 as `9e4` to save some bytes. If this condition is true, we output a 1, else we output a 0. I use this output to index directly into the cell array. Because MATLAB starts indexing at 1, I also had to add 1 to complete the indexing. What's nice is that adding `true` with 1 gives 2, while adding `false` with 1 gives 1. This will output either `Trash!` or `Retina!` in the MATLAB command prompt.
# Example
```
>> w=1920;h=1080;d=4.95;
>> c={'Trash!','Retina!'};c{(w*w+h*h>9e4*d*d)+1}
ans =
Retina!
```
[Answer]
# XSLT, 400 bytes
This is the debut of a never-before seen language on PPCG, and I hope to use it more in the future as I get to know it more.
## Code:
```
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="input"><xsl:variable name="n" select="for $i in tokenize(.,'[^\d\.]+')return number($i)" /><xsl:choose><xsl:when test="$n[1]*$n[1]+$n[2]*$n[2]>90000*$n[3]*$n[3]">Retina!</xsl:when><xsl:otherwise>Trash!</xsl:otherwise></xsl:choose></xsl:template></xsl:stylesheet>
```
### Pretty Printed
```
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="input">
        <xsl:variable name="n" select="for $i in tokenize(.,'[^\d\.]+')return number($i)" />
        <xsl:choose>
            <xsl:when test="$n[1]*$n[1]+$n[2]*$n[2]>90000*$n[3]*$n[3]">
                Retina!
            </xsl:when>
            <xsl:otherwise>
                Trash!
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
```
## Notes:
As XSLT has no way of taking input via STDIN, we have to use an XML file, with the input between two `<input>` tags. Of course, this method has its limitations but it will work perfectly well for most challenges.
## Example I/O
### Input file:
```
<?xml version="1.0" encoding="ISO-8859-1"?>
<input>3000 1500 11.18</input> 
```
### Output file:
```
<?xml version="1.0" encoding="UTF-8"?>Retina!
```
---
### Input file:
```
<?xml version="1.0" encoding="ISO-8859-1"?>
<input>1920 1080 10.5</input>
```
### Output file:
```
<?xml version="1.0" encoding="UTF-8"?>Trash!
```
[Answer]
## C# (81)
```
string D(int w,int h,double d){return Math.Sqrt(w*w+h*h)/d>300?"Retina":"Trash";}
```
Ungolfed:
```
string Density(int width, int height, double diagonal)
{
    return Math.Sqrt(width * width + height * height) / diagonal > 300 ? "Retina" : "Trash";
}
```
[Answer]
## Swift, 77 bytes
Function parameter declerations mean this takes up way more characters than it should:
`func r(w:Float,h:Float,d:Float){print((w*w+h*h)>9e4*d*d ?"Retina!":"Trash!")}`
[Answer]
# Swift, 56 bytes
```
let r={print($0*$0+$1*$1>9e4*$2*$2 ?"Retina!":"Trash!")}
```
Basically the same as [GoatInTheMachine](https://codegolf.stackexchange.com/users/32504/goatinthemachine)'s but with implicit closure parameters
When Code Golfing with Swift, always declare methods like this, it's much shorter
[Answer]
## Haskell, 46
```
f w h d|w^2+h^2>d^2*9e4="Retina!"|0<1="Trash!"
```
[Answer]
**C++ 72 70 Byte**
```
void F(int w,int h,float d){cout<<w*w+h*h>9e4*d*d?"Retina!":"Trash!";}
```
Similiar to other solutions, figured out myself to warm up with code golf.
[Answer]
Here is my contribution for this problem
## Ruby, 67 bytes reading from stdin
```
w,h,d=ARGV.map{|v|Float(v)}
puts w*w+h*h>d*d*9e4?"Retina!":"Trash!"
```
## Ruby, 56 bytes in a function
A bit shorter
```
def r(w,h,d)
puts w*w+h*h>d*d*9e4?"Retina!":"Trash!"
end
```
Thanks to the previous contributors for the 9e4!
[code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'")[ruby](/questions/tagged/ruby "show questions tagged 'ruby'")
[Answer]
# Bash, 85 bytes
```
if [ $(echo "sqrt($1^2+$2^2)/$3"|bc) -gt 300 ];then
echo Retina!
else
echo Trash!
fi
```
[Answer]
# PHP, 47,43,40 38 bytes
```
<?=sqrt($w*$w+$h*$h)/$d>300?'Retina':'Trash'?>!
<?=sqrt($w*$w+$h*$h)/$d>300?Retina:Trash?>!
<?=$w*$w+$h*$h>9e4*$d*$d?Retina:Trash?>!
```
```
<?=hypot($w,$h)/$d>300?Retina:Trash?>!
```
Requires `register_globals==true` (which it should never be!), with GET values w,h,d  
- Saved 4 bytes by removing quotes around string. Bad coding, but it works.  
- Moved `d` and square root to the other side of the equation, saving the `sqrt()` function  
- Saved 2 bytes by switching to [`hypot()`](http://php.net/hypot) (thank you [Lucas Costa)](https://codegolf.stackexchange.com/users/42414/lucas-costa)
[Answer]
# C# 6, 67 Bytes
```
string D(int w,int h,double d)=>w*w+h*h>9e4*d*d?"Retina!":"Trash!";
```
This answer is based on Wolfsheads answer. I made it 8 bytes shorter using a new feature of C# 6.
[Answer]
# JavaScript (ES6) 58 54 43 Bytes
### 43 Bytes
Removed function assignment (as per PPCG rules) (-2), as well as remove square root and comparing to 900 (300^2) (-12)
```
(w,h,d)=>w*w+h*h/d*d>300?"Retina!":"Trash!"
```
### 54 Bytes
Got rid of unnessesary parentheses (-4 bytes)
```
a=(w,h,d)=>Math.sqrt(w*w+h*h)/d>300?"Retina!":"Trash!"
```
### 58 Bytes
```
a=(w,h,d)=>Math.sqrt((w*w)+(h*h))/d>300?"Retina!":"Trash!"
```
Explanation here:
```
a =                           // The function is a
 (w,h,d) =>                   // Accepts the three arguments
   Math.sqrt((w*w)+(h*h))/d   // Calculate pixel density
   > 300                      // Above the threshold
   ? "Retina!"                // If so, return "Retina!"
   : "Trash!"                 // Otherwise return "Trash!"
```
This uses [ternary operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) to test the density and kills a couple of bytes by using [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)
[Answer]
# Java, ~~82~~ 74 bytes
```
String g(int w,int h,double d){return 9e4*d*d>w*w+h*h?"Trash!":"Retina!";}
```
Call it with `g(width,height,diagonal)`
[Answer]
# Clojure, 58 bytes
```
#(if(>(+(* %1%1)(* %2%2))(* %3%3 90000))"Retina!""Trash!")
```
Used @Kroltan's fancy math to shorten this. Uses implicit arguments passed in the order of (w, h, d).
First Clojure golf...I was surprised how much whitespace I am allowed to leave out
]