Skip to content

Instantly share code, notes, and snippets.

View piotrek1543's full-sized avatar
:octocat:
Busy... I may be slow to respond.

Piotr piotrek1543

:octocat:
Busy... I may be slow to respond.
View GitHub Profile
@piotrek1543
piotrek1543 / ascii_clock.kt
Created July 31, 2019 13:58
Solution to ASCII art digital clock - write a function: String asciiClock(int hours, int minutes) which returns an ASCII art rendering of a digital clock.
/*
ASCII art digital clock:
write a function:
String asciiClock(int hours, int minutes)
which returns an ASCII art rendering of a digital clock.
Time is expressed between 00:00 to 23:59 (with only hours and minutes).
@piotrek1543
piotrek1543 / PalindromeCreator.java
Created May 16, 2020 19:34
The coding challenge solution to Coderbytes task. Have the function PalindromeCreator(str) take the str parameter being passed and determine if it is possible to create a palindromic string of minimum length 3 characters by removing 1 or 2 characters
/**
* Have the function PalindromeCreator(str) take the str parameter being passed and determine if it is possible to create a palindromic string of minimum length 3 characters by removing 1 or 2 characters. For example: if str is "abjchba" then you can remove the characters jc to produce "abhba" which is a palindrome. For this example your program should return the two characters that were removed with no delimiter and in the order they appear in the string, so jc. If 1 or 2 characters cannot be removed to produce a palindrome, then return the string not possible. If the input string is already a palindrome, your program should return the string palindrome.
* <p>
* The input will only contain lowercase alphabetic characters. Your program should always attempt to create the longest palindromic substring by removing 1 or 2 characters (see second sample test case as an example). The 2 characters you remove do not have to be adjacent in the string.
* Examples
* Input: "mmop"
* Output: not possible
* Input
@piotrek1543
piotrek1543 / MinWindowSubstring.kt
Last active December 20, 2023 23:04
Have the function MinWindowSubstring(strArr) take the array of strings stored in strArr, which will contain only two strings, the first parameter being the string N and the second parameter being a string K of some characters, and your goal is to determine the smallest substring of N that contains all the characters in K. For example: if strArr …
// https://coderbyte.com/editor/Min%20Window%20Substring:Kotlin
/**
* Min Window Substring
* Have the function MinWindowSubstring(strArr) take the array of strings stored in strArr, which will contain only two strings, the first parameter being the string N and the second parameter being a string K of some characters, and your goal is to determine the smallest substring of N that contains all the characters in K. For example: if strArr is ["aaabaaddae", "aed"] then the smallest substring of N that contains the characters a, e, and d is "dae" located at the end of the string. So for this example your program should return the string dae.
* </p>
* Another example: if strArr is ["aabdccdbcacd", "aad"] then the smallest substring of N that contains all of the characters in K is "aabd" which is located at the beginning of the string. Both parameters will be strings ranging in length from 1 to 50 characters and all of K's characters will exist somewhere in the string N. Both strings will only contains lowercase
@piotrek1543
piotrek1543 / CurrencySelectorListItem.kt
Created June 4, 2020 08:07
Trying to create generic divider item using Kotlin delegates... Here with FastAdapter RecyclerView library.
class CurrencySelectorListItem(
private val cardCurrencyFilter: CardCurrencyFilter
) : AbstractItem<CurrencySelectorListItem.ViewHolder>(), WithDividerItem by WithHorizontalDividerItem() {
override fun getViewHolder(parent: View) = ViewHolder(parent).apply {
val divider = create(parent.context)
(parent as ConstraintLayout).addView(divider)
ConstraintSet().apply {
clone(parent)
connect(divider.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM)