7 kyu

Katastrophe!

1,479 of 3,510jackcarlisle
Description
Loading description...
Mathematics
Fundamentals
  • Please sign in or sign up to leave a comment.
  • o2001 Avatar

    Based on the author's solution, there seems to be an implicit assumption that whatever the size of the outer array, is also the size of each of the inner arrays. If this is the case, it needs to be explictized (and will probably invalidate some answers). All the current tests hardcode a length of 3, and the random tests of the Python translation hardcode the inner array size as 3. The description should be cleaned up to sort this out, as it makes adapting this Kata awkward into languages that support tuples or compile-time sized arrays because each person who adapts this Kata seems to make a different set of assumptions.

  • tobeannouncd Avatar

    Haskell fork

    • Added random tests
  • anter69 Avatar

    Ruby should be updated to v3 (new test framework) + needs random tests

  • Just4FunCoder Avatar

    Python fork

    • Fixed test framework setup
    • Added assertion message & random test in actual test

    Actually a complete rework of the actual test, please review carefully :)

  • kaluginpeter Avatar

    Excellent kata, became 1111 my solved kata. I had to think about it, but it was fun.

  • Ciprian Amza Avatar

    This one was fun!

  • Voile Avatar

    Some languages do not have random tests.

  • hksong Avatar

    A building will fall if the magnitude of the earthquake is greater than the strength of the building.

    The most popular solution tests for greater than or equal to instead of greater than.

    You should either update the description or invalidate older solutions by adding a test case that has the magnitude equal to the strength of the building.

  • esteban-ellicker Avatar

    Javascript version of Kata should include more test cases, better if are random

  • danielsnewman Avatar

    I think there may be an issue with one of these test cases: strongEnough([[ 5, 1, 7 ], [ 1, 1, 1 ], [ 4, 1, 2 ] ], 100).

    [ 5 + 1 + 7 ],* [ 1 + 1 + 1 ] * [ 4 + 1 + 2 ] returns 273

    Building Age is 100 and 1000 - 1% one hundred times returns 0.

    0 is less than 273, which would require "Needs Reinforcements!" but it is expecting "Safe!".

  • Raphango Avatar

    Python 3 please? Congrats for the Kata BTW!

  • dragzaras Avatar

    This comment has been hidden.

  • donaldsebleung Avatar

    Javascript version of Kata should ideally include random test cases; keep that in mind when authoring future Kata :)

  • Adamparishspok Avatar

    This comment has been hidden.

  • 1UnitedPower Avatar

    This comment has been hidden.

  • debarnache Avatar

    Hi,

    My script works fine on IDLE but when I run it using the "Submit" button it will give an error and won't accept my solution.

    Despite the fact that the "Output" window shows the correct answer ("Safe!" or "Needs Reinforcement!"), it says "None should equal 'Safe!'"

    This is my first try and I'm stuck. Am I doing anything wrong?

    Should I post my code here?

    Thanks in advance

    EDIT: I just noticed I was printing instead of returning!

  • mmilosh Avatar

    This comment has been hidden.

  • Insti Avatar

    This kata is more difficult than 7kyu

  • syllie Avatar

    I really liked this one! I had to look up how exponential decay works and I see a lot of different implementations here. Gonna read up a bit more :) Thanks for a practical approach with a good story line.

  • pioraid Avatar

    I published a CoffeeScript translation.

    What's supposed to happen if the strength of the earthquake equals the strength of the building? I'd assume that it means it needs reinforcement.

  • jbarget Avatar

    Really good kata! Taught me a lot

  • O-kasso Avatar

    Fantastic little story to illustrate a real-world example that succesfully masks what'd otherwise be a dry excercise in implementing simple maths.

    As another commenter pointed out, I'm a little disappointed that Codewars is accepting the less accurate implementation w/ simple percentages instead of the proper exponential equation, but I assume that's at no fault of the author and a limitation of either the website or maybe Ruby itself.

  • dargaCode Avatar

    This comment has been hidden.

  • stoex Avatar

    This comment has been hidden.

  • stely Avatar

    This comment has been hidden.

  • kirilloid Avatar

    I've ported this kata to Haskell. Also * symbols in your arithmetic expression are parsed as italics markers, hence I escaped them with backticks.

  • jolaf Avatar

    This comment has been hidden.

  • ZozoFouchtra Avatar

    Python translation kumited.

    (Tests shuffled) more info on how to approve it ( or not )

  • computerguy103 Avatar

    "Exponential decay" is when a value decreases by a fixed percentage per time interval. I'd suggest using that phrase to explain how the strength of the building decreases, and include a link to https://en.wikipedia.org/wiki/Exponential_decay.

  • suic Avatar

    Hi, I'm not sure if test case no. 4 is correct:

    { 'earthquake': [ [ 5, 1, 7 ], [ 1, 1, 1 ], [ 4, 1, 2 ] ], 'age': 100 }

    Expected: Safe!, instead got: Needs Reinforcement!

    But if

    A building begins with a strength value of 1000, but this value decreases by 1% after every subsequent year it's been built.

    then strength of that building should be 0.

    Thanks,

    suic