First I get all items and save them in items. Then I sort them by their distance to me and approach the next one.
The actual code is a bit more complicated (I don’t check all coins on the field), but for my idea to work I need to sort a given coin-array by distance. According to this thread I can’t use a lambda-function, so I try to create one outside and use it like the following:
The comparison function can be simplified since it needs a positive, negative, or zero value (not necessarily +1, -1, and 0) to check if it’s greater, lower, or equal.
I copy and paste that line and drop it into my code and Immediately it gives me a “Your parentheses must match” error…
(I changed getItems to findItems still same error)
so I change it to something simple that shouldn’t have problems…
gg = sorted([5,4,3,2,1], cmp=compare_distance)
and I get the same error??? (it doesn’t care if “compare_distance” is defined or not)
@Gulzt I believe CodeCombat’s Python compiler does not support keyword arguments (named parameters) yet.
The “your parentheses must match” error message is incorrectly applied to this parsing error — I believe Aether thinks your parentheses don’t match because the error occurs when parsing a function call’s arguments. That is, the keyword arguments syntax is not supported and the compiler fails to parse the function call’s arguments.
The correct solution would be, of course, adding keyword arguments support to Filbert (CoCo’s Python -> JS transpiler).