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 believe you are correct! The C# (and the Java and Swift translations) are overlooking solutions where the squares of one or more of a,b,c exceed the integer bound.
For example, for diff = 8696, low = 945745, high = 2531281, the Python solution finds (947864, 51654240, 51662936) as a valid triple. But the C# version does all the calculations in integers, and so overlooks this (and other triples). If the calculations are done using doubles (as your program wisely does), it finds them. Amazingly, all the people who solved the C# version previously overlooked this as well (so I don't feel so bad :-)).
I believe I have fixed the translations.
Congratulations on discovering this!
yes, you shouldnt make it so returning anything is dependent on if one triplet found is actually invalid. I believe your mistake is in making it return no valid triples based off the fact that one triple had a > b. I would reccomend making it so a!>b is a condition within the statement that checks if for a given value of a, if a is triplet so it doesnt add an invalid ( a>b triplet to the list in the first place). Unless i misunderstand your problem i think that is what needs a fix.
When doing a full attempt, it comes up saying i have extra triples, although these triples are valid, and Im pretty confident my iteration through range of a is working correctly. I saw that the task was somewhat old and that wisdou had issues with c# big numbers before, thought it possible that the testing algorithm had become outdated or something maybe. Can you perhaps look at my code and tell me whether I have just created a faulty program or if the issue is something deeper. Am new to both c# and codewars so could issue be a me issue.
If i return [] everytime first element is not smallest i get another error telling [] should be some not empty list.
Nvm, solved.
a, the first element of the triple, has to be the smallest side. This is not true for 1128, 846, 1410.
what makes you think it's broken?
is this broken?
create_pythagorean_triples(564, 456, 1654)
[(1128, 846, 1410)] should equal []
But 1128 ** 2 + 846 ** 2 == 1410 ** 2, 846 + 564 == 1410
Did i miss something?
Great solution.
I upvoted on clever, because its very similar to my solution ;)
WOW
Tried using this syntax for something else using elifs, didn't realise multiple elses could be chained like this until now.
The aim is to have the most cards at the end. Not take the most of them each turn.
Sometimes it's better to just take one.
Remember the instructions : Bob also tries to play optimally.
In your case, Bob could take 9 cards by playing it smarter so Alice would be able to only take 4 cards.
For 13 cards:
5 should equal 4
What's wrong in this?
Alice took 1, Bob 6, left 6
Alice took 3, Bob 1, left 2
Alice took 1, Bob 1, left 0
Alice totally took 5, test says 4.
Loading more items...