6 kyu

Financing Plan on Planet XY140Z-n

869 of 4,888g964
Description
Loading description...
Mathematics
Algorithms
  • Please sign in or sign up to leave a comment.
  • ejini战神 Avatar

    JS Node 18. should be enabled

  • 3au4onok Avatar

    Terrible description, after spending 20 minutes, I still didn’t understand what the author meant. What should happen in week 7? Zero? Again? It seems like it’s customary to use international units on the site, but the author starts the week on Sunday... Another Kata “Copy the formula from the Internet”

  • saudiGuy Avatar
  • NiXeon Avatar

    This comment has been hidden.

  • ejini战神 Avatar

    C#: method name should be PascalCase (Please refer to implementation of backward compatibility here )

  • vmbot Avatar

    Can someone explain how was the 1 liner solution formula calculated? I submitted my looped solution & I'm still not understanding the takeaway message here.

  • Allwaysjun93 Avatar

    I've decided this task correctly. I see correct answer in compiler. But when i'm trying to test it here it shows me error "n := 365" Expected: "24513765" But was: "140732687806485" but in compiler i see correct answer. Why its happening. Help pls

  • akar-0 Avatar
  • akar-0 Avatar
  • martynov-94 Avatar

    Another "find the right formula"? What does it have to do with programming?

  • Leqso Avatar

    Hello, you have an error in tests! to correct the error, it is necessary to perform n + 1 (examples do not match the description of the pattern). Or the conditions of Kata are not clear enough!

  • adezxc Avatar

    Hello,

    I have solved the Kata using recursion, but for some reason it doesn't pass the test even though it passes the test on Go playground and local development, could you check if it works properly?

  • yo1993 Avatar

    Sorry, I think I am a little confused. Why is there so many blanks in this table? I feel like it doesn't make sense. What happens to all the money from the previous week? I am thinking, like if n == 3, you end the week with 3, but you don't start the next week with 3 but looking at w0 to w1 We ends with 3, but Su should start with 3 but going by the chart I start with 1. This is why I am a little lost on how the solutions came up with their solutions. Thank you

  • rge123 Avatar

    This comment has been hidden.

  • rge123 Avatar

    julia:

    ERROR: LoadError: LoadError: UndefVarError: Finance not defined
    Stacktrace:
     [1] include at ./boot.jl:317 [inlined]
     [2] include_relative(::Module, ::String) at ./loading.jl:1044
     [3] include(::Module, ::String) at ./sysimg.jl:29
     [4] include(::String) at ./client.jl:392
     [5] top-level scope at none:0
     [6] include at ./boot.jl:317 [inlined]
     [7] include_relative(::Module, ::String) at ./loading.jl:1044
     [8] include(::Module, ::String) at ./sysimg.jl:29
     [9] exec_options(::Base.JLOptions) at ./client.jl:266
     [10] _start() at ./client.jl:425
    in expression starting at /workspace/fixture.jl:2
    in expression starting at /workspace/runtests.jl:3
    
  • Ilirjan Avatar

    Very nice kata!

  • FArekkusu Avatar

    TypeScript 3.3 fails because types are not specified for variables in the fixture.

  • FArekkusu Avatar

    There're no performance requirements in C, JavaScript, CoffeeScript, C++, C#, Go, Java, TypeScript (at least) at all.

  • FArekkusu Avatar

    Please, remove O(n^2) reference solution in Python and Ruby (at least). If you want to test the time complexity, increase the input range, but don't waste 85-90% of the allowed time to "take it away" from the user.

  • NicholasRoy96 Avatar

    This comment has been hidden.

  • krishp Avatar

    I can't even submit any solution. No matter what I do, it times out. Even when I told it to just return n, it still timed out. Is anyone experiencing this problem?

  • krogKrog Avatar

    With R: I tried it with a single for loop, stored all the series of numbers in a list, then summed at the end. This always timed out. But then I realized, I did not need to save anything as I went, so instead used an integer and added to it as the loops went through. Using an integer to store the sum instead of a list got it down to 2200 ms.

    I agree with everyone else, the description is not very clear.

  • engiwengi Avatar

    This comment has been hidden.

  • zaibacu Avatar

    Read the description N times, still couldn't get it. Looked at example, remembered doing something related at school. Blindly implemented mathematical solution and solved the problem.

    Programming is != Mathematics, lecturers and teachers usually fails to understand this, it looks like similar problems are coming up to the surface in Codewars as well.

  • christophermilne Avatar

    Ok so after re-reading the description 5 more times, I think what the poster intends to convey is that 'n' is a variable that represents both the number of days and the number of weeks. Therefore the function only takes one argument. So n=99 would indicate saving for a 100 weeks with each week having 100 days...

  • christophermilne Avatar

    I have no idea from reading the description if the function I'm supposed to write accepts the number of weeks or the number of days in the week as the argument. Confusingly, they are both referred to as 'n' in the description, and the example showing how the function is to be used does not say what n is supposed to be.

  • MangoGT Avatar

    Good kata. Try to figure out the pattern and get a formula.

    But if there could be more specifications such as the detailed calculating process of finance(5), this kata will be better!

  • kaftw Avatar

    Does anyone have trouble getting this one to pass the final "Attempt" test? I keep getting SIGKILLs, but it passes the provided test in 1200 ms. I even ran the code locally and it takes at most 600 ms.

  • Riael Avatar

    This is seriously confusing, why do you skip days while starting to save?

    Edit: Also what? The 5 should return 156, which is 168-12 rather than 105.

  • nhatlee Avatar

    This comment has been hidden.

  • smotti Avatar

    Edit:

    Puh quite tough. Found a more efficient way to generate the table with the saving values but still the Attempt always times out. This isn't a challenge for juniors, one needs to know quite a lot about clojure, in order to squeeze every last bit of performance out of it.

    boot.user=> (time (reduce + (map #(reduce + 0 %) (savings 5000))))
    "Elapsed time: 1028.586814 msecs"
    
    boot.user=> (time (reduce + (pmap #(reduce + 0 %) (savings 5000))))
    "Elapsed time: 558.229904 msecs"
    

    Hm when using pmap all tests pass on codewars but it still says it fails due to timeout, though the output says something else:

    Passed: 7 Failed: 0 Errors: 1
    
    Completed in 8928.513241 ms
    
    STDERR:
    Process was terminated. It took longer than 12000ms to complete
    

    Sample test:

    (deftest a-test1
      (testing "test1"
        (is (= (finance 5) 105))))
    (deftest a-test2
      (testing "test2"
        (is (= (finance 6) 168))))
    (deftest a-test3
      (testing "test3"
        (is (= (finance 8) 360))))
    (deftest a-test4
      (testing "test4"
        (is (= (finance 15) 2040))))
    (deftest a-test5
        (testing "test5"
          (is (= (finance 2000) 4006002000))))
    (deftest a-test6
        (testing "test6"
          (is (= (finance 1202) 870495612))))
    (deftest a-test7
        (testing "test7"
          (is (= (finance 7249) 190539058875))))
    

    Always hitting the time limit with Clojure :/. And it looks like codewars doesn't like pmap. Locally in the REPL i can cut the time almost in half by using pmap. While using pmap it actually fails way more often on codewars, than with a normal map Oo.

    boot.user=> (time (apply + (map #(reduce + %) (savings 5000))))
    "Elapsed time: 2543.204782 msecs"
    
    boot.user=> (time (apply + (pmap #(reduce + %) (savings 5000))))
    "Elapsed time: 1417.828051 msecs"
    

    Where savings returns a lazy seq of lists. With each list representing a week and the saving amount for each weekday.

    Note that the performance of apply in the outermost form is the same as with reduce. Though the anonymous reduce fn in the innermost helps to improve performance a lot.

  • user5036852 Avatar

    Once again: Great kata! :-) To do it without nested loops is easier than to do with them. ;-)

  • dojeda Avatar

    This problem is very difficult to understand, I still don't understand what the question is. E.g. ".. after I save 12"... 12 what? days? weeks? units of money? Ah! It's after the saturday where I saved 12 units. Difficult to catch. Then there is a table of days with missing values... is it zero? And finally, what's the point of mentioning the planet? Just to number the weeks?

  • catscarlet Avatar

    Sorry. I didn't catch the question. If It will be 168 while n=6, why it is 105 while n=5? On the W6 it got 12 so why 105? Why not 156?

  • user1546304 Avatar

    I get the following error running my PHP solution: http://imgur.com/a/uMYng

    It appears to be a memory issue or stack overflow, maybe? Granted, I solved it recursively so a "large" number could blow up the whole thing. Messing with the tests, the Codwars runner appears to handle N up to 199.

    Do the submission tests use N = 200 or higher?

  • Vasir Avatar

    This comment has been hidden.

  • bouchert Avatar

    I think you should get rid of the "Su Mo Tu We Th Fr Sa" heading on the table, replacing them with something like Day 1, Day 2, etc. or calling them Zerosday, Onesday, Twosday, Threesday...Nsday, or really anything other than the traditional names for days of the week. It might also be a good idea to show the table for something other than n=6. By continuing to use the familiar 7-day week, it increases the chances of overlooking the instruction about the days being numbered 0 to n, and misunderstanding how the saving plan extends to values of n greater (and perhaps less) than 6.

  • TheXela Avatar

    In C# all the 4 visible tests are passing and it runs fine in Visual Studio too, but when I click "Submit" I get the following error message:

    Compilation succeeded - 1 warning(s)

    {"stdout":"","stderr":"/tmp/csharp116429-21-ibjr83/fixture.cs(8,8): warning CS0414: The private field `FinanceTests.randomGenerator' is assigned but its value is never used\n","wallTime":0} Unknown error

    This seems to be some type of bug that exists in the FinanceTests class that I cannot see. Could you please look into it? Thanks

  • Dimedrollum Avatar

    hey:) the c# implementation sucks... The tests are written for int, and they fail if ulong is used. The tests after submint requre ulong....

  • KervyN Avatar

    Does someone solved it in ruby? I alway run into a timeout (6000ms).

  • jhoffner Avatar

    I'm not really sure how to rank this one. Everyone has voted 7 kyu, because programmatically its not difficult, but its more along the lines of a puzzle and is certainly harder than most 7 kyu in terms of needing to undertand the solution. The author intended for it to be a 5 kyu. I just don't know what to do here. Would love to hear what others think.

  • YiyangLi Avatar

    Please fogive me. I still don't get it, what about week 7, do you save anything on Sunday of W7? How to yield 252?

  • zamcl Avatar

    in haskell the parameter is the number of the days+1