g | x | w | all
Bytes Lang Time Link
013AGL250215T224924ZErikDaPa
081Haskell250624T171001ZIbozz91
068Perl 5 p250220T190244ZXcali
078C clang250218T155452Zjdt
006Husk250215T210554ZGlory2Uk
078Javascript ES6161101T193257ZRobert H
081JavaScript ES6161028T205143ZNeil
240Java 7161031T103120ZKevin Cr
00905AB1E161028T180635ZMagic Oc
095R161030T105211ZBillywob
100PHP161029T103713Zchococha
096PHP161028T191820ZJör
056Groovy161029T235405ZGolfIsAG
321Racket161029T161933Zrnso
164C161029T094438ZSteadybo
054Ruby161028T221523ZLee W
050Python 2161028T204721ZKarl Nap
010Jelly161028T191854ZJonathan
075Python 3161028T191723ZC. Smith
054Python 2161028T192110Zxnor
012Pyth161028T172047ZPurkkaKo

AGL, 13 bytes

[1] for increasing wavy, [-1] for decreasing wavy, otherwise not wavy.

s#2{-.-}/⌀-^

Explanation:

s#2{-.-}/⌀-^
s#           => convert into codepoints
  2{-.-}/    => find pairwise deltas
         ⌀-  => filter out 0s
           ^ => deduplicate

Haskell, 81 bytes

import Data.List
f s=[b&&t==s,b&&(reverse t)==s]where t=sort s;b=(length$nub t)>2

Try it online!

Perl 5 -p, 68 bytes

$_=(s/(.)\1*/$1.*?/g>2)*(($a=join'',A..Z)=~/$_/<=>(reverse$a)=~/$_/)

Try it online!

Outputs -1/0/1 for decreasing wavy/not wavy/increasing wavy.

C (clang), 82 78 bytes

d;f(*s,*r,n){for(*r=n>3?strcmp(s,++s):0;*s;*r*=!d|d<1^*r>0)d=strcmp(s-1,s++);}

Try it online!

-4 bytes thanks to @ceilingcat!

Returns:

Husk, 7 6 bytes

e#<¹#>

Try it online!

Otputs a list of two values \$[a, b]\$:

Commented:

    #>   -- count adjacent pairs where the 1st character is "greater" than the 2nd
 #<¹     -- count adjacent pairs where the 1st character is "less" than the 2nd
e        -- add to the list
         -- output implicitly

Javascript (ES6), 84 80 78 bytes

i=>new Set(s=[...i]).size>2?[i,s.reverse().join``].indexOf(s.sort().join``):-1

Where wavy increasing is 0, decreasing is 1, and -1 is not wavy.

Thanks to @Neil for helping me save 2 bytes.

JavaScript (ES6), 84 81 bytes

s=>(new Set(t=[...s]).size>2)*(!t.some((c,i)=>c>s[i+1])-!t.some((c,i)=>c<s[i+1]))

Assumes the input is all in the same case. Returns 1 for raising wavy, -1 for decreasing wavy, 0 or -0 (both are falsy) for not wavy. Edit: Saved 3 bytes thanks to @RobertHickman.

Java 7, 254 240 bytes

import java.util.*;int c(String s){char[]a=s.toCharArray(),x=a.clone();Arrays.sort(x);return s.replaceAll("(.)\\1{1,}","$1").length()<3?0:Arrays.equals(a,x)|Arrays.equals(x,(new StringBuffer(s).reverse()+"").toCharArray())?a[0]>a[1]?1:2:0;}

Outputs 0 if the input string isn't wavy, 1 if it's a raising wave, and 2 if it's a decreasing wave.

Ungolfed & test code:

Try it here.

import java.util.*;
class M{
  static int c(String s){
    char[] a = s.toCharArray(),
           x = a.clone();
    Arrays.sort(x);
    return s.replaceAll("(.)\\1{1,}", "$1").length() < 3
            ? 0
            : Arrays.equals(a, x) | Arrays.equals(x, (new StringBuffer(s).reverse()+"").toCharArray())
               ? a[0] > a[1]
                  ? 1
                  : 2
               : 0;
  }

  public static void main(String[] a){
    System.out.print(c("ADEPT") + ", ");
    System.out.print(c("BEGIN") + ", ");
    System.out.print(c("BILL") + ", ");
    System.out.print(c("BOSS") + ", ");
    System.out.print(c("BOOST") + ", ");
    System.out.print(c("CHIMP") + ", ");
    System.out.println(c("KNOW"));

    System.out.print(c("SPONGE") + ", ");
    System.out.print(c("SPOON") + ", ");
    System.out.print(c("TROLL") + ", ");
    System.out.println(c("WOLF"));

    System.out.print(c("WATCH") + ", ");
    System.out.print(c("EARTH") + ", ");
    System.out.print(c("NINON") + ", ");
    System.out.print(c("FOO") + ", ");
    System.out.print(c("BAR") + ", ");
    System.out.print(c("WAVE") + ", ");
    System.out.print(c("SELECTION") + ", ");
    System.out.print(c("YES") + ", ");
    System.out.print(c("NO") + ", ");
    System.out.print(c("DEFINITION") + ", ");
    System.out.print(c("WATER") + ", ");
    System.out.print(c("WINE") + ", ");
    System.out.print(c("CODE") + ", ");
    System.out.print(c("AAAHHHH") + ", ");
    System.out.print(c("I") + ", ");
    System.out.print(c("MM") + ", ");
    System.out.println(c("ABCA"));
  }
}

Output:

2, 2, 2, 2, 2, 2, 2
1, 1, 1, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

05AB1E, 11 9 bytes (Thanks to Adnan)

Dg2›iÇü‹Ù

Try it online!

Wavy Cases:

0 - Decreasing Wavy

1 - Increasing Wavy

Not Wavy Cases:

[0,1] - Not wavy, initially decreasing, but then has an increase/equality that broke the pattern.

[1,0] - Not wavy, initially increasing, but then has a decrease/equality that broke the pattern

Input String - Not possible to be wavy in the first place due to length.

Explanation:

Dg2›iÇü‹Ù   # Full program

D           # Push 2 copies of input.
 g2›i       # If length is greater than 2. 
     Ç      # Push ASCII values for all characters in the string.
      ü     # Push pairwise array.
       ‹    # Vectorize 1 if negative difference, 0 if positive difference.
        Ù   # Uniquify using right most unique values first.
            # Else just print the string back, letting them know it's not valid input.

R, 96 95 bytes

function(x,d=diff(rle(utf8ToInt(x))$v))if(any(d>0)&any(d<0)|sum(1|d)<2)3 else`if`(all(d<1),2,1)

Returns:

Explained


Try all the test cases at R-fiddle (note that it's named such that it can be vectorized for the test cases).

PHP, 100 bytes

$n=$m=$l=str_split($argv[1]);sort($n);rsort($m);echo(($n==$l)-($m==$l))*(count(array_unique($l))>2);

Returns:

PHP, 96 Bytes

for(;($t=$argv[1])[++$i];)$s+=$r[]=$t[$i-1]<=>$t[$i];echo(max($r)-min($r)<2)*(0<=>$s)*(1<$s*$s);

or 98 Bytes

$s=str_split($t=$argv[1]);sort($s);echo(-($t==strrev($j=join($s)))|$t==$j)*!!count_chars($t,3)[2];

0 not wavy 1 raising -1 decreasing

Groovy - 56 bytes

{d=it[0];c=[0]*3;it.each{a->c[(a<=>d)]=1;d=a};c[1..-1]}

Outputs [1,0] for raising wavy, [0,1] for decreasing wavy, [0,0] for single character input or [1,1] for non-wavy.

NOTE: Assumes input is either a String or a char[] and all letters are of the same case.

Racket 321 bytes

(let*((ld(λ(sl)(for/list((i(sub1(length sl))))(-(list-ref sl(add1 i))(list-ref sl i)))))(l(ld(remove-duplicates(map
(λ(x)(char->integer x))(string->list s)))))(am andmap)(N"Not WAVY")(d displayln))(cond[(<(length l)2)(d N)][(am(λ(x)(>= x 0))l)
(d"YES; RAISING")][(am(λ(x)(<= x 0))l)(d"YES; DECREASING")][else(d N)])))

Ungolfed:

(define (f s)
  (let*  ((ld (lambda(sl)          ; sub-fn to get differences in list elements
                (for/list ((i (sub1(length sl))))
                  (- (list-ref sl (add1 i))
                     (list-ref sl i) ) )))
          (l (ld
              (remove-duplicates
               (map
                (lambda(x)
                  (char->integer x))
                (string->list s)))))
          (am andmap)
          (N "Not WAVY")
          (d displayln))
    (cond
      [(< (length l) 2)(d N)]
      [(am (lambda(x) (>= x 0)) l) (d "YES; RAISING")]
      [(am (lambda(x) (<= x 0)) l) (d "YES; DECREASING")]
      [else (d N)]
      )))

Testing:

(f "ADEPT"); > YES > RAISING
(f "BEGIN"); > YES > RAISING
(f "BILL"); > YES > RAISING
(f "BOSS"); > YES > RAISING
(f "BOOST"); > YES > RAISING
(f "CHIMP"); > YES > RAISING
(f "KNOW"); > YES > RAISING
(f "SPONGE"); > YES > DECREASING
(f "SPOON"); > YES > DECREASING
(f "TROLL"); > YES > DECREASING
(f "WOLF"); > YES > DECREASING

(f "WATCH")
(f "EARTH")
(f "NINON")
(f "FOO")
(f "BAR")
(f "WAVE")
(f "SELECTION")

Output:

YES; RAISING
YES; RAISING
YES; RAISING
YES; RAISING
YES; RAISING
YES; RAISING
YES; RAISING
YES; DECREASING
YES; DECREASING
YES; DECREASING
YES; DECREASING
Not WAVY
Not WAVY
Not WAVY
Not WAVY
Not WAVY
Not WAVY
Not WAVY

C, 164 bytes

main(){char s[99];scanf("%s",s);char *c=&s;int p=*c;while(*c^0){if(p>*c){if(c-&s[0]>1)return 0;while(*c^0){if(p<*c)return 0;p=*c;c++;}return 2;}p=*c;c++;}return 1;}

Returns 0 if not wawy, 1 if wawy and raising, 2 if decreasing.

Ruby, 54 bytes

->w{c=w.chars.uniq;c==(s=c.sort)?2:(c==s.reverse)?1:0}

Returns 0 if the word is not wavy, 1 if backwards wavy, and 2 if forwards wavy.

Python 2, 53 52 50 bytes

Expects input enclosed in quotes, e.g. "watch"

As unnamed lambda:

lambda s:(sum(map(cmp,s[1:],s))+1)/min(len(s)-1,3)

Sums the sign of difference between each letters and integer-divides by len-1. If all were 1 (increasing) the sum is len-1 it displays 1, similar for decreasing -1 and for mixed 1,-1 the sum is smaller than len-1 so it displays 0.

-1 byte for changing cmp,s[1:],s[:-1]) to cmp,s[1:],s)+1

Jelly, 10 bytes

OIṠḟ0µL’aQ

TryItOnline! or run all test cases

Returns:
[1] for wavy increasing
[-1] for wavy decreasing
something else otherwise ([], [0], [-1,1], or [1,-1])

(Declared as unnecessary: For a single value for each OIṠḟ0µL’aQS (11 bytes) will return 1, -1, and 0 respectively.)

How?

OIṠḟ0µL’aQ - Main link: s
O          - cast to ordinals
 I         - incremental differences
  Ṡ        - sign (-1 for decreasing, 0 for no change, 1 for increasing)
   ḟ0      - filter out zeros
     µ     - monadic chain separation
      L    - length
       ’   - decremented
        a  - and
         Q - unique items

Python 3, 77 75 bytes

lambda x:(len(set(x))>2)*(list(x)==sorted(x)or(list(x)==sorted(x)[::-1])*2)

Assumes all letters are of the same case.

Returns:

Removed unnecessary spaces thanks @ETHproductions

Python 2, 54 bytes

lambda s:[2<len(set(s))<s[::b]==sorted(s)for b in-1,1]

Takes input as a list of characters. Outputs:

[False, True] for ascending
[True, False] for descending
[False, False] for neither

Checks if the sorted input string equals its original or reverse. Does so by slicing with step sizes of 1 and -1. At the same time, we check whether the word has at least 2 distinct letters.

If "exit with error" can be used an output for the neither case, we can go down to 51 bytes:

lambda s:[s,s[::-(len(set(s))>2)]].index(sorted(s))

Pyth, 12 bytes

x*<2lrQ8_BQS

Try it online. Test suite.