Kick off your book project in 2 hours! Live workshop on Zoom. You’ll leave with a real book project, progress on your first chapter, and a clear plan to keep going. Tuesday, June 16, 2026. Learn more…

Leanpub Header

Skip to main content

Kotlin Exercises

This book is 100% completeLast updated on 2026-06-12

A collection of over 100 Kotlin exercises.

Minimum price

$10.00

$19.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
About

About

About the Book

This is a collection of exercises and solutions from Kotlin Essentials, Functional Kotlin, Kotlin Coroutines: Deep Dive, and Advanced Kotlin.

Share this book

Categories

Author

About the Author

Marcin Moskała

Marcin Moskala is an experienced developer and Kotlin trainer. He is the founder of the kt.academy, Kotlin GDE, an official JetBrains partner for teaching Kotlin, and author of the books Effective Kotlin, Kotlin Coroutines, and Android Development with Kotlin.

Leanpub Podcast

Episode 254

An Interview with Marcin Moskała

Contents

Table of Contents

Introduction

  1. Kotlin Essentials exercises
  2. Exercise: Your first program
  3. Exercise: Basic values operations
  4. Exercise: Using when
  5. Exercise: Pretty time display
  6. Exercise: Person details display
  7. Exercise: Range Operations
  8. Exercise: User Information Processor
  9. Exercise: Implementing the Product class
  10. Exercise: GUI View Hierarchy Simulation
  11. Exercise: Data class practice
  12. Exercise: Pizza factory
  13. Exercise: Catching exceptions
  14. Exercise: Days of the week enum
  15. Exercise: Conversion and measurement unit creation
  16. Exercise: Inventory management
  17. Exercise: Money operations
  18. Exercise: The closest supertype of types
  19. Exercise: Stock
  20. Final Project: Workout manager
  21. Functional Kotlin exercises
  22. Exercise: Function types and literals
  23. Exercise: Observable value
  24. Exercise: Inferred function types
  25. Exercise: Function references
  26. Exercise: Inline functions
  27. Exercise: Implement map
  28. Exercise: Optimize collection processing
  29. Exercise: Adding element at position
  30. Exercise: Implement shop functions
  31. Exercise: Prime access list
  32. Exercise: Top articles
  33. Exercise: Refactor collection processing
  34. Exercise: Passing students list
  35. Exercise: Best students list
  36. Exercise: Functional Quick Sort
  37. Exercise: Powerset
  38. Exercise: All possible partitions of a set
  39. Exercise: Understanding sequences
  40. Exercise: HTML table DSL
  41. Exercise: Creating user table row
  42. Exercise: Using scope functions
  43. Exercise: orThrow
  44. Exercise: Logger
  45. Final Project: UserService
  46. Kotlin Coroutines exercises
  47. Exercise: Factorial sequence
  48. Exercise: Prime numbers sequence
  49. Exercise: Callback function wrappers
  50. Exercise: Continuation storage
  51. Exercise: What is stored by a continuation?
  52. Exercise: UserDetailsRepository
  53. Exercise: BestStudentUseCase
  54. Exercise: CommentService
  55. Exercise: mapAsync
  56. Exercise: Understanding context propagation
  57. Exercise: CounterContext
  58. Exercise: Using dispatchers
  59. Exercise: DiscNewsRepository
  60. Exercise: Experiments with dispatchers
  61. Exercise: Correct mistakes with cancellation
  62. Exercise: NotificationSender
  63. Exercise: BaseViewModel
  64. Exercise: UserDownloader
  65. Exercise: CompanyDetailsRepository
  66. Exercise: CancellingRefresher
  67. Exercise: TokenRepository
  68. Exercise: Suspended lazy
  69. Exercise: mapAsync with concurrency limit
  70. Exercise: Test UserDetailsRepository
  71. Exercise: Testing mapAsync
  72. Exercise: Testing the NotificationSender class
  73. Exercise: Testing a View Model
  74. Exercise: UserRefresher
  75. Exercise: Cafeteria simulation
  76. Exercise: raceOf
  77. Exercise: Flow utils
  78. Exercise: All users flow
  79. Exercise: distinct
  80. Exercise: TemperatureService
  81. Exercise: NewsViewModel
  82. Exercise: ProductService
  83. Exercise: Flow Kata
  84. Exercise: MessageService
  85. Exercise: Update ProductService
  86. Exercise: Update TemperatureService
  87. Exercise: LocationService
  88. Exercise: PriceService
  89. Exercise: NewsViewModel using stateIn
  90. Exercise: Flow testing
  91. Advanced Kotlin exercises
  92. Exercise: Usage of generic types
  93. Exercise: Generic Response
  94. Exercise: Generic Consumer
  95. Exercise: ApplicationScope
  96. Exercise: Lateinit delegate
  97. Exercise: Blog Post Properties
  98. Exercise: Mutable lazy delegate
  99. Exercise: Coroutine time measurement
  100. Exercise: Adjust Kotlin for Java usage
  101. Exercise: Multiplatform LocalDateTime
  102. Exercise: Migrating a Kotlin/JVM project to KMP
  103. Exercise: Function caller
  104. Exercise: Object serialization to JSON
  105. Exercise: Object serialization to XML
  106. Exercise: DSL-based dependency injection library
  107. Exercise: Mocking library
  108. Exercise: Annotation Processing execution measurement wrapper
  109. Exercise: KSP execution measurement wrapper
  110. Effective Kotlin exercises
  111. Exercise: A mutability problem
  112. Exercise: Flow with history
  113. Exercise: Correct InMemoryUserRepository
  114. Exercise: Chunking a flow
  115. Exercise: Specify expectations
  116. Exercise: Unit testing
  117. Exercise: Unit testing using mocks
  118. Exercise: Composition vs inheritance
  119. Exercise: Make DeckConnector comparable
  120. Exercise: Correct EventListenerRegistry
  121. Exercise: Market data processing optimization
  122. Exercise: Prime access list
  123. Exercise: Crime analysis

Exercise solutions

  1. Solution: Basic values operations
  2. Solution: Using when
  3. Solution: Pretty time display
  4. Solution: Person details display
  5. Solution: Range Operations
  6. Solution: User Information Processor
  7. Solution: Implementing the Product class
  8. Solution: GUI View Hierarchy Simulation
  9. Solution: Data class practice
  10. Solution: Pizza factory
  11. Solution: Catching exceptions
  12. Solution: Days of the week enum
  13. Solution: Conversion and measurement unit creation
  14. Solution: Inventory management
  15. Solution: Money operations
  16. Solution: The closest supertype of types
  17. Solution: Stock
  18. Solution: Workout manager
  19. Solution: Function types and literals
  20. Solution: Observable value
  21. Solution: Inferred function types
  22. Solution: Function references
  23. Solution: Inline functions
  24. Solution: Implement map
  25. Solution: Optimize collection processing
  26. Solution: Adding element at position
  27. Solution: Implement shop functions
  28. Solution: Prime access list
  29. Solution: Top articles
  30. Solution: Refactor collection processing
  31. Solution: Passing students list
  32. Solution: Best students list
  33. Solution: Functional Quick Sort
  34. Solution: Powerset
  35. Solution: All possible partitions of a set
  36. Solution: Understanding sequences
  37. Solution: HTML table DSL
  38. Solution: Creating user table row
  39. Solution: Using scope functions
  40. Solution: orThrow
  41. Solution: Logger
  42. Solution: UserService
  43. Solution: Factorial sequence
  44. Solution: Prime numbers sequence
  45. Solution: Callback function wrappers
  46. Solution: Continuation storage
  47. Solution: What is stored by a continuation?
  48. Solution: UserDetailsRepository
  49. Solution: BestStudentUseCase
  50. Solution: CommentService
  51. Solution: mapAsync
  52. Solution: Understanding context propagation
  53. Solution: CounterContext
  54. Solution: Using dispatchers
  55. Solution: DiscNewsRepository
  56. Solution: Experiments with dispatchers
  57. Solution: Correct mistakes with cancellation
  58. Solution: NotificationSender
  59. Solution: BaseViewModel
  60. Solution: UserDownloader
  61. Solution: CompanyDetailsRepository
  62. Solution: CancellingRefresher
  63. Solution: TokenRepository
  64. Solution: Suspended lazy
  65. Solution: mapAsync with concurrency limit
  66. Solution: Test UserDetailsRepository
  67. Solution: Testing mapAsync
  68. Solution: Testing the NotificationSender class
  69. Solution: UserRefresher
  70. Solution: Cafeteria simulation
  71. Solution: raceOf
  72. Solution: Flow utils
  73. Solution: All users flow
  74. Solution: distinct
  75. Solution: TemperatureService
  76. Solution: NewsViewModel
  77. Solution: ProductService
  78. Solution: Flow Kata
  79. Solution: MessageService
  80. Solution: Update ProductService
  81. Solution: Update TemperatureService
  82. Solution: LocationService
  83. Solution: PriceService
  84. Solution: NewsViewModel using stateIn
  85. Solution: Usage of generic types
  86. Solution: Generic Response
  87. Solution: Generic Consumer
  88. Solution: ApplicationScope
  89. Solution: Lateinit delegate
  90. Solution: Blog Post Properties
  91. Solution: Mutable lazy delegate
  92. Solution: Coroutine time measurement
  93. Solution: Adjust Kotlin for Java usage
  94. Solution: Multiplatform LocalDateTime
  95. Solution: Migrating a Kotlin/JVM project to KMP
  96. Solution: Function caller
  97. Solution: Object serialization to JSON
  98. Solution: Object serialization to XML
  99. Solution: DSL-based dependency injection library
  100. Solution: Mocking library
  101. Solution: Annotation Processing execution measurement wrapper
  102. Solution: KSP execution measurement wrapper
  103. Solution: A mutability problem
  104. Solution: Flow with history
  105. Solution: Correct InMemoryUserRepository
  106. Solution: Chunking a flow
  107. Solution: Specify expectations
  108. Solution: Make DeckConnector comparable
  109. Solution: Correct EventListenerRegistry
  110. Solution: Market data processing optimization
  111. Solution: Crime analysis

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub