You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
g ["a a","b"] returns "ab a", which is not correct - "a ba" also minimises length and is lexicographically less, as ' ' is less than all printable ASCII chars. I don't think there's any way of fixing this case without rewriting the entire thing 😢
However, with that fact in mind, you can shorten down the final solution to 132 chars which still yields the flag:
(x:a)#(y:b)=max x y:a#b
x#y=x++y
g=head.sortOn(0<$).sort.map(foldl1(\r->(#r).until(and.zipWith(((<'!').).min)r)('':))).permutations
Surprisingly, using these optimisations in the solution which covers edge cases allows the solution to be submitted:
(x:a)#(y:b)=max x y:a#b
x#y=x++y
u=reverse.dropWhile(=='')
g=head.sortOn(0<$).sort.map(foldl(\r->(#r).until(and.zipWith(((<'!').).min)r)('':))"").permutations.map(u.u)
which fails to yield the flag. In fact, removing.map(u.u) in the solution allows the flag to be retrieved! I don't understand what's going on here, but it seems like the task was ill-defined.
The text was updated successfully, but these errors were encountered:
Indeed, I apparently missed yet another special case. I think with your approach of using the ordering of chars, which gives us another 13 bytes for the solution, it could be possible to rewrite the solution to cover this case as well, for example by replacing the until and instead of taking the first solution finding all solutions (although you need to figure out when to stop), but I currently don't have the time to look into this further.
Regarding what solutions get accepted there definitely seems to be something wrong with the 2nd rule, or we are all just misunderstanding it. I guess instead of the service not supplying strings with leading/trailing spaces, we just got lucky and the service did not trigger the special case that I dropped at the end. My second idea would have been the same as in your writeup, trimming spaces when looking at the length but not when returning them, but as you pointed out, this fails as well.
I guess it's best to wait until they (hopefully) release the source code.
g ["a a","b"]
returns "ab a", which is not correct - "a ba" also minimises length and is lexicographically less, as' '
is less than all printable ASCII chars. I don't think there's any way of fixing this case without rewriting the entire thing 😢However, with that fact in mind, you can shorten down the final solution to 132 chars which still yields the flag:
Surprisingly, using these optimisations in the solution which covers edge cases allows the solution to be submitted:
which fails to yield the flag. In fact, removing
.map(u.u)
in the solution allows the flag to be retrieved! I don't understand what's going on here, but it seems like the task was ill-defined.The text was updated successfully, but these errors were encountered: