Skip to content

Instantly share code, notes, and snippets.

@odhiambo123
odhiambo123 / EvaluationService.java
Last active August 3, 2022 05:44
Problem solutions from EvaluationService .java
package com.revature.eval.java.core;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class EvaluationService {
/**
* 1.A Speed Converter - Convert to MilesPerHour
@odhiambo123
odhiambo123 / KthSmallest.kt
Created June 20, 2022 16:54
the Kth smallest , please give any suggestions to improve the code
class KthSmallest {
var arr = intArrayOf(45,34,5,6,34,7,78,9,79,0,89,70,58,54,68,73,72,82,45,67,32,67,92)
var k = 7
}
fun main(){
val a: KthSmallest = KthSmallest()
println(a.arr.size)
var sortedA = a.arr.sortedBy { it.dec() }
@odhiambo123
odhiambo123 / MyArrays.kt
Last active June 20, 2022 16:50
reversing subArrays - Incomplete needs fixing , please give any suggestions if you can
//2. Given an array arr[] of positive integers of size N. Reverse every sub-array group of
//size K.
fun main(){
var c : MyArrays = MyArrays()
//println( c.arr.toSortedSet())
var mySorted = c.arr.sortedBy { it.dec() }
println(mySorted)
@odhiambo123
odhiambo123 / Main.kt
Created June 20, 2022 14:27
find the first largest word in array
fun main() {
//var e:Exercise1 = Exercise1()
var sen = mutableListOf("lof",123,45, "komb",67,78,"honda",456,"lophomgmjtldgk7","joingsds", "persontwo","hello","hendustan","koghtndbsa","gregerggdfgd","gregerggdfgr","lophomgmjtldgkt","lophomgmjrldgko")
val myList = mutableListOf<Any>()
for (i in sen){
myList.add(i.toString())
}
//println(myList)
@odhiambo123
odhiambo123 / UnsplashResponse.kt
Created June 7, 2022 02:42
Unsplash response code
//contains the results we get from the response
data class UnsplashResponse (
val results: List<UnsplashPhoto>
)
@odhiambo123
odhiambo123 / activity_main.xml
Created June 7, 2022 02:25
Code for activity main xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment_main"
@odhiambo123
odhiambo123 / nav_graph.xml
Created June 6, 2022 02:30
code for nav graph
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/galleryFragment">
<activity
android:id="@+id/galleryFragment"
android:name="com.davidodhiambo.unsplashphotos.ui.gallery.GalleryFragment"
@odhiambo123
odhiambo123 / build.gradle
Created June 6, 2022 01:34
get the dependencies
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
}
android {
compileSdk 32
defaultConfig {
@odhiambo123
odhiambo123 / nav_graph.xml
Created June 6, 2022 01:18
nav graph for the Gallery fragment
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/galleryFragment">
<activity
android:id="@+id/galleryFragment"
android:name="com.davidodhiambo.unsplashphotos.ui.gallery.GalleryFragment"
@odhiambo123
odhiambo123 / UnsplashPhoto.kt
Created June 6, 2022 00:25
code for the UnsplashPhoto data class
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
@Parcelize
data class UnsplashPhoto(
val id: String,
val description: String,
val urls: UnsplashPhotoUrls,//urls have their own properties
val user: UnsplashUser, //users have their own properties