kotlin-99 | Ninety-Nine Problems in Kotlin | Learning library
kandi X-RAY | kotlin-99 Summary
kandi X-RAY | kotlin-99 Summary
This is an adaptation of Ninety-Nine Scala Problems by Phil Gold which itself is an adaptation of the Ninety-Nine Prolog Problems written by Werner Hett at the Berne University of Applied Sciences in Berne, Switzerland. Some problems have been altered to be more amenable to programming in Kotlin. You might want to do these problems if you want to learn Kotlin, are interested in the problems described below, or both. The main reason to prefer this to using websites like hackerrank.com and codewars.com is that there is no vendor lock-in and no hidden agenda pursued by the website owner. The suggested workflow is to solve a problem yourself and then compare solution to the one provided. Solutions are available by clicking on the link at the beginning of the problem description. Your goal should be to find the most elegant solution to the given problems. Efficiency is important, but clarity is even more crucial. Some of the (easy) problems can be trivially solved using built-in functions. However, in these cases, you can learn more if you try to find your own solution. The problems have different levels of difficulty. Those marked with a single asterisk * are easy. If you have successfully solved the preceding problems, you might be able to solve them within a few (say 15) minutes. Problems marked with two asterisks ** are of intermediate difficulty and might take about 30-90 minutes to solve. Problems marked with three asterisks *** are more difficult. You may need more time (i.e. a few hours or more) to find a good solution. Please note that levels of difficulty is just a guess and assumes you are somewhat familiar with the problem domain. It is perfectly ok if some of them take longer. Overall, the goal is to learn, not to finish "on time". You might notice that there are less than 99 problems. This is because numbering of original problems was wrong. It was kept here for consistency with 99 problems in other programming languages. The first 50 or so problems are easy. If this is boring for you, feel free to jump to Binary Trees. All contributions are welcome (including alternative solutions for problems which already have a solution).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of kotlin-99
kotlin-99 Key Features
kotlin-99 Examples and Code Snippets
Community Discussions
Trending Discussions on kotlin-99
QUESTION
I was trying out some example code from https://github.com/dkandalov/kotlin-99#lists. First there is a function that takes a list of any type and returns a list of lists
...ANSWER
Answered 2019-Nov-11 at 18:16This is about nullability.
In Kotlin, the top type is Any?
, which can hold any object or null
. The subtype Any
, however, is not nullable, and can't store a null.
In your first version, the generic type T
could be any type; in particular, it could be a nullable type. So the compiler won't let you return a T
as Any
, in case it's null.
You could solve this by declaring it to return Any?
, or by restricting the generic type to be non-nullable. In your second version, you've done the latter by restricting T
to be the non-nullable Any
type.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install kotlin-99
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page