Talk:Law of cosines - triples: Difference between revisions

(Reply re discrepancy in Python results.)
 
(One intermediate revision by one other user not shown)
Line 138:
 
:::As 18394 - 588 = 17806 that explains Paddy's results. --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 21:20, 26 September 2018 (UTC)
:::: Aha ! Well spotted :-) Mutation is a tricky business ... [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 21:43, 26 September 2018 (UTC)
 
 
====I woke in the night...====
 
With an idea that the continue statements might be at fault.<br>
(I am disowning them in my use of English, but it was me).<br>
I commented-out all the continue statements in method1 and method2 as I literally had that lightbulb moment of thinking that in my loops, I didn't allow for one triple to be in more than one of the three groups.
 
Before sleeping I had added Houts case as method3; seen that hehad captured cases that I had not; but was unable to work out why and had gonne to bed with the problem
 
<lang python># Houts code with a slight modification to his `main` function so that it returned `triangles(f60unequal, 10000)`
# ...
#%%
 
method3_t60_uneven_strings = main() # Houts'
method3_t60_uneven = [tuple(eval(triple_list_str))
for triple_list_str in method3_t60_uneven_strings]
method2_t60_uneven = [(a, b, c) for a, b, c in method2_t60 if a != b or b != c]
method1_t60_uneven = [(a, b, c) for a, b, c in method1_t60 if a != b or b != c]
#%%
methods_t60_uneven = [method1_t60_uneven, method2_t60_uneven, method3_t60_uneven]
whos_methods = "Paddys set, Paddys dict, Houts dict".split(", ")
 
print("\n# Stated extra credit answers")
for who, t60u in zip(whos_methods, methods_t60_uneven):
print(f" {who:12s}: {len(t60u)}")
 
print("\n# Filtered (again in some cases) for unequal sides")
for who, t60u in zip(whos_methods, methods_t60_uneven):
t60uf = [(a, b, c) for a, b, c in t60u if a != b or b != c]
print(f" {who:12s}: {len(t60uf)}")
 
print("\n# Filtered, ordered, and duplicates removed: size changes")
for who, t60u in zip(whos_methods, methods_t60_uneven):
t60ufod = set([tuple(sorted([a, b, c]))
for a, b, c in t60u if a != b or b != c])
print(f" {who:12s}: From {len(t60u)} to {len(t60ufod)}")
 
diff13 = sorted(set(method1_t60_uneven) - set(method3_t60_uneven))
diff31 = sorted(set(method3_t60_uneven) - set(method1_t60_uneven))
print(f'\n# I have {len(diff13)} triples that Hout does not have')
print(f'# Hout has {len(diff31)} triples that I do not have')</lang>
 
 
;Original output:
<pre>60 degrees - uneven triangles of maximum side 10000. Total:
18394
 
# Stated extra credit answers
Paddys set : 17806
Paddys dict : 17806
Houts dict : 18394
 
# Filtered (again in some cases) for unequal sides
Paddys set : 17806
Paddys dict : 17806
Houts dict : 18394
 
# Filtered, ordered, and duplicates removed: size changes
Paddys set : From 17806 to 17806
Paddys dict : From 17806 to 17806
Houts dict : From 18394 to 18394
 
# I have 0 triples that Hout does not have
# Hout has 588 triples that I do not have</pre>
 
;Output when those continue statements in method1 and method2 are removed:
<pre># Stated extra credit answers
Paddys set' : 18394
Paddys dict': 18394
Houts dict : 18394
 
# Filtered (again in some cases) for unequal sides
Paddys set' : 18394
Paddys dict': 18394
Houts dict : 18394
 
# Filtered, ordered, and duplicates removed: size changes
Paddys set' : From 18394 to 18394
Paddys dict': From 18394 to 18394
Houts dict : From 18394 to 18394
 
# I have 0 triples that Hout does not have
# Hout has 0 triples that I do not have</pre>
 
'''Yay!!!''' From the discussions of sharper minds above, I found that you had already found the answer, but I thought I would go ahead and finish my public debugging session. <br>
Thanks people :-)<br>
[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 01:18, 27 September 2018 (UTC)
Anonymous user