forked from tjhickey724/OctaveBat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tested functions.txt
260 lines (127 loc) · 48.9 KB
/
tested functions.txt
1
Please include here, in alphabetical order, the names and definitions of the functions you are choosing to implement and test for hw4. Also, include your name.alarm_clock(day,vacation)-Given a day of the week encoded as 0=Sun, 1=Mon, 2=Tue, ...6=Sat, and a boolean indicating if we are on vacation, return a string of the form "7:00" indicating when the alarm clock should ring. Weekdays, the alarm should be "7:00" and on the weekend it should be "10:00". Unless we are on vacation -- then on weekdays it should be "10:00" and weekends it should be "off". -seife kassahunarray_count9-Given an array of ints, return the number of 9's in the array. -Sara Shahanaghiarray_front9(a,b,c,d) - Given an array of 4 ints, return True if one of the 4 elements in the array is 9. - Kai Wuarray11(array,index) - Given an array of ints, compute recursively the number of times that the value 11 appears in the array. -Ritu PradhanbabyPoop(fFart,pFart) -Given two baby farts (fFart and pFart), the function will return ‘Disgusting!’ if both are true, will return ‘Do I have to change it?’ if only pFart is true, will return ‘You just went an hour ago!’ if only fFart is true, or if neither are true, will return ‘Thank goodness’. -Livia BellbackAround - Given a string, take the last char and return a new string with the last char added at the front and back, so "cat" yields "tcatt". The original string will be length 1 or more. Jean-Paul WiegandbigDiff - Given an array length 1 or more of ints, return the difference between the largest and smallest values in the array. Note: the built-in Math.min(v1, v2) and Math.max(v1, v2) methods return the smaller or larger of two values - Ben SetelbiggerTwo - Given 2 arrays, return the array which has the largest sum. In the event of a tie, return the first array. - Gabe Guerrablackjack(a, b) - Given two values a and b greater than zero, return whichever value is nearest to 21 without going over. Return value of a and b if both are the same. Return zero if they both go over. -- Adam Rosenbloomblackjack - Given 2 int values greater than 0, return whichever value is nearest to 21 without going over. Return 0 if they both go over. (Taha Bakhtiyar)blueTicket - You have a blue lottery ticket, with ints a, b, and c on it. This makes three pairs, which we'll call ab, bc, and ac. Consider the sum of the numbers in each pair. If any pair sums to exactly 10, the result is 10. Otherwise if the ab sum is exactly 10 more than either bc or ac sums, the result is 5. Otherwise the result is 0. - Sean KilachandbunnyEars(b) - We have a number of bunnies and each bunny has two big floppy ears. We want to compute the total number of ears across all the bunnies recursively (without loops or multiplication). - Mehreen AsadbunnyEars2 - We have bunnies standing in a line, numbered 1, 2, ... The odd bunnies (1, 3, ..) have the normal 2 ears. The even bunnies (2, 4, ..) we'll say have 3 ears, because they each have a raised foot. Recursively return the number of "ears" in the bunny line 1, 2, ... n (without loops or multiplication). - Antonio CanciocanBalance(a) - Given a non-empty array, return true if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side. Makensley Lordeuscaught_speeding(speed, is_birthday):You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: 0=no ticket, 1=small ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the result is 2. Unless it is your birthday -- on that day, your speed can be 5 higher in all cases. - R. HeimerCaught_speeding-You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: 0=no ticket, 1=small ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the result is 2. Unless it is your birthday -- on that day, your speed can be 5 higher in all cases. -seife kassahuncigarParty(cigars,weekend) - 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 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of cigars. Return true if the party with the given values is successful, or false otherwise. - Ritu PradhancloseFar- Given three ints, a b c, return true if one of b or c is "close" (differing from a by at most 1), while the other is "far", differing from both other values by 2 or more. Note: Math.abs(num) computes the absolute value of a number. -Marcus Kellyclose_far(int a, int b, int c) Given three ints, a b c, return True if one of b or c is "close" (differing from a by at most 1), while the other is "far", differing from both other values by 2 or more. Note: abs(num) computes the absolute value of a number. -Noah Rudermanclose10(a,b) - Given 2 int values, return whichever value is nearest to the value 10, or return 0 in the event of a tie - Tim Hickeycombo_string(a,b) - Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0). ---- Huimin JiacommonTwo(a,b) - Start with two arrays of strings, a and b, each in alphabetical order, possibly with duplicates. Return the count of the number of strings which appear in both arrays. The best "linear" solution makes a single pass over both arrays, taking advantage of the fact that they are in alphabetical order.----- (Tarif Riyad Rahman) count7: Given a non-negative int n, return the count of the occurrences of 7 as a digit, so for example 717 yields 2. (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). - Varenya Prasadcount8 - Given a non-negative int n, compute recursively (no loops) the count of the occurrences of 8 as a digit, except that an 8 with another 8 immediately to its left counts double, so 8818 yields 4. Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). - Brian Slepiancount11(string) Given a string, compute recursively (no loops) the number of "11" substrings in the string. The "11" substrings should not overlap. - Josh Scount_code(string) - Return the number of times that the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count. - Huimin JiacountClumps(nums) - Say that a "clump" in an array is a series of 2 or more adjacent elements of the same value. Return the number of clumps in the given array. - Jeremy “The Man” PattondateFashion - 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, and "date" is the stylishness of your date's clothes. The result getting the table is encoded as an int value with 0=no, 1=maybe, 2=yes. If either of you is very stylish, 8 or more, then the result is 2 (yes). With the exception that if either of you has style of 2 or less, then the result is 0 (no). Otherwise the result is 1 (maybe). - Brian SlepiandelDel(a) - Given a string, if the string "del" appears starting at index 1, return a string where that "del" has been deleted. Otherwise, return the string unchanged. -Gabriel Bronkdiff 21(n) - (Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21. ) - Abhirup DasdividesSelf: We'll say that a positive int divides itself if every digit in the number divides into the number evenly. So for example 128 divides itself since 1, 2, and 8 all divide into 128 evenly. We'll say that 0 does not divide into anything evenly, so no number with a 0 digit divides itself. Note: use % to get the rightmost digit, and / to discard the rightmost digit. -Varenya PrasadevenlySpaced - Given three ints, a b c, one of them is small, one is medium and one is large. Return true if the three values are evenly spaced, so the difference between small and medium is the same as the difference between medium and large. (Taha Bakhtiyar)everyNth(s,N) - Given a non-empty string and an int N, return the string made starting with char 0, and then every Nth char of the string. So if N is 3, use char 0, 3, 6, ... and so on. N is 1 or more - Tim HickeyFactorial (n): Given n of 1 or more, return the factorial of n, which is n * (n-1) * (n-2) ... 1. Compute the result recursively (without loops). --Robin Jhafibonacci: The fibonacci sequence is a famous bit of mathematics, and it happens to have a recursive definition. The first two values in the sequence are 0 and 1 (essentially 2 base cases). Each subsequent value is the sum of the previous two values, so the whole sequence is: 0, 1, 1, 2, 3, 5, 8, 13, 21 and so on. Define a recursive fibonacci(n) method that returns the nth fibonacci number, with n=0 representing the start of the sequence - -Varenya PrasadfirstLast6: Given an array of ints, return true if 6 appears as either the first or last element in the array. The array will be length 1 or more. --Adam RosenbloomfirstLast6(x) Given an array, returns 1 if the first or last value in the array is 6, returns 0 otherwise. - Ian ReichekfrontBack(a) - Given a string, return a new string where the first and last characters have been exchanged. -Gabriel BronkfrontTimes - Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front; frontTimes("Chocolate", 2) → "ChoCho" Nadav Havivifront22 (string) - Given a string, take the first 2 chars and return the string with the 2 chars added at both the front and back, so "kitten" yields"kikittenki". If the string length is less than 2, use whatever chars are there. - Ray Kuncewitchfront3(string) Given a string, we'll say that the front is the first 3 chars of the string. If the string length is less than 3, the front is whatever is there. Return a new string which is 3 copies of the front. (Warmup-1) - Stuart DavisgetIntersection(o, d, s_o, s_r) - A ray casted from an arbitrary origin o and into an arbitrary direction d is checked to see if it intersects with a sphere defined by origin s_o and radius s_r. If so, return the intersection point and the normal at that point. →Victor “The Hebrew Hammer” FrenkelgetSandwich - A sandwich is two pieces of bread with something in between. Return the string that is between the first and last appearance of "bread" in the given string, or return the empty string "" if there are not two pieces of bread. - Sean KilachandgHappy(s) - 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 g's in the given string, s, are happy. -Antonio CanciogreenTicket(int a, int b, int c)-You have a green lottery ticket, with ints a, b, and c on it. If the numbers are all different from each other, the result is 0. If all of the numbers are the same, the result is 20. If two of the numbers are the same, the result is 10.-Joshua LintongreenTicket(a,b,c) You have a green lottery ticket, with ints a, b, and c on it. If the numbers are all different from each other, the result is 0. If all of the numbers are the same, the result is 20. If two of the numbers are the same, the result is 10. - Siddhi KrishnagroupNoAdj(start,nums,target) - Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given target with this additional constraint: If a value in the array is chosen to be in the group, the value immediately following it in the array must not be chosen. (No loops needed.) - Jeremy “von Doom” PattongroupSum(start,nums,target) - Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given target? - Jeremy “The Hacker” PattongroupSum6() Given an array of ints, is it possible to choose a group of some of the ints, beginning at the start index, such that the group sums to the given target? However, with the additional constraint that all 6's must be chosen. (No loops needed.) - Josh ShasTeen(a, b, c) - Given 3 int values, return true if 1 or more of them are in the range 13...19 inclusive. - Gabriel Bronkhas22 - Given an array of ints, return True if the array contains a 2 next to a 2 somewhere - Ben Setelhas23-Given an int array length 2, return true if it contains a 2 or a 3. -Sara ShahanaghihasTeen(a,b,c)- true if one of the values contains 13-19 inclusive-Helen Shapiroicyhot(a,b) - Given two temperatures, return true if one is less than 0 and the other is greater than 100. - Abhirup DasicyHot (x,y) - Given two temperatures, return true if one is less than 0 and the other is greater than 100. - Ray KuncewitchinOrder(a,b,c) Given three ints, a b c, return true if b is greater than a, and c is greater than b. However, with the exception that if "bOk" is true, b does not need to be greater than a. - Siddhi Krishnain3050(a,b) - Given 2 int values, return true if they are both in the range (30,40) inclusive, or they are both in the range (40,50) inclusive. (Iain Crosby)intMax(a,b,c) - Given three int values, A B C, return the largest. (Iain Crosby)isPrime(a) determines if the value a is a prime number or not. If it is prime, it also returns the factors of a - Siddhi KrishnalastDigit(int a, int b)- Given two non-negative int values, return true if they have the same last digit, such as with 27 and 57. (Sara Shahanaghi)lessBy10(int a, int b, int c)-Given three ints, a b c, return true if one of them is 10 or more less than one of the others.loneSum - Given 3 int values, a b c, return their sum. However, if one of the values is the same as another of the values, it does not count towards the sum. -- Adam Rosenbloomlone_sum(int a, int b, int c) Given 3 int values, a b c, return their sum. However, if one of the values is the same as another of the values, it does not count towards the sum. -Noah RudermanloneTeen(n) - We'll say that a number is "teen" if it is in the range 13..19 inclusive. Given 2 int values, return true if one or the other is teen, but not both. - Liz LiLove6(a,b) - The number 6 is a truly great number. Given two int values, a and b, return true if either one is 6. Or if their sum or difference is 6.- Mehreen AsadluckySum- Given 3 int values, a b c, return their sum. However, if one of the values is 13 then it does not count towards the sum and values to its right do not count. So for example, if b is 13, then both b and c do not counlucky_sum(int a, int b, int c) Given 3 int values, a b c, return their sum. However, if one of the values is 13 then it does not count towards the sum and values to its right do not count. So for example, if b is 13, then both b and c do not count. -Noah RudermanmakeBrick(goal,small,big) - We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops. Makensley LordeusmakeBricks -We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops. -Marcus KellymakeChocolate - We want make a package of goal kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of small bars to use, assuming we always use big bars before small bars. Return -1 if it can't be done. (Taha Bakhtiyar)make100 - Given 2 numbers, find a third number that will make the sum of the 3 numbers 100. -Yohanes Santosomakes10-Given 2 ints, a and b, return true if one if them is 10 or if their sum is 10. Mike Ladermanmax1020(a,b) - Given 2 positive int values, return the larger value that is in the range 10..20 inclusive, or return 0 if neither is in that range. Mike Ladermanmax_end3(X) - Given an array of ints length 3, figure out which is larger between the first and last elements in the array, and set all the other elements to be that value. Return the changed array. -R. HeimermaxSpan(int[] nums) Consider the leftmost and righmost appearances of some value in an array. We'll say that the "span" is the number of elements between the two inclusive. A single value has a span of 1. Returns the largest span found in the given array. (Efficiency is not a priority.). (Array-3) - Stuart DavismirrorEnds - Given n>=0, create an array length n*n with the following pattern, shown here for n=3 : {0, 0, 1, 0, 2, 1, 3, 2, 1} (spaces added to show the 3 groups) - Ben SetelmissingChar-Given a non-empty string and an int n, return a new string where the char at index n has been removed. The value of n will be a valid index of a char in the original string (i.e. n will be in the range 0..str.length()-1 inclusive). Jean-Paul WiegandmixStart (string) - Return true if the given string begins with "mix", except the 'm' can be anything, so "pix", "9ix" .. all count. - Ray KuncewitchmonkeyTrouble(a,b) - We have two monkeys, a and b, and the parameters aSmile and bSmile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return true if we are in trouble. Mike LadermannearHundred - Given an int n, return true if it is within 10 of 100 or 200. Note: Math.abs(num) computes the absolute value of a number. - Liz LinearOnes(a) - returns true if a is within 10 of 100 or 1000 -Livia Bellneighbor23(a,b) returns value nearest to 23, or if both are equidistant from 23, returns 0 -Livia Bellno_teen_sum(a, b, c) Given 3 int values, a b c, return their sum. However, if any of the values is a teen -- in the range 13..19 inclusive -- then that value counts as 0, except 15 and 16 do not count as a teens. Write a separate helper "def fix_teen(n):"that takes in an int value and returns that value fixed for the teen rule. In this way, you avoid repeating the teen code 3 times (i.e. "decomposition"). Define the helper below and at the same indent level as the main no_teen_sum(). -Nadav HavivinoTriples(Y) Given an array of ints, we'll say that a triple is a value appearing 3 times in a row in the array. Return true if the array does not contain any triples. R. Heimernum_21(a,b,c,d,e,f) - This function allows you to analyse who is the winner of number 21. We input 6 ints ranging from 1 to 13. The former three cards belongs to A, the rest ones belongs to B. - Kai WunyseClosed(d): determines if the New York Stock Exchange was closed on a particular date d. The date must be entered as a date string in the format 'dd-Mmm-yyyy'. For example '05-Mar-2011'. Includes all known and anticipated closes from 1-Jan-1955 to 1-Jan-2050. -- Adam RosenbloomODDtoEven(n) - Given an integer, return odd or even, and convert odd to even - Abhirup Dasparrot_trouble(talking, hour) - We have a loud talking parrot. The "hour" parameter is the current hour time in the range 0..23. We are in trouble if the parrot is talking and the hour is before 7 or after 20. Return True if we are in trouble. -Kai WuparenBit - Given a string that contains a single pair of parenthesis, compute recursively a new string made of only of the parenthesis and their contents, so "xyz(abc)123" yields "(abc)". -Antonio CancioPosNeg(a,b) - true if one of the values is negative -Helen ShapiropowerN(base,n) - Given base and n that are both 1 or more, compute recursively (no loops) the value of base to the n power, so powerN(3, 2) is 9 (3 squared).- (Tarif Riyad Rahman)rentpayment - Given the cost of monthly rent and how much money you have now, calculate how many months of rent you can afford.-Yohanes SantosoroundSum(int a, int b, int c)- For this problem, we'll round an int value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20. Alternately, round down to the previous multiple of 10 if its rightmost digit is less than 5, so 12 rounds down to 10. Given 3 ints, a b c, return the sum of their rounded values. (Joshua Linton)sameFirstLast(x) Given an array, returns 1 if the first and last value are equal, returns 0 otherwise. - Ian ReichekscoresIncreasing - Given an array of scores, return 1 (true) if the scores are in increasing order, return 0 if they are not - Gabe Guerrascores100(int[] scores): Given an array of scores, return true if there are scores of 100 next to each other in the array. The array length will be at least 2. --Robin Jhaservepercentage - Given the number of tennis serves made and the number of errors, calculate the service percentage. -Yohanes SantosoSleepIn(weekday,vacation) - Returns True if we get to sleep in. Returns False if we don’t get to sleep in. The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We get to sleep in if it is not a weekday or we are on vacation. For example SleepIn(False, False) returns True, since it is not a weekday. (Iain Crosby)sortaSum - Pass two numbers and return their sum. If the sum is in the range 10 - 19 return 20 instead of the sum. - Gabe GuerrasplitArray(a) - Given an array of ints, is it possible to divide the ints into two groups, so that the sums of the two groups are the same. Every int must be in one group or the other. Write a recursive helper method that takes whatever arguments you like, and make the initial call to your recursive helper from splitArray(). (No loops needed.) Makensley LordeussquareUp - Given n>=0, create an array length n*n with the following pattern, shown here for n=3 : {0, 0, 1, 0, 2, 1, 3, 2, 1} (spaces added to show the 3 groups) - Ben SetelsquirrelPlay - Given a temperature and whether or not it is summer, decide true if the temperature is between 60 and 90 inclusive, or 60 and 100 inclusive if summer. - Brian SlepianStartHi(s) - Given a string, return true if the string starts with "hi" and false otherwise- Helen ShapirostartOz - Given a string, return a string made of the first 2 chars (if present), however include first char only if it is 'o' and include the second only if it is 'z', so "ozymandias" yields "oz". Jean-Paul WiegandstrCount(s,sub) - Given a string and a non-empty substring sub, compute recursively the number of times that sub appears in the string, without the sub strings overlapping. -Ritu PradhanstrDist(string, substring) Given a string and a non-empty substring sub, compute recursively the largest substring which starts and ends with sub and return its length. - Josh SstringE(s) - Return true if the given string contains between 1 and 3 'e' chars. - Liz ListringE(string) Return true if the given string contains between 1 and 3 'e' chars. (Warmup-1) - Stuart DavisstringSplosion(k) - Given a non-empty string like "Code" return a string like "CCoCodCode". Nadav Havivistring_splosion - Given a non-empty string like "Code" return a string like "CCoCodCode". ---Huimin JiaSumDouble(a,b) - Given two int values, return their sum. Unless the two values are the same, then return double their sum. - Mehreen AsadsumDigits(n) - Given a non-negative int n, return the sum of its digits recursively (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). ----------- (Tarif Riyad Rahman)sum3(x) Given an array of length 3, returns the sum of all values. - Ian ReichekSum3-Given an array of ints length 3, return the sum of all the elements.-seife kassahunteaParty - We are having a party with amounts of tea and candy. Return the int outcome of the party encoded as 0=bad, 1=good, or 2=great. A party is good (1) if both tea and candy are at least 5. However, if either tea or candy is at least double the amount of the other one, the party is great (2). However, in all cases, if either tea or candy is less than 5, the party is always bad (0). - Sean Kilachandtriangle(int rows): We have triangle made of blocks. The topmost row has 1 block, the next row down has 2 blocks, the next row has 3 blocks, and so on. Compute recursively (no loops or multiplication) the total number of blocks in such a triangle with the given number of rows. --Robin Jha