Comments (2)
By the way, this next solution (which was my first try) also makes the test pass, but I guess this is not a correct solution, because it counts the number of orders that contain the product and I guess an order could contain a particular product more than once, but the test doesn't test for this case.
fun Shop.getNumberOfTimesProductWasOrdered(product: Product): Int {
// Return the number of times the given product was ordered.
// Note: a customer may order the same product for several times.
return customers.flatMap { it.orders }.count { it.products.contains(product) }
}
from kotlin-koans.
Thanks! I've updated the solution (you're right, your version looks simple enough) and added the necessary test.
from kotlin-koans.
Related Issues (20)
- Html builder(todoTask39) link to documentation HOT 1
- N25ComparisonKtTest not testing proper comaprison
- Shows tasks compilation errors, when it's not HOT 1
- Compilation Failed HOT 15
- ./gradlew test - ArrayIndexOutOfBoundsException: 450 HOT 1
- Conventions : For loop - task fails to run on https://try.kotlinlang.org HOT 2
- Task 21: Partition Task
- Not quite perfect answer in "Object expressions" and "SAM conversions" online koans
- Missing iii_conventions/_29_Tips.kt?
- Debug Breakpoints
- Upgrade to latest Gradle release version HOT 2
- Unable to save plugin settings (Android Studio 3.1.4) HOT 1
- Task 32 java.lang.NoSuchMethodError: when we have Int property
- [online] Kotlin Koans 5/42 contains incorrect assertion
- Bug in Collections/Compound tasks? HOT 10
- commenting.
- Build via Gradle Kotlin DSL
- Migrate to JUnit 5 HOT 1
- Use plugins edutools HOT 4
- Android apk
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlin-koans.