- 50.9k
- 11
- 133
- 364
Python 3, (削除) 159 (削除ここまで) (削除) 141 (削除ここまで) 152(削除) 152 (削除ここまで) 128 bytes
import ast
def f(s):
g={}
for k in s:
if'='in k:
*v,l=k.split('=')
for r in v:
try:g[r]=ast.literal_evalg[r]=int(l)
except:g[r]=g[l]
return g
+11 bytes thanks to Shaggy for pointing out a bug
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
Python 3, (削除) 159 (削除ここまで) (削除) 141 (削除ここまで) 152 bytes
import ast
def f(s):
g={}
for k in s:
if'='in k:
*v,l=k.split('=')
for r in v:
try:g[r]=ast.literal_eval(l)
except:g[r]=g[l]
return g
+11 bytes thanks to Shaggy for pointing out a bug
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
Python 3, (削除) 159 (削除ここまで) (削除) 141 (削除ここまで) (削除) 152 (削除ここまで) 128 bytes
def f(s):
g={}
for k in s:
if'='in k:
*v,l=k.split('=')
for r in v:
try:g[r]=int(l)
except:g[r]=g[l]
return g
+11 bytes thanks to Shaggy for pointing out a bug
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
- 50.9k
- 11
- 133
- 364
Python 3, (削除) 159 (削除ここまで) 141(削除) 141 (削除ここまで) 152 bytes
import ast
def f(s,g={}):
g={}
for k in s:
if'='in k:
*v,l=k.split('=')
for r in v:
try:g[r]=ast.literal_eval(l)
except:g[r]=g[l]
return g
+11 bytes thanks to Shaggy for pointing out a bug
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
Python 3, (削除) 159 (削除ここまで) 141 bytes
import ast
def f(s,g={}):
for k in s:
if'='in k:
*v,l=k.split('=')
for r in v:
try:g[r]=ast.literal_eval(l)
except:g[r]=g[l]
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
Python 3, (削除) 159 (削除ここまで) (削除) 141 (削除ここまで) 152 bytes
import ast
def f(s):
g={}
for k in s:
if'='in k:
*v,l=k.split('=')
for r in v:
try:g[r]=ast.literal_eval(l)
except:g[r]=g[l]
return g
+11 bytes thanks to Shaggy for pointing out a bug
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
- 50.9k
- 11
- 133
- 364
Python 3, 159(削除) 159 (削除ここまで) 141 bytes
import ast
def f(s,g={}):
for k in filter(lambda as:'='in
if'='in a,s)k:
*v *v,l=k.split('=')
for for r in v:
try try:g[r]=ast.literal_eval(l)
except except:g[r]=g[l]
return g
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
Python 3, 159 bytes
import ast
def f(s,g={}):
for k in filter(lambda a:'='in a,s):
*v,l=k.split('=')
for r in v:
try:g[r]=ast.literal_eval(l)
except:g[r]=g[l]
return g
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
Python 3, (削除) 159 (削除ここまで) 141 bytes
import ast
def f(s,g={}):
for k in s:
if'='in k:
*v,l=k.split('=')
for r in v:
try:g[r]=ast.literal_eval(l)
except:g[r]=g[l]
Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values
- 50.9k
- 11
- 133
- 364
- 50.9k
- 11
- 133
- 364
- 50.9k
- 11
- 133
- 364