Skip to content

kreved77/Java_Basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 

Repository files navigation

Java_Basics

Codewars.Com

Ranking CodeWars

[Task link] Write a class User: it is used to calculate the Rank/Progress that a user will progress through a ranking system similar to the one Codewars uses.

[Task link] A function that finds the maximum sum of consecutive numbers from the top to the bottom of the pyramid. (A path down from a current element - are only the two elements under it.)

[Task link] Write a function that accepts int[][] - a square matrix (N x N 2D array) and returns the determinant of the matrix.

[Task link] A function that checks if a portion of str1 characters can be rearranged to match str2. (('rkqodlw', 'world') ==> True)

[Task link] A function that takes a string of braces, and determines if the order of the braces is valid. ("(){}[]" => True, "[(})" => False)

[Task link] A function that removes from int[] extra repeating numbers - so the new will contain each number only up to N times, without changing the order. (Ex: int[] {1,1,2,3,1,2,2,3,3,4}, times=2 => [1,1,2,3,2,3,4])

[Task link] A function that finds in int[] such a number (the one!) that appears an odd number of times. (Ex: int[] {0,1,0,1,0} => 0, as it occurs 3 (odd) times)

[Task link] A function that formats an ordered list of integers: use separated by a comma(,) for individual integers, or by a dash(-) for a range of integers - from starting integer to the end integer in the range. (Ex: int[] {-6,-2,-1,0,1,3,4,5,7,8,9,14,15,17,18,19,20} => "-6,-2-1,3-5,7-9,14,15,17-20")

[Task link] A function that finds in int[] such an index N - the Sum to the left of N is equal to the Sum to the right of N. Otherwise, return -1. (Ex: int[] {1,2,3,4,3,2,1} => 3)

[Task link] A function that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once. (Ex: [ [1,4],[7, 10],[3, 5] ] => 7)

[Task link] Write a function that computes the N-th smallest Hamming number - a positive integer of the form (2^i)(3^j)(5^k), for i, j, k = [0; +). (Ex: (2^0)(3^0)(5^0) => 1, (2^1)(3^0)(5^0) => 2, (2^0)(3^1)(5^0) => 3, ...)

[Task link] Narcissistic Number - a positive number which is the sum of its digits, each raised to the power of the number of digits. Your code must check imput and return true or false. (Ex: 153 = (1^3)(5^3)(3^3) = 1 + 125 + 27 = 153 => true)

[Task link] You receive two integers that defines the range [a, b]. Find such numbers in range that sum of (digit ^ it position) gives the same number. (Ex: 89 = (8^1)+(9^2), 135 = (1^1)(3^2)(5^3), ...)

[Task link] A function that continues an array of 3 numbers (like [1, 1, 1]) with the next number - generated as a sum the last 3 numbers of the sequence, and returns double[] of the first n elements. (if n == 0, then return an empty array.)

[Task link] A function that from an input String[] of directions ("NORTH", "SOUTH", "WEST", "EAST") will return the cleared array: "NORTH" and "SOUTH" are opposite, "WEST" and "EAST" too - will annihilate each other.

[Task link] Write a function that will return TRUE if the walk takes you 10min and returns you to starting point. (Input is a char[] array containing a random assortment of direction letters - 'n', 's', 'e', 'w'.)

[Task link] Get an integer N to create an array int[N][N] -> NxN clockwise spiral of numbers '1' separated with numbers '0'. So, the snake made with '1' cannot touch to itself. (Ex: N = 5 -> [[1,1,1,1,1],[0,0,0,0,1],[1,1,1,0,1],[1,0,0,0,1],[1,1,1,1,1]] : 1 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 1 1 1 1 1 )

[Task link] Write a function that receives an integer N -> returns an NxN array int[N][N] with numbers 1 to NxN represented as a clockwise spiral. (Ex: N = 3 -> [[1,2,3],[8,9,4],[7,6,5]] : 1 2 3
8 9 4
7 6 5 )

[Task link] The "like" system - a function that takes an array with the names of people and returns the text as shown. (Ex: ["Peter"] -> "Peter likes this", ["Alex", "Jacob", "Mark", "Max"] -> "Alex, Jacob and 2 others like this")

[Task link] Is a pangram? A function that checks: if an input string contains every letter of the alphabet [A-Z] at least once. Yes -> True, No -> False. (Ignore letter case, numbers and punctuation.)

[Task link] Is an isogram? A function that checks: if an input string contains no repeating letters. (Ignore letter case. The empty string is an isogram.) (Ex: "arRay" --> false)

[Task link] A function that converts a string to a new string where: if a character appears only once -> it changes to "(" in the new string, or ")" if that character appears more than once. Ignore capitalization. (Ex: "recede" --> "()()()")

[Task link] Write a function that splits the string into pairs of two characters. (For an odd number of characters - replace the missing second character of the final pair with '_').

[Task link] Write a function that converts dash(-)/underscore(_) delimited words into camelCasing. (The first word stays as original. The next words should be always capitalized.)

[Task link] Write a function that will break up camel casing, using a space between words.

[Task link] Write a function that converts strings to -> Capitalizing Every Each Word.

[Task link] Write a function that takes a single-lined text and emulates text justification to the expected width. Each line should contain as many words as possible. Use spaces to fill in the gaps between words. Use '\n' to separate lines. Last line: should not be justified, single space between words. (Ex: "Lorem ipsum dolor sit amet,")

[Task link] Write a function that converts RGB decimal values -> in a hexadecimal representation, 6 characters long. (Ex: (0,0,0) -> 000000, (255,255,255) -> FFFFFF)

[Task link] Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number (xxx) xxx-xxxx.

[Task link] Write a function that checks a string -> returns true if it's a valid form of a phone number. (Ex: "(123) 456-7890" => true)

[Task link] Write a function, which subtracts one list from another and returns the result. It should remove all values from list a, which are present in list b keeping their order.

*** customVersion: returns Only Unique and Ordered values of Two Arrays.

[Task link] A function that takes any non-negative integer and return it with its digits in descending order (rearranges them from the highest first). (Input: 1315. Output: 5311)

[Task link] Take 2 strings of integers [0-9] and return a new string of the sum of those integers. (Numbers are huge! Don't use BigInteger and BigDecimal.) (Ex: '12','0123' => '135')

[Task link] Take 2 strings and return a new sorted string, containing distinct letters - each taken only once. (Ex: "xyaabbbc","xxyyzaab" -> "abcxyz")

[Task link] Write a function that takes 2 arrays of strings[] -> returns a sorted array (a-z order) of such strings in a1 that are substrings of a2. It must be without duplicates.

[Task link] Write a function that takes an array of strings[] and an integer k, and returns the longest string consisting of k consecutive strings. (consecutive : follow one after another without an interruption)

[Task link] Each word in the input string contains a single number - the position of the word in the result string. Write a function that will order given words to the correct string. (Ex: "is2 Thi1s T4est 3a" -> "Thi1s is2 3a T4est")

[Task link] A function takes a string -> returns it, but in every word moves the 1st letter to the end, and then add "ay" to the end of the word. (Ex: "Pig latin is cool" => "igPay atinlay siay oolcay")

[Task link] Write a function that takes a string of words -> and returns it, but with reversed every 5+ letter word. (Ex: "Hey fellow" => "Hey wollef")

[Task link] Write a function that returns the number (count) of characters that occur more than once in the input string. (Ignore letter case.) (Ex: "aabBcde" -> 2)

[Task link] Write a function that returns the number (count) of vowels in the given string. (a, e, i, o, u - are vowels for this Kata, but not y).

[Task link] Write a function that takes a string of words, and returns a single word with the highest score of its letters: a = 1, b = 2, c = 3, ... (Ex: "abad" score is 8 (1 + 2 + 1 + 4))

[Task link] Write a function that takes a string of space separated numbers, and returns the highest and lowest number (output: string with two numbers separated by a single space, highest number is first).

[Task link] Write a function that takes a list of non-negative integers and strings and returns a new list with the strings filtered out.

Tasks

• "Calculator that calls each of function from a separate method:

input, 1(+) 2(-) 3(*) 4(/) 5(^2) 6(^) 7(%) 8(!) (0)Quit"

• "Sort ASC/DESC an int[] array: (1)bubble sort, (2)using Arrays"

• "Sort ASC/DESC 2D int[][] array."

• "Find sum of 2 factorials"

• "Find maximum, minimum and average values in an Integer array"

for, while

• "Задача 1. Даны целые числа K и N (N > 0).

Вывести N раз число K.

• "Задача 2. Даны два целых числа A и B (A < B).

Вывести в порядке возрастания все целые числа,расположенные между A и B (включая сами числа A и B).
Вывести также количество N этих чисел.

• "Задача 3. Дано вещественное число — цена 1 кг конфет.

Вывести стоимость 1, 2, …, 10 кг конфет.

• "Задача 4. Даны два целых числа A и B (A < B).

Найти сумму всех целых чисел от A до B включительно

• "Задача 5. Дано целое число N (> 0), являющееся некоторой степенью числа 2: N = 2^K.

Найти целое число K — показатель этой степени.

• "Задача 6. Дано целое число N (> 1).

Найти наибольшее целое число K, при котором выполняется неравенство 3K < N.

• "Задача 3. ВАРИАНТ с сортировкой по возрастанию. Даны три переменные вещественного типа: A, B, C.

• Если их значения упорядочены по возрастанию, то удвоить их; 
• в противном случае отсортировать по возрастанию. 
Вывести новые значения переменных A, B, C"

• "Задача 1. Дано целое число.

• Если оно является положительным, то прибавить к нему 1;
• в противном случае не изменять его.
Вывести полученное число."

• "Задача 2. Дано целое число.

• Если оно является положительным, то прибавить к нему 1;
• если отрицательным, то вычесть из него 2;
• если нулевым, то заменить его на 10.
Вывести полученное число."

• "Задача 3. Даны три переменные вещественного типа: A, B, C.

• Если их значения упорядочены по возрастанию, то удвоить их; 
• в противном случае заменить значение каждой переменной на противоположное. 
Вывести новые значения переменных A, B, C"

• "Задача 4.

• Единицы массы пронумерованы следующим образом: 1 — килограмм, 2 — миллиграмм, 3 — грамм, 4 — тонна, 5 — центнер.
• Дан номер единицы массы (целое число в диапазоне 1–5) и масса тела в этих единицах (вещественное число).
Найти массу тела в килограммах."

• "Задача 5. Необходимо реализовать консольный калькулятор со всеми основными арифметическими операциями.

• Пользователь вводит 2 числа с клавиатуры
• и выбирает операцию из списка.
• Если пользователь выбрал не существующую операцию необходимо вывести соответствующее сообщение.
Вывести полученный результат."

• "Задача 6. Дано целое число в диапазоне 1–7.

Вывести строку — название дня недели, соответствующее данному числу (1 — «понедельник», 2 — «вторник» и т. д.)"
• "Программа вычисления Площади и Периметра прямоугольника со сторонами A и B."

About

My Codewars Solutions in Java

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages