When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40...
Search Results
Searching for: conditionals
Individual Exercises
You and your date are trying to get a table at a restaurant. The parameter you
is the stylishness of your clothes, in the range 0..10,...
You have a green lottery ticket, with int
s a
, b
, and c
on it. If the numbers are all different from each other, the result is 0. If all...
Given a string, consider the prefix string made of the first N chars of the string. Does that prefix string appear somewhere else in the...
Returns true if for every '*' (star) in the string, if there are chars both immediately before and after the star, they are the same.
Given two strings, base
and remove
, return a version of the base
string where all instances of the remove
string have been removed (not...
Given a string, return true if the number of appearances of "is" anywhere in the string is equal to the number of appearances of "not"...
We'll say that a "triple" in a string is a char appearing three times in a row. Return the number of triples in the given string. The...
We'll say that a lowercase 'g' in a string is "happy" if there is another 'g' immediately to its left or right. Return true if all the...
Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are the same.
Given a string, look for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or...
Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more...
Given a string, return a string where every appearance of the lowercase word "is" has been replaced with "is not". The word "is" should...
Given two integers, return true if the first number is evenly divisible by the second, and false otherwise. Return false if the second...
Given three double
values representing prices, return the smallest price. For example, if the values passed in are 19.95, 12.85, and...
Given a day number (1-7), return the day of the week ("Sunday", "Monday", etc.). If an invalid day number is provided, return "Invalid".
...Given an integer num
, return the sum of the multiples of num
between 1 and 100. For example, if num
is 20, the returned value should be...
Given a String str
and a character ch
, return the number of times ch
appears in str
. For example, if str
is "Hello" and ch
is 'l', the...
Given an array of integers, return the average of all values in the array as a double
. For example, if an array containing the values...
Given an array of integers and an integer target
, return a count of the number of times the target
value occurs in the array.
Given an array of integers, return the largest value that occurs in the array. You may want to use the constant Integer.MIN_VALUE
, which...
Given an array of integers, return the smallest value that occurs in the array. You may want to use the constant Integer.MAX_VALUE
, which...
Given an array of double
values that contains the prices of merchandise, return the range of the prices (the difference between the...
Given two strings of equal length, return an array of char
values that contains the characters of the strings in alternating order. For...
A magic date is one when written in the following format, the month times the date equals the year e.g. 6/10/60. Write code that figures...