본문 바로가기

FOR78

Find the odd int Description: Given an array of integers, find the one that appears an odd number of times. There will always be only one integer that appears an odd number of times. Examples [7] should return 7, because it occurs 1 time (which is odd). [0] should return 0, because it occurs 1 time (which is odd). [1,1,2] should return 2, because it occurs 1 time (which is odd). [0,1,0,1,0] should return 0, beca.. 2022. 3. 30.
Sum of the first nth term of Series Description: Task: Your task is to write a function which returns the sum of following series upto nth term(parameter). Series: 1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 +... Rules: You need to round the answer to 2 decimal places and return it as String. If the given value is 0 then it should return 0.00 You will only be given Natural Numbers as arguments. Examples:(Input --> Output) 1 --> 1 --> "1.00.. 2022. 3. 29.
Reverse words Description: Complete the function that accepts a string parameter, and reverses each word in the string. All spaces in the string should be retained. Examples "This is an example!" ==> "sihT si na !elpmaxe" "double spaces" ==> "elbuod secaps" Solution: 1. Separate text based on space. 2. Turn over the separated text and put it in an array. 3. Convert the text in the array to a string with space.. 2022. 3. 28.
Invert values Description: 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([]) == [] You can assume that all values are integers. Do not mutate the input array/list. Solution: 1. Get the numbers in the array. 2. Change positive numbers to nega.. 2022. 3. 27.
How many pages in a book? Description: Every book has n pages with page numbers 1 to n. The summary is made by adding up the number of digits of all page numbers. Task: Given the summary, find the number of pages n the book has. Example If the input is summary=25, then the output must be n=17: The numbers 1 to 17 have 25 digits in total: 1234567891011121314151617. Be aware that you'll get enormous books having up to 100... 2022. 3. 26.
Find the divisors! Description: Create a function named divisors/Divisors that takes an integer n > 1 and returns an array with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prime' (null in C#) (use Either String a in Haskell and Result in Rust). Example: divisors(12); #should return [2,3,4,6] divisors(25); #shoul.. 2022. 3. 24.