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.
nice kata, had me searching and overthinking before coming to a simple solution (clojure)
description amended
I rewrote the JavaScript tests suite, as well as enabled Node 18 + chai assertions. the test suite now includes edge cases (almost-sorted arrays, sorted arrays of length 2)
the error comes from your code, at this line:
if
array[1] == array[0]
, this divides by0
, thus raising aSIGFPE
as of now, TypeScript 4.9 is the only version available
duplicate of this issue
fixed
re-raised there as an issue
re-raised there as an issue
https://docs.codewars.com/training/troubleshooting/#c-c-signal-11---sigsegv
for some inputs, control flow can leave your function without returning any value, so your code effectively returns random memory addresses in those cases. this is visible if you add
return "???";
at the very end of your function(OP's language was Java) added fixed tests with duplicate elements
This comment is hidden because it contains spoiler information about the solution
That moment when "mean" is actually... meaner
Fun and tidy kata—cheers!
Double check the description and make improvements. Here's a recommended description:
Task
Write a function that takes an array of integers whose length is odd ( ≥ 3 ).
Every element in the array has the same value except for one unique element.
Return that unique element.
Guarantees
• The array length is odd.
• Exactly one element differs from the others.
• All values are integers.
Examples
[1, 1, 2] => 2
[17, 17, 3, 17, 17, 17, 17] => 3
Clarification
If the array is [4, 4, 4, 9, 4], the function should return 9, because 9 is the only value that is not equal to 4.
Great Kata for teaching Enumerables
Loading more items...