Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * 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.
- myFunction(25) => "odd"
- myFunction(12) => "even"
- myFunction(20) => "even"
- myFunction('string') => error || "not a number"
- ------
- * Complete the solution so that it reverses all of the words within the string passed in.
- solution("The greatest victory is that which requires no battle") => "battle no requires which that is victory greatest The"
- solution("Hello there my friend") => "friend my there Hello"
- solution("Swing that thing for me, mamma") => "mamma me, for thing that Swing"
- -------------
- * Your task is simply to count the total number of lowercase letters in a string.
- lowercaseCountCheck("abc") == 3
- lowercaseCountCheck("abcABC123") == 3
- lowercaseCountCheck("abcABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"") == 3
- lowercaseCountCheck("") == 0
- lowercaseCountCheck("ABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"") == 0
- lowercaseCountCheck("abcdefghijklmnopqrstuvwxyz") == 26
- ------------------------
- Consider an array of sheep where some sheep may be missing from their place.
- We need a function that counts the number of sheep present in the array (true means present).
- [true, true, true, false,
- true, true, true, true ,
- true, false, true, false,
- true, false, false, true ,
- true, true, true, true ,
- false, false, true, true]
- The correct answer would be 17.
- ---------------------------------
- Given an array of integers.
- Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers.
- If the input array is empty or null, return an empty array.
- Example
- For input [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15], you should return [10, -65].
- -------------------------------
- Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives.
- invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5]
- invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5]
- invert([]) == []
- -------------------------------------
- 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:
- * I love you
- * a little
- * a lot
- * passionately
- * madly
- * not at all
- When the last petal was torn there were cries of excitement, dreams, surging thoughts and emotions.
- 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
- ----------------------
- Write a simple regex to validate a username. Allowed characters are:
- lowercase letters,
- numbers,
- underscore
- two or more special characters (*, /, $, %, &, @, !, , , +, -)
- Length should be between 4 and 16 characters (both included).
- -------------------------
- Write function bmi that calculates body mass index (bmi = weight / height ^ 2).
- if bmi <= 18.5 return "Underweight"
- if bmi <= 25.0 return "Normal"
- if bmi <= 30.0 return "Overweight"
- if bmi > 30 return "Obese"
- ----------------------
- 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.
- 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:
- [sheep, sheep, sheep, sheep, sheep, wolf, sheep, sheep]
- (YOU ARE HERE AT THE FRONT OF THE QUEUE)
- 7 6 5 4 3 2 1
- 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.
- Note: there will always be exactly one wolf in the array.
- warnTheSheep(["sheep", "sheep", "sheep", "wolf", "sheep"]) === "Oi! Sheep number 1! You are about to be eaten by a wolf!"
- warnTheSheep(["sheep", "sheep", "wolf"]) === "Pls go away and stop eating my sheep"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement