Skip to main content
Commonmark migration
Source Link

#Python 2, 53 52 50 bytes

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

#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

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

added 5 characters in body
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31

#Python 2, 53 52 4550 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) 

Previous solution:

s=input() print (sum(map(cmp,s[1:],s))+1)/(len(s)-13) 

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

#Python 2, 53 52 45 bytes

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

As unnamed lambda:

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

Previous solution:

s=input() print (sum(map(cmp,s[1:],s))+1)/(len(s)-1) 

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

#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

added 64 characters in body
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31

#Python 2, 53 52 45 bytes

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

As unnamed lambda:

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

Previous solution:

s=input() print (sum(map(cmp,s[1:],s))+1)/(len(s)-1) 

Sums the sign of difference between each letters and integer-divides by len-1. For increasingIf all were 1 (increasing) the sum is len-1 it displays 1, similar for decreasing -1 and everything elsefor 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

#Python 2, 53 52 45 bytes

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

As unnamed lambda:

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

Previous solution:

s=input() print (sum(map(cmp,s[1:],s))+1)/(len(s)-1) 

Sums the sign of difference between each letters and integer-divides by len-1. For increasing it displays 1, decreasing -1 and everything else 0.

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

#Python 2, 53 52 45 bytes

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

As unnamed lambda:

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

Previous solution:

s=input() print (sum(map(cmp,s[1:],s))+1)/(len(s)-1) 

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

added 64 characters in body
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31
Loading
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31
Loading