Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
i like this logic, bravo man
man I used math.floor() to get the answer just to realise that could've done this just divided it and type casted into int
I must say that it possibly not universal solution, but deffinitely very resourcefully!
that makes two of us, I feel so dumb after I finally get a solution and I submit, someone posts something like this and I feel like a neanderthal. ;D
actually, that's a pretty good insight.
It is a short hand if else statment. Each of the statments
(p1 + p2).equals("scissorspaper") || (p1 + p2).equals("rockscissors") || (p1 + p2).equals("paperrock")
are all conditions of the if statament and if any of them are met then the player that wins will be 1.
When it says
int p =
at the start it is stating what will the 1 : 2 equal after the if statment.G E N I U S
clever
using a ternary operator, this is so genius!
beautiful, why didn't i think of that?
nice code!
It works just because JVM maintains a pool of strings that are known at compile time. Hense two string variables could potentially point to the same object in memory.
But usually, it's not the case.
And in general, it's a bad practice to substitute equals with '==' while you are checking for equality of values.
this solution made me realize that i'm a f idiot haha
Beautiful
Jesus, I used over 30 lines of code. Now I feel stupid)
Loading more items...