This comment is hidden because it contains spoiler information about the solution
This doesn't really work because it doesn't check the preconditions. The current random tests often fail with a message like "expected -1, got -49".
Oh, I just saw that you did do a lot of hard work in your other solution. Did you succeed in the end? Most of the code is commented out...
That's a very secret agent. :-)
I think this smells like cheating (I mean, look at how much hard work the others had to go through), but you're right - it's Hack-22. All's fair in love and war. ;-)
Hi DasBrain (and others),
good job! It's great to see that the original idea (without any non-JDK libraries) is basically still working. Or working again. :-)
Of course, this kata has always been a bit crazy, and I expected it to break whenever Codewars made some changes (for example, update to a newer JDK). Heck, I didn't even expect it to work in the first place. I expect it will break again in the future in unexpected ways. That's OK. Trying to fix it whenever it breaks would be a waste of time. Let's have fun while it lasts, and when some old solutions stop working, let's try to find new ones. But at the moment, it's definitely possible to solve this in several different ways, so I'll mark this issue as resolved.
It also took me a whole day to come up with my solution. :-) There are a few other approaches, but yours should be fine.
The problem with 'Unable to get pid' should be fixed soon. Maybe it already is. I don't have time to try right now...
Non-spoiler reply so that @janitormeir get's a notification.
@kazk Could you have a look at this? https://github.com/docker-library/openjdk/issues/76
I don't know Docker much, and I don't even know if you use Docker, but if you do: did you make some changes there? Could you try the --init flag suggested in the comments and see if it fixes this kata (or at least some of the solutions)? Thanks!
@EAirPeter: Codewars had to update their test environment, which means that some solutions of this kata currently don't work anymore. My original solution (which worked pretty much like yours, as far as I can tell) doesn't work anymore either. We're working on a fix.
Good point. I added "not in write mode" and "not in read mode" to the messages.
I'm not sure I understand what you mean, but I guess you're asking about the order of the bytes read and written. If your example represents a timeline of calls to write() and read(), it's correct. The calls to flip() are missing though.
I'll mark this question as resolved. If you have other questions, let us know.