7 kyu

Shortest Word

96,206 of 252,094PG1
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • zxcWeeJee Avatar

    хороший и простой ката

  • Mohamed253 Avatar

    The test gives an error, while the code was submitted successfully Lang: C++

    The Error: In file included from main.cpp:7: ./tests.cpp:2:2: error: expected member name or ';' after declaration specifiers {6 ^ 1 error generated.

  • Lexa_777 Avatar

    Are these exactly 7kyu?

  • metatable Avatar
  • Fruits68 Avatar

    This comment has been hidden.

  • dvvis Avatar

    never realized that so many problems could be solved with lists. good thing i like lists.

  • avichii Avatar

    had fun on this one.

  • immuneFOMO Avatar

    Check the full text of the tests, you may have missed something in your checks ' (;

  • aditya nandlal Avatar

    This comment has been hidden.

  • potionsnotusedlol Avatar

    This comment has been hidden.

  • elJaredr Avatar

    I spent around 15 minutes trying to write a loop to make this work but then I realized this is python. There must be some functions I can use to automatically get the shortest word. So I just went ahead and used those functions and it worked :D

  • bcdyzi Avatar

    This comment has been hidden.

  • UlrichBerntien Avatar

    Rust test cases: Add string including multibyte characters, e.g.

    dotest("abc 💖 de", 1);
    dotest("abc 💖💖 def", 2);
    
  • Pastor1715 Avatar

    This comment has been hidden.

  • StonedWolf94 Avatar

    This comment has been hidden.

  • hakloi Avatar

    This comment has been hidden.

  • vicpari Avatar

    I'm having problems while validating the solution, it's not finding the Kata class.

  • Alissy Avatar

    This comment has been hidden.

  • weiihii Avatar

    This comment has been hidden.

  • jdx-code Avatar

    This comment has been hidden.

  • mirekfranc Avatar

    When it comes to D version, it seems to me, that the sample tests are missing two imports import solution : findShort; and import std.string : format;. Main tests are fine.

  • jdleval Avatar

    where are the examples?

  • hobovsky Avatar
  • hobovsky Avatar

    This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/144.
    Please join the discussion to help us identify duplicate kata and retire them.

  • gabrielcosta89 Avatar

    Ververy nice kata!

  • akar-0 Avatar
  • Gambit7991 Avatar

    This comment has been hidden.

  • Alexcodeit Avatar

    When I try in xcode(Swift) everything fine but here I get

    XCTAssertEqual failed: ("3") is not equal to ("5") - XCTAssertEqual failed: ("1") is not equal to ("7") - XCTAssertEqual failed: ("2") is not equal to ("4") -

  • Skadwick Avatar

    Getting the following error on C#, repeatedly. Most of the random tests have 'BTC' in them, which should be the shortest, but it's stating some other word is the shortest.

    RandomTests Log (printing the test string below, quotes added manually for clarity) --

    "Monero Ripple Lisk Ripple Dash BTC LiteCoin Bitcoin Lisk Classic MadeSafeCoin Classic 21inc Steem ProofOfStake Waves Mine Monero DarkCoin Mine Ripple Monero 21inc Waves"

    Test Failed It should work for random inputs too Expected: 4 But was: 3

  • CresixU Avatar

    Test show the wrong answers and I can't pass it

  • DmytrQ Avatar

    Task definition is uncorrect "Simple, given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types".

    Separator is not defined. And 'word' is not defined. "ThisIsAlsoAStringOfWords", "and,this,is,also,a,string,of,words", "and probably, even this is a string of words: let's Twas brillig, and the slithy tovesDid gyre and gimble in the wabe;All mimsy werethe borogoves,And the mome raths outgrabe."

  • thyCHP Avatar

    My fellow comrades. I have quite the issue on my hands here. Although my code is correct, for some odd reason, the test refuses to give me the green light. I've had this in most of my kata up until now, but this was the last straw. To give yall an example:

    Log: 3

    None should equal to 3

    #WRONG!

    This is the problem I'm facing, and it could really help to get some feedback.

  • Hetfield_666 Avatar

    Hi fellows codders, i have a little problem : i work in java, and the program i wrote returns "4" instead of "3" and i don't see my mistake, and when i try to return the length of the shortest word - 1, i got the REAL length - 1, can anyone help me ?

  • Hetfield_666 Avatar

    Hi fellows codders, i have a little problem : i work in java, and the program i wrote returns "4" instead of "3" and i don't see my mistake, and when i try to return the length of the shortest word - 1, i got the REAL length - 1 can anyone help me ?

  • Xoalh Avatar

    This comment has been hidden.

  • Xoalh Avatar

    This comment has been hidden.

  • NastassiaDen Avatar

    Why am I getting this error? src/Solution.cs(5,25): error CS1061: 'string[]' does not contain a definition for 'Min' and no accessible extension method 'Min' accepting a first argument of type 'string[]' could be found (are you missing a using directive or an assembly reference?)

  • frankdin1 Avatar

    Why am I getting this error? I declared ch as const char *ch. solution.c:9:15: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] ch = strtok(s, " ");

  • akar-0 Avatar
  • BogSala Avatar

    I have $arr = ["who" , "the"] But what i need to return? returing this array i get: Array (...) does not match expected type "integer"

  • BogSala Avatar

    in first test i have two words with lenth 7, but test need one from them? my script not wrong, its just different! Or do two right variants, or make a normal instruction

  • geresik Avatar

    Hi, everything works in PyCharm, but Codewars indentation error: indentation does not correspond to any external indentation level. Help xD

  • 9inch Avatar

    Hard one

  • programmer101.101 Avatar

    This comment has been hidden.

  • income3000 Avatar

    This comment has been hidden.

  • Trosh Avatar

    This comment has been hidden.

  • xvrach Avatar

    Hello warriors :)

    I am new to codewars, and I have one question...

    We have kata description and some snippet of code, if kata snippet is:

    def find_short(s):
        # your code...
        return l # l: shortest word length
    

    is acceptable solution like:

    def find_short(s):
        return bla bla bla... 
    

    I mean all calc in return ... not calculate L and return it...

  • ovanderzee Avatar

    This comment has been hidden.

  • IGraciarena Avatar

    This comment has been hidden.

  • gbchang Avatar

    How do I know how long my program needs to run?

  • ratkevichnikita Avatar

    This comment has been hidden.

  • codingkapur Avatar

    This comment has been hidden.

  • cobblers-apprentice Avatar

    This comment has been hidden.

  • ejini战神 Avatar

    This comment has been hidden.

  • TIGERTIDES Avatar

    UndefinedBehaviorSanitizer:DEADLYSIGNAL ==1==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000008 (pc 0x000000425a34 bp 0x000000000000 sp 0x7fff5d700c30 T1) ==1==The signal is caused by a READ memory access. ==1==Hint: address points to the zero page. ==1==WARNING: invalid path to external symbolizer! ==1==WARNING: Failed to use and restart external symbolizer! #0 0x425a33 (/workspace/test+0x425a33) #1 0x428ae9 (/workspace/test+0x428ae9) #2 0x426dce (/workspace/test+0x426dce) #3 0x426949 (/workspace/test+0x426949) #4 0x42658b (/workspace/test+0x42658b) #5 0x42be95 (/workspace/test+0x42be95) #6 0x425c3d (/workspace/test+0x425c3d) #7 0x7f948d6fabf6 (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6) #8 0x4049d9 (/workspace/test+0x4049d9)

    UndefinedBehaviorSanitizer can not provide additional info. ==1==ABORTING

  • jeremiesiller Avatar

    did anyone else got confused becaus you coudnt loop threw the source? it wasnt null-terminated ...

  • KLIJIN Avatar

    This comment has been hidden.

  • anipnwr Avatar

    how can the length of a word be 0?

    it expects 0 answer from our code

  • ezmicken Avatar

    This kata description does not mention that words of length 1 should be omitted. Not so simple ;)

  • inbarvernia Avatar

    This comment has been hidden.

  • BenoitLardinois Avatar

    This comment has been hidden.

  • wr4th_3rd Avatar

    I don't know what is this error ? Actual: 1, Expected: 3 String: "Nqad mfxiu ecuq bhw gsou ociqk dam fynd iclm dxz vgtn nplsy chg vok bpbl oxqux gsyz vpx jvll tqahb jqxuk ubkr qjts rjr smndt wwqzs psv gpfq" ?? I don't know why Actual is 1.

  • siddot Avatar

    Python is language for genius solutions.All coders need o use that!👍

  • MobulaKuhlii Avatar
  • dan-el Avatar

    This comment has been hidden.

  • BreadStixFTW Avatar

    This comment has been hidden.

  • Aaryan Prasain Avatar

    This comment has been hidden.

  • eneamuskaj Avatar

    This comment has been hidden.

  • KittyKora Avatar

    This comment has been hidden.

  • jonasgheer Avatar

    I was unable to use String.split_on_char, is there any reason for this? The error was something like "split_on_char cannot be found on String".

  • ebrilo Avatar

    Tests are valid only for non-unicode strings

  • MysticMan Avatar

    This comment has been hidden.

  • MoukimHF Avatar

    when i run my code on my machine it works correctly but here it says s.map not a function

  • simson2710 Avatar

    it is testing for test.assert_equals(find_short(""), 3)...sholuld be test.assert_equals(find_short(""), 0), right??

  • franciscostacom Avatar

    This comment has been hidden.

  • AmolSB Avatar

    If taking space complexity in account =>

    Math.min.apply(0, s.split(' ').map(w => w.length));

    http://ejohn.org/blog/fast-javascript-maxmin/

  • titkov49 Avatar

    This comment has been hidden.

  • B1ts Avatar

    Prolog translation kumited. Please review ;)

  • dinglemouse Avatar

    The initial solution of Java has the unncessary import java.util.Arrays; which seems to be steering solutions in a particular direction for no good reason...

  • stellartux Avatar
  • yudi4625 Avatar

    This comment has been hidden.

  • lokvahdin Avatar

    Unless I am misunderstanding something... My method should take a string with two or more words, Examine each word for word length, then return the length of the shortest word, or words?

    I'm not certain how the javascript tests are working for this. Test.describe("Example tests",_=>{ Test.assertEquals(findShort("bitcoin take over the world maybe who knows perhaps"), 3); Test.assertEquals(findShort("turns out random test cases are easier than writing out basic ones"), 4); });

    The second example test case has three words that are of length 3. However the assertion is looking for a length of 4. Should I specifically ignore this test cases failure or did I completly misunderstand what is being asked?

    If what I am actually being asked to do is return the number of words that have the shortest length (first shame on whoever hasn't fixed this in the description by now), and second the first test case and second test case fail as there are 2 words of a length of three in the first one, and 3 words with a length of three in the second test case.

    Which is it, and if I attempt to solve this will submitting it pass even though the example test cases most assurdily will not pass?

  • brancyxy Avatar

    This comment has been hidden.

  • IdotEXE Avatar

    CAN SOMEONE PLEASE ACTUALLY CREATE A TASK IN WHICH THE WORDING CLEARLY MAKES SENSE. GOD THIS WEBISTE IS TERRIBLE.

  • OnePro Avatar

    test.assert_equals(find_short("bitcoin take over the world maybe who knows perhaps"), 3)

    Actually 2 ("the", "who")

    Issues in test cases

  • jenndroid Avatar

    This comment has been hidden.

  • user1925374 Avatar

    I think this test is broken for Java. I wrote a public static int class that successfully returns the length of the shortest word(s) and the CodeWars editor just throws all sorts of errors no matter what I do. My code works perfectly on IntelliJ IDEA though, so no clue what's going wrong.

  • user8436785 Avatar
  • BeckMarquez Avatar

    As I may suppose, there is a mistake in this Kata when I try to resolve it on C#, because my code successfully completes Basic Tests when I "RUN SAMPLE TESTS", but error occur in Basic Tests when I try to "ATTEMPT"

  • user8436785 Avatar

    There appears to be a Nim translation waiting.

  • jhooker330 Avatar

    I've solved the kata and submitted my final code. How long does it take before I can view other solutions? It says I would need to forfeit elibility.

  • Arnzero Avatar

    This comment has been hidden.

  • danielvandenberg95 Avatar

    c++ random test case expects -1.

  • infomaniac Avatar

    Please add another test case with unicode characters: {"lets add one unicode character → makes this more interesting", 1}, {"lets add two unicode characters →→ makes this more interesting", 2},

    All the current test cases only cover the number of bytes of the shortest word!

  • BotPandora Avatar

    This comment has been hidden.

  • Unnamed Avatar

    There should be tests where the last word is the shortest, especially in the languages where lower level code is more likely to be written. This C++ solution should be invalidated: https://www.codewars.com/kata/reviews/5c7d32946e54c8000115c266/groups/5cabd37ea11d9600017e430a

  • kzm Avatar
  • merlz6 Avatar

    The test appears broken for Javascript? the answers to multiple of the tests are not the shortest word in the string? The function is returning the correct index however testing is showing an incorrect index for the shortest word.

  • uniapi Avatar
  • JimboJimbo Avatar

    This comment has been hidden.

  • uniapi Avatar

    Please, C Translation

  • a.merezhanyi Avatar

    C++ translation has been provided. Please review and approve.

  • Boneclock54 Avatar

    This comment has been hidden.

  • a.merezhanyi Avatar

    TypeScript translation has been provided. Please review and approve.

  • Ikorai Avatar

    This comment has been hidden.

  • Louis Thievent Avatar

    some code breaking cases are not supported: -spaces at the beginning/end of array -multiple spaces -really long words

  • kdmatrosov Avatar

    Kotlin Translation

    Please, review and approve/comment

  • xavierguihot Avatar

    Scala translation available for approval.

  • Jokown Avatar

    This comment has been hidden.

  • lex-r Avatar

    Hi, I made a GO translation for this kata.

    Please check and approve it)

  • Eleonora_K Avatar

    This comment has been hidden.

  • Ahmedxdh Avatar

    This comment has been hidden.

  • khanTT Avatar

    This comment has been hidden.

  • 君子剑岳不群 Avatar

    what should i can do?

  • razzako Avatar

    This comment has been hidden.

  • Ross_2k_18 Avatar

    Please help me. I mean that words contain is any characters is not " " (space) I right understand this task?

  • jakeluo Avatar

    This comment has been hidden.

  • sci4me Avatar

    This comment has been hidden.

  • keon-lam Avatar

    This comment has been hidden.

  • xehpuk Avatar

    There's a dangling "x" in front of the Kata description. Why?

  • cebailey33 Avatar

    C# needs the expected vs actual Assertions fixed as they are not correct causing attempts to fail. I found an incorrect Assertion "Expected 3, found 2" in the first C# Assertion test. Once I corrected (and added a few more Assertions for sanity sake), they all passed. My Submission Attempt is failing and I'm questioning if it is due to the same issue as found in the Tests. Please review and reply, thanks!

  • cebailey33 Avatar

    The BasicTests had incorrect assertions. First test was looking for 3 even though there were only 2 words of the same smallest length. I added additional Assertions in the basic tests and all passed yet I am failing the Submission Attempt. Methinks there are also incorrect Assertions in the "Attempt" tests. Please check and validate as I know my code is correct. Thanks!

  • hangxian@1 Avatar

    This comment has been hidden.

  • leealovey Avatar

    This comment has been hidden.

  • sout1_11 Avatar

    This comment has been hidden.

  • Yovchenko Avatar

    This comment has been hidden.

  • GrayPaper Avatar

    I am getting a correct answer yet it shows fail , am I doing something wrong ?

  • i-me-you Avatar

    why don't i see my output even if im getting it wrong i need to see my scripts output to know where the error is

  • Sanjeev589 Avatar

    This comment has been hidden.

  • andreymullin Avatar

    This comment has been hidden.

  • vikash.nepal Avatar

    This comment has been hidden.

  • mentalplex Avatar

    R Translation kumited!

    Please carefully review and approve! Reference solution and test suite commented for your pleasure!

    -mpx

  • balramsingh Avatar

    This comment has been hidden.

  • maribies Avatar

    This comment has been hidden.

  • maribies Avatar

    This comment has been hidden.

  • Apwjgaming123 Avatar

    im new n confused

  • ErdraugPl Avatar

    Sample PHP test cases have mixed expected and actual values. In PHPUnit first expected value is provided than actual value. See https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertEquals

  • zbinf Avatar

    This comment has been hidden.

  • shubhamv123 Avatar

    This comment has been hidden.

  • azabache Avatar

    This comment has been hidden.

  • ryancabanas Avatar

    In Java, the method name given in the starting code is "FindShort", but the Kata actually looks for "findShort". Please fix.

  • arjunsingh91 Avatar

    This comment has been hidden.

  • DahliaSR Avatar

    This comment has been hidden.

  • farhah.k Avatar

    This comment has been hidden.

  • apeg3200 Avatar

    This comment has been hidden.

  • bestwebua Avatar

    Thank you for nice one-line kata!

  • xander-miller Avatar

    This feels like an 8 kyu to me. It's too straight forward for 7 kyu.

  • DSchwettmann Avatar

    Java Translation has a compiling error, as the method in the user code is named 'FindShort' but should be 'findShort'.

  • Javatlacati Avatar

    This comment has been hidden.

  • Javatlacati Avatar

    It would be nice to add the data types to crystal translation: def find_short(s : String) : Int32

  • Javatlacati Avatar

    This comment has been hidden.

  • GiacomoSorbi Avatar

    And you got Crystal, pete.

  • lx_hu Avatar

    This comment has been hidden.

  • nym1k Avatar

    This comment has been hidden.

  • misteryx96 Avatar

    This comment has been hidden.

  • bvce Avatar

    In python 2.7 the funcion array.sort() does not work

  • filthycoding Avatar

    This comment has been hidden.

  • Late347 Avatar

    This comment has been hidden.

  • Robin-Andrews Avatar

    This comment has been hidden.

  • user3220651 Avatar

    This comment has been hidden.

  • devkornelia Avatar

    This comment has been hidden.

  • user5036852 Avatar

    This comment has been hidden.

  • donaldsebleung Avatar

    PHP Variant needs random test cases!

  • JohanWiltink Avatar

    Random tests! :]