Ad
  • Default User Avatar

    linlux's calculation, i.e.
    "interestsPerDay = 100 * 0,0098 / 360 = 0,00272222222222222222222222222222"
    is not correct because interest per day is not a constant.

  • Custom User Avatar

    There is a bit of that isnt there :-)....reminds me of life at work. I've updated the description a little to hopefully make it easier to understand.

    Hope you enjoyed it!

  • Default User Avatar

    So by banks logic "in a year" means in 360 days...and it means that 6 more days are coming to finish a calendar year.

  • Default User Avatar

    After a year: 100 -> 100,98 (100 * 1,0098 or 100 + 100 * 0,98 / 100 )

    so until that you compound annually

    361 / 100,9827489 362 / 100,9854978...

    and then daily...

    Try to compound always the same way.

  • Default User Avatar

    Yes, kind of inconsistency... but when a language has arrays easy to test the examples and the tests are [["M: 37", "B: 5", "C: 4"], ["M: 100", "B: 14", "C: 11"]] and when a language has arrays not so easy to test (Java in particular) the result is tested as an entire string mimicking an array so without strings inside a string...
    Hope it is clear enough. Anyway for a given language it is always better to look at the examples. Thanks for your post, cheers!

  • Default User Avatar

    Thanks.
    I'm glad you enjoyed it! :-)

    Have a good time on CodeWars!

  • Default User Avatar

    @linlux

    I still have my old code for the bitmap reading.
    If you're interested, I could provide you with it.

    But doing trying to do that on your own first, should be better.

  • Default User Avatar

    @linlux:

    I did not solve it the same way.
    But it's not hard to come to this solution when you understand binary and are familiar with shifting / logical operations.
    It's not something you see often in Java but more in something like C or C++.
    If you want to come up with solutions like that, you should try projects like reading an RLE encoded bitmap and manipulate it in C.

    You can start with https://msdn.microsoft.com/en-us/library/windows/desktop/dd183392(v=vs.85).aspx

    If you have any questions, feel free to contact me.
    When I did something like that, it had support for 8 bit and 24 bit Bitmaps and RLE8 encoded only.
    The reading and saving are about 300 - 350 lines of code.

    Things you should utilize in a project like that:

    You could start with something simple like calculating how often each color occurs.

    If that project would be too big for you, you could also go for short bit manipulating methods.
    Like writing a method that is doing a Circular Shift https://en.wikipedia.org/wiki/Circular_shift

    Or write something that is doing a Circular Shift on 2 bits that run in opposite directions like this:
    100000001
    010000010
    001000100
    000101000
    000010000
    000101000
    001000100
    010000010
    100000001
    100000001
    010000010
    ...
    // ignore that i accidentally used 9 bits ...
    Print an ascii character at the position where the 1's are and enjoy how they are moving around.

  • Default User Avatar

    TIL: you can't reply to a reply on codewars ..

    @linlux:

    The bits get shifted to the left.
    take for example the binary number: 1000 (8)
    In the first iteration, you get:    0001
    
    The loop runs as many times as
    there are digits.
    Take away the first iteration cause
    there is nothing shifted
    And you end up with 3 more shifts:  1000
    Every digit that is added at the
    right most position is shifted by
    the remaining amount of loop iterations
    
  • Custom User Avatar

    Alright, suppose the list of bits is [1, 1, 0, 1, 0, 1] and you start with int number = 0.

    Here's every operation:

    0 << 1 ⟶ 0

    0 | 1 ⟶ 1

    1 << 1 ⟶ 10

    10 | 1 ⟶ 11

    11 << 1 ⟶ 110

    110 | 0 ⟶ 110

    110 << 1 ⟶ 1100

    1100 | 1 ⟶ 1101

    1101 << 1 ⟶ 11010

    11010 | 0 ⟶ 11010

    11010 << 1 ⟶ 110100

    110100 | 1 ⟶ 110101

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    You're right. As every card only appears once, there is no necessity to blank sorted cards.