# Is this relationship creepy?

According to this XKCD comic, there is a formula to determine whether or not the age gap in a relationship is "creepy". This formula is defined as:

(Age/2) + 7


being the minimum age of people you can date.

Therefore a relationship is creepy if either of the people in said relationship are younger than the minimum age of the other.

Given the age of two people, can you output whether or not that relationship is creepy?

### Rules

1. Your program should take two integers as input, the age of both people in the relationship. These can be taken in any reasonable format.

2. Your program must then output a truthy or falsy value describiing whether or not the relationship is "creepy" (Truthy = Creepy).

3. Standard loopholes are not allowed.
4. This puzzle is Code Golf, so the answer with the shortest source code in bytes wins

### Test Cases

40, 40    - Not Creepy
18, 21    - Not Creepy
80, 32    - Creepy
15, 50    - Creepy
47, 10000 - Creepy
37, 38    - Not Creepy
22, 18    - Not Creepy

• How should age/2 be rounded? Probably up if the exact half is supposed to be the minimum? 17,21 would make a good test case. May 24, 2017 at 18:20
• @MartinEnder The value is a minimum, so do not round at all. It doesn't have to be an integer.
– Leo
May 24, 2017 at 18:24
• You could also add 13, 13 - Creepy. May 24, 2017 at 19:20
• 47, 10000 is an... interesting combination. I would also like to point out that according to this formula, it is creepy for Doctor Who to date any human. May 26, 2017 at 15:01
• @DavidConrad - well yeah. its basically beastiality on his part.... May 26, 2017 at 16:47

# Fourier, 37 bytes

oI~AI~B>A{1}{A~SA~BS~B}A/2+7>B{1}{@o}


Try it on FourIDE!

Takes two numbers as input. Will golf later.

• It doesn't need to output a string like that, can be truthy or falsy
– Leo
May 24, 2017 at 18:26
• Nice golf. That was quick. May 24, 2017 at 18:38

# PHP, 29 Bytes

prints 1 for creepy, nothing for Not creepy

<?=max($_GET)/2+7>min($_GET);


Try it online!

• As I understand the rules this fails on [34,19] Oct 15, 2017 at 12:43

# Japt, 11 bytes

Returns true for "creepy" and false for not.

wV /2+7>UmV


Try it online

## Explanation

      :Implicit input of first integer U
wV    :Get the maximum of U and the second integer V
/2+7  :Divide by 2 & add 7
>     :Check if the result is greater than...
UmV   :the minimum of the two integers.


# J, 10 bytes

<.<7+2%~>.


Outputs 1 for not creepy, 0 for creepy

### Explanation

<.          NB. the minimum
>         NB. is greater than
7+2%~>. NB. half the maximum + 7


# J-uby, 25 bytes

:>%[:min,:max|~:/&2|:+&7]


Call like f^[80,32]. Gives true for not creepy, false for creepy.

### Explanation

    :min                  # the minimum
:>%[    ,               ] # is greater than
:max|            # the maximum...
~:/&2|        # over two...
:+&7    # plus 7

• This is a beautiful language. I spent a long time trying to accomplish similar ends with Ruby (I called it "Blurb"), but leaning heavily on method_missing led to too much complexity. This approach is clean and elegant. Congrats! May 25, 2017 at 2:53
• @Jordan thanks! I can't take all the credit, as this was heavily inspired by J (hence the name). I'm open to suggestions from a fellow Ruby programmer if you have any. May 25, 2017 at 3:04
• @Jordan you should see some of the other more complex J-uby answers. They're quite something. May 25, 2017 at 3:21

# AWK, 26 bytes

{$0=$1/2+7>$2||$2/2+7>$1}1  Try it online! Outputs 1 for "Creepy" and 0 for "Not Creepy". Could save 3 bytes if no-output could be consider a falsy value, via: $0=$1/2+7>$2||$2/2+7>$1


# Swift - 33 bytes

var f={max($0,$1)/2+7>min($0,$1)}


A lambda-function's equivalent in Swift, but unfortunately cannot take an array :((. Outputs true for truthy and false for falsy. If one must not count the declaration of the function (Python doesn't) the byte count would be 27. Usage: print(f(age1,age2))

Check it out!

# Röda, 16 bytes

{sort|[_<_/2+7]}


Try it online!

This is an anonymous function that takes input as two literals (not an array) from the input stream.

### Explanation

{sort|[_<_/2+7]}                 Anonymous function
sort                            Sorts the numbers in the input stream
|[       ]                  And push
_<                        whether the smaller value  is less than
_/2+7                   the greater value / 2 + 7


# Ruby, 21 bytes

->*x{x.max/2+7>x.min}


Yup.

f = ->*x{x.max/2+7>x.min}
f[18,21]  #=> false
f[80,32]  #=> true


# z-shell (zsh), 38 bytes

n=(${(no)@});echo$((n/2+7-n>0))


${(no)@} is a numeric sort of the argument array # Perl 5, 34 + 2 (-ap) = 36 bytes $_=$F/2+7>$F|$F/2+7>$F


Try it online!

## BASH, 135 bytes

I dabbled in this area a few years ago. I think that Greg Martin's point should factor in, and wonder how he picked 13 and not, (for example) 12 as 13 is the upper bound of x < x/2+7. Leo what is the test cases for [14,21], [15,15] and [16,21]?

#!/bin/bash
[ $1 -lt$2 ]&&./$0$2 $1&&exit [$(($1+$2)) -ge $(((($1-$2)/2)**2)) ]&&[$((((($2*10)+5)/19)+7)) -lt$2 ]&&echo -n 'Not ';echo Creepy


(could save bytes by using ✗ for "Creepy" and ✓ for "Not Creepy" or exit codes)

# ARBLE, 25 bytes

lt(min(a,b),max(a,b)/2+7)


Try it online!

# Python 3, 115 bytes

Edit : Bugfix according to @Alexx Roche

a=int(input())
b=int(input())
c=a
d=b
if b < a:
c=b
d=a
if not c < d/2.0+7:
print("Not ",end='')
print("Creepy")


Try it online!

• This answer is far from golfed. For example, you can right your if statements all on one line, remove excess whitespace in all your comparisons, take the input as simply a,b=eval(input()). Furthermore there are many changes in the algorithm you're using that could make it shorter. Nov 20, 2017 at 20:59

# ><>, 14 Bytes

:{:{(?r2,7+)n;


Pretty simple, but I don't see any obvious ways to cut down on characters.

### Explanation:

               | Assume input is on the stack
:{:{           | Duplicate items on the stack (we pop them for inequality testing)
(?r        | Sort them, so that the larger is on top of the stack
2,7+    | Divide top item by 2 and add 7
)n; | Print the truthy value of younger > (older/2) + 7


Prints 1 for non-creepy relationships, 0 for creepy ones

# Befunge, 28 bytes

&:&:00p00g\> #0 #\_\7-2*.@


Try It Online

Since Befunge uses integer math, I flipped it and added 7 to the minimum then multiplied by 2. 1 = Creepy, 0 = Not creepy

L,#2/7+>


Try it online!

2 bytes off Jelly just feels weird

## How it works

L,   - Lambda function
- Example arguments: [15 50]
#  - Sort;      STACK = [15 50]
2/ - Halve;     STACK = [15 25]
7+ - Add 7;     STACK = [15 32]
>  - Greater;   STACK = 

• I see no output when I run it. Aug 16 at 7:24
• @TheEmptyStringPhotographer That's because it's an anonymous function. You need to actually call it to get output, which you can do with the -i flag: Try it online! Aug 16 at 11:39

# Pyt, 7 bytes

Đ↔₂7+≥Π


Try it online!

Takes input as an array of integers

Explanation:

       Implicit input [x,y]
Đ      Duplicate the array  [x,y],[x,y]
↔      Flip the top array   [x,y],[y,x]
₂      Divide the top of the stack by 2    [x,y],[y/2,x/2]
7+     Add 7 to each element of the top of the stack    [x,y],[y/2+7,x/2+7]
≥      Is the second on the stack greater than or equal to the top elementwise [x>=y/2+7,y>=x/2+7]
Π      Take the product (auto-casts to integers)
Implicit print


# Stax, 6 bytes

Æ╠àá;╚


Run and debug online

Here's the ungolfed ascii representation of the same program.

oE  sort inputs and push each to stack, now the larger age is on top of the stack
^h  increment larger age and integer divide by 2
<   is the first number less than the second?


Run this one

# Japt, 10 bytes

n v <U/2+7


Try it online!

Takes a 2-element array as input.

### How it works

Un v <U/2+7

Un  Sort the input
v   Pop the first element (smaller one)
<   less than...
U/2+7  Implicitly cast the remaining 1-length array to number (larger one)
then calculate /2+7


# Vyxal, 8 bytes

sh½7+⁰t≥


Try it Online!

Inputs are a 2 element list.

# Husk, 8 bytes

F·>o+7½O


Takes input as a 2-element list

F·>o+7½O
O  sort
F         fold / apply following binary function to the elements
· o+7½   apply this to the second argument
½   halve
>       compare


Try it online!

# PowerShell, 60 bytes

$c={param($a,$b)[math]::max($a,$b)/2+7-gt[math]::min($a,$b)}  Try it online! No doubt could be improved upon! # Excel VBA, 28 Bytes Anonymous immediate window function that tTakes age inputs from cells [A1] and [B1] as expected type Integer and outputs a Boolean value representing creepyness to the VBE immediate window ?[B1]/2+7>[A1]|[A1]/2+7>[B1]  • Can't you just write this as a formula in a cell? – Neil May 24, 2017 at 18:53 • @Neil, yes I <s>could</s> have, though my particular purpose in golfing with VBA is more to keep some level of practice up with the language, rather than optimizing for the byte count May 25, 2017 at 13:10 • Ah yes, VBA is a slightly different language. – Neil May 25, 2017 at 13:26 ## QBIC, 30 bytes ~:>:|c=a┘d=b\c=b┘d=a]?d>=c/2+7  Explanation  First, we mustsort the input parameters ~:>: IF a (from cmd line) > b (from cmd line) |c=a┘d=b THEN set c and d \c=b┘d=a ELSE set c and d in the other way ] END IF ?d>=c/2+7 PRINT -1 if d is higher than c's lower bound, 0 for creepy  # shortC, 21 bytes D(a,b)a/2+7<b|b/2+7<a  # CJam, 10 bytes q~$~2d/7+<


Takes input as a list.

Try it online!

### Explanation

q~          e# Read and eval input.
$e# Sort the list. ~ e# Dump the list on the stack. 2d/7+ e# Apply age/2+7 to the greater age. < e# Check if the other age is less than that.  • Do you need the d? all the test cases work without it. May 24, 2017 at 20:41 • @Challenger5 OP said not to round if the age is an odd number, so I assume so. May 24, 2017 at 23:04 # Pyth, 171613 12 bytes >+7/.)JSQ2hJ  Takes a list. Outputs True for creepy, False for not creepy. Try it! ### explanation >+7/.)JSQ2hJ JSQ # Sort the input list (Q) and store the result in J .) # pop the last/largest element from J (lets call it x) hJ # the first/only element of J (lets call it y) >+7/ 2 # 7 + x/2 > y  ## old approach, 13 bytes s.b<Y+7/N2_QQ  Takes a list. Outputs 1 for creepy, 0 for not-creepy. Try it! ### explanation s.b<Y+7/N2_QQ .b _QQ # map over the list and it's reversal (variables: Y,N) <Y+7/N2 # Y < N/2 + 7 s # sum: False + False = 0; True + False = 1 (; True + True = 2 can never occur, because one of the ages is always larger or equal)  # Actually, 12 bytes ;RZ⌠i½7+≤⌡Mπ  Outputs 1 if it's not creepy, and 0 if it is. Explanation: ;RZ⌠i½7+≤⌡Mπ implicit input: [a, b] ;RZ zip input with its reverse ([[a,b], [b,a]]) ⌠i½7+≤⌡M for each pair: i flatten ½7+ half of one plus 7 ≤ is less than or equal to the other? π product (acts as a boolean AND)  # tcl, 59 scan$argv %d\ %d x y
puts [expr max($x,$y)/2+7>min($x,$y)]


demo

To try, type

tclsh main.tcl Age1 Age2

on the green area.