Skip to main content
fixed
Source Link
etene
  • 448
  • 2
  • 7

Python 3, 114 110 109109 116 bytes

Actually would have taken two bytes less in Python 2 because exec is a statement and doesn't need parentheses...

  • Saved 4 extra bytes thanks to @ElPedro

  • Saved an extra byte by taking advantage of the fact that find returns -1 on error, which can then be used as an index

  • +7 bytes because I hadn't noticed the no-newlines rule :(

i=0;exec(";".join("i+=1 i-=1 i*=2 i/=2 print(i,end='') exit()".split()["idmhP".find(h[0])]for h in input().split()))

Try it online!Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

Python 3, 114 110 109 bytes

Actually would have taken two bytes less in Python 2 because exec is a statement and doesn't need parentheses...

  • Saved 4 extra bytes thanks to @ElPedro

  • Saved an extra byte by taking advantage of the fact that find returns -1 on error, which can then be used as an index

i=0;exec(";".join("i+=1 i-=1 i*=2 i/=2 print(i) exit()".split()["idmhP".find(h[0])]for h in input().split()))

Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

Python 3, 114 110 109 116 bytes

Actually would have taken two bytes less in Python 2 because exec is a statement and doesn't need parentheses...

  • Saved 4 extra bytes thanks to @ElPedro

  • Saved an extra byte by taking advantage of the fact that find returns -1 on error, which can then be used as an index

  • +7 bytes because I hadn't noticed the no-newlines rule :(

i=0;exec(";".join("i+=1 i-=1 i*=2 i/=2 print(i,end='') exit()".split()["idmhP".find(h[0])]for h in input().split()))

Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

golf one more byte
Source Link
etene
  • 448
  • 2
  • 7

Python 3, 114 110110 109 bytes

Saved 4 extra bytes thanks to @ElPedro Actually would have taken two bytes less in Python 2 because exec is a statement and doesn't need parentheses...

  • Saved 4 extra bytes thanks to @ElPedro

  • Saved an extra byte by taking advantage of the fact that find returns -1 on error, which can then be used as an index

i=0;exec(";".join("i+=1 i-=1 i*=2 i/=2 print(i) exit()".split()["idmhPe"["idmhP".find(h[0])]for h in input().split()))

Try it online!Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

Python 3, 114 110 bytes

Saved 4 extra bytes thanks to @ElPedro

i=0;exec(";".join("i+=1 i-=1 i*=2 i/=2 print(i) exit()".split()["idmhPe".find(h[0])]for h in input().split()))

Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

Python 3, 114 110 109 bytes

Actually would have taken two bytes less in Python 2 because exec is a statement and doesn't need parentheses...

  • Saved 4 extra bytes thanks to @ElPedro

  • Saved an extra byte by taking advantage of the fact that find returns -1 on error, which can then be used as an index

i=0;exec(";".join("i+=1 i-=1 i*=2 i/=2 print(i) exit()".split()["idmhP".find(h[0])]for h in input().split()))

Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

golf some more
Source Link
etene
  • 448
  • 2
  • 7

Python 3, 114114 110 bytes

Saved 4 extra bytes thanks to @ElPedro

i=0;exec(";".join(("i+=1","i"i+=1 i-=1","i*=2","i=1 i*=2 i/=2","print=2 print(i)","exit exit()".split()["idmhPe".find(h[0])]for h in input().split()))

Try it online!Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

Python 3, 114 bytes

i=0;exec(";".join(("i+=1","i-=1","i*=2","i/=2","print(i)","exit()")["idmhPe".find(h[0])]for h in input().split()))

Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

Python 3, 114 110 bytes

Saved 4 extra bytes thanks to @ElPedro

i=0;exec(";".join("i+=1 i-=1 i*=2 i/=2 print(i) exit()".split()["idmhPe".find(h[0])]for h in input().split()))

Try it online!

Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.

Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

Source Link
etene
  • 448
  • 2
  • 7
Loading