Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Python 2, (削除) 110 (削除ここまで)(削除) 87 (削除ここまで) 60 bytes

Python 2, (削除) 110 (削除ここまで)(削除) 87 (削除ここまで) 60 bytes

Saving 1 byte thanks to Neil

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e<-1

Inspired by xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen

#Python 2, (削除) 110 (削除ここまで)(削除) 87 (削除ここまで) 60 bytes

Saving 1 byte thanks to Neil

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e<-1

Inspired by xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen

Python 2, (削除) 110 (削除ここまで)(削除) 87 (削除ここまで) 60 bytes

Saving 1 byte thanks to Neil

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e<-1

Inspired by xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

#Python 2, (削除) 110 (削除ここまで) (削除) 87 (削除ここまで) 60 bytes

Saving 1 byte thanks to Neil

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e<-1

Inspired by xnor xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen Kevin Cruijssen

#Python 2, (削除) 110 (削除ここまで) (削除) 87 (削除ここまで) 60 bytes

Saving 1 byte thanks to Neil

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e<-1

Inspired by xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen

#Python 2, (削除) 110 (削除ここまで) (削除) 87 (削除ここまで) 60 bytes

Saving 1 byte thanks to Neil

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e<-1

Inspired by xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen

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

#Python 2, (削除) 110 (削除ここまで) (削除) 87 (削除ここまで) 6160 bytes

Saving 1 byte thanks to Neil

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e==a*c+b*d|e<-21

Inspired by xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen

#Python 2, (削除) 110 (削除ここまで) (削除) 87 (削除ここまで) 61 bytes

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e==-2

Inspired by xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen

#Python 2, (削除) 110 (削除ここまで) (削除) 87 (削除ここまで) 60 bytes

Saving 1 byte thanks to Neil

Requires input enclosed in quotes, e.g. 'KNEES'

True if it is an infinity word, False if not and it has length of 5 and prints error message if wrong length

s=input()
a,b,c,d,e=map(cmp,s,s[1:]+s[0])
print a*c+b*d|e<-1

Inspired by xnor's answer using map(cmp...

s=input()
e=map(cmp,s,s[1:]+s[0])
print e[4]==0and e[0]*e[2]+e[1]*e[3]==-2and 5==len(s)

previous solution:

s=input()
d=[ord(x)-ord(y)for x,y in zip(s,s[1:])]
print s[0]==s[4]and d[0]*d[2]<0and d[1]*d[3]<0and 4==len(d)

Using the optimized logic of Kevin Cruijssen

deleted 3 characters in body
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31
Loading
added 247 characters in body
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31
Loading
added 247 characters in body
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31
Loading
edited body
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31
Loading
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31
Loading

AltStyle によって変換されたページ (->オリジナル) /