Ad
  • Custom User Avatar

    I did not know you could load packages. I'd suggest arranging the data by innauguration date just as precaution. I like the use of map_chr(). Check my solution; I used only base-R.

  • Custom User Avatar

    not for very large numbers

  • Custom User Avatar

    A couple of things...

    1. If someone needs to include the data frame in their solution, it should be included in the solution setup. The Details page says,

    The following data.frame of US presidents from Kennedy through Trump is preloaded for you and is used in the testing.
    but I received errors when testing my solution until I included the data frame myself.

    1. In R it is almost never to return NULL. If you want the coder to reutrn "nothing", far better is character(0) so the return type is consistent for all cases. But, R has something very few other languages have, the ability to represent "unknown" values with NA. Either of these would be more appropriate for the language than NULL. In this, specific, context, I think NA would be most appropriate for any date after April 30, 1789 since there is a US President for all of those dates (presumably into the future as well) even if we don't know who it is, and character(0) for any dates before that since there was no US President before that date.

    2. As far as the problem goes,

    or is more than 8 years after the last inauguration

    should be,

    or is more than 8 4 years after the last inauguration

    Since US Presidents are elected for 4 year terms.

  • Default User Avatar

    Don't worry about it, and thank you.

  • Default User Avatar

    Please accept my sincerest apologies, I didn't mean to spoil the kata. Take care.

  • Default User Avatar

    Hi, please use the spoiler tag when posting code, otherwise everyone can see it.

  • Default User Avatar

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

  • Default User Avatar

    The presidents data frame seems to be broken. As is, I get an error, $ operator is invalid for atomic vectors, when attempting to access a column of presidents, but if I copy/paste the data frame definition from the instructions to the sample tests area, everything runs fine.

  • Custom User Avatar

    Wiki - Creating your first kata

    Also, read how othjer people did it. When you solve a kata, you can look at the tests. If you fork a solution, you can look at Preloaded ( where applicable ).

    Try to learn from others' mistakes - life's too short. Read comments on existing kata as well.

  • Custom User Avatar

    Figured out how to delete the JS version.

  • Custom User Avatar

    It's in R, not JS. Are you wanting to translate this?

  • Custom User Avatar

    I've been googling to figure out how to do a random test. Do you have a reference?

  • Custom User Avatar

    There's a broken JavaScript version.

  • Custom User Avatar

    No random tests.