Skip to content

g3th/CodeAcademy-Hyperskill-Courses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 

Repository files navigation

Codebase/Hyperskill Courses Excercises

Code Problems Used to Complete Codebase/Hyperskill Courses

Kotlin

Chimps (CodeAcademy)

Problem to understand Kotlin collections like lists, sets and maps.

Will take user input and use various methods to change/delete/insert values into various types of containers.

squareAnTriangle (CodeAcademy)

Understanding Loops, and using for and while to draw grids, squares and triangle shapes with characters.

customFunctions (CodeAcademy)

Learning how to use functions in Kotlin, including lambdas and anonymous functions.

Writing custom functions to return minimum, maximum, average and checking if a value exists in a container.

happyNewYear (CodeAcademy)

Recursion.

calculator (CodeAcademy)

Kotlin calculator with user input, which includes 4 basic operations plus a custom powers function, instead of using Math library.

whichday (Hyperskill)

Enter a day of the week then enter a number, and find out which day it will be in (n) days passed.

Cinema (Hyperskill)

First, it prints cinema rows and seats in a square grid.

Then, the user inputs two positive integer numbes: the number of rows and the number of seats in each row. The ticket price is determined by the following rules:

If the total number of seats in the screen room is not more than 60, then the price of each ticket is 10 dollars. In a larger room, the tickets are 10 dollars for the front half of the rows and 8 dollars for the back half. Please note that the number of rows can be odd, for example, 9 rows. In this case, the first half is the first 4 rows, and the second half is the rest 5 rows.

Calculate the profit from the sold tickets depending on the number of seats and print the result as shown in the examples below. After that, your program should stop. Note that in this project, the number of rows and seats won't be greater than 9.

This results in a program which is complete cancer.

divideby4 (Hyperskill)

Return largest number divisible by four in a list of Integers, without using the max() function.

rightRotation

Input a list of [n] numbers, and a [n] which indicates the number of positions which it will rotate by. I.e.

A list of 5 numbers (1,2,3,4,5), rotate it by 2 (4,5,1,2,3)

indexOfFirsMax

Reads a list of integers and finds the index of the first maximum in the list

numbersInARow

Reads a list of integers and two numbers: n1 and n2. The program is to check that n1 and n2 never occur next to each other (also in reverse order) in the list.

tickets

Variation on the cinema project. Prints out cinema hall, allows user to pick a row and seat, and prints out the ticket price for row + seat picked, together with a printout of the location of row + seat in the entire Cinema hall (marked by 'B' instead of 'S').

cinemaMenu

Same cinema script, but adds a menu that will allow options to buy tickets and display the current state of the seating arrangement. Draws hall with list of lists, and retains the state of the seats.

cinemaCompleted

Completed "Cinema Room Manager" project, part of "Kotlin Core" course.

When the item Statistics is chosen, your program should print the following information:

The number of purchased tickets;

The number of purchased tickets represented as a percentage. Percentages should be rounded to 2 decimal places;

Current income;

The total income that shows how much money the theatre will get if all the tickets are sold. The rest of the menu items should work the same way as before, except the item Buy a ticket shouldn't allow a user to buy a ticket that has already been purchased.

If a user chooses an already taken seat, print That ticket has already been purchased! and ask them to enter different seat coordinates until they pick an available seat. Of course, you shouldn't allow coordinates that are out of bounds. If this happens, print Wrong input! and ask to enter different seat coordinates until the user picks an available seat.

pieceOfAlphabet

Reads a string and output true only when the letters of this string form a substring of the ordered English alphabet, for example, "abc", "xy", "pqrst".

compressionAlgo

Reads an input of chars. The string "aaaabbсaa" is converted into "a4b2с1a2", and so on.

unique

Write a program that reads a word and prints the number of characters that appear in it only once.

numberInASet

Write a program that checks if a set of N numbers contains a number M.

The first line contains the N number. The next N lines contain the set of numbers one number per line.

The last line contains one integer number M.

You need to output either YES or NO.

gettingSubstrings

All letters after last 'u' should be uppercase.

charSequence

Write a function that takes in a CharSequence and returns a new CharSequence with every other character of the original one removed.

compoundInterest

A program that reads the name and the value of a new parameter, calculates the compound interest, and prints the final amount for this new parameter. Implements named arguments to solve this problem.

previousChar

Input 4 chars, and it will print the previous Unicode char for each character inputted.

weatherComparison

Returns the coldest weather in three cities. How to use Property Accessors (getters and setters).

triples

Returns number of triples when iterating through a number sequence.

alphabetLetters

Write a program that reads a letter and prints all the preceding letters of the English alphabet.

numberOfTens

Write a program that reads a number and prints the tens in that number. Use indexes to solve this problem!

countVowels

Takes a CharSequence as input and returns the number of vowels.

timeDifference

We are going to consider two moments in time that happened on the same day — hours, minutes, and seconds. It is known that the second moment happened not earlier than the first one. Find how many seconds passed between the two moments.

dateTime

The function isLeapYear(year: String): Boolean takes a year as a parameter and returns true if it is a leap year. Write the correct code for the isLeapYear() function. This is using the kotlinx.datetime library and will need to be imported into build.gradle.kts "dependencies."

checkElements

Reads a list of numbers, then takes an input of 2 numbers and check if those numbers are present in the first list. An example of using Kotlin's great collection functions/operations, like distinct and intersect.

angleBetweenVectors

Calculate the angle between 4 given vectors, entered by the user in two separate inputs (i.e. 1 2 - 3 4), using the dot product formula.

getters_setters

How to implement getters and setters in the Kotlin language.

if_expr

Write a program that reads an integer number and checks if it is divisible by 2, 3, 5, or 6. (problem of the day)

whileLoops

Write a program that prints a part of the following sequence 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 ... (the number of repetitions is equal to the respective number). Input is a positive integer n – the number of the elements of the sequence that the program should print. Output the sequence of numbers, written in a single line, separated by spaces.

For example, if n is 7, the program should output 1 2 2 3 3 3 4 (seven numbers).

Note that a space at the end of the output line does not affect the result. Pay attention to the numbers. (problem of the day)

Releases

No releases published

Packages

No packages published

Languages