Skip to main content
sytes baved
Source Link

Python 3, 168 157 152 139 144144 136 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :(

Thanks to Leaky Nun for saving 5 bytes, and to jmilloy for saving 13 8 bytes.

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:n=qm=(m,q-p;m=n ifp)[(s[p:q]in"lucky")*n>m else m;q*q-p>m];q-=1
 p-=1;q=k
print(2**m-2*sum(i in "omen" forin"omen"for i in s))

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

Python 3, 168 157 152 139 144 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :(

Thanks to Leaky Nun for saving 5 bytes, and to jmilloy for saving 13 8 bytes.

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:n=q-p;m=n if(s[p:q]in"lucky")*n>m else m;q-=1
 p-=1;q=k
print(2**m-2*sum(i in "omen" for i in s))

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

Python 3, 168 157 152 139 144 136 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :(

Thanks to Leaky Nun for saving 5 bytes, and to jmilloy for saving 13 8 bytes.

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:m=(m,q-p)[(s[p:q]in"lucky")*q-p>m];q-=1
 p-=1;q=k
print(2**m-2*sum(i in"omen"for i in s))

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

fixed error
Source Link

Python 3, 168 157 152 139139 144 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :(

Thanks to Leaky Nun for saving 5 bytes, and to jmilloy for saving 1313 8 bytes.

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:n=q-p;m=n if(s[p:q]in"lucky")*n>m else m;q-=1
 p-=1;q=k
print(2**m-2*2*sum(i in"omen"forin "omen" for i in s))

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

Python 3, 168 157 152 139 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :(

Thanks to Leaky Nun for saving 5 bytes, and to jmilloy for saving 13 bytes.

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:n=q-p;m=n if(s[p:q]in"lucky")*n>m else m;q-=1
 p-=1;q=k
print(2**m-2*(i in"omen"for i in s))

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

Python 3, 168 157 152 139 144 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :(

Thanks to Leaky Nun for saving 5 bytes, and to jmilloy for saving 13 8 bytes.

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:n=q-p;m=n if(s[p:q]in"lucky")*n>m else m;q-=1
 p-=1;q=k
print(2**m-2*sum(i in "omen" for i in s))

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

bytes saved
Source Link

Python 3, 168 157 152152 139 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :( Thanks

Thanks to Leaky Nun for saving 5 bytes, and to jmilloy for saving 13 bytes.

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:b=s[p:q];n=qn=q-p;m=n if(b in"lucky"s[p:q]in"lucky")*n>m else m;q-=1
 p-=1;q=k
x=2**m
forprint(2**m-2*(i in"omen"for i in s:x-=2*(i in"omen")
print(x)

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

Python 3, 168 157 152 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :( Thanks to Leaky Nun for saving 5 bytes

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:b=s[p:q];n=q-p;m=n if(b in"lucky")*n>m else m;q-=1
 p-=1;q=k
x=2**m
for i in s:x-=2*(i in"omen")
print(x)

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

Python 3, 168 157 152 139 bytes

EDIT: Really obvious things I should have seen easier have been changed, and some slightly less obvious.

Edit 2: stoopid (˚n˚). The program threw errors. I fixed it up. not actually 153 :(

Thanks to Leaky Nun for saving 5 bytes, and to jmilloy for saving 13 bytes.

s=input()
p=q=k=len(s)
m=0
while-~p:
 while-~q:n=q-p;m=n if(s[p:q]in"lucky")*n>m else m;q-=1
 p-=1;q=k
print(2**m-2*(i in"omen"for i in s))

The program runs through all possibly possible substrings in input (possibly possible, because it computes impossible substrings as well, 8 to 7, for example), checks if the substring is in "lucky", then sets the exponent of 2 to the length of the substring should it be greater than the current value. Possibly could be improved by using only one while loop. Could possibly use some improvement; I'm still getting the hang of this.

bytes saved
Source Link
Loading
grammar
Source Link
Loading
Added highlighting.
Source Link
NoOneIsHere
  • 2.2k
  • 1
  • 21
  • 46
Loading
fixed stupidity
Source Link
Loading
Source Link
Loading