Skip to content

Instantly share code, notes, and snippets.

@dz0
Last active March 30, 2021 13:27
Show Gist options
  • Select an option

  • Save dz0/6d854f54c71567e03bad826b02c36b06 to your computer and use it in GitHub Desktop.

Select an option

Save dz0/6d854f54c71567e03bad826b02c36b06 to your computer and use it in GitHub Desktop.
# palyginimui su https://www.facebook.com/photo.php?fbid=10158413583218323&set=p.10158413583218323&type=3
def varza(grandine):
R = 0
for varzu_eil in grandine:
atvirkstiniu_suma = sum(1/x for x in varzu_eil)
R += 1 / atvirkstiniu_suma
return R
# nuskaitymas C++ srauto formatu nedėkingas Python'ui, geriau būtų JSON
with open("Duom1.txt") as duom:
eilutes = duom.readlines()
matrica = [eil.split()[1:] for eil in eilutes]
R = varza(matrica)
with open("Rez1.txt") as rez:
rez.write(round(R, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment