first commit

This commit is contained in:
baldeau 2024-10-14 11:37:17 +02:00
commit bb3d2b0b03
427 changed files with 31784 additions and 0 deletions

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-65.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.3.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.6.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.11.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.8",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.8",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-12.0.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "acronym",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-10-17T21:23:31.446577Z",
"generator": "pub",
"generatorVersion": "3.1.3"
}

View File

@ -0,0 +1,22 @@
{
"authors": [
"Stargator"
],
"contributors": [
"kytrinyx"
],
"files": {
"solution": [
"lib/acronym.dart"
],
"test": [
"test/acronym_test.dart"
],
"example": [
".meta/lib/example.dart"
]
},
"blurb": "Convert a long phrase to its acronym.",
"source": "Julien Vanier",
"source_url": "https://github.com/monkbroc"
}

View File

@ -0,0 +1 @@
{"track":"dart","exercise":"acronym","id":"f7d3531357154fdeb9d0614897b99b73","url":"https://exercism.org/tracks/dart/exercises/acronym","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false}

38
acronym/HELP.md Normal file
View File

@ -0,0 +1,38 @@
# Help
## Running the tests
To run the tests:
```sh
$ dart test
```
## Submitting your solution
You can submit your solution using the `exercism submit lib/acronym.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

36
acronym/README.md Normal file
View File

@ -0,0 +1,36 @@
# Acronym
Welcome to Acronym on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
Convert a phrase to its acronym.
Techies love their TLA (Three Letter Acronyms)!
Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).
Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input.
For example:
|Input|Output|
|-|-|
|As Soon As Possible|ASAP|
|Liquid-crystal display|LCD|
|Thank George It's Friday!|TGIF|
## Source
### Created by
- @Stargator
### Contributed to by
- @kytrinyx
### Based on
Julien Vanier - https://github.com/monkbroc

View File

@ -0,0 +1,18 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps

9
acronym/lib/acronym.dart Normal file
View File

@ -0,0 +1,9 @@
class Acronym {
String abbreviate(String phrase) {
return phrase
.split(RegExp(r"\s+|\-+|_+"))
.where((word) => word.isNotEmpty)
.map((word) => word[0].toUpperCase())
.join();
}
}

365
acronym/pubspec.lock Normal file
View File

@ -0,0 +1,365 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
url: "https://pub.dev"
source: hosted
version: "65.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
url: "https://pub.dev"
source: hosted
version: "6.3.0"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb"
url: "https://pub.dev"
source: hosted
version: "1.6.4"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.11.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: d983a57c33dde6d44b1fb8635f67c91f4b41d26cf227c147963affa97d63563d
url: "https://pub.dev"
source: hosted
version: "1.24.8"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: "2f866bf4b20c11327ac166ee6036bddafb7fe9e35505ff8324f788e66913f967"
url: "https://pub.dev"
source: hosted
version: "0.5.8"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: a13d5503b4facefc515c8c587ce3cf69577a7b064a9f1220e005449cf1f64aad
url: "https://pub.dev"
source: hosted
version: "12.0.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"

5
acronym/pubspec.yaml Normal file
View File

@ -0,0 +1,5 @@
name: 'acronym'
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
test: '<2.0.0'

View File

@ -0,0 +1,53 @@
import 'package:acronym/acronym.dart';
import 'package:test/test.dart';
void main() {
final acronym = Acronym();
group('Acronym', () {
test('basic', () {
final result = acronym.abbreviate('Portable Network Graphics');
expect(result, equals('PNG'));
}, skip: false);
test('lowercase words', () {
final result = acronym.abbreviate('Ruby on Rails');
expect(result, equals('ROR'));
}, skip: true);
test('punctuation', () {
final result = acronym.abbreviate('First In, First Out');
expect(result, equals('FIFO'));
}, skip: true);
test('all caps word', () {
final result = acronym.abbreviate('GNU Image Manipulation Program');
expect(result, equals('GIMP'));
}, skip: true);
test('punctuation without whitespace', () {
final result = acronym.abbreviate('Complementary metal-oxide semiconductor');
expect(result, equals('CMOS'));
}, skip: true);
test('very long abbreviation', () {
final result = acronym.abbreviate('Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me');
expect(result, equals('ROTFLSHTMDCOALM'));
}, skip: true);
test('consecutive delimiters', () {
final result = acronym.abbreviate('Something - I made up from thin air');
expect(result, equals('SIMUFTA'));
}, skip: true);
test('apostrophes', () {
final result = acronym.abbreviate('Halley\'s Comet');
expect(result, equals('HC'));
}, skip: true);
test('underscore emphasis', () {
final result = acronym.abbreviate('The Road _Not_ Taken');
expect(result, equals('TRNT'));
}, skip: true);
});
}

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-65.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.3.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.7.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.11.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.9",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.9",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-13.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "allergies",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-11-01T16:52:36.971279Z",
"generator": "pub",
"generatorVersion": "3.1.5"
}

View File

@ -0,0 +1,23 @@
{
"authors": [
"amscotti"
],
"contributors": [
"Stargator",
"kytrinyx"
],
"files": {
"solution": [
"lib/allergies.dart"
],
"test": [
"test/allergies_test.dart"
],
"example": [
".meta/lib/example.dart"
]
},
"blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.",
"source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.",
"source_url": "https://turing.edu"
}

View File

@ -0,0 +1 @@
{"track":"dart","exercise":"allergies","id":"bddb04d85bf244bc8f741a3288cf3436","url":"https://exercism.org/tracks/dart/exercises/allergies","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false}

38
allergies/HELP.md Normal file
View File

@ -0,0 +1,38 @@
# Help
## Running the tests
To run the tests:
```sh
$ dart test
```
## Submitting your solution
You can submit your solution using the `exercism submit lib/allergies.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

47
allergies/README.md Normal file
View File

@ -0,0 +1,47 @@
# Allergies
Welcome to Allergies on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.
An allergy test produces a single numeric score which contains the information about all the allergies the person has (that they were tested for).
The list of items (and their value) that were tested are:
- eggs (1)
- peanuts (2)
- shellfish (4)
- strawberries (8)
- tomatoes (16)
- chocolate (32)
- pollen (64)
- cats (128)
So if Tom is allergic to peanuts and chocolate, he gets a score of 34.
Now, given just that score of 34, your program should be able to say:
- Whether Tom is allergic to any one of those allergens listed above.
- All the allergens Tom is allergic to.
Note: a given score may include allergens **not** listed above (i.e. allergens that score 256, 512, 1024, etc.).
Your program should ignore those components of the score.
For example, if the allergy score is 257, your program should only report the eggs (1) allergy.
## Source
### Created by
- @amscotti
### Contributed to by
- @Stargator
- @kytrinyx
### Based on
Exercise by the JumpstartLab team for students at The Turing School of Software and Design. - https://turing.edu

View File

@ -0,0 +1,18 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps

View File

@ -0,0 +1,18 @@
class Allergies {
static const List<String> _allergies = [
'eggs',
'peanuts',
'shellfish',
'strawberries',
'tomatoes',
'chocolate',
'pollen',
'cats',
];
bool allergicTo(final String item, final int allergyScore) =>
((allergyScore >> _allergies.indexOf(item)) & 1) == 1;
List<String> list(final int allergyScore) =>
_allergies.where((allergy) => allergicTo(allergy, allergyScore)).toList();
}

365
allergies/pubspec.lock Normal file
View File

@ -0,0 +1,365 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
url: "https://pub.dev"
source: hosted
version: "65.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
url: "https://pub.dev"
source: hosted
version: "6.3.0"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
url: "https://pub.dev"
source: hosted
version: "1.7.1"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.11.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f
url: "https://pub.dev"
source: hosted
version: "1.24.9"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a
url: "https://pub.dev"
source: hosted
version: "0.5.9"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"

5
allergies/pubspec.yaml Normal file
View File

@ -0,0 +1,5 @@
name: 'allergies'
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
test: '<2.0.0'

View File

@ -0,0 +1,317 @@
import 'package:allergies/allergies.dart';
import 'package:test/test.dart';
final allergies = Allergies();
void main() {
group('Allergies: testing for eggs allergy - ', testingForEggsAllergy);
group('Allergies: testing for peanuts allergy - ', testingForPeanutsAllergy);
group('Allergies: testing for shellfish allergy - ',
testingForShellfishAllergy);
group('Allergies: testing for strawberries allergy - ',
testingForStrawberriesAllergy);
group(
'Allergies: testing for tomatoes allergy - ', testingForTomatoesAllergy);
group('Allergies: testing for chocolate allergy - ',
testingForChocolateAllergy);
group('Allergies: testing for pollen allergy - ', testingForPollenAllergy);
group('Allergies: testing for cats allergy - ', testingForCatsAllergy);
group('Allergies: list when: - ', listWhen);
}
void testingForEggsAllergy() {
test('not allergic to anything', () {
final result = allergies.allergicTo('eggs', 0);
expect(result, equals(false));
}, skip: false);
test('allergic only to eggs', () {
final result = allergies.allergicTo('eggs', 1);
expect(result, equals(true));
}, skip: false);
test('allergic to eggs and something else', () {
final result = allergies.allergicTo('eggs', 3);
expect(result, equals(true));
}, skip: false);
test('allergic to something, but not eggs', () {
final result = allergies.allergicTo('eggs', 2);
expect(result, equals(false));
}, skip: false);
test('allergic to everything', () {
final result = allergies.allergicTo('eggs', 255);
expect(result, equals(true));
}, skip: false);
}
void testingForPeanutsAllergy() {
test('not allergic to anything', () {
final result = allergies.allergicTo('peanuts', 0);
expect(result, equals(false));
}, skip: false);
test('allergic only to peanuts', () {
final result = allergies.allergicTo('peanuts', 2);
expect(result, equals(true));
}, skip: false);
test('allergic to peanuts and something else', () {
final result = allergies.allergicTo('peanuts', 7);
expect(result, equals(true));
}, skip: false);
test('allergic to something, but not peanuts', () {
final result = allergies.allergicTo('peanuts', 5);
expect(result, equals(false));
}, skip: false);
test('allergic to everything', () {
final result = allergies.allergicTo('peanuts', 255);
expect(result, equals(true));
}, skip: false);
}
void testingForShellfishAllergy() {
test('not allergic to anything', () {
final result = allergies.allergicTo('shellfish', 0);
expect(result, equals(false));
}, skip: false);
test('allergic only to shellfish', () {
final result = allergies.allergicTo('shellfish', 4);
expect(result, equals(true));
}, skip: false);
test('allergic to shellfish and something else', () {
final result = allergies.allergicTo('shellfish', 14);
expect(result, equals(true));
}, skip: false);
test('allergic to something, but not shellfish', () {
final result = allergies.allergicTo('shellfish', 10);
expect(result, equals(false));
}, skip: false);
test('allergic to everything', () {
final result = allergies.allergicTo('shellfish', 255);
expect(result, equals(true));
}, skip: false);
}
void testingForStrawberriesAllergy() {
test('not allergic to anything', () {
final result = allergies.allergicTo('strawberries', 0);
expect(result, equals(false));
}, skip: false);
test('allergic only to strawberries', () {
final result = allergies.allergicTo('strawberries', 8);
expect(result, equals(true));
}, skip: false);
test('allergic to strawberries and something else', () {
final result = allergies.allergicTo('strawberries', 28);
expect(result, equals(true));
}, skip: false);
test('allergic to something, but not strawberries', () {
final result = allergies.allergicTo('strawberries', 20);
expect(result, equals(false));
}, skip: false);
test('allergic to everything', () {
final result = allergies.allergicTo('strawberries', 255);
expect(result, equals(true));
}, skip: false);
}
void testingForTomatoesAllergy() {
test('not allergic to anything', () {
final result = allergies.allergicTo('tomatoes', 0);
expect(result, equals(false));
}, skip: false);
test('allergic only to tomatoes', () {
final result = allergies.allergicTo('tomatoes', 16);
expect(result, equals(true));
}, skip: false);
test('allergic to tomatoes and something else', () {
final result = allergies.allergicTo('tomatoes', 56);
expect(result, equals(true));
}, skip: false);
test('allergic to something, but not tomatoes', () {
final result = allergies.allergicTo('tomatoes', 40);
expect(result, equals(false));
}, skip: false);
test('allergic to everything', () {
final result = allergies.allergicTo('tomatoes', 255);
expect(result, equals(true));
}, skip: false);
}
void testingForChocolateAllergy() {
test('not allergic to anything', () {
final result = allergies.allergicTo('chocolate', 0);
expect(result, equals(false));
}, skip: false);
test('allergic only to chocolate', () {
final result = allergies.allergicTo('chocolate', 32);
expect(result, equals(true));
}, skip: false);
test('allergic to chocolate and something else', () {
final result = allergies.allergicTo('chocolate', 112);
expect(result, equals(true));
}, skip: false);
test('allergic to something, but not chocolate', () {
final result = allergies.allergicTo('chocolate', 80);
expect(result, equals(false));
}, skip: false);
test('allergic to everything', () {
final result = allergies.allergicTo('chocolate', 255);
expect(result, equals(true));
}, skip: false);
}
void testingForPollenAllergy() {
test('not allergic to anything', () {
final result = allergies.allergicTo('pollen', 0);
expect(result, equals(false));
}, skip: false);
test('allergic only to pollen', () {
final result = allergies.allergicTo('pollen', 64);
expect(result, equals(true));
}, skip: false);
test('allergic to pollen and something else', () {
final result = allergies.allergicTo('pollen', 224);
expect(result, equals(true));
}, skip: false);
test('allergic to something, but not pollen', () {
final result = allergies.allergicTo('pollen', 160);
expect(result, equals(false));
}, skip: false);
test('allergic to everything', () {
final result = allergies.allergicTo('pollen', 255);
expect(result, equals(true));
}, skip: false);
}
void testingForCatsAllergy() {
test('not allergic to anything', () {
final result = allergies.allergicTo('cats', 0);
expect(result, equals(false));
}, skip: false);
test('allergic only to cats', () {
final result = allergies.allergicTo('cats', 128);
expect(result, equals(true));
}, skip: false);
test('allergic to cats and something else', () {
final result = allergies.allergicTo('cats', 192);
expect(result, equals(true));
}, skip: false);
test('allergic to something, but not cats', () {
final result = allergies.allergicTo('cats', 64);
expect(result, equals(false));
}, skip: false);
test('allergic to everything', () {
final result = allergies.allergicTo('cats', 255);
expect(result, equals(true));
}, skip: false);
}
void listWhen() {
test('no allergies', () {
final result = allergies.list(0);
expect(result, equals(<String>[]));
}, skip: false);
test('just eggs', () {
final result = allergies.list(1);
expect(result, equals(<String>['eggs']));
}, skip: false);
test('just peanuts', () {
final result = allergies.list(2);
expect(result, equals(<String>['peanuts']));
}, skip: false);
test('just strawberries', () {
final result = allergies.list(8);
expect(result, equals(<String>['strawberries']));
}, skip: false);
test('eggs and peanuts', () {
final result = allergies.list(3);
expect(result, equals(<String>['eggs', 'peanuts']));
}, skip: false);
test('more than eggs but not peanuts', () {
final result = allergies.list(5);
expect(result, equals(<String>['eggs', 'shellfish']));
}, skip: false);
test('lots of stuff', () {
final result = allergies.list(248);
expect(
result,
equals(<String>[
'strawberries',
'tomatoes',
'chocolate',
'pollen',
'cats'
]));
}, skip: false);
test('everything', () {
final result = allergies.list(255);
expect(
result,
equals(<String>[
'eggs',
'peanuts',
'shellfish',
'strawberries',
'tomatoes',
'chocolate',
'pollen',
'cats'
]));
}, skip: false);
test('no allergen score parts', () {
final result = allergies.list(509);
expect(
result,
equals(<String>[
'eggs',
'shellfish',
'strawberries',
'tomatoes',
'chocolate',
'pollen',
'cats'
]));
}, skip: false);
test('no allergen score parts without highest valid score', () {
final result = allergies.list(257);
expect(result, equals(<String>['eggs']));
}, skip: false);
}

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-65.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.3.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.6.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.11.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.8",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.8",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-12.0.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "anagram",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-10-17T20:35:38.494286Z",
"generator": "pub",
"generatorVersion": "3.1.3"
}

View File

@ -0,0 +1,22 @@
{
"authors": [
"Stargator"
],
"contributors": [
"kytrinyx"
],
"files": {
"solution": [
"lib/anagram.dart"
],
"test": [
"test/anagram_test.dart"
],
"example": [
".meta/lib/example.dart"
]
},
"blurb": "Given a word and a list of possible anagrams, select the correct sublist.",
"source": "Inspired by the Extreme Startup game",
"source_url": "https://github.com/rchatley/extreme_startup"
}

View File

@ -0,0 +1 @@
{"track":"dart","exercise":"anagram","id":"ca4731cfe77c441f9bd99d4dd06c3501","url":"https://exercism.org/tracks/dart/exercises/anagram","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false}

38
anagram/HELP.md Normal file
View File

@ -0,0 +1,38 @@
# Help
## Running the tests
To run the tests:
```sh
$ dart test
```
## Submitting your solution
You can submit your solution using the `exercism submit lib/anagram.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

32
anagram/README.md Normal file
View File

@ -0,0 +1,32 @@
# Anagram
Welcome to Anagram on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`.
A word is not its own anagram: for example, `"stop"` is not an anagram of `"stop"`.
Given a target word and a set of candidate words, this exercise requests the anagram set: the subset of the candidates that are anagrams of the target.
The target and candidates are words of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`).
Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `StoP` is not an anagram of `sTOp`.
The anagram set is the subset of the candidate set that are anagrams of the target (in any order).
Words in the anagram set should have the same letter case as in the candidate set.
Given the target `"stone"` and candidates `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, `"Seton"`, the anagram set is `"tones"`, `"notes"`, `"Seton"`.
## Source
### Created by
- @Stargator
### Contributed to by
- @kytrinyx
### Based on
Inspired by the Extreme Startup game - https://github.com/rchatley/extreme_startup

View File

@ -0,0 +1,21 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps
# Style rules
- directives_ordering

21
anagram/lib/anagram.dart Normal file
View File

@ -0,0 +1,21 @@
class Anagram {
List<String> findAnagrams(String anagram, List<String> checkList) {
List<String> anagrams = [];
List<String> chars = anagram.toLowerCase().split('');
for (final word in checkList) {
if (word.length != anagram.length ||
word.toLowerCase() == anagram.toLowerCase()) {
continue;
}
final wordChars = word.toLowerCase().split('');
if (wordChars.every((char) => chars.remove(char))) {
anagrams.add(word);
chars = anagram.toLowerCase().split('');
}
}
return anagrams;
}
}

365
anagram/pubspec.lock Normal file
View File

@ -0,0 +1,365 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
url: "https://pub.dev"
source: hosted
version: "65.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
url: "https://pub.dev"
source: hosted
version: "6.3.0"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb"
url: "https://pub.dev"
source: hosted
version: "1.6.4"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.11.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: d983a57c33dde6d44b1fb8635f67c91f4b41d26cf227c147963affa97d63563d
url: "https://pub.dev"
source: hosted
version: "1.24.8"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: "2f866bf4b20c11327ac166ee6036bddafb7fe9e35505ff8324f788e66913f967"
url: "https://pub.dev"
source: hosted
version: "0.5.8"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: a13d5503b4facefc515c8c587ce3cf69577a7b064a9f1220e005449cf1f64aad
url: "https://pub.dev"
source: hosted
version: "12.0.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"

5
anagram/pubspec.yaml Normal file
View File

@ -0,0 +1,5 @@
name: 'anagram'
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
test: '<2.0.0'

View File

@ -0,0 +1,89 @@
import 'package:anagram/anagram.dart';
import 'package:test/test.dart';
final anagram = Anagram();
void main() {
group('Anagram', () {
test('no matches', () {
final result = anagram.findAnagrams('diaper', <String>['hello', 'world', 'zombies', 'pants']);
expect(result, equals(<String>[]));
}, skip: false);
test('detects two anagrams', () {
final result = anagram.findAnagrams('solemn', <String>['lemons', 'cherry', 'melons']);
expect(result, equals(<String>['lemons', 'melons']));
}, skip: true);
test('does not detect anagram subsets', () {
final result = anagram.findAnagrams('good', <String>['dog', 'goody']);
expect(result, equals(<String>[]));
}, skip: true);
test('detects anagram', () {
final result = anagram.findAnagrams('listen', <String>['enlists', 'google', 'inlets', 'banana']);
expect(result, equals(<String>['inlets']));
}, skip: true);
test('detects three anagrams', () {
final result =
anagram.findAnagrams('allergy', <String>['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']);
expect(result, equals(<String>['gallery', 'regally', 'largely']));
}, skip: true);
test('detects multiple anagrams with different case', () {
final result = anagram.findAnagrams('nose', <String>['Eons', 'ONES']);
expect(result, equals(<String>['Eons', 'ONES']));
}, skip: true);
test('does not detect non-anagrams with identical checksum', () {
final result = anagram.findAnagrams('mass', <String>['last']);
expect(result, equals(<String>[]));
}, skip: true);
test('detects anagrams case-insensitively', () {
final result = anagram.findAnagrams('Orchestra', <String>['cashregister', 'Carthorse', 'radishes']);
expect(result, equals(<String>['Carthorse']));
}, skip: true);
test('detects anagrams using case-insensitive subject', () {
final result = anagram.findAnagrams('Orchestra', <String>['cashregister', 'carthorse', 'radishes']);
expect(result, equals(<String>['carthorse']));
}, skip: true);
test('detects anagrams using case-insensitive possible matches', () {
final result = anagram.findAnagrams('orchestra', <String>['cashregister', 'Carthorse', 'radishes']);
expect(result, equals(<String>['Carthorse']));
}, skip: true);
test('does not detect an anagram if the original word is repeated', () {
final result = anagram.findAnagrams('go', <String>['go Go GO']);
expect(result, equals(<String>[]));
}, skip: true);
test('anagrams must use all letters exactly once', () {
final result = anagram.findAnagrams('tapper', <String>['patter']);
expect(result, equals(<String>[]));
}, skip: true);
test('words are not anagrams of themselves', () {
final result = anagram.findAnagrams('BANANA', <String>['BANANA']);
expect(result, equals(<String>[]));
}, skip: true);
test('words are not anagrams of themselves even if letter case is partially different', () {
final result = anagram.findAnagrams('BANANA', <String>['Banana']);
expect(result, equals(<String>[]));
}, skip: true);
test('words are not anagrams of themselves even if letter case is completely different', () {
final result = anagram.findAnagrams('BANANA', <String>['banana']);
expect(result, equals(<String>[]));
}, skip: true);
test('words other than themselves can be anagrams', () {
final result = anagram.findAnagrams('LISTEN', <String>['LISTEN', 'Silent']);
expect(result, equals(<String>['Silent']));
}, skip: true);
});
}

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-64.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.2.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.6.3",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.6",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.6",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-11.10.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "armstrong_numbers",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-09-28T18:35:17.919861Z",
"generator": "pub",
"generatorVersion": "3.1.3"
}

View File

@ -0,0 +1,23 @@
{
"authors": [
"Stargator"
],
"contributors": [
"amscotti",
"kytrinyx"
],
"files": {
"solution": [
"lib/armstrong_numbers.dart"
],
"test": [
"test/armstrong_numbers_test.dart"
],
"example": [
".meta/lib/example.dart"
]
},
"blurb": "Determine if a number is an Armstrong number.",
"source": "Wikipedia",
"source_url": "https://en.wikipedia.org/wiki/Narcissistic_number"
}

View File

@ -0,0 +1 @@
{"track":"dart","exercise":"armstrong-numbers","id":"57e3463640274723a9d154d6803c5c2d","url":"https://exercism.org/tracks/dart/exercises/armstrong-numbers","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false}

38
armstrong-numbers/HELP.md Normal file
View File

@ -0,0 +1,38 @@
# Help
## Running the tests
To run the tests:
```sh
$ dart test
```
## Submitting your solution
You can submit your solution using the `exercism submit lib/armstrong_numbers.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

View File

@ -0,0 +1,34 @@
# Armstrong Numbers
Welcome to Armstrong Numbers on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits.
For example:
- 9 is an Armstrong number, because `9 = 9^1 = 9`
- 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 1`
- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
- 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`
Write some code to determine whether a number is an Armstrong number.
[armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number
## Source
### Created by
- @Stargator
### Contributed to by
- @amscotti
- @kytrinyx
### Based on
Wikipedia - https://en.wikipedia.org/wiki/Narcissistic_number

View File

@ -0,0 +1,18 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps

View File

@ -0,0 +1,9 @@
class ArmstrongNumbers {
bool isArmstrongNumber(String number) {
BigInt armstrong = BigInt.from(0);
for (int i = 0; i < number.length; i++) {
armstrong += BigInt.parse(number[i]).pow(number.length);
}
return armstrong == BigInt.parse(number);
}
}

View File

@ -0,0 +1,365 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
url: "https://pub.dev"
source: hosted
version: "64.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
url: "https://pub.dev"
source: hosted
version: "6.2.0"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097"
url: "https://pub.dev"
source: hosted
version: "1.6.3"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.10.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9"
url: "https://pub.dev"
source: hosted
version: "1.24.6"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265"
url: "https://pub.dev"
source: hosted
version: "0.5.6"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
url: "https://pub.dev"
source: hosted
version: "11.10.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"

View File

@ -0,0 +1,5 @@
name: 'armstrong_numbers'
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
test: '<2.0.0'

View File

@ -0,0 +1,65 @@
import 'package:armstrong_numbers/armstrong_numbers.dart';
import 'package:test/test.dart';
void main() {
final armstrongNumbers = ArmstrongNumbers();
group('ArmstrongNumbers', () {
test('Zero is an Armstrong number', () {
final result = armstrongNumbers.isArmstrongNumber('0');
expect(result, equals(true));
}, skip: false);
test('Single-digit numbers are Armstrong numbers', () {
final result = armstrongNumbers.isArmstrongNumber('5');
expect(result, equals(true));
}, skip: false);
test('There are no two-digit Armstrong numbers', () {
final result = armstrongNumbers.isArmstrongNumber('10');
expect(result, equals(false));
}, skip: false);
test('Three-digit number that is an Armstrong number', () {
final result = armstrongNumbers.isArmstrongNumber('153');
expect(result, equals(true));
}, skip: false);
test('Three-digit number that is not an Armstrong number', () {
final result = armstrongNumbers.isArmstrongNumber('100');
expect(result, equals(false));
}, skip: false);
test('Four-digit number that is an Armstrong number', () {
final result = armstrongNumbers.isArmstrongNumber('9474');
expect(result, equals(true));
}, skip: false);
test('Four-digit number that is not an Armstrong number', () {
final result = armstrongNumbers.isArmstrongNumber('9475');
expect(result, equals(false));
}, skip: false);
test('Seven-digit number that is an Armstrong number', () {
final result = armstrongNumbers.isArmstrongNumber('9926315');
expect(result, equals(true));
}, skip: false);
test('Seven-digit number that is not an Armstrong number', () {
final result = armstrongNumbers.isArmstrongNumber('9926314');
expect(result, equals(false));
}, skip: false);
test('Armstrong number containing seven zeroes', () {
final result = armstrongNumbers
.isArmstrongNumber('186709961001538790100634132976990');
expect(result, equals(true));
}, skip: false);
test('The largest and last Armstrong number', () {
final result = armstrongNumbers
.isArmstrongNumber('115132219018763992565095597973971522401');
expect(result, equals(true));
}, skip: false);
});
}

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-65.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.3.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.7.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.11.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.9",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.9",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-13.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "beer_song",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-11-01T16:03:59.779304Z",
"generator": "pub",
"generatorVersion": "3.1.5"
}

View File

@ -0,0 +1,19 @@
{
"authors": [
"Zureka"
],
"files": {
"solution": [
"lib/beer_song.dart"
],
"test": [
"test/beer_song_test.dart"
],
"example": [
".meta/lib/example.dart"
]
},
"blurb": "Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.",
"source": "Learn to Program by Chris Pine",
"source_url": "https://pine.fm/LearnToProgram/?Chapter=06"
}

View File

@ -0,0 +1 @@
{"track":"dart","exercise":"beer-song","id":"83d34b28216c41ce9dec1888e536075b","url":"https://exercism.org/tracks/dart/exercises/beer-song","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false}

38
beer-song/HELP.md Normal file
View File

@ -0,0 +1,38 @@
# Help
## Running the tests
To run the tests:
```sh
$ dart test
```
## Submitting your solution
You can submit your solution using the `exercism submit lib/beer_song.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

322
beer-song/README.md Normal file
View File

@ -0,0 +1,322 @@
# Beer Song
Welcome to Beer Song on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
Recite the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.
Note that not all verses are identical.
```text
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.
96 bottles of beer on the wall, 96 bottles of beer.
Take one down and pass it around, 95 bottles of beer on the wall.
95 bottles of beer on the wall, 95 bottles of beer.
Take one down and pass it around, 94 bottles of beer on the wall.
94 bottles of beer on the wall, 94 bottles of beer.
Take one down and pass it around, 93 bottles of beer on the wall.
93 bottles of beer on the wall, 93 bottles of beer.
Take one down and pass it around, 92 bottles of beer on the wall.
92 bottles of beer on the wall, 92 bottles of beer.
Take one down and pass it around, 91 bottles of beer on the wall.
91 bottles of beer on the wall, 91 bottles of beer.
Take one down and pass it around, 90 bottles of beer on the wall.
90 bottles of beer on the wall, 90 bottles of beer.
Take one down and pass it around, 89 bottles of beer on the wall.
89 bottles of beer on the wall, 89 bottles of beer.
Take one down and pass it around, 88 bottles of beer on the wall.
88 bottles of beer on the wall, 88 bottles of beer.
Take one down and pass it around, 87 bottles of beer on the wall.
87 bottles of beer on the wall, 87 bottles of beer.
Take one down and pass it around, 86 bottles of beer on the wall.
86 bottles of beer on the wall, 86 bottles of beer.
Take one down and pass it around, 85 bottles of beer on the wall.
85 bottles of beer on the wall, 85 bottles of beer.
Take one down and pass it around, 84 bottles of beer on the wall.
84 bottles of beer on the wall, 84 bottles of beer.
Take one down and pass it around, 83 bottles of beer on the wall.
83 bottles of beer on the wall, 83 bottles of beer.
Take one down and pass it around, 82 bottles of beer on the wall.
82 bottles of beer on the wall, 82 bottles of beer.
Take one down and pass it around, 81 bottles of beer on the wall.
81 bottles of beer on the wall, 81 bottles of beer.
Take one down and pass it around, 80 bottles of beer on the wall.
80 bottles of beer on the wall, 80 bottles of beer.
Take one down and pass it around, 79 bottles of beer on the wall.
79 bottles of beer on the wall, 79 bottles of beer.
Take one down and pass it around, 78 bottles of beer on the wall.
78 bottles of beer on the wall, 78 bottles of beer.
Take one down and pass it around, 77 bottles of beer on the wall.
77 bottles of beer on the wall, 77 bottles of beer.
Take one down and pass it around, 76 bottles of beer on the wall.
76 bottles of beer on the wall, 76 bottles of beer.
Take one down and pass it around, 75 bottles of beer on the wall.
75 bottles of beer on the wall, 75 bottles of beer.
Take one down and pass it around, 74 bottles of beer on the wall.
74 bottles of beer on the wall, 74 bottles of beer.
Take one down and pass it around, 73 bottles of beer on the wall.
73 bottles of beer on the wall, 73 bottles of beer.
Take one down and pass it around, 72 bottles of beer on the wall.
72 bottles of beer on the wall, 72 bottles of beer.
Take one down and pass it around, 71 bottles of beer on the wall.
71 bottles of beer on the wall, 71 bottles of beer.
Take one down and pass it around, 70 bottles of beer on the wall.
70 bottles of beer on the wall, 70 bottles of beer.
Take one down and pass it around, 69 bottles of beer on the wall.
69 bottles of beer on the wall, 69 bottles of beer.
Take one down and pass it around, 68 bottles of beer on the wall.
68 bottles of beer on the wall, 68 bottles of beer.
Take one down and pass it around, 67 bottles of beer on the wall.
67 bottles of beer on the wall, 67 bottles of beer.
Take one down and pass it around, 66 bottles of beer on the wall.
66 bottles of beer on the wall, 66 bottles of beer.
Take one down and pass it around, 65 bottles of beer on the wall.
65 bottles of beer on the wall, 65 bottles of beer.
Take one down and pass it around, 64 bottles of beer on the wall.
64 bottles of beer on the wall, 64 bottles of beer.
Take one down and pass it around, 63 bottles of beer on the wall.
63 bottles of beer on the wall, 63 bottles of beer.
Take one down and pass it around, 62 bottles of beer on the wall.
62 bottles of beer on the wall, 62 bottles of beer.
Take one down and pass it around, 61 bottles of beer on the wall.
61 bottles of beer on the wall, 61 bottles of beer.
Take one down and pass it around, 60 bottles of beer on the wall.
60 bottles of beer on the wall, 60 bottles of beer.
Take one down and pass it around, 59 bottles of beer on the wall.
59 bottles of beer on the wall, 59 bottles of beer.
Take one down and pass it around, 58 bottles of beer on the wall.
58 bottles of beer on the wall, 58 bottles of beer.
Take one down and pass it around, 57 bottles of beer on the wall.
57 bottles of beer on the wall, 57 bottles of beer.
Take one down and pass it around, 56 bottles of beer on the wall.
56 bottles of beer on the wall, 56 bottles of beer.
Take one down and pass it around, 55 bottles of beer on the wall.
55 bottles of beer on the wall, 55 bottles of beer.
Take one down and pass it around, 54 bottles of beer on the wall.
54 bottles of beer on the wall, 54 bottles of beer.
Take one down and pass it around, 53 bottles of beer on the wall.
53 bottles of beer on the wall, 53 bottles of beer.
Take one down and pass it around, 52 bottles of beer on the wall.
52 bottles of beer on the wall, 52 bottles of beer.
Take one down and pass it around, 51 bottles of beer on the wall.
51 bottles of beer on the wall, 51 bottles of beer.
Take one down and pass it around, 50 bottles of beer on the wall.
50 bottles of beer on the wall, 50 bottles of beer.
Take one down and pass it around, 49 bottles of beer on the wall.
49 bottles of beer on the wall, 49 bottles of beer.
Take one down and pass it around, 48 bottles of beer on the wall.
48 bottles of beer on the wall, 48 bottles of beer.
Take one down and pass it around, 47 bottles of beer on the wall.
47 bottles of beer on the wall, 47 bottles of beer.
Take one down and pass it around, 46 bottles of beer on the wall.
46 bottles of beer on the wall, 46 bottles of beer.
Take one down and pass it around, 45 bottles of beer on the wall.
45 bottles of beer on the wall, 45 bottles of beer.
Take one down and pass it around, 44 bottles of beer on the wall.
44 bottles of beer on the wall, 44 bottles of beer.
Take one down and pass it around, 43 bottles of beer on the wall.
43 bottles of beer on the wall, 43 bottles of beer.
Take one down and pass it around, 42 bottles of beer on the wall.
42 bottles of beer on the wall, 42 bottles of beer.
Take one down and pass it around, 41 bottles of beer on the wall.
41 bottles of beer on the wall, 41 bottles of beer.
Take one down and pass it around, 40 bottles of beer on the wall.
40 bottles of beer on the wall, 40 bottles of beer.
Take one down and pass it around, 39 bottles of beer on the wall.
39 bottles of beer on the wall, 39 bottles of beer.
Take one down and pass it around, 38 bottles of beer on the wall.
38 bottles of beer on the wall, 38 bottles of beer.
Take one down and pass it around, 37 bottles of beer on the wall.
37 bottles of beer on the wall, 37 bottles of beer.
Take one down and pass it around, 36 bottles of beer on the wall.
36 bottles of beer on the wall, 36 bottles of beer.
Take one down and pass it around, 35 bottles of beer on the wall.
35 bottles of beer on the wall, 35 bottles of beer.
Take one down and pass it around, 34 bottles of beer on the wall.
34 bottles of beer on the wall, 34 bottles of beer.
Take one down and pass it around, 33 bottles of beer on the wall.
33 bottles of beer on the wall, 33 bottles of beer.
Take one down and pass it around, 32 bottles of beer on the wall.
32 bottles of beer on the wall, 32 bottles of beer.
Take one down and pass it around, 31 bottles of beer on the wall.
31 bottles of beer on the wall, 31 bottles of beer.
Take one down and pass it around, 30 bottles of beer on the wall.
30 bottles of beer on the wall, 30 bottles of beer.
Take one down and pass it around, 29 bottles of beer on the wall.
29 bottles of beer on the wall, 29 bottles of beer.
Take one down and pass it around, 28 bottles of beer on the wall.
28 bottles of beer on the wall, 28 bottles of beer.
Take one down and pass it around, 27 bottles of beer on the wall.
27 bottles of beer on the wall, 27 bottles of beer.
Take one down and pass it around, 26 bottles of beer on the wall.
26 bottles of beer on the wall, 26 bottles of beer.
Take one down and pass it around, 25 bottles of beer on the wall.
25 bottles of beer on the wall, 25 bottles of beer.
Take one down and pass it around, 24 bottles of beer on the wall.
24 bottles of beer on the wall, 24 bottles of beer.
Take one down and pass it around, 23 bottles of beer on the wall.
23 bottles of beer on the wall, 23 bottles of beer.
Take one down and pass it around, 22 bottles of beer on the wall.
22 bottles of beer on the wall, 22 bottles of beer.
Take one down and pass it around, 21 bottles of beer on the wall.
21 bottles of beer on the wall, 21 bottles of beer.
Take one down and pass it around, 20 bottles of beer on the wall.
20 bottles of beer on the wall, 20 bottles of beer.
Take one down and pass it around, 19 bottles of beer on the wall.
19 bottles of beer on the wall, 19 bottles of beer.
Take one down and pass it around, 18 bottles of beer on the wall.
18 bottles of beer on the wall, 18 bottles of beer.
Take one down and pass it around, 17 bottles of beer on the wall.
17 bottles of beer on the wall, 17 bottles of beer.
Take one down and pass it around, 16 bottles of beer on the wall.
16 bottles of beer on the wall, 16 bottles of beer.
Take one down and pass it around, 15 bottles of beer on the wall.
15 bottles of beer on the wall, 15 bottles of beer.
Take one down and pass it around, 14 bottles of beer on the wall.
14 bottles of beer on the wall, 14 bottles of beer.
Take one down and pass it around, 13 bottles of beer on the wall.
13 bottles of beer on the wall, 13 bottles of beer.
Take one down and pass it around, 12 bottles of beer on the wall.
12 bottles of beer on the wall, 12 bottles of beer.
Take one down and pass it around, 11 bottles of beer on the wall.
11 bottles of beer on the wall, 11 bottles of beer.
Take one down and pass it around, 10 bottles of beer on the wall.
10 bottles of beer on the wall, 10 bottles of beer.
Take one down and pass it around, 9 bottles of beer on the wall.
9 bottles of beer on the wall, 9 bottles of beer.
Take one down and pass it around, 8 bottles of beer on the wall.
8 bottles of beer on the wall, 8 bottles of beer.
Take one down and pass it around, 7 bottles of beer on the wall.
7 bottles of beer on the wall, 7 bottles of beer.
Take one down and pass it around, 6 bottles of beer on the wall.
6 bottles of beer on the wall, 6 bottles of beer.
Take one down and pass it around, 5 bottles of beer on the wall.
5 bottles of beer on the wall, 5 bottles of beer.
Take one down and pass it around, 4 bottles of beer on the wall.
4 bottles of beer on the wall, 4 bottles of beer.
Take one down and pass it around, 3 bottles of beer on the wall.
3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
1 bottle of beer on the wall, 1 bottle of beer.
Take it down and pass it around, no more bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
```
## Source
### Created by
- @Zureka
### Based on
Learn to Program by Chris Pine - https://pine.fm/LearnToProgram/?Chapter=06

View File

@ -0,0 +1,18 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps

View File

@ -0,0 +1,23 @@
class BeerSong {
List<String> recite(int amountOfBeers, int amountOfVerses) {
if (amountOfVerses == 0) return [];
if (amountOfBeers == 0)
return [
'No more bottles of beer on the wall, no more bottles of beer.',
'Go to the store and buy some more, 99 bottles of beer on the wall.',
];
if (amountOfBeers == 1)
return [
'1 bottle of beer on the wall, 1 bottle of beer.',
'Take it down and pass it around, no more bottles of beer on the wall.',
if (amountOfVerses > 1) '',
] +
recite(amountOfBeers - 1, amountOfVerses - 1);
return [
'$amountOfBeers bottles of beer on the wall, $amountOfBeers bottles of beer.',
'Take one down and pass it around, ${(amountOfBeers - 1 == 1) ? '1 bottle' : '${amountOfBeers - 1} bottles'} of beer on the wall.',
if (amountOfVerses > 1) ''
] +
recite(amountOfBeers - 1, amountOfVerses - 1);
}
}

365
beer-song/pubspec.lock Normal file
View File

@ -0,0 +1,365 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
url: "https://pub.dev"
source: hosted
version: "65.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
url: "https://pub.dev"
source: hosted
version: "6.3.0"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
url: "https://pub.dev"
source: hosted
version: "1.7.1"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.11.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f
url: "https://pub.dev"
source: hosted
version: "1.24.9"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a
url: "https://pub.dev"
source: hosted
version: "0.5.9"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"

5
beer-song/pubspec.yaml Normal file
View File

@ -0,0 +1,5 @@
name: 'beer_song'
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
test: '<2.0.0'

View File

@ -0,0 +1,402 @@
import 'package:beer_song/beer_song.dart';
import 'package:test/test.dart';
void main() {
final beerSong = BeerSong();
group('BeerSong', () {
group('verse', () {
group('single verse', () {
test('first generic verse', () {
final result = beerSong.recite(99, 1);
expect(
result,
equals(<String>[
'99 bottles of beer on the wall, 99 bottles of beer.',
'Take one down and pass it around, 98 bottles of beer on the wall.'
]));
}, skip: false);
test('last generic verse', () {
final result = beerSong.recite(3, 1);
expect(
result,
equals(<String>[
'3 bottles of beer on the wall, 3 bottles of beer.',
'Take one down and pass it around, 2 bottles of beer on the wall.'
]));
}, skip: true);
test('verse with 2 bottles', () {
final result = beerSong.recite(2, 1);
expect(
result,
equals(<String>[
'2 bottles of beer on the wall, 2 bottles of beer.',
'Take one down and pass it around, 1 bottle of beer on the wall.'
]));
}, skip: true);
test('verse with 1 bottle', () {
final result = beerSong.recite(1, 1);
expect(
result,
equals(<String>[
'1 bottle of beer on the wall, 1 bottle of beer.',
'Take it down and pass it around, no more bottles of beer on the wall.'
]));
}, skip: true);
test('verse with 0 bottles', () {
final result = beerSong.recite(0, 1);
expect(
result,
equals(<String>[
'No more bottles of beer on the wall, no more bottles of beer.',
'Go to the store and buy some more, 99 bottles of beer on the wall.'
]));
}, skip: true);
});
});
group('lyrics', () {
group('multiple verses', () {
test('first two verses', () {
final result = beerSong.recite(99, 2);
expect(
result,
equals(<String>[
'99 bottles of beer on the wall, 99 bottles of beer.',
'Take one down and pass it around, 98 bottles of beer on the wall.',
'',
'98 bottles of beer on the wall, 98 bottles of beer.',
'Take one down and pass it around, 97 bottles of beer on the wall.'
]));
}, skip: true);
test('last three verses', () {
final result = beerSong.recite(2, 3);
expect(
result,
equals(<String>[
'2 bottles of beer on the wall, 2 bottles of beer.',
'Take one down and pass it around, 1 bottle of beer on the wall.',
'',
'1 bottle of beer on the wall, 1 bottle of beer.',
'Take it down and pass it around, no more bottles of beer on the wall.',
'',
'No more bottles of beer on the wall, no more bottles of beer.',
'Go to the store and buy some more, 99 bottles of beer on the wall.'
]));
}, skip: true);
test('all verses', () {
final result = beerSong.recite(99, 100);
expect(
result,
equals(<String>[
'99 bottles of beer on the wall, 99 bottles of beer.',
'Take one down and pass it around, 98 bottles of beer on the wall.',
'',
'98 bottles of beer on the wall, 98 bottles of beer.',
'Take one down and pass it around, 97 bottles of beer on the wall.',
'',
'97 bottles of beer on the wall, 97 bottles of beer.',
'Take one down and pass it around, 96 bottles of beer on the wall.',
'',
'96 bottles of beer on the wall, 96 bottles of beer.',
'Take one down and pass it around, 95 bottles of beer on the wall.',
'',
'95 bottles of beer on the wall, 95 bottles of beer.',
'Take one down and pass it around, 94 bottles of beer on the wall.',
'',
'94 bottles of beer on the wall, 94 bottles of beer.',
'Take one down and pass it around, 93 bottles of beer on the wall.',
'',
'93 bottles of beer on the wall, 93 bottles of beer.',
'Take one down and pass it around, 92 bottles of beer on the wall.',
'',
'92 bottles of beer on the wall, 92 bottles of beer.',
'Take one down and pass it around, 91 bottles of beer on the wall.',
'',
'91 bottles of beer on the wall, 91 bottles of beer.',
'Take one down and pass it around, 90 bottles of beer on the wall.',
'',
'90 bottles of beer on the wall, 90 bottles of beer.',
'Take one down and pass it around, 89 bottles of beer on the wall.',
'',
'89 bottles of beer on the wall, 89 bottles of beer.',
'Take one down and pass it around, 88 bottles of beer on the wall.',
'',
'88 bottles of beer on the wall, 88 bottles of beer.',
'Take one down and pass it around, 87 bottles of beer on the wall.',
'',
'87 bottles of beer on the wall, 87 bottles of beer.',
'Take one down and pass it around, 86 bottles of beer on the wall.',
'',
'86 bottles of beer on the wall, 86 bottles of beer.',
'Take one down and pass it around, 85 bottles of beer on the wall.',
'',
'85 bottles of beer on the wall, 85 bottles of beer.',
'Take one down and pass it around, 84 bottles of beer on the wall.',
'',
'84 bottles of beer on the wall, 84 bottles of beer.',
'Take one down and pass it around, 83 bottles of beer on the wall.',
'',
'83 bottles of beer on the wall, 83 bottles of beer.',
'Take one down and pass it around, 82 bottles of beer on the wall.',
'',
'82 bottles of beer on the wall, 82 bottles of beer.',
'Take one down and pass it around, 81 bottles of beer on the wall.',
'',
'81 bottles of beer on the wall, 81 bottles of beer.',
'Take one down and pass it around, 80 bottles of beer on the wall.',
'',
'80 bottles of beer on the wall, 80 bottles of beer.',
'Take one down and pass it around, 79 bottles of beer on the wall.',
'',
'79 bottles of beer on the wall, 79 bottles of beer.',
'Take one down and pass it around, 78 bottles of beer on the wall.',
'',
'78 bottles of beer on the wall, 78 bottles of beer.',
'Take one down and pass it around, 77 bottles of beer on the wall.',
'',
'77 bottles of beer on the wall, 77 bottles of beer.',
'Take one down and pass it around, 76 bottles of beer on the wall.',
'',
'76 bottles of beer on the wall, 76 bottles of beer.',
'Take one down and pass it around, 75 bottles of beer on the wall.',
'',
'75 bottles of beer on the wall, 75 bottles of beer.',
'Take one down and pass it around, 74 bottles of beer on the wall.',
'',
'74 bottles of beer on the wall, 74 bottles of beer.',
'Take one down and pass it around, 73 bottles of beer on the wall.',
'',
'73 bottles of beer on the wall, 73 bottles of beer.',
'Take one down and pass it around, 72 bottles of beer on the wall.',
'',
'72 bottles of beer on the wall, 72 bottles of beer.',
'Take one down and pass it around, 71 bottles of beer on the wall.',
'',
'71 bottles of beer on the wall, 71 bottles of beer.',
'Take one down and pass it around, 70 bottles of beer on the wall.',
'',
'70 bottles of beer on the wall, 70 bottles of beer.',
'Take one down and pass it around, 69 bottles of beer on the wall.',
'',
'69 bottles of beer on the wall, 69 bottles of beer.',
'Take one down and pass it around, 68 bottles of beer on the wall.',
'',
'68 bottles of beer on the wall, 68 bottles of beer.',
'Take one down and pass it around, 67 bottles of beer on the wall.',
'',
'67 bottles of beer on the wall, 67 bottles of beer.',
'Take one down and pass it around, 66 bottles of beer on the wall.',
'',
'66 bottles of beer on the wall, 66 bottles of beer.',
'Take one down and pass it around, 65 bottles of beer on the wall.',
'',
'65 bottles of beer on the wall, 65 bottles of beer.',
'Take one down and pass it around, 64 bottles of beer on the wall.',
'',
'64 bottles of beer on the wall, 64 bottles of beer.',
'Take one down and pass it around, 63 bottles of beer on the wall.',
'',
'63 bottles of beer on the wall, 63 bottles of beer.',
'Take one down and pass it around, 62 bottles of beer on the wall.',
'',
'62 bottles of beer on the wall, 62 bottles of beer.',
'Take one down and pass it around, 61 bottles of beer on the wall.',
'',
'61 bottles of beer on the wall, 61 bottles of beer.',
'Take one down and pass it around, 60 bottles of beer on the wall.',
'',
'60 bottles of beer on the wall, 60 bottles of beer.',
'Take one down and pass it around, 59 bottles of beer on the wall.',
'',
'59 bottles of beer on the wall, 59 bottles of beer.',
'Take one down and pass it around, 58 bottles of beer on the wall.',
'',
'58 bottles of beer on the wall, 58 bottles of beer.',
'Take one down and pass it around, 57 bottles of beer on the wall.',
'',
'57 bottles of beer on the wall, 57 bottles of beer.',
'Take one down and pass it around, 56 bottles of beer on the wall.',
'',
'56 bottles of beer on the wall, 56 bottles of beer.',
'Take one down and pass it around, 55 bottles of beer on the wall.',
'',
'55 bottles of beer on the wall, 55 bottles of beer.',
'Take one down and pass it around, 54 bottles of beer on the wall.',
'',
'54 bottles of beer on the wall, 54 bottles of beer.',
'Take one down and pass it around, 53 bottles of beer on the wall.',
'',
'53 bottles of beer on the wall, 53 bottles of beer.',
'Take one down and pass it around, 52 bottles of beer on the wall.',
'',
'52 bottles of beer on the wall, 52 bottles of beer.',
'Take one down and pass it around, 51 bottles of beer on the wall.',
'',
'51 bottles of beer on the wall, 51 bottles of beer.',
'Take one down and pass it around, 50 bottles of beer on the wall.',
'',
'50 bottles of beer on the wall, 50 bottles of beer.',
'Take one down and pass it around, 49 bottles of beer on the wall.',
'',
'49 bottles of beer on the wall, 49 bottles of beer.',
'Take one down and pass it around, 48 bottles of beer on the wall.',
'',
'48 bottles of beer on the wall, 48 bottles of beer.',
'Take one down and pass it around, 47 bottles of beer on the wall.',
'',
'47 bottles of beer on the wall, 47 bottles of beer.',
'Take one down and pass it around, 46 bottles of beer on the wall.',
'',
'46 bottles of beer on the wall, 46 bottles of beer.',
'Take one down and pass it around, 45 bottles of beer on the wall.',
'',
'45 bottles of beer on the wall, 45 bottles of beer.',
'Take one down and pass it around, 44 bottles of beer on the wall.',
'',
'44 bottles of beer on the wall, 44 bottles of beer.',
'Take one down and pass it around, 43 bottles of beer on the wall.',
'',
'43 bottles of beer on the wall, 43 bottles of beer.',
'Take one down and pass it around, 42 bottles of beer on the wall.',
'',
'42 bottles of beer on the wall, 42 bottles of beer.',
'Take one down and pass it around, 41 bottles of beer on the wall.',
'',
'41 bottles of beer on the wall, 41 bottles of beer.',
'Take one down and pass it around, 40 bottles of beer on the wall.',
'',
'40 bottles of beer on the wall, 40 bottles of beer.',
'Take one down and pass it around, 39 bottles of beer on the wall.',
'',
'39 bottles of beer on the wall, 39 bottles of beer.',
'Take one down and pass it around, 38 bottles of beer on the wall.',
'',
'38 bottles of beer on the wall, 38 bottles of beer.',
'Take one down and pass it around, 37 bottles of beer on the wall.',
'',
'37 bottles of beer on the wall, 37 bottles of beer.',
'Take one down and pass it around, 36 bottles of beer on the wall.',
'',
'36 bottles of beer on the wall, 36 bottles of beer.',
'Take one down and pass it around, 35 bottles of beer on the wall.',
'',
'35 bottles of beer on the wall, 35 bottles of beer.',
'Take one down and pass it around, 34 bottles of beer on the wall.',
'',
'34 bottles of beer on the wall, 34 bottles of beer.',
'Take one down and pass it around, 33 bottles of beer on the wall.',
'',
'33 bottles of beer on the wall, 33 bottles of beer.',
'Take one down and pass it around, 32 bottles of beer on the wall.',
'',
'32 bottles of beer on the wall, 32 bottles of beer.',
'Take one down and pass it around, 31 bottles of beer on the wall.',
'',
'31 bottles of beer on the wall, 31 bottles of beer.',
'Take one down and pass it around, 30 bottles of beer on the wall.',
'',
'30 bottles of beer on the wall, 30 bottles of beer.',
'Take one down and pass it around, 29 bottles of beer on the wall.',
'',
'29 bottles of beer on the wall, 29 bottles of beer.',
'Take one down and pass it around, 28 bottles of beer on the wall.',
'',
'28 bottles of beer on the wall, 28 bottles of beer.',
'Take one down and pass it around, 27 bottles of beer on the wall.',
'',
'27 bottles of beer on the wall, 27 bottles of beer.',
'Take one down and pass it around, 26 bottles of beer on the wall.',
'',
'26 bottles of beer on the wall, 26 bottles of beer.',
'Take one down and pass it around, 25 bottles of beer on the wall.',
'',
'25 bottles of beer on the wall, 25 bottles of beer.',
'Take one down and pass it around, 24 bottles of beer on the wall.',
'',
'24 bottles of beer on the wall, 24 bottles of beer.',
'Take one down and pass it around, 23 bottles of beer on the wall.',
'',
'23 bottles of beer on the wall, 23 bottles of beer.',
'Take one down and pass it around, 22 bottles of beer on the wall.',
'',
'22 bottles of beer on the wall, 22 bottles of beer.',
'Take one down and pass it around, 21 bottles of beer on the wall.',
'',
'21 bottles of beer on the wall, 21 bottles of beer.',
'Take one down and pass it around, 20 bottles of beer on the wall.',
'',
'20 bottles of beer on the wall, 20 bottles of beer.',
'Take one down and pass it around, 19 bottles of beer on the wall.',
'',
'19 bottles of beer on the wall, 19 bottles of beer.',
'Take one down and pass it around, 18 bottles of beer on the wall.',
'',
'18 bottles of beer on the wall, 18 bottles of beer.',
'Take one down and pass it around, 17 bottles of beer on the wall.',
'',
'17 bottles of beer on the wall, 17 bottles of beer.',
'Take one down and pass it around, 16 bottles of beer on the wall.',
'',
'16 bottles of beer on the wall, 16 bottles of beer.',
'Take one down and pass it around, 15 bottles of beer on the wall.',
'',
'15 bottles of beer on the wall, 15 bottles of beer.',
'Take one down and pass it around, 14 bottles of beer on the wall.',
'',
'14 bottles of beer on the wall, 14 bottles of beer.',
'Take one down and pass it around, 13 bottles of beer on the wall.',
'',
'13 bottles of beer on the wall, 13 bottles of beer.',
'Take one down and pass it around, 12 bottles of beer on the wall.',
'',
'12 bottles of beer on the wall, 12 bottles of beer.',
'Take one down and pass it around, 11 bottles of beer on the wall.',
'',
'11 bottles of beer on the wall, 11 bottles of beer.',
'Take one down and pass it around, 10 bottles of beer on the wall.',
'',
'10 bottles of beer on the wall, 10 bottles of beer.',
'Take one down and pass it around, 9 bottles of beer on the wall.',
'',
'9 bottles of beer on the wall, 9 bottles of beer.',
'Take one down and pass it around, 8 bottles of beer on the wall.',
'',
'8 bottles of beer on the wall, 8 bottles of beer.',
'Take one down and pass it around, 7 bottles of beer on the wall.',
'',
'7 bottles of beer on the wall, 7 bottles of beer.',
'Take one down and pass it around, 6 bottles of beer on the wall.',
'',
'6 bottles of beer on the wall, 6 bottles of beer.',
'Take one down and pass it around, 5 bottles of beer on the wall.',
'',
'5 bottles of beer on the wall, 5 bottles of beer.',
'Take one down and pass it around, 4 bottles of beer on the wall.',
'',
'4 bottles of beer on the wall, 4 bottles of beer.',
'Take one down and pass it around, 3 bottles of beer on the wall.',
'',
'3 bottles of beer on the wall, 3 bottles of beer.',
'Take one down and pass it around, 2 bottles of beer on the wall.',
'',
'2 bottles of beer on the wall, 2 bottles of beer.',
'Take one down and pass it around, 1 bottle of beer on the wall.',
'',
'1 bottle of beer on the wall, 1 bottle of beer.',
'Take it down and pass it around, no more bottles of beer on the wall.',
'',
'No more bottles of beer on the wall, no more bottles of beer.',
'Go to the store and buy some more, 99 bottles of beer on the wall.'
]));
}, skip: true);
});
});
});
}

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-65.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.3.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.7.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.11.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.9",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.9",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-13.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "binary_search_tree",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-11-09T11:54:52.131756Z",
"generator": "pub",
"generatorVersion": "3.1.5"
}

View File

@ -0,0 +1,23 @@
{
"authors": [
"devkabiir"
],
"contributors": [
"amscotti",
"Stargator"
],
"files": {
"solution": [
"lib/binary_search_tree.dart"
],
"test": [
"test/binary_search_tree_test.dart"
],
"example": [
".meta/lib/example.dart"
]
},
"blurb": "Insert and search for numbers in a binary tree.",
"source": "Josh Cheek",
"source_url": "https://twitter.com/josh_cheek"
}

View File

@ -0,0 +1 @@
{"track":"dart","exercise":"binary-search-tree","id":"656291c53fb24f4eadb7299d5e5ba95d","url":"https://exercism.org/tracks/dart/exercises/binary-search-tree","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false}

View File

@ -0,0 +1,38 @@
# Help
## Running the tests
To run the tests:
```sh
$ dart test
```
## Submitting your solution
You can submit your solution using the `exercism submit lib/binary_search_tree.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

View File

@ -0,0 +1,67 @@
# Binary Search Tree
Welcome to Binary Search Tree on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
Insert and search for numbers in a binary tree.
When we need to represent sorted data, an array does not make a good data structure.
Say we have the array `[1, 3, 4, 5]`, and we add 2 to it so it becomes `[1, 3, 4, 5, 2]`.
Now we must sort the entire array again!
We can improve on this by realizing that we only need to make space for the new item `[1, nil, 3, 4, 5]`, and then adding the item in the space we added.
But this still requires us to shift many elements down by one.
Binary Search Trees, however, can operate on sorted data much more efficiently.
A binary search tree consists of a series of connected nodes.
Each node contains a piece of data (e.g. the number 3), a variable named `left`, and a variable named `right`.
The `left` and `right` variables point at `nil`, or other nodes.
Since these other nodes in turn have other nodes beneath them, we say that the left and right variables are pointing at subtrees.
All data in the left subtree is less than or equal to the current node's data, and all data in the right subtree is greater than the current node's data.
For example, if we had a node containing the data 4, and we added the data 2, our tree would look like this:
4
/
2
If we then added 6, it would look like this:
4
/ \
2 6
If we then added 3, it would look like this
4
/ \
2 6
\
3
And if we then added 1, 5, and 7, it would look like this
4
/ \
/ \
2 6
/ \ / \
1 3 5 7
## Source
### Created by
- @devkabiir
### Contributed to by
- @amscotti
- @Stargator
### Based on
Josh Cheek - https://twitter.com/josh_cheek

View File

@ -0,0 +1,18 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps

View File

@ -0,0 +1,45 @@
class BinarySearchTree {
final TreeNode root;
List<String> get sortedData => _traverseInOrder(this.root);
BinarySearchTree(String rootValue) : root = TreeNode(rootValue);
void insert(String value) {
TreeNode newTreeNode = TreeNode(value);
TreeNode currentValue = root;
while (true) {
if (int.parse(value) <= int.parse(currentValue.data)) {
if (currentValue.left == null) {
currentValue.left = newTreeNode;
break;
}
currentValue = currentValue.left!;
} else {
if (currentValue.right == null) {
currentValue.right = newTreeNode;
break;
}
currentValue = currentValue.right!;
}
}
}
List<String> _traverseInOrder(TreeNode? node) {
List<String> data = [];
if (node != null) {
data.addAll(_traverseInOrder(node.left));
data.add(node.data);
data.addAll(_traverseInOrder(node.right));
}
return data;
}
}
class TreeNode {
String data;
TreeNode? left;
TreeNode? right;
TreeNode(this.data);
}

View File

@ -0,0 +1,365 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
url: "https://pub.dev"
source: hosted
version: "65.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
url: "https://pub.dev"
source: hosted
version: "6.3.0"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
url: "https://pub.dev"
source: hosted
version: "1.7.1"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.11.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f
url: "https://pub.dev"
source: hosted
version: "1.24.9"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a
url: "https://pub.dev"
source: hosted
version: "0.5.9"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"

View File

@ -0,0 +1,5 @@
name: 'binary_search_tree'
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
test: '<2.0.0'

View File

@ -0,0 +1,92 @@
import 'package:binary_search_tree/binary_search_tree.dart';
import 'package:test/test.dart';
void main() {
group('BinarySearchTree', () {
test('data is retained', () {
final bst = BinarySearchTree('4');
expect(bst.root.data, equals('4'));
}, skip: false);
group('insert data at proper node', () {
test('smaller number at left node', () {
final bst = BinarySearchTree('4')..insert('2');
expect(bst.root.data, equals('4'));
expect(bst.root.left!.data, equals('2'));
}, skip: false);
test('same number at left node', () {
final bst = BinarySearchTree('4')..insert('4');
expect(bst.root.data, equals('4'));
expect(bst.root.left!.data, equals('4'));
}, skip: false);
test('greater number at right node', () {
final bst = BinarySearchTree('4')..insert('5');
expect(bst.root.data, equals('4'));
expect(bst.root.right!.data, equals('5'));
}, skip: false);
test('can create complex tree', () {
final bst = BinarySearchTree('4')
..insert('2')
..insert("6")
..insert("1")
..insert("3")
..insert("5")
..insert("7");
expect(bst.root.data, equals('4'));
expect(bst.root.left!.data, equals('2'));
expect(bst.root.left!.left!.data, equals('1'));
expect(bst.root.left!.right!.data, equals('3'));
expect(bst.root.right!.data, equals('6'));
expect(bst.root.right!.left!.data, equals('5'));
expect(bst.root.right!.right!.data, equals('7'));
}, skip: false);
});
group('can sort data', () {
test('can sort single number', () {
final bst = BinarySearchTree('2');
expect(bst.sortedData, equals(['2']));
}, skip: false);
test('can sort if second number is smaller than first', () {
final bst = BinarySearchTree('2')..insert('1');
expect(bst.sortedData, equals(['1', '2']));
}, skip: false);
test('can sort if second number is same as first', () {
final bst = BinarySearchTree('2')..insert('2');
expect(bst.sortedData, equals(['2', '2']));
}, skip: false);
test('can sort if second number is greater than first', () {
final bst = BinarySearchTree('2')..insert('3');
expect(bst.sortedData, equals(['2', '3']));
}, skip: false);
test('can sort complex tree', () {
final bst = BinarySearchTree('2')
..insert("1")
..insert("3")
..insert("6")
..insert("7")
..insert("5");
expect(bst.sortedData, equals(['1', '2', '3', '5', '6', '7']));
}, skip: false);
});
});
}

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-65.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.3.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.6.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.11.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.7",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.7",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-12.0.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "bob",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-10-12T09:05:38.454028Z",
"generator": "pub",
"generatorVersion": "3.1.0"
}

Binary file not shown.

24
bob/.exercism/config.json Normal file
View File

@ -0,0 +1,24 @@
{
"authors": [
"SuperPaintman"
],
"contributors": [
"camuthig",
"kytrinyx",
"Stargator"
],
"files": {
"solution": [
"lib/bob.dart"
],
"test": [
"test/bob_test.dart"
],
"example": [
".meta/lib/example.dart"
]
},
"blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.",
"source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.",
"source_url": "https://pine.fm/LearnToProgram/?Chapter=06"
}

View File

@ -0,0 +1 @@
{"track":"dart","exercise":"bob","id":"2644de1cc3b04e9da508b9f93b3e15de","url":"https://exercism.org/tracks/dart/exercises/bob","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false}

38
bob/HELP.md Normal file
View File

@ -0,0 +1,38 @@
# Help
## Running the tests
To run the tests:
```sh
$ dart test
```
## Submitting your solution
You can submit your solution using the `exercism submit lib/bob.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

51
bob/README.md Normal file
View File

@ -0,0 +1,51 @@
# Bob
Welcome to Bob on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Introduction
Bob is a [lackadaisical][] teenager.
He likes to think that he's very cool.
And he definitely doesn't get excited about things.
That wouldn't be cool.
When people talk to him, his responses are pretty limited.
[lackadaisical]: https://www.collinsdictionary.com/dictionary/english/lackadaisical
## Instructions
Your task is to determine what Bob will reply to someone when they say something to him or ask him a question.
Bob only ever answers one of five things:
- **"Sure."**
This is his response if you ask him a question, such as "How are you?"
The convention used for questions is that it ends with a question mark.
- **"Whoa, chill out!"**
This is his answer if you YELL AT HIM.
The convention used for yelling is ALL CAPITAL LETTERS.
- **"Calm down, I know what I'm doing!"**
This is what he says if you yell a question at him.
- **"Fine. Be that way!"**
This is how he responds to silence.
The convention used for silence is nothing, or various combinations of whitespace characters.
- **"Whatever."**
This is what he answers to anything else.
## Source
### Created by
- @SuperPaintman
### Contributed to by
- @camuthig
- @kytrinyx
- @Stargator
### Based on
Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. - https://pine.fm/LearnToProgram/?Chapter=06

18
bob/analysis_options.yaml Normal file
View File

@ -0,0 +1,18 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps

17
bob/lib/bob.dart Normal file
View File

@ -0,0 +1,17 @@
class Bob {
String response(String input) {
if (input.isQuestion && input.isUppercase)
return "Calm down, I know what I'm doing!";
if (input.isQuestion) return "Sure.";
if (input.isUppercase) return "Whoa, chill out!";
if (input.isNothing) return "Fine. Be that way!";
return "Whatever.";
}
}
extension on String {
bool get isQuestion => this.trim().endsWith('?');
bool get isUppercase =>
this == this.toUpperCase() && this != this.toLowerCase();
bool get isNothing => this.contains('silence') || this.trim().isEmpty;
}

365
bob/pubspec.lock Normal file
View File

@ -0,0 +1,365 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
url: "https://pub.dev"
source: hosted
version: "65.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
url: "https://pub.dev"
source: hosted
version: "6.3.0"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb"
url: "https://pub.dev"
source: hosted
version: "1.6.4"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.11.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: a20ddc0723556dc6dd56094e58ec1529196d5d7774156604cb14e8445a5a82ff
url: "https://pub.dev"
source: hosted
version: "1.24.7"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: "96382d0bc826e260b077bb496259e58bc82e90b603ab16cd5ae95dfe1dfcba8b"
url: "https://pub.dev"
source: hosted
version: "0.5.7"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: a13d5503b4facefc515c8c587ce3cf69577a7b064a9f1220e005449cf1f64aad
url: "https://pub.dev"
source: hosted
version: "12.0.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"

5
bob/pubspec.yaml Normal file
View File

@ -0,0 +1,5 @@
name: 'bob'
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
test: '<2.0.0'

133
bob/test/bob_test.dart Normal file
View File

@ -0,0 +1,133 @@
import 'package:bob/bob.dart';
import 'package:test/test.dart';
void main() {
final bob = Bob();
group('Bob', () {
test('stating something', () {
final result = bob.response('Tom-ay-to, tom-aaaah-to.');
expect(result, equals('Whatever.'));
}, skip: false);
test('shouting', () {
final result = bob.response('WATCH OUT!');
expect(result, equals('Whoa, chill out!'));
}, skip: true);
test('shouting gibberish', () {
final result = bob.response('FCECDFCAAB');
expect(result, equals('Whoa, chill out!'));
}, skip: true);
test('asking a question', () {
final result = bob.response('Does this cryogenic chamber make me look fat?');
expect(result, equals('Sure.'));
}, skip: true);
test('asking a numeric question', () {
final result = bob.response('You are, what, like 15?');
expect(result, equals('Sure.'));
}, skip: true);
test('asking gibberish', () {
final result = bob.response('fffbbcbeab?');
expect(result, equals('Sure.'));
}, skip: true);
test('talking forcefully', () {
final result = bob.response('Hi there!');
expect(result, equals('Whatever.'));
}, skip: true);
test('using acronyms in regular speech', () {
final result = bob.response('It\'s OK if you don\'t want to go work for NASA.');
expect(result, equals('Whatever.'));
}, skip: true);
test('forceful question', () {
final result = bob.response('WHAT\'S GOING ON?');
expect(result, equals('Calm down, I know what I\'m doing!'));
}, skip: true);
test('shouting numbers', () {
final result = bob.response('1, 2, 3 GO!');
expect(result, equals('Whoa, chill out!'));
}, skip: true);
test('no letters', () {
final result = bob.response('1, 2, 3');
expect(result, equals('Whatever.'));
}, skip: true);
test('question with no letters', () {
final result = bob.response('4?');
expect(result, equals('Sure.'));
}, skip: true);
test('shouting with special characters', () {
final result = bob.response('ZOMG THE %^*@#\$(*^ ZOMBIES ARE COMING!!11!!1!');
expect(result, equals('Whoa, chill out!'));
}, skip: true);
test('shouting with no exclamation mark', () {
final result = bob.response('I HATE THE DENTIST');
expect(result, equals('Whoa, chill out!'));
}, skip: true);
test('statement containing question mark', () {
final result = bob.response('Ending with ? means a question.');
expect(result, equals('Whatever.'));
}, skip: true);
test('non-letters with question', () {
final result = bob.response(':) ?');
expect(result, equals('Sure.'));
}, skip: true);
test('prattling on', () {
final result = bob.response('Wait! Hang on. Are you going to be OK?');
expect(result, equals('Sure.'));
}, skip: true);
test('silence', () {
final result = bob.response('');
expect(result, equals('Fine. Be that way!'));
}, skip: true);
test('prolonged silence', () {
final result = bob.response(' ');
expect(result, equals('Fine. Be that way!'));
}, skip: true);
test('alternate silence', () {
final result = bob.response('\t\t\t\t\t\t\t\t\t\t');
expect(result, equals('Fine. Be that way!'));
}, skip: true);
test('multiple line question', () {
final result = bob.response('\nDoes this cryogenic chamber make me look fat?\nNo.');
expect(result, equals('Whatever.'));
}, skip: true);
test('starting with whitespace', () {
final result = bob.response(' hmmmmmmm...');
expect(result, equals('Whatever.'));
}, skip: true);
test('ending with whitespace', () {
final result = bob.response('Okay if like my spacebar quite a bit? ');
expect(result, equals('Sure.'));
}, skip: true);
test('other whitespace', () {
final result = bob.response('\n\r \t');
expect(result, equals('Fine. Be that way!'));
}, skip: true);
test('non-question ending with whitespace', () {
final result = bob.response('This is a statement ending with whitespace ');
expect(result, equals('Whatever.'));
}, skip: true);
});
}

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-64.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.2.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.6.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.7",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.7",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-12.0.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "collatz_conjecture",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-10-09T12:07:27.377032Z",
"generator": "pub",
"generatorVersion": "3.1.0"
}

View File

@ -0,0 +1,22 @@
{
"authors": [
"amscotti"
],
"contributors": [
"kytrinyx"
],
"files": {
"solution": [
"lib/collatz_conjecture.dart"
],
"test": [
"test/collatz_conjecture_test.dart"
],
"example": [
".meta/lib/example.dart"
]
},
"blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.",
"source": "An unsolved problem in mathematics named after mathematician Lothar Collatz",
"source_url": "https://en.wikipedia.org/wiki/3x_%2B_1_problem"
}

View File

@ -0,0 +1 @@
{"track":"dart","exercise":"collatz-conjecture","id":"f26990640b27404d8b4db2ab1cb57945","url":"https://exercism.org/tracks/dart/exercises/collatz-conjecture","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false}

View File

@ -0,0 +1,38 @@
# Help
## Running the tests
To run the tests:
```sh
$ dart test
```
## Submitting your solution
You can submit your solution using the `exercism submit lib/collatz_conjecture.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

View File

@ -0,0 +1,48 @@
# Collatz Conjecture
Welcome to Collatz Conjecture on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
The Collatz Conjecture or 3x+1 problem can be summarized as follows:
Take any positive integer n.
If n is even, divide n by 2 to get n / 2.
If n is odd, multiply n by 3 and add 1 to get 3n + 1.
Repeat the process indefinitely.
The conjecture states that no matter which number you start with, you will always reach 1 eventually.
Given a number n, return the number of steps required to reach 1.
## Examples
Starting with n = 12, the steps would be as follows:
0. 12
1. 6
2. 3
3. 10
4. 5
5. 16
6. 8
7. 4
8. 2
9. 1
Resulting in 9 steps.
So for input n = 12, the return value would be 9.
## Source
### Created by
- @amscotti
### Contributed to by
- @kytrinyx
### Based on
An unsolved problem in mathematics named after mathematician Lothar Collatz - https://en.wikipedia.org/wiki/3x_%2B_1_problem

View File

@ -0,0 +1,18 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps

View File

@ -0,0 +1,12 @@
class CollatzConjecture {
int steps(int start) {
if (start < 1)
throw new ArgumentError('Only positive integers are allowed');
if (start == 1) return 0;
if (start.isEven) {
return 1 + this.steps(start ~/= 2);
} else {
return 1 + this.steps(start * 3 + 1);
}
}
}

View File

@ -0,0 +1,365 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
url: "https://pub.dev"
source: hosted
version: "64.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
url: "https://pub.dev"
source: hosted
version: "6.2.0"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb"
url: "https://pub.dev"
source: hosted
version: "1.6.4"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.10.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: a20ddc0723556dc6dd56094e58ec1529196d5d7774156604cb14e8445a5a82ff
url: "https://pub.dev"
source: hosted
version: "1.24.7"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: "96382d0bc826e260b077bb496259e58bc82e90b603ab16cd5ae95dfe1dfcba8b"
url: "https://pub.dev"
source: hosted
version: "0.5.7"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: a13d5503b4facefc515c8c587ce3cf69577a7b064a9f1220e005449cf1f64aad
url: "https://pub.dev"
source: hosted
version: "12.0.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"

View File

@ -0,0 +1,5 @@
name: 'collatz_conjecture'
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
test: '<2.0.0'

View File

@ -0,0 +1,44 @@
import 'package:collatz_conjecture/collatz_conjecture.dart';
import 'package:test/test.dart';
void main() {
final collatzConjecture = CollatzConjecture();
/// We are using a predicate to better match the error message from collatzConjecture.
/// Knowing about predicates are not needed for completing this exercise,
/// but you can find out more info at https://pub.dev/documentation/test/latest/
/// if you wish to learn more about predicates and matchers used in Unit Testing for Dart.
final onlyPositive = predicate(
(ArgumentError e) => e is ArgumentError && e.message == 'Only positive integers are allowed',
'an ArgumentError with the message "Only positive integers are allowed"');
group('CollatzConjecture', () {
test('zero steps for one', () {
final result = collatzConjecture.steps(1);
expect(result, equals(0));
}, skip: false);
test('divide if even', () {
final result = collatzConjecture.steps(16);
expect(result, equals(4));
}, skip: true);
test('even and odd steps', () {
final result = collatzConjecture.steps(12);
expect(result, equals(9));
}, skip: true);
test('large number of even and odd steps', () {
final result = collatzConjecture.steps(1000000);
expect(result, equals(152));
}, skip: true);
test('zero is an error', () {
expect(() => collatzConjecture.steps(0), throwsA(onlyPositive));
}, skip: true);
test('negative value is an error', () {
expect(() => collatzConjecture.steps(-15), throwsA(onlyPositive));
}, skip: true);
});
}

View File

@ -0,0 +1,284 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-65.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "analyzer",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/analyzer-6.3.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "args",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/args-2.4.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/collection-1.18.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/coverage-1.7.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "crypto",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/file-7.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/frontend_server_client-3.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "glob",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/http_parser-4.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "io",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "logging",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "meta",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/meta-1.11.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/mime-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pool",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf-1.4.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_static-1.1.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/shelf_web_socket-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_maps",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stack_trace-1.11.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test-1.24.9",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_api",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_api-0.6.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "test_core",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/test_core-0.5.9",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "typed_data",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/vm_service-13.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "watcher",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/web_socket_channel-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/fabian/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "darts",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.18"
}
],
"generated": "2023-11-08T20:26:56.604672Z",
"generator": "pub",
"generatorVersion": "3.1.5"
}

Some files were not shown because too many files have changed in this diff Show More