I need 150+ characters to even parse the input numbers in Java. Could you share some ideas on how to parse the input in shorter code?
Donât try to parse input.
As Plopx said: donât try to parse the input. And think about what inputs you actually need.
@Plopx: You also need 66 characters of Java stuff (class definition, method signature, etc) around your actual logic, donât you?
I was assuming that the coordinates of the light power and the initial position of Thor are necessary.
Could you give some hints on how the problem could be solved without even knowing these numbers? Or do you just use the input to distinguish between test cases and then return hardcoded answers?
As far as I know you need to at least distinguish between test cases. And then itâs hard coded, yes. Although I have a complete solution with (probably not fully optimized) 284 characters as well
49 are enough
(/me wonders why so much people want to use Java, itâs one of the most boring language for golfing)
49? No way! o.O(darnâŚ)
Well, Java was just my first language to start with (since itâs the one I know best). And now there are too many with less characters to call it a day
Thanks for the reply.
I confirm Plopx statement, 49 is enough , other stuff is your logic
Please add more testcases and re run all submissions.
I want to see how many peopleâs solution breaks
I got away with some weird stuff like not incrementing thorâs y postion
More testcases would really be amazing.
@Plopx, @PouletRoti: I think I got it - I counted my âthrows exceptionâ as well. Without that I have even less than 49 characters But you have to deal with that IOException somehow, donât you?
My code size is 137 in C++.
the smallest codes are public? I would like to see how someone have got the 82 bytes of code in C++ and compare it to my code.
No codes are public for now, and especially the smallest one, because if you have it, why not copy paste to be first too?
Iâm new here, there are some type of temporary competition with public write-ups after competition?
PD: I get a code of 129 chars Maybe getting the smallest possible size is not useful, but is funny.
Nope no IO exceptions for me.
Hi, destructuring assignment seems to work only in ES6, how did you make it run in puzzles?
Javascript on CodinGame is executed in SpiderMonkey, Firefox javascript engine. If something works in Firefox, it works on CodinGame. For destructuing assignement itâs like this:
var [a, b] = '10 25'.split(' ');
Hello, there is something I canât explain with Javascript can someone help me ?
In my code I increment/decrement Thorâs position after printing thhe solution to keep track of Thorâs moves, something like :
var inputs = readline().split(' ')
// do stuff...
while(true){
print(...);
if (condition) {
inputs[1]++;
} else if (otherCondition) {
inputs[1]--;
}
}
While this kind of approach seems to work well with Ruby - with loop do
- in JavaScript the content of the while(true) loop is executed 200 times between each print(âŚ). So the position of Thor is not accurate at all after the first move.
Using a little bit of trigonometry, the walk of thor can be rendered in better way.
In my solution I calculate the azimuth between the current position of thor and the target, then I round the azimut to eights of 2PI so the direction of the step is more visually straight.
Not requested, but more correct and visually better.
I wonder how they got lower than 107 in Python3âŚ