| Bytes | Lang | Time | Link |
|---|---|---|---|
| 055 | Tcl | 170526T180647Z | sergiol |
| 028 | Swift 6 | 250425T152639Z | macOSist |
| 026 | Raku Perl 6 rakudo | 250320T152741Z | xrs |
| 008 | Jalapeño | 250325T220617Z | ATaco |
| 052 | SAKO | 250320T090104Z | Acrimori |
| 047 | Go | 250320T165325Z | bigyihsu |
| 026 | Janet | 250320T121043Z | xigoi |
| 044 | Tcl | 170526T183726Z | sergiol |
| 042 | PowerShell | 231207T060547Z | MarkJust |
| 060 | PowerShell | 231106T123111Z | Mark Har |
| 005 | Nekomata + e | 230615T023332Z | alephalp |
| 008 | Uiua | 231106T051826Z | Bubbler |
| 024 | ARM64 machine code | 231106T045136Z | Nate Eld |
| 016 | x8664 machine code | 231106T044312Z | Nate Eld |
| 020 | Arturo | 230615T020349Z | chunes |
| 016 | K oK | 230614T235049Z | Boris Ka |
| 005 | Thunno 2 G | 230614T164406Z | The Thon |
| 008 | Husk | 220930T230517Z | Natte |
| 008 | Vyxal | 220930T201845Z | pacman25 |
| 010 | Japt | 180523T071100Z | Bubbler |
| 006 | Stax | 180319T170605Z | recursiv |
| 096 | FORTH 96 Bytes | 180319T155249Z | panicmor |
| 007 | Pyt | 180318T040201Z | mudkip20 |
| 008 | Add++ | 171130T225006Z | caird co |
| 028 | Befunge | 171201T010020Z | Jo King |
| 014 | ><> | 171120T212218Z | Bolce Bu |
| 551 | NAND gates | 170904T165556Z | Khuldrae |
| 115 | Python 3 | 170527T155713Z | Luatic |
| 025 | ARBLE | 171016T043158Z | ATaco |
| 135 | BASH | 171015T120037Z | Alexx Ro |
| 045 | Python 3 | 170524T184635Z | kuantum |
| 262 | NAND gates | 170903T204811Z | Khuldrae |
| 011 | Jq 1.5 | 171014T050631Z | jq170727 |
| 016 | q/kdb+ | 170525T184820Z | mkst |
| 007 | Sakura | 170904T190610Z | TuxCraft |
| 056 | C | 170903T220100Z | HatsuPoi |
| 011 | Dyalog APL | 170904T141336Z | Adalynn |
| 008 | Ly | 170825T014036Z | LyricLy |
| nan | Perl 5 | 170825T012305Z | Xcali |
| 009 | TIBasic | 170524T183957Z | pizzapan |
| 010 | MATL | 170614T010100Z | DrQuariu |
| 027 | Python 3 | 170526T172249Z | nocturam |
| 025 | R | 170524T193149Z | Giuseppe |
| 006 | 05AB1E | 170524T182752Z | Riley |
| 024 | Excel | 170525T130835Z | Taylor R |
| 029 | C | 170524T183612Z | MD XF |
| 018 | Alice | 170526T002950Z | Nitrodon |
| 038 | zshell zsh | 170527T194242Z | gsker |
| 064 | S.I.L.O.S | 170527T135815Z | Rohan Jh |
| 016 | Wolfram Language | 170526T204607Z | Scott Mi |
| 031 | Python 3 | 170526T191725Z | Delya Er |
| 027 | Crystal | 170525T140726Z | TitusLuc |
| 021 | Java | 170525T213532Z | Olivier |
| nan | 170525T221407Z | Brad Gil | |
| 021 | Ruby | 170525T214734Z | daniero |
| 050 | Batch | 170525T115238Z | Neil |
| 023 | GNU APL 1.2 | 170525T114913Z | Arc676 |
| 021 | JavaScript ES6 | 170524T190439Z | Rick Hit |
| 016 | Röda | 170525T094916Z | user4180 |
| 022 | C# | 170525T084527Z | TheLetha |
| 012 | Actually | 170524T203233Z | user4594 |
| 077 | SAS | 170524T200204Z | J_Lard |
| 033 | Swift | 170524T194101Z | Mr. Xcod |
| 016 | Mathics | 170524T184003Z | Pavel |
| 012 | Pyth | 170524T185510Z | KarlKast |
| 010 | TIBasic | 170524T184413Z | Timtech |
| 010 | CJam | 170524T192719Z | Business |
| 026 | AWK | 170524T192002Z | Robert B |
| 025 | Juby | 170524T191320Z | Cyoce |
| 010 | J | 170524T190035Z | Cyoce |
| 027 | JavaScript ES6 | 170524T185349Z | Stephen |
| 021 | shortC | 170524T183721Z | MD XF |
| 011 | Japt | 170524T182531Z | Shaggy |
| 029 | PHP | 170524T185435Z | Jör |
| 006 | Jelly | 170524T185324Z | Erik the |
| 020 | Retina | 170524T184753Z | Martin E |
| 030 | QBIC | 170524T184534Z | steenber |
| 037 | Fourier | 170524T182258Z | Beta Dec |
| 028 | Excel VBA | 170524T183521Z | Taylor R |
| 026 | Python 3 | 170524T183519Z | Rod |
Swift 6, 28 bytes
let c={$0/2+7>$1||$1/2+7>$0}
Jalapeño, 8 bytes
⇊>{₃⇈/2+7
Hex-Dump of Bytecode
0 1 2 3 4 5 6 7 8 9 A B C D E F
0000: f2 5b c7 f0 53 32 50 37
Obvious answer
Explained
⇊>{₃⇈/2+7
⇊ # The minimum of the pair
>{₃ # Is larger than
⇈/2+7 # The max / 2 + 7
SAKO, 52 bytes
Subroutine, 52 bytes
PODPROGRAM:F(N,M)
F()=MAX(N/2+7,M/2+7)-MIN(N,M)
WROC
Returns positive value if creepy, and negative or zero if not.
Subroutine, 59 bytes
PODPROGRAM:F(N,M)
F()=SGN(1,MAX(N/2+7,M/2+7)-MIN(N,M))
WROC
Returns 1 if creepy, and -1 or 0 if not.
Full, 61 bytes
1)CZYTAJ:N,M
DRUKUJ(0):MAX(N/2+7,M/2+7)-MIN(N,M)
STOP1
KONIEC
Returns positive value if creepy, and negative or zero if not.
Full, 68 bytes
1)CZYTAJ:N,M
DRUKUJ(0):SGN(1,MAX(N/2+7,M/2+7)-MIN(N,M))
STOP1
KONIEC
Prints 1 if creepy, and -1 or 0 if not.
Tcl, 44 bytes
I was losing to answers implementing it as a function, so I had to make mine into a function also:
proc c x\ y {expr max($x,$y)/2+7>min($x,$y)}
PowerShell, 42 bytes
$c={param($a,$b)$a/2+7-gt$b-or$b/2+7-gt$a}
Rather than using [math]::min and ::max, I'm trying both $a vs $b and $b vs $a then -or the result.
PowerShell, 60 bytes
$c={param($a,$b)[math]::max($a,$b)/2+7-gt[math]::min($a,$b)}
No doubt could be improved upon!
Nekomata + -e, 5 bytes
Ṁä7+≥
Returns True for not creepy, False for creepy.
Ṁ Get the maximum of the input
ä Divide it by 2
7+ Add 7
≥ Is every element of the input greater than or equal to that?
Uiua, 8 bytes
<+7÷2⊃↥↧
<+7÷2⊃↥↧ input: two ages as two separate stack items
⊃↥↧ push max and min of the two ages
+7÷2 max / 2 + 7
< is greater than min?
ARM64 machine code, 24 bytes
Takes the ages in w0, w1, returns 0 or 1 in w0, following normal ARM64 calling conventions for bool creepy(int, int);. (You could handle 64-bit ages by replacing all w with x registers, with no increase in size.)
4b010402
4b000423
3100385f
3a4ed860
1a9fd7e0
d65f03c0
Assembly source follows. We test x-2*y > -14 || y-2*x > -14.
creepy:
sub w2, w0, w1, lsl #1
sub w3, w1, w0, lsl #1
cmn w2, #14
ccmn w3, #14, #0, le // #0 = none of NZCV, makes gt true
cset w0, gt
ret
x86-64 machine code, 16 bytes
Takes the ages in edi, esi, returns 0 or 1 in eax, following x86-64 SysV ABI for bool creepy(int, int);.
39 f7 7d 02 87 fe 8d 44 36 f2 29 f8 c1 e8 1f c3
Assembly source follows. We test 2*young - 14 - old < 0.
creepy:
cmp edi, esi
jge ready
xchg edi, esi
ready:
;; higher age now in edi
lea eax, [rsi*2-14]
;; eax = highest age the younger person can date
sub eax, edi
;; if result is negative, then creepy
shr eax, 31
ret
Arturo, 20 bytes
$=>[>7+0.5*do sort&]
$=>[ ; a function where input is assigned to &
sort& ; sort input
do ; dump both ages from input list onto the stack
0.5* ; multiply TOS (the higher age) by 0.5
+7 ; add 7 to TOS
> ; is NOS greater than TOS?
] ; end function
Thunno 2 G, 5 bytes
½7+r<
Port of Riley's 05AB1E answer.
Explanation
½7+r< # Implicit input
½ # Halve each value
7+ # Add seven to each
r # Reverse the list
< # Vectorised less than
# Get the maximum
# Implicit output
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
o+7 then add 7
> compare
Japt, 10 bytes
n v <U/2+7
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
Stax, 6 bytes
Æ╠àá;╚
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
7+ add 7
< is the first number less than the second?
FORTH 96 Bytes
: C 2DUP > -1 = IF SWAP THEN 2 / 7 + SWAP > -1 = IF ." CREEPY " ELSE ." NOT CREEPY " THEN ;
Output:
40 40 c NOT CREEPY ok
18 21 c
18 21 c NOT CREEPY ok
80 32 c
80 32 c CREEPY ok
15 50 c
15 50 c CREEPY ok
47 10000 c
47 10000 c CREEPY ok
37 38 c
37 38 c NOT CREEPY ok
22 18 c
22 18 c NOT CREEPY ok
Pyt, 7 bytes
Đ↔₂7+≥Π
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
Add++, 8 bytes
L,#2/7+>
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 = [1]
Befunge, 28 bytes
&:&:00p`00g\> #0 #\_\7-2*`.@
Since Befunge uses integer math, I flipped it and added 7 to the minimum then multiplied by 2. 1 = Creepy, 0 = Not creepy
><>, 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
NAND gates, 551
Created with Logisim
Same principle as my other answer, but takes 2-byte signed inputs, so it can handle 47, 10000. Works for ALL test cases!
This is not optimal for the given test cases, as 10000 can be expressed with only 15 of the 16 bits, but it works for any ages in the range [-32768, 32768). Note that any negative age will return 1.
Inputs on left (no particular order, 1-bit on top). Output in lower right.
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")
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)
Python 3, 74 45 bytes
First Code Golf, probably terrible.
29 byte reduction by @Phoenix
lambda a,b:0 if(a/2)+7>b or(b/2)+7>a else 1
NAND gates, 274 262
Better:
Created with Logisim
This takes two inputs on the left as 1-byte signed integers, with the 1-bit at the top. Output is in the lower left; the truthy and falsey here should be obvious.
Works for all test cases except 47, 10000, so I guess this is technically not a valid answer. However, the oldest person on (reliable) record was 122, so 8 bits (max 127) will work for any scenario ever possible to this point. I'll post a new answer (or should I edit this one?) when I finish the 16-bit version.
16-bit version is done!
You'll notice some vertical sections of the circuit. The first one (from the left) determines which input is greater. The next two are multiplexers, sorting the inputs. I then add 11111001 (-7) to the lesser in the fourth section, and I conclude by comparing twice this to the greater input. If it is less, the relationship is creepy. Since I shift the bits to double, I must take into account the unused bit of lesser-7. If this is a 1, then lesser-7 is negative, and the younger of the two is no older than six. Creepy. I finish with an OR gate, so if either creepiness test returns 1, the entire circuit does.
If you look closely, you'll see that I used seven one constants (hardcoding the 11111011 and the trailing 0). I did this because Logisim requires at least one value going in for a logic gate to produce an output. However, each time a constant is used, two NAND gates ensure a 1 value regardless of the constant.
-12 gates thanks to me!
q/kdb+, 17 16 bytes
Solution:
{(x&y)<7+.5*x|y}
Try it online! (oK rather than q/kdb+)
Examples:
q){(x&y)<7+.5*x|y}[22;18]
0b
q){(x&y)<7+.5*x|y}[22;17]
1b
Explanation:
Outputs creepy as boolean 1b (true, creepy) or 0b (false, not creepy)
{(x&y)<7+.5*x|y} / solution
{ } / lambda function with implicit parameters x and y
x|y / max of x and y
.5* / multiply by 0.5 (aka divide by 2)
7+ / add 7
< / less than?
(x&y) / min of x and y
Notes:
Polyglot in:
- q/kdb+
- K
- oK (see TIO link)
Sakura, 7 bytes
>Ƣ+ħ⓪7ƣ
Takes input as an array and outputs -1 if creepy and 0 otherwise.
Explanation:
> >
Ƣ max( )
+ +
ħ /2
⓪ input
7 7
ƣ min( )
input
C, C++, Java, C#, D, 56 bytes
-1 byte thanks to Zacharý
int c(int a,int b){return((a>b?a:b)/2+7)>(a>b?b:a)?1:0;}
C, C++, D optimization : 52 bytes
int c(int a,int b){return((a>b?a:b)/2+7)>(a>b?b:a);}
- C++ convert bool object to int implicitly ( false = 0, true = 1 )
- In C, booleans are represented by integers values, where 0 is false, and 1 is true.
I barely know how to print something in D, so i won't comment about boolean to int conversions in this languageZacharý just informed me that D bool to int conversion works exactly like in C/C++- Unfortunately, Java and C# can't convert an integer to a boolean, so we need to use ternary operator.
Ly, 8 bytes
a2/7+Lfp
Explanation:
a2/7+Lfp
a # sort (implicit input)
2/7+ # halve and add 7
L # less than?
fp # pop value, leaving just the result
# implicit output
TI-Basic, 20 10 9 bytes
max(2Ans<14+max(Ans
-10 bytes by using a list and part of Timtech's suggestion
-1 byte using lirtosiast's suggestion
Takes in a list of two ages, "{40,42}:prgmNAME"
Returns 1 for 'creepy' and 0 for 'not creepy'.
MATL, 10 bytes
tEP-X>-14>
My first ever solution. :) Try it online!
Explainer:
t % push the input array [a b] (possibly redundant)
EP % push the flipped(P)+doubled(E) array [2b 2a]
- % subtract to get [a-2b b-2a]
X> % take the maximum
-14> % if either exceeds -14, then it is creepy af bro!
Python 3 - 32 27 bytes
Unable to comment, but I got a slightly shorter answer than the other Python 3 solution:
lambda *a:min(a)<max(a)/2+7
-5 thanks to @Cyoce!
05AB1E, 8 6 bytes
;7+R‹Z
Try it online! or Try all test
# Implicit Input: an array of the ages
; # Divide both ages by 2
7+ # Add 7 to both ages
R # Reverse the order of the ages
# this makes the "minimum age" line up with the partner's actual age
‹ # Check for less than the input (vectorized)
Z # Push largest value in the list
Excel, 26 24 Bytes
Cell formula that takes input as numbers from cell range A1:B1 and output a boolean value representing creepiness to the formula cell
=OR(A1/2+7>B1,B1/2+7>A1)
Old Version, 26 Bytes
=MAX(A1:B1)/2+7>MIN(A1:B1)
C, 29 bytes
#define f(a,b)a/2+7>b|b/2+7>a
How it works:
#define f(a,b)defines a macro functionfthat takes two untyped arguments.a/2+7>bchecks if the first age divided by two plus seven is larger than the second age.b/2+7>achecks if the second age divided by two plus seven is larger than the first age.- If either of the above values are true, return 1 (creepy). Otherwise, return 0 (not creepy).
Alice, 21 18 bytes
/o
\i@/sh2:-6-.H+n
-3 bytes thanks to Martin Ender.
Input is in any format that includes exactly two integers. Output is 1 if creepy and 0 if not creepy.
Explanation
ish2:-6-.H+no
i Input numbers
s Sort the two ages
h2: Divide larger age by 2 rounded up
- Subtract from smaller age
6- Subtract 6
.H+ Determine whether result is negative
n Push 1 if was negative, 0 otherwise
o Output
z-shell (zsh), 38 bytes
n=(${(no)@});echo $((n[2]/2+7-n[1]>0))
${(no)@} is a numeric sort of the argument array
S.I.L.O.S, 64 bytes
readIO
j=i
readIO
x=i/2+7-j
y=j/2+7-i
if x c
if y c
print k
lblc
It prints out the letter "k" if the relationship is ok, otherwise it prints out nothing. I couldn't figure out any mathemagical way with standard mathematical operators to do an if x>0 pr y>0 to save bytes.
Alternatively, we can create an "or gate" by exploiting the fact that x^.5 will error out if the number is negative.This removes the need for a conditional, but lengthens our code. This version outputs 0 for creepy and some positive number for not creepy.
S.I.L.O.S, 67 bytes
readIO
j=i
readIO
x=0-i/2-7+j
y=0-j/2-7+i
a=x^.5+y^.5+1
printInt a
Wolfram Language, 16 bytes
Min@#<Max@#/2+7&
Takes input as a list.
Python 3, 31 bytes
lambda a,b:abs(a-b)>min(a,b)-14
Not much shorter than the other python submissions, but I found a slightly different way to check for creepiness. I noticed that the acceptable difference between ages is equal to min - 14. This follows from algebraically rearranging the formula.
min = (max/2) + 7
min - 7 = max/2
2*min - 14 = max
dif = max - min
max = dif + min
2*min - 14 = dif + min
min - 14 = dif
This let me solve without needing two constants, and also without needing to use both max and min, instead using abs(a-b). From a golfing perspective I only got one byte less than @nocturama's solution, but I used a slightly different formula to do it.
Java, 21 bytes
a->b->a/2+7>b|b/2+7>a
Absolutely not original.
Testing
import java.util.function.*;
public class Pcg122520 {
static IntFunction<IntPredicate> f = a->b->a/2+7>b|b/2+7>a;
public static void main(String[] args) {
int[][] tests = {
{40, 40},
{18, 21},
{80, 32},
{15, 50},
{47, 10000},
{37, 38},
{22, 18}
};
for (int[] test: tests) {
System.out.printf("%d, %d - %s%n", test[0], test[1], f.apply(test[0]).test(test[1]) ? "Creepy" : "Not creepy");
}
}
}
Perl 6, 15 bytes
{.max/2+7>.min}
Expanded
{ # bare block lambda with implicit parameter 「$_」
# (input is a List)
.max / 2 + 7
>
.min
}
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
Batch, 50 bytes
@if %1 gtr %2 %0 %2 %1
@cmd/cset/a"%1*2-14-%2>>31
Outputs -1 for creepy, 0 for not creepy.
Since Batch only has integer arithmetic I have to work in units of half years.
GNU APL 1.2, 23 bytes
Defines a function that takes two arguments and prints 1 if creepy, 0 if not.
∇A f B
(A⌊B)<7+.5×A⌈B
∇
Explanation
∇ begins and ends the function
A f B is the function header; function is named f and takes two arguments, A and B (functions in APL can be monadic - taking one argument - or dyadic - taking two arguments)
A⌊B is min(A,B) and A⌈B is max(A,B)
APL is evaluated right-to-left, so parentheses are needed to ensure proper precedence
The other operators are self explanatory.
Code might be golf-able, I'm still new to code-golf.
JavaScript (ES6), 21 bytes
a=>b=>a<b/2+7|b<a/2+7
Returns 0 for not creepy, 1 for creepy.
f=a=>b=>a<b/2+7|b<a/2+7
console.log(f(40)(40));
console.log(f(18)(21));
console.log(f(80)(32));
console.log(f(15)(50));
console.log(f(47)(10000));
console.log(f(37)(38));
console.log(f(22)(18));
Röda, 16 bytes
{sort|[_<_/2+7]}
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
C#, 22 bytes
n=>m=>n<m/2+7|m<n/2+7;
Actually, 12 bytes
;RZ⌠i½7+≤⌡Mπ
Try it online, or run all test cases!
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)
SAS, 77 bytes
%macro t(a,b);%put%eval(%sysfunc(max(&a,&b))/2+7>%sysfunc(min(&a,&b)));%mend;
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))
Mathics, 16 bytes
Max@#/2+7<Min@#&
-2 bytes thanks to @GregMartin
True for not creepy, false for creepy.
(* Argument: A list of integers *)
Max@# (* The maximum of the input *)
/2+7 (* Divided by 2, plus 7 *)
< (* Is less than? *)
Min@# (* The minimum of the input *)
& (* Anonymous function *)
Pyth, 17 16 13 12 bytes
>+7/.)JSQ2hJ
Takes a list. Outputs True for creepy, False for not creepy.
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.
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)
TI-Basic, 10 9 10 bytes
2min(Ans)-14≤max(Ans
List input from Ans, outputs 1 if "creepy" or 0 otherwise.
CJam, 10 bytes
q~$~2d/7+<
Takes input as a list.
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.
AWK, 26 bytes
{$0=$1/2+7>$2||$2/2+7>$1}1
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
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
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
JavaScript (ES6), 27 bytes
f=a=>b=>b>a?f(b)(a):b>a/2+7
No currying (call like f(a,b) instead of f(a)(b))
f=(a,b)=>b>a?f(b,a):b>a/2+7
If b > a, swap parameters and retry. Otherwise, check. Currying doesn't save any bytes because of the recursive call.
f=a=>b=>b>a?f(b)(a):b>a/2+7
console.log(f(18)(22))
console.log(f(22)(18))
console.log(f(18)(21))
shortC, 21 bytes
D(a,b)a/2+7<b|b/2+7<a
Japt, 11 bytes
Returns true for "creepy" and false for not.
wV /2+7>UmV
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.
PHP, 29 Bytes
prints 1 for creepy, nothing for Not creepy
<?=max($_GET)/2+7>min($_GET);
Retina, 20 bytes
O`.+
^1{7}(1+)¶1\1\1
Input is in unary with a linefeed between the two numbers. Output is 0 (not creepy) or 1 (creepy).
Explanation
O`.+
Sort the two numbers, so we know that the larger one is second.
^1{7}(1+)¶1\1\1
Call the smaller age a and the larger age b. We first capture a-7 in group 1. Then we try to match 2*(a-7)+1 in b, which means b >= 2*(a-7)+1 or b >= 2*(a-7) or b/2+7 > a which is the criterion for a creepy relationship.
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
Fourier, 37 bytes
oI~AI~B>A{1}{A~SA~BS~B}A/2+7>B{1}{@o}
Takes two numbers as input. Will golf later.
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]
