Talk:Law of cosines - triples: Difference between revisions
(→How to verify the number of triangles for the extra credit?: Yet another answer.) |
|||
Line 41: | Line 41: | ||
::I will try removing the **.5 tonight. Thanks.<br> [[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 09:15, 25 September 2018 (UTC) |
::I will try removing the **.5 tonight. Thanks.<br> [[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 09:15, 25 September 2018 (UTC) |
||
::P.S. I had actually developed a python <code>method2</code> based on dicts (and the fact that dicts are ordered by default in Python3.6). I debugged the two implementations together and they agreed when tested against each other but the Python set version was slightly faster so I only published that. I'll invetstigate further tonight. [[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 09:25, 25 September 2018 (UTC) |
Revision as of 09:25, 25 September 2018
Showing the sides in order?
I see the samples show the 60 degree triangles with the sides in ascending order, however ( a, b, c ) = ( 5, 7, 8 ) isn't a solution of
a^2 + b^2 - ab = c^2.
Where the task says "Find all integer solutions to the three specific cases, in order;", presumably this should be in order of ascending first (lowest) side?
--Tigerofdarkness (talk) 13:28, 23 September 2018 (UTC)
- You are right. Thanks for bringing this up. I fixed my Factor submission. --Chunes (talk) 14:28, 23 September 2018 (UTC)
- I changed the wording of that task's requirement (hopefully, it is more clearer). In any case, that's what I took it to mean, that the triangles are to be shown in increasing (ascending) order of the first side found. -- Gerard Schildberger (talk) 06:56, 24 September 2018 (UTC)
How to verify the number of triangles for the extra credit?
Now that there're several computer programming examples that have different output for the optional extra credit requirement, how does one verify which one is correct? -- Gerard Schildberger (talk) 11:07, 24 September 2018 (UTC)
- How about we each create a temporary "Law of cosines - triples/tmp/<language>" page containing just a list of the thousands of triples ?
- One space-separated triple per line
- Any line starting '#' treated as a comment, no other comments allowed.
- The tmp/... pages all to be deleted on 1st October 2018.
- We would have a week to examine each others results and refine the task. Paddy3118 (talk) 12:25, 24 September 2018 (UTC)
- Paddy, I suspect there may be a problem with the expression: int(c2**0.5) which occurs 3 times in your Python entry. If the power operator produces a value which is slightly less than the 'correct' integer value, then the 'int' function will round it down and the wrong tuple will be added to the set.
- Thanks to user Hout for the extra Python solution. I ran it then extracted the generation of the list for the extended credit solution and then filtered out occurrences of the same triangle to get a still differing result:
- <lang python>
t60u = triangles(f60unequal, 10000)
len(t60u) Out[4]: 18394
t60u[0] Out[5]: '[3, 7, 8]'
t60new = set([tuple(sorted(tri)) for tri in t60u])
len(t60new) Out[7]: 16161 </lang>
- P.S. I had actually developed a python
method2
based on dicts (and the fact that dicts are ordered by default in Python3.6). I debugged the two implementations together and they agreed when tested against each other but the Python set version was slightly faster so I only published that. I'll invetstigate further tonight. Paddy3118 (talk) 09:25, 25 September 2018 (UTC)
- P.S. I had actually developed a python