Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. * Create a function (or write a script in Shell) that takes an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers.
  2.  
  3. myFunction(25) => "odd"
  4. myFunction(12) => "even"
  5. myFunction(20) => "even"
  6. myFunction('string') => error || "not a number"
  7.  
  8. ------
  9. * Complete the solution so that it reverses all of the words within the string passed in.
  10.  
  11. solution("The greatest victory is that which requires no battle") => "battle no requires which that is victory greatest The"
  12. solution("Hello there my friend") => "friend my there Hello"
  13. solution("Swing that thing for me, mamma") => "mamma me, for thing that Swing"
  14.  
  15. -------------
  16. * Your task is simply to count the total number of lowercase letters in a string.
  17. lowercaseCountCheck("abc") == 3
  18. lowercaseCountCheck("abcABC123") == 3
  19. lowercaseCountCheck("abcABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"") == 3
  20. lowercaseCountCheck("") == 0
  21. lowercaseCountCheck("ABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"") == 0
  22. lowercaseCountCheck("abcdefghijklmnopqrstuvwxyz") == 26
  23.  
  24. ------------------------
  25.  
  26. Consider an array of sheep where some sheep may be missing from their place.
  27. We need a function that counts the number of sheep present in the array (true means present).
  28.  
  29. [true, true, true, false,
  30. true, true, true, true ,
  31. true, false, true, false,
  32. true, false, false, true ,
  33. true, true, true, true ,
  34. false, false, true, true]
  35.  
  36. The correct answer would be 17.
  37.  
  38. ---------------------------------
  39.  
  40. Given an array of integers.
  41. Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers.
  42. If the input array is empty or null, return an empty array.
  43. Example
  44.  
  45. For input [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15], you should return [10, -65].
  46.  
  47. -------------------------------
  48. Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives.
  49.  
  50. invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5]
  51. invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5]
  52. invert([]) == []
  53.  
  54. -------------------------------------
  55. Who remembers back to their time in the schoolyard, when girls would take a flower and tear its petals, saying each of the following phrases each time a petal was torn:
  56.  
  57. * I love you
  58. * a little
  59. * a lot
  60. * passionately
  61. * madly
  62. * not at all
  63.  
  64. When the last petal was torn there were cries of excitement, dreams, surging thoughts and emotions.
  65. Your goal in this kata is to determine which phrase the girls would say for a flower of a given number of petals, where nb_petals > 0
  66. ----------------------
  67. Write a simple regex to validate a username. Allowed characters are:
  68.  
  69. lowercase letters,
  70. numbers,
  71. underscore
  72. two or more special characters (*, /, $, %, &, @, !, , , +, -)
  73.  
  74. Length should be between 4 and 16 characters (both included).
  75. -------------------------
  76. Write function bmi that calculates body mass index (bmi = weight / height ^ 2).
  77.  
  78. if bmi <= 18.5 return "Underweight"
  79. if bmi <= 25.0 return "Normal"
  80. if bmi <= 30.0 return "Overweight"
  81. if bmi > 30 return "Obese"
  82.  
  83. ----------------------
  84. Wolves have been reintroduced to Great Britain. You are a sheep farmer, and are now plagued by wolves which pretend to be sheep. Fortunately, you are good at spotting them.
  85. Warn the sheep in front of the wolf that it is about to be eaten. Remember that you are standing at the front of the queue which is at the end of the array:
  86.  
  87. [sheep, sheep, sheep, sheep, sheep, wolf, sheep, sheep]
  88. (YOU ARE HERE AT THE FRONT OF THE QUEUE)
  89. 7 6 5 4 3 2 1
  90.  
  91. If the wolf is the closest animal to you, return "Pls go away and stop eating my sheep". Otherwise, return "Oi! Sheep number N! You are about to be eaten by a wolf!" where N is the sheep's position in the queue.
  92. Note: there will always be exactly one wolf in the array.
  93.  
  94. warnTheSheep(["sheep", "sheep", "sheep", "wolf", "sheep"]) === "Oi! Sheep number 1! You are about to be eaten by a wolf!"
  95.  
  96. warnTheSheep(["sheep", "sheep", "wolf"]) === "Pls go away and stop eating my sheep"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement