For test 4 you do. If you use the correct radius of 60 you get a value of 0.49664609605580906 for the proton, and 2.0204107484267375e-16 for the alpha particle. Both are strictly under 0.5.
Not sure where those values are coming from. According to the table, g = Q/m, which for alpha is around 0.005 (2/3727), while proton Q/m is 0.001 (much smaller). Using R = 60 in the gammaV BRC equation (right side of the equation), g ~ 0.005. My code is literally a stack of if-statements like:
g.toStringAsFixed(4) == (2/3727).toStringAsFixed(4)
and this is enough to pass the tests.
Well, except Validator 1. Would love to know why I can’t get past that.
The formula for G is 1e6 * V / (B * R * c * ((1 - V ** 2) ** 0.5))
, for a radius of 60 that gives you 0.000536624631070566
.
The proton has a g_p value of abs(charge) / mass
which is 0.0010660980810234541
If you compute the final formula abs(g_p - G) / g_p
you get 0.49664609605580906
.
I assume that your calls to toStringAsFixed are doing some rounding and that’s why you may not get the same result.
Exactly!
I’m sorry for this mistake, I am quite weak in English !
I would like to correct it, but I don’t know if I can still edit a puzzle after its approval…
You can edit your puzzle from its contribution page, even after its approval.
Hi Djoums,
I am not sure to understand where your problem came from, maybe it is because of my error in the statement with «nearest tenth» instead ef «the nearest multiple of 10».
Before writing this answer, I was sure that the abs(q)/m
particle interval does not overlap as I choose the value .5
for the threshold of abs(g_p - G) / G
such as, but my bad, abs(q)/m
interval of proton and alpha overlap !
e- : q = -1, m = 0.511 ==> abs(q)/m = 1.96 : G ∈ [ 0.978, 2.94]
p+ : q = 1, m = 938.000 ==> abs(q)/m = 0.00107 : G ∈ [0.000533, 0.0016]
n0 : q = 0, m = 940.000 ==> abs(q)/m = 0 : G ∈ [ 0, 0]
alpha: q = 2, m = 3727.000 ==> abs(q)/m = 0.000537 : G ∈ [0.000268, 0.000805]
pi+ : q = 1, m = 140.000 ==> abs(q)/m = 0.00714 : G ∈ [ 0.00357, 0.0107]
I took this criterion as a detail, but the devil is in the details!
So maybe I should change the statement
Likewise, the ratio g = |q|/m could not be computed exactly. Let’s note g_p the theoritical value of particle p (given in the table below) and G the computed value from picture with the formula above.
If
abs(g_p - G) / g_p < .5
one can conclude that the particle which just passed through the cloud chamber was p .
If none of the five known particle satifies
abs(g_p - G) / g_p < .5
one can conclude that the particle which just passed through the cloud chamber is unknown.
for
Likewise, the ratio g = |q|/m could not be computed exactly. Let’s note g_p the theoritical value of particle p (given in the table above) and G the computed value from ASCII-art picture with the formula above.
The particle p which just passed through the cloud chamber is the one with the minimal value of
abs(g_p - G) / g_p
if this value is stricly below.5
, i.e. :
abs(g_p - G) / g_p < .5
IfG
is such that
abs(g_p - G) / g_p >= .5
for every known particles (those in the table above), one can conclude that the particle which just passed through the cloud chamber is unknown (as its value ofabs(q)/m
is too far from every known particle).
An other solution would be to change the threshold .5
for a smaller value, but
- it would make the game a lot harder because a better precision on the computed radius would be needed,
- it would not be backward compatible for the test/validator.
What do you think?
Thank you !
Indeed, there were some mistake in the statement, sorry !
About your first point, as explained by @LastRick I wrote «closest tenth» instead of «nearest multiple of 10».
About your second and third point, the statement was indeed unclear and ambiguous, see my answer to @Djoums :
[Community Puzzle] Particle Detection with Cloud Chamber
I think it’s fine to take the particle with the lowest ratio, that’s what I did intuitively. Mentionning it in the description like you proposed would be enough
I’ll do that
Done !
I really enjoyed this one, even tho it all comes to finding the center of a circle, the context is original.
I didn’t use any statistics, just chose three points on the circle and deduced the center from that.
To make sure the three points are not too close from each other (which would mess the precision), I do the following:
- choose any point A on the circle
- choose a point B on the circle that maximizes AB
- choose a point C on the circle that maximizes AC x BC
Thank you @pardouin and well done !
The 3 points solution is much simpler that the overkill mine that use gradient descent along the greatest steep. My wife solved it with this method too !
I created this puzzle with the idea that one use every points of the particle path to use all the information given, but three points well chosen are enough ! After a little bit of disapointment, I am happy that you and others (including my wife) have found a simpler solution; simpler is better, faster, stronger !
I am very glad that my puzzle is puzzle of the week this week !
I’m struggling with the hidden validator #6.
I get the radius much like pardouin does in the 3 steps.
Initially I looped through known particles finding their radius and assigned the difference between expected radius and actual radius that they would have under the current circumstances. Then I filtered to those under a certain threshold and sorted by value ascending.
This worked, however I wasn’t passing hidden validator #6 (all visible tests were passing).
I went back and read the assignment several more times and then I think I did understand it, however I still fail on hidden validator #6. What I do is: for each known particle I create a g_p and G
g_p = abs(q)/m;
G = 1e6 * (1/sqrt(1-V*V)) * V / (B * r * c);
and assign each particle a ratio using abs(g_p-G)/g_p)
then I filter all of particles with ratio > 0.5 and sort them by lowest being mindful of neutron exception.
Passing all visible tests yet still failing on hidden validator #6.
Am I missing something?
@abrman I think you have well understood the statement.
Test 6 and validator 6 are the most difficult to pass because they have the smallest arc angle.
I think the most likely is that you find the right particle at validator 6, but there is an error on the radius. As the radius should be rounded to the closest multiple of 10, I think you are close to the treshold, on the right side for the test 6, but on the wrong side for validator 6.
Actually, several codingamers (including myself) have had problems with validator 6, and afaik, it was always a problem of accuracy on the radius.
Perhaps the validator 6 is a little bit more difficult than test 6… despite that they are very similar.
I feel sad that you pass every test but not every validator, it happened to me a few times and I know it’s quite a pain and annoyance!
I wish you success with this puzzle, and I hope it will be the one that gets you to level 20
@TwoSteps Would it be OK to switch test 6 with validator 6 ? Or at least, change validator 6 to make it a little be more easy (by increasing the arc angle of the particle path) ? I’m afraid it would break some already validated answer.
But I would like to make sure that any code that passes all the tests, also passes all the validators.
Several random tries later I’m lvl 20
You were right & thanks!
Another option is to make test case 6 more difficult and tricky, comparable to the validator.
I’m afraid it would break some already validated answer
You can use some existing solutions to check with your new cases.
I would like to make sure that any code that passes all the tests, also passes all the validators.
That is a good wish though theoritically and practically it is impossible to be assured.
On-the-job programmers should get used to such scenerio when debug can only be done by reverse-engineering or black-box testing.
BTW, that’s an interesting puzzle.
In order to solve validator 4, I had to confine my point selection to the exterior left side of the curve. Apparently, mixing inside and outside points from the particle path added enough error to throw off my radius calculation.
Validator 4 (and possibly 6, judging by other posts here) may be demanding higher resolution than the ASCII art contains, at least for 3-point center finding.
Still, a fun puzzle.
P.S.: And that change caused my code to fail test case 6, while passing validator 6.
Ok, update:
I finally have a solution that passes all test cases and all validators. Validator 4 was always the problem child, at least for my approach to the problem. It took some statistical analysis and point hunting at the 0.1m scale in order to resolve the circle centers finely enough to solve both case 4’s and both case 6’s with one generalized algorithm. Whew. Looks like the other published solutions tended towards finding more accurate coordinates for the particle path before starting in on any calculations. Sigh. You can do something the MACKEYTH way, or the easy way.
A tip for those intrepid souls that dare this puzzle: you’ll need to work out a way to find the center line of the particle path to a resolution of less than 1 m. The radius of several cases is perilously close to the rounding boundary between 2 different multiples of 10.
@LaurentValade, physics must be a cruel mistress if she subjects you to this sort of thing.