[Community puzzle] Horse-racing Hyperduals


#1

This topic is about the puzzle Horse-racing Hyperduals.

Feel free to send your feedback or ask some help here!


#2

I see several minor issues in this puzzle.

1) Stub has horse parameters as "s, e", while the description talks about Vi and Ei.

2) It has D >= 0 but there is not a single case or validator where D == 0.

3) I'm not sure if it is an issue or by design, but this puzzle is easily solved with O(n*2) (not even O(n*log(n)) ) brute force (even in Python), no optimization algo is actually required. Maybe number of cases should be much higher, as in the original HRD?


#3

As far as I remember, a harder version without brute force is on the rails.


#4

Good catch! It's changed from "speed" to "velocity" mid-term, to avoid more unneeded confusion between Strength and Speed. I've just corrected the stub. (I never use the stubs, so indeed I seldom think of them)

2) Yeah, I don't care enough, you can add one if you want, but I can't think of a single algorithm where it would make a difference, so WTH. It's an indication to hint to a datatype, not an edge-case.

[It's easy]

3) As nicola hinted, harder one coming up: https://www.codingame.com/contributions/view/46851c0fe09e7e9725ad1f768d091234bf9
More seriously, originally I wrote it as a reaction to the constant flow of people chiming up on the various chat channels saying "I don't understand how it's even possible to do it in bash". So now we have a harder (by some measure) version of the puzzle that still is solvable in bash. Pure bash, too.

Can't offer you a dedicated achievement if you do solve it in bash, though; sorry!


#5

Well, my initial stupid O(n**2) algo that compared each horse to each another horse actually would stumble with such a case because it specifically had to exclude identical horses. Unfortunately, I cannot add it myself, probably because of my low 24th level.


#6

You mean you excluded identical horses by excluding a difference if it was zero?!


#7

Yes.

Yes, in that draft solution I did so.


#8

Well, ok, now you can't do that anymore.

(but you should know better :worried:)


#9

I don't know much about computational complexity, but I wonder if my solution is O(n) and works in the general case.


#10

I gave the link to the hard version in an earlier post. Just try it out there and you'll see! (you'll have a bit of adjusting to do to get the large inputs in, though)


#11

I’ve just lost a bit of my soul here.

Wasted hours notwithstanding, I’ve really lost a big chunk of lifeblood here. :cry:


#12

Don’t understand what you mean JBM


#13

I just realized how much harder than I thought this puzzle was. In a depressing way.

Any approver mind if I update it to “Very Hard”?


#14

After all, your gravity tumbling is still rated “medium” and it requires to code some kind of big integer library besides a bit of googling :wink:

The problem I see with this series of puzzles is, the brute foce approach works very well in C++ until the very last one that uses pseudo-random generator to increase the input size. Maybe that’s not the case in slower languages though.


#15

Ok, so:

  1. this is both off-topic here and a big spoiler there. Don’t do that.
  2. well, suggest a change then :stuck_out_tongue:
  3. strictly speaking, neither googling (ask Stilgart) nor bigints are necessary.

More “seriously”, I didn’t agree with the linearity of the community puzzle scale since the day it was implemented, have always considered they’d be better rated simply as codingamers’ success rate, and have published all of my puzzles as Medium difficulty ever since. After all, they can’t be that hard if even I could manage them!


#16

Ok sorry, I’ve edited the spoiler out.

As for the big ints, they seem to have been the tool of choice for about every solution I saw. Too bad not every language has them as builtins, eh?
And frankly I don’t remember ever seeing the theorem the puzzle is based on in my 5 years of engineering studies. I suppose you could re-discover it if you’re very smart or very lucky, but for more limited mortals I guess Google might come in handy here.

Now that I dared tackle more than medium puzzles, I realize the difficulty level is indeed all over the place. I agree it can prove more misleading than helpful sometimes.


#17

Well, sorry, they’re still not needed. The entire puzzle can be done in linear time using no arithmetic higher than 8-bit. (actually even less, but you’d be hard-pressed to find ops to do that)

It’s a multi-layered puzzle: if you’re reaching out for the bigints, well it’s a cop-out that does work, but you’re missing part of the point. In related news: it’s not octal just to be a nuisance.

From what I heard, that’s not strictly needed either. Many did without, and we still get a message every month complaining why the puzzle has to make everything more complicated with defective tumblers.

Well now I’ve read it all! :rofl: