Skip to main content
deleted 60 characters in body
Source Link
xsot
  • 5.5k
  • 1
  • 16
  • 24

Python 2.7.10, 5554 bytes

i=0
for c in input():exec"i=i"+c+`hashexec"i=i"+c+`~ord(c)%55%3`%5%3`
print i

Input is taken as a string literal. hash~ord(c)%55%3%5%3 maps the operators to the corresponding right operands. A shorter mapping may exist as I have not tried all possibilities. Apparently

Previously, hash doesn't seem to work consistentlyI used hash(c)%55%3 which didn't yield consistent results between different versions of Python, so a shorter mapping may be possible in another version. This encouraged me to explore other formulas.

Python 2.7.10, 55 bytes

i=0
for c in input():exec"i=i"+c+`hash(c)%55%3`
print i

Input is taken as a string literal. hash(c)%55%3 maps the operators to the corresponding right operands. A shorter mapping may exist as I have not tried all possibilities. Apparently, hash doesn't seem to work consistently between different versions of Python, so a shorter mapping may be possible in another version.

Python 2, 54 bytes

i=0
for c in input():exec"i=i"+c+`~ord(c)%5%3`
print i

Input is taken as a string literal. ~ord(c)%5%3 maps the operators to the corresponding right operands.

Previously, I used hash(c)%55%3 which didn't yield consistent results between different versions of Python. This encouraged me to explore other formulas.

added 151 characters in body
Source Link
xsot
  • 5.5k
  • 1
  • 16
  • 24

Python 2.7.10, 55 bytes

i=0
for c in input():exec"i=i"+c+`hash(c)%55%3`
print i

Input is taken as a string literal. hash(c)%55%3 maps the operators to the corresponding right operands. A shorter mapping may exist as I have not tried all possibilities. Apparently, hash doesn't seem to work consistently between different versions of Python, so a shorter mapping may be possible in another version.

Python 2, 55 bytes

i=0
for c in input():exec"i=i"+c+`hash(c)%55%3`
print i

Input is taken as a string literal. hash(c)%55%3 maps the operators to the corresponding right operands. A shorter mapping may exist as I have not tried all possibilities.

Python 2.7.10, 55 bytes

i=0
for c in input():exec"i=i"+c+`hash(c)%55%3`
print i

Input is taken as a string literal. hash(c)%55%3 maps the operators to the corresponding right operands. A shorter mapping may exist as I have not tried all possibilities. Apparently, hash doesn't seem to work consistently between different versions of Python, so a shorter mapping may be possible in another version.

Source Link
xsot
  • 5.5k
  • 1
  • 16
  • 24

Python 2, 55 bytes

i=0
for c in input():exec"i=i"+c+`hash(c)%55%3`
print i

Input is taken as a string literal. hash(c)%55%3 maps the operators to the corresponding right operands. A shorter mapping may exist as I have not tried all possibilities.