A
A
aab1372020-09-13 12:06:49
Python
aab137, 2020-09-13 12:06:49

How to do it in one line?

I am a romantic and I want to write this in one line:

s = [input() for i in range(4)]
for i in range(4):
    for j in range(i+1, 4):
        print(s[i], s[j], sum(a!=b for (a, b) in [*zip(s[i], s[j])]))

I tried to use lambda, but nothing came out right:
print((lambda s:
       ([(
           (s[i], s[j], sum(a != b for (a, b) in [*zip(s[i], s[j])]))
           for i in range(4) for j in range(i+1, 4)
       )])
       )
      (input() for i in range(4)))

Who fumbles, help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aab137, 2020-09-14
@aab137

Well, something turned out like

print(*['{} {} {}'.format(*i) for i in (lambda s, a: (a, , sep='\n')

Not sure if this is the best solution

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question