6 kyu

Does my number look big in this?

73,920 of 183,564JulianNicholls
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • linjessie Avatar

    Hi all! I am new to Codewars and this is my first kata. Why does it say this when I run my code: File "tests.py", line 1, in from solution import narcissistic ImportError: cannot import name 'narcissistic' from 'solution' Note: I have not changed the beginning of the code at all

  • kalpana-roy Avatar

    Incorrect answer for value=7: expected undefined to equal true. what does it mean for the narcissisticc function

  • kalpana-roy Avatar

    Hello all! my test case hasn't passed but it runs perfectly in my machine. This is first time I am using Codewars. This is regarding my narcissisticc function solution

  • big_M Avatar

    careful BigInt Translation Dart

  • ManjulaTudi Avatar

    This comment has been hidden.

  • Archit0853A Avatar

    This comment has been hidden.

  • lingu Avatar

    ERROR

    7 is not a narcissistic number. 7 pows 3 is 343 not equal 7.

  • dengo1303 Avatar

    Buenas con todos, soy nuevo en esto de codewars espero que alguien me puede ayudar, mi codigo pasa todas las prubas pero me sigue saliendo este error ests/Fixture.cs(96,28): error CS1955: Non-invocable member 'Narcissistic' cannot be used like a method. tests/Fixture.cs(102,28): error CS1955: Non-invocable member 'Narcissistic' cannot be used like a method. tests/Fixture.cs(54,37): error CS1955: Non-invocable member 'Narcissistic' cannot be used like a method. tests/Fixture.cs(77,37): error CS1955: Non-invocable member 'Narcissistic' cannot be used like a method. tests/Fixture.cs(28,37): error CS1955: Non-invocable member 'Narcissistic' cannot be used like a method. Agradeceria ayuda

  • Manashi123 Avatar

    This comment has been hidden.

  • Dawid Żeleźniak Avatar

    it should be at 7 kata, maybe 8

  • Meedo-blip Avatar

    This comment has been hidden.

  • Igor_Bogomolov Avatar

    This comment has been hidden.

  • eldojr90 Avatar

    This comment has been hidden.

  • LordBernieCoder721 Avatar

    This comment has been hidden.

  • shenghaojin12 Avatar

    This comment has been hidden.

  • FranzMartyn Avatar
  • Eric0202 Avatar

    I have used the type __int 128 which allows you to work whit 128bit integers. In fact without it, the randomtest2failed everytime

  • OjisanGamer Avatar

    Attempted this with Python and it doesn't seem to work with very large numbers. The basic tests all turn out correct, as do most of the random ones. Could this be a problem with the input range?

  • spyros879 Avatar

    Rust user here. I have a rust solution that works on the basic test cases but gives this error on the complex ones "attempt to multiply with overflow". I have tried using both u64 and i64 types in case some tests were very demanding but i got the same error. Any ideas?

  • renatta Avatar

    This comment has been hidden.

  • cquinci Avatar

    This comment has been hidden.

  • Voile Avatar

    Nim and R has no random tests, and R sample tests do not have test_that.

    TypeScript tests are not considered random: the order of the answer is almost always fixed (as random tests almost always expects false). See this

    C++ random tests generates false test cases in a laughably weak way it's too easy to deduce the pattern and pass them. See this

    In general, the random tests in all languages need to stop cheating the negative input generation by only choosing a small subset of the full input range. Honestly it's pathetic.

  • Voile Avatar

    Different language versions have wildly different input ranges, which should be normalized. On top of that, some language version have unacceptable input ranges:

    • Haskell only goes up to n = 50000
    • Nim goes up to n = 1634
    • PHP goes up to n = 8208
    • R goes up to n = 4887 (and only positive cases up to 371)
    • Rust and Swift uses u64, which is too big for this task, since it can cause calculation overflow in certain input range (e.g 17999999999999999999)
    • Python tests number as big as 115132219018763992565095597973971522401, which is unnecessary
  • Jason_Hall Avatar

    Wow!! so wonderful!

  • Abdelmajeed0 Avatar

    This comment has been hidden.

  • jaeakins1 Avatar

    371 is narcissistic: False should equal True... I get this result when I test. If i change my return False to print(value) the test comes back passed and says 371. I dont get what return false has it do this but print lets it pass

  • okellme Avatar

    hi im just new in here and dont know anyting about coding i wish my self to have motivation every single day.

  • HarukaKanata Avatar

    Hey everyone i hope yall are having a good day im quite new to coding only doing a codecademy bootcamp. I understand the c++ language but i do not understand how im supposed to read the coding problem and figure out what to do or start with. Even with codecadmey i had the same problem so i used chat gpt as a point of reference but i feel like thats not really helping me i would skim over the code and start the problem and keep on doing it untill i know how to do it without looking at gpt. I just want to know if it is good practice to use chat gpt as a point of reference or should i just figure it out on myself.

    Any help would be nice and appreciated i hope all yall have a good day.

  • user3166835 Avatar

    This comment has been hidden.

  • who_am_i_y_me Avatar

    7 is not a narcissistic number

  • gfgruvin Avatar

    The full test suite uses 1517841543307505039. It is failing. I am using Swift and when I run this in Xcode it's telling me it's not a narcissistic number. Who is correct here?

  • razzji Avatar

    This comment has been hidden.

  • Alexfromsaturn Avatar

    This comment has been hidden.

  • AndyIsFine160 Avatar

    A good day. Can anyone help me? My code passed all the tests but it returns an error of DEADLYSIGNAL, tried to look for it online and havent quite got what that entails. Thanks in advance :D

    Edit: I found the error and tried to reduce inherited values to a minimum. Remade it from scratch and submitted!

  • FelixRock Avatar

    I passed all tests, but cannot attempt. Why?

  • RossySpike Avatar

    Hi, my code (C) passes the generic test, but i get the next error in the random test

    'should_return_uncheated_narcissistity:' 'Caught unexpected signal: SIGSEGV (11). Invalid memory access.'

  • K-a-R-a-T-e-L-L Avatar

    This comment has been hidden.

  • 0rootIV Avatar

    This comment has been hidden.

  • Astro_Trooper Avatar

    im supposed to make a function that returns true or false for the given numbers

  • niki-durak Avatar

    "expected false to equal true" what does it mean?

  • Ehsin Avatar

    Hello. I am new to computer stuff. Actually this is my first attempt to code. I wrote this code in VScode and it's working I guess but I don't know how to make it run in here. Please help me, I need guidance.

    Here is the code:

    value = int(input("Enter an integer: ")) print(value)

    len_value = len(str(value)) int_len_value = int(len_value) sum_power = 0

    for exponent in str(value): int_exponent = int(exponent) power = int_exponent ** int_len_value print(power) sum_power += power

    print(sum_power)

    if sum_power == value: print("True") else: print("False")

  • demon6281 Avatar

    This comment has been hidden.

  • leonardo-47 Avatar

    This comment has been hidden.

  • Grimaldiny69 Avatar

    This comment has been hidden.

  • Safi103 Avatar

    I think this was explained very poorly but its a good kata

  • Jlakamka Avatar

    Guys, please help me, how do I run the code in "different modes" so that first Narcissistic Number, and then not Narcissistic Number?

  • thomashoeg Avatar

    Thumbs up for this one! My solution was correct, byt way to complicated. Really nice to see good solutions by you guys that have mastered the art of programming! Inspiring to see better ways to get the job done! I think way to complicated!

  • albertoSebben Avatar

    Hi,

    I get this error Incorrect 'answer for value=153: expected false to equal true'

    But in the sample indicate that 153 is narcissisc, it means true.

    I'm missing something??

  • p3yif102 Avatar

    excellent kata . it helps to read the instructions carefully .

  • gavinlampkin Avatar

    I really enjoyed this problem, genuinley stumped me initially. Thanks for suhc a great problem!

  • Carlosdev08 Avatar

    This comment has been hidden.

  • DoctorLynch Avatar

    This comment has been hidden.

  • Kenton7 Avatar

    Strange with Swift. Tests with very large numbers do not pass. In Xcode, for example, the number 35875699062250035 outputs as false. Moreover, if I do print, then the last received number, which is raised to a power, differs by 2 digits - 35875699062250037 Does anyone know what the problem is?

  • MarkPhrank Avatar

    def narcissistic(value ): l = len(str(value)) num= [] new = 0

    for i in str(value):
        num.append (int(i)**l)
        print(num, (int(i)**l), l)
    if sum(num) == value:
        return True
    return False
    
  • jacksparrwo Avatar

    Extremely fun :)

  • Jurasan90 Avatar

    I'm stuck on this with Swift. My code passes all tests except for very large numbers apparently:

    Full Tests XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 35875699062250035 XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 4498128791164624869 XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 4929273885928088826 XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 21897142587612075 XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 1517841543307505039 XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 35641594208964132 XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 3289582984443187032

    When I logged my output I saw that I have rounding errors, for example: 9 ^ 19 = 1350851717672992089

    But Swift returns 1350851717672992000

    Has anyone had the same problem? Any tips?

  • alexfan3 Avatar

    my javascript code passes all tests. But when I press the "Attempt" button, I get a log in which one more test is added, and it is suggested to check the number value=32164049651 But, in the task, it is written that only base 10 numbers will be played.

  • KhaledGamal0 Avatar

    This comment has been hidden.

  • m@ng.zu Avatar

    バイブ🥀🥀🥀

  • ibruh_5 Avatar

    This comment has been hidden.

  • ejini战神 Avatar

    Actual and expected are swapped in PHP, also assertion messages are not filled in completely for all test cases

  • ernesto-roberts Avatar

    my js code works fine in my pc, but in my attempts I get 7 is not turning TRUE, 7 shouldn't be consider a narcisitic number acording the definition given but browsing the internet I've just found for some reason all 10 numbers from 0 to 9 are considered narcisitic...

  • NikitaBelqa Avatar

    Python Invalid syntax in tests(

    File "/workspace/default/tests.py", line 10 test.assert_equals(narcissistic(value): ^ SyntaxError: invalid syntax

  • dolce_zorro Avatar

    The examples 7 and 1654 aren't Narcissistic numbers.

  • RattyJhay Avatar

    This comment has been hidden.

  • NooobQ Avatar

    Sample Tests has a message mistake in Line 11:

    Test.assert_equals(narcissistic?( 1633 ), false, "153 is narcissistic")
    

    should be "1633 is not narcissistic"

  • SCI_ALHADDAD Avatar

    This comment has been hidden.

  • sandbarry Avatar

    Did it in one line, let's goooooo!

    In all seriousness, I think I may have just gotten lucky with this one.

  • BlaDEjavU Avatar

    Well, this bs is worst I've ever met. Took me some hours to understand how these numbers works. And after understanding, it took me a minute to make a code. So after that, I've googled and asked gpt where this stuff can be used. Got no adequate answers. Useless thing, tbh.

  • coryshrmn Avatar

    This comment has been hidden.

  • MuLIAICHI Avatar

    This comment has been hidden.

  • muradin9a Avatar

    This comment has been hidden.

  • RohitRojo Avatar

    Love the name of this kata

  • KuleshUladzislau Avatar

    JavaSript:all random tests expect False.

  • avichii Avatar

    Idk y was i doing so many typecasting :|

  • favox Avatar

    This comment has been hidden.

  • Mario_Burgos Avatar

    I might have complicated the thing but I could pass the tests. Though the attempt result I'm having is:

    Time: 3797ms Exit Code: 137

    Could be that it's not well optimized?

  • jonesy_boy Avatar

    Hello everyone. I'm really new to codding, been trying to pass this challenge but, altough it gives me the propper output in the console, it seems that i'm doing something wrong, since it does not pass the test. Is it apropriate to post some code here, so i can try to understand what the heck is wrong? Thank you all in advance!

  • Beetlepenny34521 Avatar

    This comment has been hidden.

  • hobovsky Avatar

    Haskell: all random tests expect False.

  • M4rc0_D3v Avatar

    My code passes all the tests except for these: Random_Number_Test

    Test Failed Expected: True But was: False

    I decided to log the input, output(my sum answer) and ture or false. Please point out why these should be true:

    input 1778653589 output 645006974 False


    input 199898839 output 1952354824 False


    input 671108264 output 194989385 False


    input 793241850 output 564227289 False


    Thank you

  • kcloud3 Avatar

    Here are my results. 1 and 2 pass, but where do 3 (43994) and 4 (10162087) even come from? They are not in the sample test (only 7 and 371). Thanks.

    Test Results: ~ Narcissistic Function

    should find small numbers are all narcissistic › should find these numbers are narcissistic should find these numbers are not narcissistic 43994 is not narcissistic: expected true to equal false Completed in 1ms should find that some of these are narcissistic © 10162087 may be...: expected true to equal false Completed in 1ms

  • Mikezxcv81@ Avatar

    Im not sure about the format. I inputted working code. I have the program running in Visual Studio. But the "TEST" says it's wrong.

  • Posix Avatar

    This comment has been hidden.

  • ddm104 Avatar

    This comment has been hidden.

  • AgentVenom123 Avatar

    I couldn't understand the "True" or "False" part..can anyone please explain me what it is. Thanks in advance

  • BMeza05 Avatar

    This comment has been hidden.

  • shivavishnoi Avatar

    Should be a 7 or 8kyu kata

  • brodiemark Avatar

    This problem is very similar to "Take a Number And Sum Its Digits Raised To The Consecutive Powers And ....¡Eureka!!"

  • jalilov97 Avatar

    Too easy WITH changing the value to str. Is there any way finding sollution without changing the data type?

  • BohdanOutis Avatar

    what in randomized_test_2? all test i passed except this.

  • SaharQ1986 Avatar

    I just lost. I don't know what should i do there is any place for finding solution?

  • Brian. Avatar

    quite a variety of solutions, very nice

  • Muhammaddiyor Avatar

    In C#, the testing is too bad, damn, it made me nervous

  • yakhu Avatar

    This comment has been hidden.

  • gfandrade10 Avatar

    This should be KATA 8, too ez;

  • kalebalemayehu Avatar

    How is 7 narcissitic by this definition?, and my code runs well on other editors but im also having errors here

  • khalildoba Avatar

    I have a problem, I wrote the program and it works perfect on my machine with the right output, but when I put it in your IDE I get an eoferror, I know that it's a problem with the input() function, how can I solve this problem?

  • doutdes0 Avatar

    Loved the challenge, spent half the day on it only to realize my solution could be fitted in 1-3 lines. sadge

  • gparch Avatar

    I'm completely lost. How is it that 5**10 is 5? To be a narcissitic number, it should be 5, but my result is 9765625. Where am I getting lost? Can someone guide me?

  • akar-0 Avatar
  • hobovsky Avatar

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

  • kuddusi98 Avatar

    my code was not a one line code at first. Then i shrinked it into a one line code to look cooler. I dont think it looks good but this was the first and probabaly last oppurtunity to do it.

  • KayleighWasTaken Avatar
  • Doty Avatar

    In my opinion this kata could be 8 kyu or 7, as the solution is almost straightforward.

  • ri-chand Avatar

    is it necessary to use the function?

  • fcr-- Avatar
  • tri@ Avatar
  • aliakbrhasan Avatar

    This comment has been hidden.

  • Andrew-Borys Avatar

    This comment has been hidden.

  • user3837495 Avatar

    This comment has been hidden.

  • unicornware Avatar

    awesome kata!

    in the spirit of diversifying solutions, a nice amendment to the description would be challenging folks to implement the function without converting value to a string 😁

  • cookieM0nster Avatar

    This comment has been hidden.

  • salatulmaghrib Avatar

    Is it cheating to make a list of narcissistic numbers and check if the input is in the list?

  • pablomager979 Avatar

    non ho capito come risolverlo

  • tsorros Avatar

    This comment has been hidden.

  • UncensoredMax Avatar

    I really enjoyed this Kata. While being my first one here it showed me what to expect. Solved with Python

  • stolen toilet Avatar

    if your results are matching with the test but it is still not letting you pass, consider changing "True" to 1 and "False to 0

  • VanoKi Avatar

    Fine Kata, i think it plase - 7 kyu

  • Peardrax Avatar

    C#: All tests passing but the random number one? Can we get more details on whats in the random numbers? can these include negatives?

  • GiuProgramert Avatar

    The test are givin me 122 in the second test when it should be 371

  • dfhwze Avatar

    Nim: no sample tests

  • akar-0 Avatar
  • polistirex Avatar

    am i Stupid, or is 7 not a narcissistic number? the test case say that it should output true, but 7^3 is definitely not 7....

  • SFBoca Avatar

    This comment has been hidden.

  • samuel-constantino Avatar

    The test is failing on a case that should have been successful.

    371 is narcissistic: expected false to equal true

    language: JavaScript

  • laurelis24 Avatar

    Good kata, atleast i could understand what i need to do.

  • aboanarijesy Avatar

    Really appreciate this Kata for C!

  • nanowolf Avatar

    This comment has been hidden.

  • suyundukov Avatar
  • aphar.magaramova Avatar

    I get this eror: "src/Solution.cs(11,36): error CS0103: The name 'Math' does not exist in the current context"

    but I think c# has Math fuction. and I use "Math.Pow(x, y)" methode.

  • MasterOfswords Avatar

    This comment has been hidden.

  • jknock Avatar

    The description of what a narcissistic number is is wrong. It says the digits are to be raised to the power of the digits in a given base, and goes on to explain that the base is 10. So, power of 10? You should just copy the definition from Wikipedia - "the sum of its own digits each raised to the power of the number of digits" (in the number, not in the base).

  • ainsl.ie Avatar

    Enjoyed this one! Amusing name, too.

  • hakam123456 Avatar

    Liked this kata because of the awesome name hahahh.

  • oumellahni-nabil Avatar

    what's the problem please !!!

    main.cpp:9:5: error: redefinition of 'main' int main(int, const char *[]) { ^ ./solution.cpp:30:5: note: previous definition is here int main(int, const char *[]) { ^ 1 error generated.

  • Lunos Avatar

    For C++, using #include<math.h> lets us use the pow() function.

  • dark249367 Avatar

    This comment has been hidden.

  • vsaurav026 Avatar

    This comment has been hidden.

  • user6944666 Avatar

    This comment has been hidden.

  • miichu Avatar

    This comment has been hidden.

  • Saroj1154 Avatar

    Language: Ruby I am not being able to add the numbers after i did x.to_i**power to get their power. I split them with the use of to_s and split function and mapped through items and to_i each item and **power. Here, ppower is the length of the number when I converted it into string. Can someone help ??

  • awpala Avatar

    In C++ version set with clang 8 compiler (default option), the compiler will not recognize the function std::pow...so even though my solution is correct, it generates a run-time error and cannot pass. The Kata description does not prohibit use of the standard library, so it appears to be an issue with how the #includes are set in the test runner containing main.

    EDIT/UPDATE: I was able to resolve this issue via #include <math.h> in my solution code outside of / immediately preceding my solution inside of narcissistic, i.e.,:

    #include <math.h> // must explicitly include dependencies
    
    bool narcissistic(int value) {
      // ... solution  code ...
    }
    

    I generally prefer not to modify code outside of the solution function's scope when doing coding challenges (which is pretty standard practice on these types of platforms), but leaving this comment here for future reference in case anybody else encounters this for the Kata (and presumably in others). Therefore, be advised that the Kata does not use something like <bits/stdc++.h> in the test runner, but rather requires explicit #includes for specific dependencies.

  • MouseGray Avatar

    This comment has been hidden.

  • darkseid93 Avatar

    This comment has been hidden.

  • Jowex Avatar

    This comment has been hidden.

  • shvedoff98 Avatar

    I've solved it, but c++ compiler on my pc doesn't report any problems and i passed all tests successfully. However, when i upload my code into the website, i don't pass final 2 tests..Why?? (i rebuilt my code so that it had 1 function called narcissistic(int x))

  • hottabych04 Avatar

    Guys. I wrote and came up with a solution in 20 minutes. I accidentally closed the code and I can't remember the solution for the second day (((((((

  • darkwolf86 Avatar

    This comment has been hidden.

  • akar-0 Avatar

    This comment has been hidden.

  • d1x3 Avatar

    This comment has been hidden.

  • leonpoh Avatar

    This comment has been hidden.

  • skinny_gorgeous Avatar

    This comment has been hidden.

  • araujobarros Avatar

    Notem que a potência é fixa (número de dígitos), não me atentei a isso e criei um loop desnecessário dentro de outro para fazer para todas as potências. fazendo com que o tempo excedesse.

  • kyle-platt Avatar

    This comment has been hidden.

  • ThutaZaw Avatar

    I write with JS. I can loop and test for math all work in editor but not here; and i also confuse the question, am i only need to output TRUE or FALSE ? OR what. plz help me explain this :<

  • mateuszmacheta Avatar

    It is stated in description "Error checking for text strings or other invalid inputs is not required, only valid positive non-zero integers will be passed into the function." However I'm getting 0 in random tests for C#.

  • mrtgrf Avatar

    This comment has been hidden.

  • ydgohil05 Avatar

    This comment has been hidden.

  • greg.dorian Avatar

    This comment has been hidden.

  • LyranGod Avatar

    That was the hardest kata I have solved to date. Unbelievably challenging. I loved it.

  • Ghost_Hash Avatar

    this its very close, to take a few more minutes for solve, thanks!

  • acstash Avatar

    When you think you have done a good job figuring it out for 30m then you submit the kata and see the 1 line of code guy.

    feelsbadman t.t

  • tanvir316 Avatar

    HELP ME WITH THIS ERROR PLEASE!!!

    main.cpp:64:5: error: conflicting types for 'main' int main(int, const char *[]) { ^ main.cpp:12:5: note: previous definition is here int main() ^ 1 error generated.

    MY CODE WORKS FINE ON MY EDITOR .BUT DOESNT GET ACCEPTED WHEN TRYING TO TEST IT HERE.WHAT TO DO?

  • SamirPS Avatar

    371 it's not a narcis no? because 3^1+7^1+1^1=10

  • SoggyCuticle Avatar

    Hmm. For c# I finished but am getting an arithmetic overflow exception. Not totally sure since I'm just a beginner.

  • InStyle Avatar

    This comment has been hidden.

  • Satoshi4 Avatar

    This comment has been hidden.

  • Horhi Avatar

    Only quantum computers can do that or i'm so stupid

  • Chrono79 Avatar

    C++ "randomized_test_2" generates numbers with leading zeroes from time to time, is that right?

  • gabejm.hines@gmail.com Avatar

    What number is being tested inside of the "randomized_test_2" ? I am failing that edge case.

  • deepakv Avatar

    Hi Guys, I'm trying the run the solution but getting this error - The name 'Math' does not exist in the current context? How could I add the required namespace in the CodeWars IDE? Thanks

  • Kampfkartoffel02 Avatar

    This comment has been hidden.

  • Unnamed Avatar

    It's not specified if 0 is a valid input. If it is, there should be tests with it.

  • zhuk.cs Avatar

    2^3+3^3+7^3 = 378 but 378 isn't Narcissistic number. Why? explain pls

  • souvikdas54 Avatar

    Did not realise we have to include the header files in the editor. Also can anyone tell me why #include<bits/stdc++.h> is not working in this platform? For this reason it was showing invalid identifier when I used pow function.

  • dozatop Avatar

    This comment has been hidden.

  • h4r01d Avatar

    This comment has been hidden.

  • Ramages Avatar

    In c++ if you solve the problem using a vector, you have to clear the vector on every test run

  • xavierguihot Avatar

    Scala translation available for review.

  • SteveRedka Avatar

    Message in third test case for Ruby is wrong:

      it "should find these numbers are NOT narcissistic" do
        Test.assert_equals(narcissistic?( 1633 ), false, "153 is narcissistic")
        # Correct:
        # Test.assert_equals(narcissistic?( 1633 ), false, "1633 is not narcissistic")
      end
    
  • Fire914 Avatar

    I feel I'm missing something here. 371 is suppose to return true but: 371 3^1 + 7^1 + 1^1 3 + 7 + 1

    I get 11...

  • IFcoltransG Avatar

    Starter function definition code in Python uses "// Code away" as a comment, but that will give a syntax error if left there. Python comments are "#Code away".

  • Ywacch Avatar

    This comment has been hidden.

  • richard.gaugler Avatar

    This comment has been hidden.

  • brianascraig@gmail.com Avatar

    My code works and passes tests in other editors, but not here. Please see the repl.it link in my code.

  • Aerros Avatar

    On the c# version of this kata, I would highly recommend making a minor edit of the argument variable from "value" to "n", "number", or even "val". Value is a built in property in C# (which exists for pretty much any non-enumerable objects), so in general it's not great practice to use that as a variable name due to potential conflicts. In the case of this kata, it does not create conflicts, but this might give newer programmers that don't know any better misleading ideas for variable naming. This is not an urgent fix by any means, but it's definitely a quick and easy one to change if you get the chance to.

    Edit: I'm referring not to the test case, but rather the default code structure shown in the "solution" window.

    I also noticed in the test case that your numbers are not entirely random. You have a fixed array of integers and randomly select from that list. Instead, I would recommend using rnd.Next(1, x) (x being the max number you want to test) so that it's actually random. In order to generate the entire random test case, you can use linq to populate the container with the following:

    using System.Linq; using System.Collections.Generic;

    private static int[] nNums = new int[50];

    [Test, Description("Random Tests")] private void RandomTests() { Random rnd = new Random(); var randomNums = nNums.Select(x => rnd.Next(1, 999999)); foreach(var n in randomNums) { Assert.AreEqual(n, Kata.Narcissistic(n)); } }

    You can use any maximum number or number of tests (in this case I used a max of '999999' and 50 total tests). I also used a similar structure and variable names to make it a bit easier to potentially make the changes. This just ensures the tests themselves are actually random and not just selecting randomly from an array of fixed numbers.

  • uniapi Avatar
  • uniapi Avatar

    Please, C Translation

  • rupali317 Avatar

    can negative numbers be considered as narcissists? How do we calculate -153?

    • (1^3 + 5^3 + 3^3)? Is this how it is considered?
  • agusGuevara Avatar

    Should change Kata instrunctions, since you have to return a boolean, instead of a number. This is preventing me from completing the kata.

  • emgordon154 Avatar

    The JavaScript sample test cases are overly lenient; they allow the function to return any truthy value.

  • DougLefelhocz Avatar

    According to Wikipedia, the sequence of increasing narcissistic numbers varies by the base used. In base two, the only narcissistic numbers are zero and 1. As another example, in base ten "six" is a narcissistic number, but in base five, "six" is not a narcissistic number. I didn't see a base specified in the posing of this question. Consequently, I find the question ill-posed.

  • mouloud Avatar

    Hi, I published a C++ translation for this Kata.