Earlier quoted context omitted.
Reminds me of the ants-on-a-stick problem. 100 ants are spaced evenly on a 1m stick. They travel at 1m/minute. When an ant bumps into another ant, they both turn around and go the other way. When an ant reaches the end of the stick it falls off. How long before all the ants fall off?
That's not solvable as stated. I think you may have accidentally misstated the question. > 100 ants are spaced evenly on a 1m stick Are the ends at the end of the line of evenly spaced ants on the very ends of the stick? > They travel at 1m/minute. Is each ant initially traveling? What is the initial travel direction of each traveling ant? This matters because if the ants are all traveling in initially traveling then…
My Favorite Math Problem
81–86 of 86 posts
Re: My Favorite Math Problem
#82Earlier quoted context omitted.
> there is also a very elegant solution that fits in a tweet. (If you don't want to try solving it, or have tried and have given up, here is the solution I tried to understand the tweet a couple of times, but I couldn't follow the proof from the tweet itself, so I wrote it up again with the basic axiom from the tweet as a basis + work out each step of the process. https://gist.github.com/t3rmin4t0r/a953450ac64b686854…
I'm trying it with this TXR Lisp, just for fun. It uses an implementation of John MacCarthy's amb operator based on delimited continuations, which are slow. (defmacro amb-scope (. forms) ^(block amb-scope ,*forms)) (defun amb (. args) (suspend amb-scope cont (each ((a args)) (whenlet ((res (and a (call cont a)))) (return-from amb-scope res))))) (defmacro 0-9 () '(amb 0 1 2 3 4 5 6 7 8 9)) (defmacro val (p q r) ^(+ (*…
We must invent a related operator. Let us call it kanzen, Japanese for completion/perfection (完全). (This is not the "kan" in "kanren" which is 関連).
amb-scope and amb are defined exactly as before, but we add:
(defun kanzen (. args)
(suspend amb-scope cont
(return-from amb-scope
(append-each ((a args))
(whenlet ((res (and a (call cont a))))
(list res))))))
Using only amb, let's find some pair of integers x y, in the range 0 to 9, whose product is 12: (prinl
(amb-scope
(let ((x (amb 0 1 2 3 4 5 6 7 8 9))
(y (amb 0 1 2 3 4 5 6 7 8 9)))
(amb (eql (* x y) 12))
(list x y))))
The output is: (2 6)
Now, let's change the first amb to kanzen. Just the first one: (prinl
(amb-scope
(let ((x (kanzen 0 1 2 3 4 5 6 7 8 9))
(y (amb 0 1 2 3 4 5 6 7 8 9)))
(amb (eql (* x y) 12))
(list x y))))
The output now is: ((2 6) (3 4) (4 3) (6 2))
all the (x y) pairs are found that multiply to 12.What does kanzen do differently? Like amb, it cares only about non-nil arguments. However, instead of just finding the first non-nil argument for which the future computation succeeds (returns non-nil), and then returning that result out of amb-scope, kanzen probes all non-nil arguments. It continues the future computation with each value, and for each computation that succeeds (returns non-nil), it collects that value into a list. Then it aborts amb-scope using that list as the result value.
So the weird thing to be understood here is that (list x y) doesn't necessarily determine the ultimate result value of the amb-scope form. The first amb or kanzen call holds the reins, so to speak. If the first operator is amb then, indeed, the result value will be one that was produced by (list x y). amb will try the different futures, and when it finds one that yields non-nil, it aborts amb-scope with that value.
What happens with kanzen is that the ((y (amb ...))) part will find successful y values, and abort amb-scope. But it's doing that aborting within the scope of a continuation created by kanzen, so kanzen intercepts that, collects the (list x y) value, and keeps trying other futures. Thus, confusingly, the result doesn't have shape expected by (list x y).
Note how this is fundamentally hostile to static typing. This code depends on exactly the same piece of syntax, the amb-scope block, having a different type in different contexts: a list of integers during the execution of the search, and a list of lists of integers in the ultimate return.
A static typing theory could be developed for this which assigns multiple types to a node in the program. The interior of amb-scope can see its return value as "pair of integers". all the continuations captured within that scope have that return type. But because of the presence of kanzen, the node can be assigned an external static type as "list of pairs of integers". Or something like that.
Re: My Favorite Math Problem
#83Earlier quoted context omitted.
The original comment (by tasty_freeze) was an argument to symmetry. Just saying "because of symmetry" is not a proper explanation.
You're right that it's not a proper explanation. This feels just like a case of "details are left as an exercise". This is most frustrating when you're learning a subject, and you want to be able to check the details, or you are skeptical of a claim. Inevitably though people elide things that they think the reader (who they model as similar to themselves) will immediately be able to guess based on their experience. I…
The sibling to my first comment says it a lot better than I did: in a similar but different situation there's symmetry but no analogous strategy, so further explanation really is needed here.
In a sense, that makes it even more damning. Eliding details that you don't realise are important, but actually are, shows a real lack of understanding of your own argument. And that's something I have definitely witnessed in my own field!
Re: My Favorite Math Problem
#84Earlier quoted context omitted.
That's not solvable as stated. I think you may have accidentally misstated the question. > 100 ants are spaced evenly on a 1m stick Are the ends at the end of the line of evenly spaced ants on the very ends of the stick? > They travel at 1m/minute. Is each ant initially traveling? What is the initial travel direction of each traveling ant? This matters because if the ants are all traveling in initially traveling then…
Does it matter if they are evenly spaced? I think max time needed is the same if they are randomly spaced.
There are many initial configurations that achieve the maximum time before the last ant falls off the stick, and that includes configurations where they are evenly spaced and configurations where all but one ant is randomly spaced (achieving maximum time requires that at least one ant be in a particular initial state--I'm being vague to avoid spoilers).
(This is all assuming mathematical ants...point sized and can change direction instantly)
Re: My Favorite Math Problem
#85Earlier quoted context omitted.
You're right that it's not a proper explanation. This feels just like a case of "details are left as an exercise". This is most frustrating when you're learning a subject, and you want to be able to check the details, or you are skeptical of a claim. Inevitably though people elide things that they think the reader (who they model as similar to themselves) will immediately be able to guess based on their experience. I…
I can think of things where I would leave out details that a non-expert would need filled in. Except, I wouldn't do that in an interview situation where someone is specifically asking me to explain that one thing. (Yes they started with the giant coin thing, but "symmetry" is still the substantial majority of their argument.) The sibling to my first comment says it a lot better than I did: in a similar but different…
Re: My Favorite Math Problem
#86Earlier quoted context omitted.
Normally in these kind of cryptogram puzzles the leading digits of a number can't be 0. Your solution has A = 0.
In that case, we can easily add these constraints to look for another solution, like this --- but that is a poor way: (compile-only (amb-scope (let* ((A (0-9)) (B (0-9)) (C (0-9)) (D (0-9)) (E (0-9)) (F (0-9)) (G (0-9)) (H (0-9)) (I (0-9)) (J (0-9))) (amb (and (eql (+ (val A B C) (val D E F) (val G H I)) (+ 1230 J)) (nzerop A) (nzerop D) (nzerop G) ;; don't do this (eql 1023 (mask A B C D E F G H I J)))) (prinl (list…