#challenge
💻 Array of Multiples | #easy
Create a function that takes two numbers as arguments (
Examples:
🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
#interview
💻 Array of Multiples | #easy
Create a function that takes two numbers as arguments (
num
, length
) and returns an array of multiples of num
until the array length reaches length
.Examples:
ArrayOfMultiples(7, 5) ➞ [7, 14, 21, 28, 35]For your convenience: dotnetfiddle.
ArrayOfMultiples(12, 10) ➞ [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]
ArrayOfMultiples(17, 6) ➞ [17, 34, 51, 68, 85, 102]
🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
#interview
✨ Here is a solution for the #challenge above
💬 Personally, I like the first solution more, it is much more expressive!
💬 Personally, I like the first solution more, it is much more expressive!
#challenge
💻 Check if a Number is Prime | #easy
Create a function that returns
The first ten prime numbers are:
🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
#interview
💻 Check if a Number is Prime | #easy
Create a function that returns
true
if a number is prime, and false
otherwise. A prime number is any positive integer that is evenly divisible by only two divisors: 1 and itself.The first ten prime numbers are:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29
Examples:isPrime(31) ➞ trueFor your convenience: dotnetfiddle.
isPrime(18) ➞ false
isPrime(11) ➞ true
🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
#interview
#challenge
💻 Capitalize the First Letter of Each Word | #easy
Create a function that takes a string as an argument and converts the first character of each word to uppercase. Return the newly formatted string.
Examples:
🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
#interview
💻 Capitalize the First Letter of Each Word | #easy
Create a function that takes a string as an argument and converts the first character of each word to uppercase. Return the newly formatted string.
Examples:
MakeTitle("This is a title") ➞ "This Is A Title"For your convenience: dotnetfiddle.
MakeTitle("capitalize every word") ➞ "Capitalize Every Word"
MakeTitle("I Like Pizza") ➞ "I Like Pizza"
MakeTitle("PIZZA PIZZA PIZZA") ➞ "PIZZA PIZZA PIZZA"
🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
#interview
#challenge
💻 Perfect Number | #easy
Create a function that tests whether or not an integer is a perfect number. A perfect number is a number that can be written as the sum of its factors, (equal to sum of its proper divisors) excluding the number itself.
For example, 6 is a perfect number, since 1 + 2 + 3 = 6, where 1, 2, and 3 are all factors of 6. Similarly, 28 is a perfect number, since 1 + 2 + 4 + 7 + 14 = 28.
Examples:
#interview
💻 Perfect Number | #easy
Create a function that tests whether or not an integer is a perfect number. A perfect number is a number that can be written as the sum of its factors, (equal to sum of its proper divisors) excluding the number itself.
For example, 6 is a perfect number, since 1 + 2 + 3 = 6, where 1, 2, and 3 are all factors of 6. Similarly, 28 is a perfect number, since 1 + 2 + 4 + 7 + 14 = 28.
Examples:
CheckPerfect(6) ➞ true🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
CheckPerfect(28) ➞ true
CheckPerfect(496) ➞ true
CheckPerfect(12) ➞ false
CheckPerfect(97) ➞ false
#interview
#challenge
💻 Is the Input Factorial of an Integer? | #easy
Create a function that checks if a given integer is exactly the factorial of an integer or not. true if it is, false otherwise.
Examples:
#interview
💻 Is the Input Factorial of an Integer? | #easy
Create a function that checks if a given integer is exactly the factorial of an integer or not. true if it is, false otherwise.
Examples:
isFactorial(2) ➞ true🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
// 2 = 2 * 1 = 2!
isFactorial(27) ➞ false
isFactorial(24) ➞ true
// 24 = 4 * 3 * 2 * 1 = 4!
#interview
#challenge
💻 Largest Gap | #easy
Given an array of integers, return the largest gap between elements of the sorted version of that array.
Here's an illustrative example. Consider the array:
9, 4, 26, 26, 0, 0, 5, 20, 6, 25, 5
... which, after sorting, becomes the array:
0, 0, 4, 5, 5, 6, 9, 20, 25, 26, 26
... so that we now see that the largest gap in the array is the gap of 11 between 9 and 20.
Examples:
#interview
💻 Largest Gap | #easy
Given an array of integers, return the largest gap between elements of the sorted version of that array.
Here's an illustrative example. Consider the array:
9, 4, 26, 26, 0, 0, 5, 20, 6, 25, 5
... which, after sorting, becomes the array:
0, 0, 4, 5, 5, 6, 9, 20, 25, 26, 26
... so that we now see that the largest gap in the array is the gap of 11 between 9 and 20.
Examples:
LargestGap(new int[] { 9, 4, 26, 26, 0, 0, 5, 20, 6, 25, 5 }) ➞ 11🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
// After sorting get { 0, 0, 4, 5, 5, 6, 9, 20, 25, 26, 26 }
// Largest gap of 11 between 9 and 20
LargestGap(new int[] { 14, 13, 7, 1, 4, 12, 3, 7, 7, 12, 11, 5, 7 }) ➞ 4
// After sorting get { 1, 3, 4, 5, 7, 7, 7, 7, 11, 12, 12, 13, 14 }
// Largest gap of 4 between 7 and 11
#interview
✨ Here is a solution for the #challenge above
💬 At first blush, it seems tricky but, in my opinion, this solution is really graceful
💬 At first blush, it seems tricky but, in my opinion, this solution is really graceful
#challenge
💻 Compounding Letters | #easy
Create a function that takes a string and returns a new string with each new character accumulating by +1. Separate each set with a dash.
Capitalize the first letter of each set.
Examples:
#interview
💻 Compounding Letters | #easy
Create a function that takes a string and returns a new string with each new character accumulating by +1. Separate each set with a dash.
Capitalize the first letter of each set.
Examples:
Accum("abcd") ➞ "A-Bb-Ccc-Dddd"🏆 Leave your solutions in the comments. The solution will be posted below in a couple of hours 👇
Accum("RqaEzty") ➞ "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
Accum("cwAt") ➞ "C-Ww-Aaa-Tttt"
#interview