commit bb3d2b0b0326f09e53cb535528f815de3af241dc Author: baldeau Date: Mon Oct 14 11:37:17 2024 +0200 first commit diff --git a/acronym/.dart_tool/package_config.json b/acronym/.dart_tool/package_config.json new file mode 100644 index 0000000..e65acd6 --- /dev/null +++ b/acronym/.dart_tool/package_config.json @@ -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" +} diff --git a/acronym/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/acronym/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..a9be026 Binary files /dev/null and b/acronym/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/acronym/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/acronym/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..beacbea Binary files /dev/null and b/acronym/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/acronym/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot b/acronym/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot new file mode 100644 index 0000000..572e398 Binary files /dev/null and b/acronym/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot differ diff --git a/acronym/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/acronym/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..bbe31f5 Binary files /dev/null and b/acronym/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/acronym/.exercism/config.json b/acronym/.exercism/config.json new file mode 100644 index 0000000..105c93e --- /dev/null +++ b/acronym/.exercism/config.json @@ -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" +} diff --git a/acronym/.exercism/metadata.json b/acronym/.exercism/metadata.json new file mode 100644 index 0000000..7add34b --- /dev/null +++ b/acronym/.exercism/metadata.json @@ -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} \ No newline at end of file diff --git a/acronym/HELP.md b/acronym/HELP.md new file mode 100644 index 0000000..9bc564b --- /dev/null +++ b/acronym/HELP.md @@ -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. \ No newline at end of file diff --git a/acronym/README.md b/acronym/README.md new file mode 100644 index 0000000..739c590 --- /dev/null +++ b/acronym/README.md @@ -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 \ No newline at end of file diff --git a/acronym/analysis_options.yaml b/acronym/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/acronym/analysis_options.yaml @@ -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 diff --git a/acronym/lib/acronym.dart b/acronym/lib/acronym.dart new file mode 100644 index 0000000..b69a240 --- /dev/null +++ b/acronym/lib/acronym.dart @@ -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(); + } +} diff --git a/acronym/pubspec.lock b/acronym/pubspec.lock new file mode 100644 index 0000000..cb97626 --- /dev/null +++ b/acronym/pubspec.lock @@ -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" diff --git a/acronym/pubspec.yaml b/acronym/pubspec.yaml new file mode 100644 index 0000000..adc9359 --- /dev/null +++ b/acronym/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'acronym' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/acronym/test/acronym_test.dart b/acronym/test/acronym_test.dart new file mode 100644 index 0000000..bad677e --- /dev/null +++ b/acronym/test/acronym_test.dart @@ -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); + }); +} diff --git a/allergies/.dart_tool/package_config.json b/allergies/.dart_tool/package_config.json new file mode 100644 index 0000000..9e47db3 --- /dev/null +++ b/allergies/.dart_tool/package_config.json @@ -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" +} diff --git a/allergies/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/allergies/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..b8dbb4e Binary files /dev/null and b/allergies/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/allergies/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/allergies/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..1aae62b Binary files /dev/null and b/allergies/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/allergies/.exercism/config.json b/allergies/.exercism/config.json new file mode 100644 index 0000000..88e02c2 --- /dev/null +++ b/allergies/.exercism/config.json @@ -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" +} diff --git a/allergies/.exercism/metadata.json b/allergies/.exercism/metadata.json new file mode 100644 index 0000000..c6aac31 --- /dev/null +++ b/allergies/.exercism/metadata.json @@ -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} \ No newline at end of file diff --git a/allergies/HELP.md b/allergies/HELP.md new file mode 100644 index 0000000..75390cc --- /dev/null +++ b/allergies/HELP.md @@ -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. \ No newline at end of file diff --git a/allergies/README.md b/allergies/README.md new file mode 100644 index 0000000..674de96 --- /dev/null +++ b/allergies/README.md @@ -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 \ No newline at end of file diff --git a/allergies/analysis_options.yaml b/allergies/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/allergies/analysis_options.yaml @@ -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 diff --git a/allergies/lib/allergies.dart b/allergies/lib/allergies.dart new file mode 100644 index 0000000..095def3 --- /dev/null +++ b/allergies/lib/allergies.dart @@ -0,0 +1,18 @@ +class Allergies { + static const List _allergies = [ + 'eggs', + 'peanuts', + 'shellfish', + 'strawberries', + 'tomatoes', + 'chocolate', + 'pollen', + 'cats', + ]; + + bool allergicTo(final String item, final int allergyScore) => + ((allergyScore >> _allergies.indexOf(item)) & 1) == 1; + + List list(final int allergyScore) => + _allergies.where((allergy) => allergicTo(allergy, allergyScore)).toList(); +} diff --git a/allergies/pubspec.lock b/allergies/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/allergies/pubspec.lock @@ -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" diff --git a/allergies/pubspec.yaml b/allergies/pubspec.yaml new file mode 100644 index 0000000..ebb7045 --- /dev/null +++ b/allergies/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'allergies' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/allergies/test/allergies_test.dart b/allergies/test/allergies_test.dart new file mode 100644 index 0000000..ebb67bc --- /dev/null +++ b/allergies/test/allergies_test.dart @@ -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([])); + }, skip: false); + + test('just eggs', () { + final result = allergies.list(1); + expect(result, equals(['eggs'])); + }, skip: false); + + test('just peanuts', () { + final result = allergies.list(2); + expect(result, equals(['peanuts'])); + }, skip: false); + + test('just strawberries', () { + final result = allergies.list(8); + expect(result, equals(['strawberries'])); + }, skip: false); + + test('eggs and peanuts', () { + final result = allergies.list(3); + expect(result, equals(['eggs', 'peanuts'])); + }, skip: false); + + test('more than eggs but not peanuts', () { + final result = allergies.list(5); + expect(result, equals(['eggs', 'shellfish'])); + }, skip: false); + + test('lots of stuff', () { + final result = allergies.list(248); + expect( + result, + equals([ + 'strawberries', + 'tomatoes', + 'chocolate', + 'pollen', + 'cats' + ])); + }, skip: false); + + test('everything', () { + final result = allergies.list(255); + expect( + result, + equals([ + 'eggs', + 'peanuts', + 'shellfish', + 'strawberries', + 'tomatoes', + 'chocolate', + 'pollen', + 'cats' + ])); + }, skip: false); + + test('no allergen score parts', () { + final result = allergies.list(509); + expect( + result, + equals([ + '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(['eggs'])); + }, skip: false); +} diff --git a/anagram/.dart_tool/package_config.json b/anagram/.dart_tool/package_config.json new file mode 100644 index 0000000..1568e26 --- /dev/null +++ b/anagram/.dart_tool/package_config.json @@ -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" +} diff --git a/anagram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/anagram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..a9be026 Binary files /dev/null and b/anagram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/anagram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/anagram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..3565798 Binary files /dev/null and b/anagram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/anagram/.exercism/config.json b/anagram/.exercism/config.json new file mode 100644 index 0000000..d5d2664 --- /dev/null +++ b/anagram/.exercism/config.json @@ -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" +} diff --git a/anagram/.exercism/metadata.json b/anagram/.exercism/metadata.json new file mode 100644 index 0000000..e40b116 --- /dev/null +++ b/anagram/.exercism/metadata.json @@ -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} \ No newline at end of file diff --git a/anagram/HELP.md b/anagram/HELP.md new file mode 100644 index 0000000..1730fd9 --- /dev/null +++ b/anagram/HELP.md @@ -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. \ No newline at end of file diff --git a/anagram/README.md b/anagram/README.md new file mode 100644 index 0000000..3fc5121 --- /dev/null +++ b/anagram/README.md @@ -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 \ No newline at end of file diff --git a/anagram/analysis_options.yaml b/anagram/analysis_options.yaml new file mode 100644 index 0000000..149ebe9 --- /dev/null +++ b/anagram/analysis_options.yaml @@ -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 diff --git a/anagram/lib/anagram.dart b/anagram/lib/anagram.dart new file mode 100644 index 0000000..3445304 --- /dev/null +++ b/anagram/lib/anagram.dart @@ -0,0 +1,21 @@ +class Anagram { + List findAnagrams(String anagram, List checkList) { + List anagrams = []; + List 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; + } +} diff --git a/anagram/pubspec.lock b/anagram/pubspec.lock new file mode 100644 index 0000000..cb97626 --- /dev/null +++ b/anagram/pubspec.lock @@ -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" diff --git a/anagram/pubspec.yaml b/anagram/pubspec.yaml new file mode 100644 index 0000000..637ac03 --- /dev/null +++ b/anagram/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'anagram' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/anagram/test/anagram_test.dart b/anagram/test/anagram_test.dart new file mode 100644 index 0000000..4438e5d --- /dev/null +++ b/anagram/test/anagram_test.dart @@ -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', ['hello', 'world', 'zombies', 'pants']); + expect(result, equals([])); + }, skip: false); + + test('detects two anagrams', () { + final result = anagram.findAnagrams('solemn', ['lemons', 'cherry', 'melons']); + expect(result, equals(['lemons', 'melons'])); + }, skip: true); + + test('does not detect anagram subsets', () { + final result = anagram.findAnagrams('good', ['dog', 'goody']); + expect(result, equals([])); + }, skip: true); + + test('detects anagram', () { + final result = anagram.findAnagrams('listen', ['enlists', 'google', 'inlets', 'banana']); + expect(result, equals(['inlets'])); + }, skip: true); + + test('detects three anagrams', () { + final result = + anagram.findAnagrams('allergy', ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']); + expect(result, equals(['gallery', 'regally', 'largely'])); + }, skip: true); + + test('detects multiple anagrams with different case', () { + final result = anagram.findAnagrams('nose', ['Eons', 'ONES']); + expect(result, equals(['Eons', 'ONES'])); + }, skip: true); + + test('does not detect non-anagrams with identical checksum', () { + final result = anagram.findAnagrams('mass', ['last']); + expect(result, equals([])); + }, skip: true); + + test('detects anagrams case-insensitively', () { + final result = anagram.findAnagrams('Orchestra', ['cashregister', 'Carthorse', 'radishes']); + expect(result, equals(['Carthorse'])); + }, skip: true); + + test('detects anagrams using case-insensitive subject', () { + final result = anagram.findAnagrams('Orchestra', ['cashregister', 'carthorse', 'radishes']); + expect(result, equals(['carthorse'])); + }, skip: true); + + test('detects anagrams using case-insensitive possible matches', () { + final result = anagram.findAnagrams('orchestra', ['cashregister', 'Carthorse', 'radishes']); + expect(result, equals(['Carthorse'])); + }, skip: true); + + test('does not detect an anagram if the original word is repeated', () { + final result = anagram.findAnagrams('go', ['go Go GO']); + expect(result, equals([])); + }, skip: true); + + test('anagrams must use all letters exactly once', () { + final result = anagram.findAnagrams('tapper', ['patter']); + expect(result, equals([])); + }, skip: true); + + test('words are not anagrams of themselves', () { + final result = anagram.findAnagrams('BANANA', ['BANANA']); + expect(result, equals([])); + }, skip: true); + + test('words are not anagrams of themselves even if letter case is partially different', () { + final result = anagram.findAnagrams('BANANA', ['Banana']); + expect(result, equals([])); + }, skip: true); + + test('words are not anagrams of themselves even if letter case is completely different', () { + final result = anagram.findAnagrams('BANANA', ['banana']); + expect(result, equals([])); + }, skip: true); + + test('words other than themselves can be anagrams', () { + final result = anagram.findAnagrams('LISTEN', ['LISTEN', 'Silent']); + expect(result, equals(['Silent'])); + }, skip: true); + }); +} diff --git a/armstrong-numbers/.dart_tool/package_config.json b/armstrong-numbers/.dart_tool/package_config.json new file mode 100644 index 0000000..d1fbd56 --- /dev/null +++ b/armstrong-numbers/.dart_tool/package_config.json @@ -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" +} diff --git a/armstrong-numbers/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/armstrong-numbers/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..07e8fe3 Binary files /dev/null and b/armstrong-numbers/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/armstrong-numbers/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/armstrong-numbers/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..82c646d Binary files /dev/null and b/armstrong-numbers/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/armstrong-numbers/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/armstrong-numbers/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..27fbdb1 Binary files /dev/null and b/armstrong-numbers/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/armstrong-numbers/.exercism/config.json b/armstrong-numbers/.exercism/config.json new file mode 100644 index 0000000..463661e --- /dev/null +++ b/armstrong-numbers/.exercism/config.json @@ -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" +} diff --git a/armstrong-numbers/.exercism/metadata.json b/armstrong-numbers/.exercism/metadata.json new file mode 100644 index 0000000..9c7af90 --- /dev/null +++ b/armstrong-numbers/.exercism/metadata.json @@ -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} \ No newline at end of file diff --git a/armstrong-numbers/HELP.md b/armstrong-numbers/HELP.md new file mode 100644 index 0000000..ce92049 --- /dev/null +++ b/armstrong-numbers/HELP.md @@ -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. \ No newline at end of file diff --git a/armstrong-numbers/README.md b/armstrong-numbers/README.md new file mode 100644 index 0000000..b1f1d23 --- /dev/null +++ b/armstrong-numbers/README.md @@ -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 \ No newline at end of file diff --git a/armstrong-numbers/analysis_options.yaml b/armstrong-numbers/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/armstrong-numbers/analysis_options.yaml @@ -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 diff --git a/armstrong-numbers/lib/armstrong_numbers.dart b/armstrong-numbers/lib/armstrong_numbers.dart new file mode 100644 index 0000000..6551085 --- /dev/null +++ b/armstrong-numbers/lib/armstrong_numbers.dart @@ -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); + } +} diff --git a/armstrong-numbers/pubspec.lock b/armstrong-numbers/pubspec.lock new file mode 100644 index 0000000..235179f --- /dev/null +++ b/armstrong-numbers/pubspec.lock @@ -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" diff --git a/armstrong-numbers/pubspec.yaml b/armstrong-numbers/pubspec.yaml new file mode 100644 index 0000000..1932b14 --- /dev/null +++ b/armstrong-numbers/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'armstrong_numbers' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/armstrong-numbers/test/armstrong_numbers_test.dart b/armstrong-numbers/test/armstrong_numbers_test.dart new file mode 100644 index 0000000..e9306bb --- /dev/null +++ b/armstrong-numbers/test/armstrong_numbers_test.dart @@ -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); + }); +} diff --git a/beer-song/.dart_tool/package_config.json b/beer-song/.dart_tool/package_config.json new file mode 100644 index 0000000..2a9883d --- /dev/null +++ b/beer-song/.dart_tool/package_config.json @@ -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" +} diff --git a/beer-song/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/beer-song/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..b8dbb4e Binary files /dev/null and b/beer-song/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/beer-song/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/beer-song/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..2ca4399 Binary files /dev/null and b/beer-song/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/beer-song/.exercism/config.json b/beer-song/.exercism/config.json new file mode 100644 index 0000000..0027731 --- /dev/null +++ b/beer-song/.exercism/config.json @@ -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" +} diff --git a/beer-song/.exercism/metadata.json b/beer-song/.exercism/metadata.json new file mode 100644 index 0000000..afca87f --- /dev/null +++ b/beer-song/.exercism/metadata.json @@ -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} \ No newline at end of file diff --git a/beer-song/HELP.md b/beer-song/HELP.md new file mode 100644 index 0000000..97d4d5a --- /dev/null +++ b/beer-song/HELP.md @@ -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. \ No newline at end of file diff --git a/beer-song/README.md b/beer-song/README.md new file mode 100644 index 0000000..5ec5291 --- /dev/null +++ b/beer-song/README.md @@ -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 \ No newline at end of file diff --git a/beer-song/analysis_options.yaml b/beer-song/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/beer-song/analysis_options.yaml @@ -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 diff --git a/beer-song/lib/beer_song.dart b/beer-song/lib/beer_song.dart new file mode 100644 index 0000000..375db45 --- /dev/null +++ b/beer-song/lib/beer_song.dart @@ -0,0 +1,23 @@ +class BeerSong { + List 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); + } +} diff --git a/beer-song/pubspec.lock b/beer-song/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/beer-song/pubspec.lock @@ -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" diff --git a/beer-song/pubspec.yaml b/beer-song/pubspec.yaml new file mode 100644 index 0000000..b058bf5 --- /dev/null +++ b/beer-song/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'beer_song' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/beer-song/test/beer_song_test.dart b/beer-song/test/beer_song_test.dart new file mode 100644 index 0000000..51129c4 --- /dev/null +++ b/beer-song/test/beer_song_test.dart @@ -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([ + '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([ + '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([ + '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([ + '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([ + '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([ + '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([ + '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([ + '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); + }); + }); + }); +} diff --git a/binary-search-tree/.dart_tool/package_config.json b/binary-search-tree/.dart_tool/package_config.json new file mode 100644 index 0000000..5619c22 --- /dev/null +++ b/binary-search-tree/.dart_tool/package_config.json @@ -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" +} diff --git a/binary-search-tree/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot b/binary-search-tree/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot new file mode 100644 index 0000000..6ea874b Binary files /dev/null and b/binary-search-tree/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot differ diff --git a/binary-search-tree/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/binary-search-tree/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..d75f406 Binary files /dev/null and b/binary-search-tree/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/binary-search-tree/.exercism/config.json b/binary-search-tree/.exercism/config.json new file mode 100644 index 0000000..5cdef1c --- /dev/null +++ b/binary-search-tree/.exercism/config.json @@ -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" +} diff --git a/binary-search-tree/.exercism/metadata.json b/binary-search-tree/.exercism/metadata.json new file mode 100644 index 0000000..aeeba4f --- /dev/null +++ b/binary-search-tree/.exercism/metadata.json @@ -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} \ No newline at end of file diff --git a/binary-search-tree/HELP.md b/binary-search-tree/HELP.md new file mode 100644 index 0000000..e62bbd1 --- /dev/null +++ b/binary-search-tree/HELP.md @@ -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. \ No newline at end of file diff --git a/binary-search-tree/README.md b/binary-search-tree/README.md new file mode 100644 index 0000000..075b7a5 --- /dev/null +++ b/binary-search-tree/README.md @@ -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 \ No newline at end of file diff --git a/binary-search-tree/analysis_options.yaml b/binary-search-tree/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/binary-search-tree/analysis_options.yaml @@ -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 diff --git a/binary-search-tree/lib/binary_search_tree.dart b/binary-search-tree/lib/binary_search_tree.dart new file mode 100644 index 0000000..e868aa3 --- /dev/null +++ b/binary-search-tree/lib/binary_search_tree.dart @@ -0,0 +1,45 @@ +class BinarySearchTree { + final TreeNode root; + List 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 _traverseInOrder(TreeNode? node) { + List 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); +} diff --git a/binary-search-tree/pubspec.lock b/binary-search-tree/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/binary-search-tree/pubspec.lock @@ -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" diff --git a/binary-search-tree/pubspec.yaml b/binary-search-tree/pubspec.yaml new file mode 100644 index 0000000..116be67 --- /dev/null +++ b/binary-search-tree/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'binary_search_tree' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/binary-search-tree/test/binary_search_tree_test.dart b/binary-search-tree/test/binary_search_tree_test.dart new file mode 100644 index 0000000..b2ebb5a --- /dev/null +++ b/binary-search-tree/test/binary_search_tree_test.dart @@ -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); + }); + }); +} diff --git a/bob/.dart_tool/package_config.json b/bob/.dart_tool/package_config.json new file mode 100644 index 0000000..de0a177 --- /dev/null +++ b/bob/.dart_tool/package_config.json @@ -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" +} diff --git a/bob/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/bob/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..e6fd0f6 Binary files /dev/null and b/bob/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/bob/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/bob/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..15d89b0 Binary files /dev/null and b/bob/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/bob/.exercism/config.json b/bob/.exercism/config.json new file mode 100644 index 0000000..2959f18 --- /dev/null +++ b/bob/.exercism/config.json @@ -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" +} diff --git a/bob/.exercism/metadata.json b/bob/.exercism/metadata.json new file mode 100644 index 0000000..d4e0850 --- /dev/null +++ b/bob/.exercism/metadata.json @@ -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} \ No newline at end of file diff --git a/bob/HELP.md b/bob/HELP.md new file mode 100644 index 0000000..cad405d --- /dev/null +++ b/bob/HELP.md @@ -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. \ No newline at end of file diff --git a/bob/README.md b/bob/README.md new file mode 100644 index 0000000..25091a1 --- /dev/null +++ b/bob/README.md @@ -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 \ No newline at end of file diff --git a/bob/analysis_options.yaml b/bob/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/bob/analysis_options.yaml @@ -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 diff --git a/bob/lib/bob.dart b/bob/lib/bob.dart new file mode 100644 index 0000000..7af7138 --- /dev/null +++ b/bob/lib/bob.dart @@ -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; +} diff --git a/bob/pubspec.lock b/bob/pubspec.lock new file mode 100644 index 0000000..d5af5b2 --- /dev/null +++ b/bob/pubspec.lock @@ -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" diff --git a/bob/pubspec.yaml b/bob/pubspec.yaml new file mode 100644 index 0000000..ec25611 --- /dev/null +++ b/bob/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'bob' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/bob/test/bob_test.dart b/bob/test/bob_test.dart new file mode 100644 index 0000000..2cb738e --- /dev/null +++ b/bob/test/bob_test.dart @@ -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); + }); +} diff --git a/collatz-conjecture/.dart_tool/package_config.json b/collatz-conjecture/.dart_tool/package_config.json new file mode 100644 index 0000000..9671267 --- /dev/null +++ b/collatz-conjecture/.dart_tool/package_config.json @@ -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" +} diff --git a/collatz-conjecture/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/collatz-conjecture/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/collatz-conjecture/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/collatz-conjecture/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/collatz-conjecture/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..dae8932 Binary files /dev/null and b/collatz-conjecture/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/collatz-conjecture/.exercism/config.json b/collatz-conjecture/.exercism/config.json new file mode 100644 index 0000000..1348336 --- /dev/null +++ b/collatz-conjecture/.exercism/config.json @@ -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" +} diff --git a/collatz-conjecture/.exercism/metadata.json b/collatz-conjecture/.exercism/metadata.json new file mode 100644 index 0000000..a110488 --- /dev/null +++ b/collatz-conjecture/.exercism/metadata.json @@ -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} \ No newline at end of file diff --git a/collatz-conjecture/HELP.md b/collatz-conjecture/HELP.md new file mode 100644 index 0000000..7f81a09 --- /dev/null +++ b/collatz-conjecture/HELP.md @@ -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. \ No newline at end of file diff --git a/collatz-conjecture/README.md b/collatz-conjecture/README.md new file mode 100644 index 0000000..050fc16 --- /dev/null +++ b/collatz-conjecture/README.md @@ -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 \ No newline at end of file diff --git a/collatz-conjecture/analysis_options.yaml b/collatz-conjecture/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/collatz-conjecture/analysis_options.yaml @@ -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 diff --git a/collatz-conjecture/lib/collatz_conjecture.dart b/collatz-conjecture/lib/collatz_conjecture.dart new file mode 100644 index 0000000..80c7356 --- /dev/null +++ b/collatz-conjecture/lib/collatz_conjecture.dart @@ -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); + } + } +} diff --git a/collatz-conjecture/pubspec.lock b/collatz-conjecture/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/collatz-conjecture/pubspec.lock @@ -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" diff --git a/collatz-conjecture/pubspec.yaml b/collatz-conjecture/pubspec.yaml new file mode 100644 index 0000000..d9f5e10 --- /dev/null +++ b/collatz-conjecture/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'collatz_conjecture' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/collatz-conjecture/test/collatz_conjecture_test.dart b/collatz-conjecture/test/collatz_conjecture_test.dart new file mode 100644 index 0000000..ceb5173 --- /dev/null +++ b/collatz-conjecture/test/collatz_conjecture_test.dart @@ -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); + }); +} diff --git a/darts/.dart_tool/package_config.json b/darts/.dart_tool/package_config.json new file mode 100644 index 0000000..d0393a1 --- /dev/null +++ b/darts/.dart_tool/package_config.json @@ -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" +} diff --git a/darts/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot b/darts/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot new file mode 100644 index 0000000..6ea874b Binary files /dev/null and b/darts/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot differ diff --git a/darts/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/darts/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..7d3027b Binary files /dev/null and b/darts/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/darts/.exercism/config.json b/darts/.exercism/config.json new file mode 100644 index 0000000..f5dd7c1 --- /dev/null +++ b/darts/.exercism/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "lib/darts.dart" + ], + "test": [ + "test/darts_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Write a function that returns the earned points in a single toss of a Darts game.", + "source": "Inspired by an exercise created by a professor Della Paolera in Argentina" +} diff --git a/darts/.exercism/metadata.json b/darts/.exercism/metadata.json new file mode 100644 index 0000000..f24c263 --- /dev/null +++ b/darts/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"darts","id":"6a7b1cf6dbc448f98ee9abdbae270494","url":"https://exercism.org/tracks/dart/exercises/darts","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/darts/HELP.md b/darts/HELP.md new file mode 100644 index 0000000..93945ee --- /dev/null +++ b/darts/HELP.md @@ -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/darts.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. \ No newline at end of file diff --git a/darts/README.md b/darts/README.md new file mode 100644 index 0000000..d978716 --- /dev/null +++ b/darts/README.md @@ -0,0 +1,42 @@ +# Darts + +Welcome to Darts on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Write a function that returns the earned points in a single toss of a Darts game. + +[Darts][darts] is a game where players throw darts at a [target][darts-target]. + +In our particular instance of the game, the target rewards 4 different amounts of points, depending on where the dart lands: + +- If the dart lands outside the target, player earns no points (0 points). +- If the dart lands in the outer circle of the target, player earns 1 point. +- If the dart lands in the middle circle of the target, player earns 5 points. +- If the dart lands in the inner circle of the target, player earns 10 points. + +The outer circle has a radius of 10 units (this is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1. +Of course, they are all centered at the same point — that is, the circles are [concentric][] defined by the coordinates (0, 0). + +Write a function that given a point in the target (defined by its [Cartesian coordinates][cartesian-coordinates] `x` and `y`, where `x` and `y` are [real][real-numbers]), returns the correct amount earned by a dart landing at that point. + +[darts]: https://en.wikipedia.org/wiki/Darts +[darts-target]: https://en.wikipedia.org/wiki/Darts#/media/File:Darts_in_a_dartboard.jpg +[concentric]: https://mathworld.wolfram.com/ConcentricCircles.html +[cartesian-coordinates]: https://www.mathsisfun.com/data/cartesian-coordinates.html +[real-numbers]: https://www.mathsisfun.com/numbers/real-numbers.html + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @kytrinyx + +### Based on + +Inspired by an exercise created by a professor Della Paolera in Argentina \ No newline at end of file diff --git a/darts/analysis_options.yaml b/darts/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/darts/analysis_options.yaml @@ -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 diff --git a/darts/lib/darts.dart b/darts/lib/darts.dart new file mode 100644 index 0000000..5984d2d --- /dev/null +++ b/darts/lib/darts.dart @@ -0,0 +1,15 @@ +import 'dart:math' as math; + +class Darts { + int score(double x, double y) { + double distance = math.sqrt(x * x + y * y); + if (distance <= 1) { + return 10; + } else if (distance <= 5) { + return 5; + } else if (distance <= 10) { + return 1; + } + return 0; + } +} diff --git a/darts/pubspec.lock b/darts/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/darts/pubspec.lock @@ -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" diff --git a/darts/pubspec.yaml b/darts/pubspec.yaml new file mode 100644 index 0000000..167d6ba --- /dev/null +++ b/darts/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'darts' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/darts/test/darts_test.dart b/darts/test/darts_test.dart new file mode 100644 index 0000000..c2a129d --- /dev/null +++ b/darts/test/darts_test.dart @@ -0,0 +1,73 @@ +import 'package:darts/darts.dart'; +import 'package:test/test.dart'; + +void main() { + final darts = Darts(); + + group('Darts', () { + test('Missed target', () { + final result = darts.score(-9, 9); + expect(result, equals(0)); + }, skip: false); + + test('On the outer circle', () { + final result = darts.score(0, 10); + expect(result, equals(1)); + }, skip: false); + + test('On the middle circle', () { + final result = darts.score(-5, 0); + expect(result, equals(5)); + }, skip: false); + + test('On the inner circle', () { + final result = darts.score(0, -1); + expect(result, equals(10)); + }, skip: false); + + test('Exactly on centre', () { + final result = darts.score(0, 0); + expect(result, equals(10)); + }, skip: false); + + test('Near the centre', () { + final result = darts.score(-0.1, -0.1); + expect(result, equals(10)); + }, skip: false); + + test('Just within the inner circle', () { + final result = darts.score(0.7, 0.7); + expect(result, equals(10)); + }, skip: false); + + test('Just outside the inner circle', () { + final result = darts.score(0.8, -0.8); + expect(result, equals(5)); + }, skip: false); + + test('Just within the middle circle', () { + final result = darts.score(-3.5, 3.5); + expect(result, equals(5)); + }, skip: false); + + test('Just outside the middle circle', () { + final result = darts.score(-3.6, -3.6); + expect(result, equals(1)); + }, skip: false); + + test('Just within the outer circle', () { + final result = darts.score(-7.0, 7.0); + expect(result, equals(1)); + }, skip: false); + + test('Just outside the outer circle', () { + final result = darts.score(7.1, -7.1); + expect(result, equals(0)); + }, skip: false); + + test('Asymmetric position between the inner and middle circles', () { + final result = darts.score(0.5, -4); + expect(result, equals(5)); + }, skip: false); + }); +} diff --git a/diamond/.dart_tool/package_config.json b/diamond/.dart_tool/package_config.json new file mode 100644 index 0000000..232313e --- /dev/null +++ b/diamond/.dart_tool/package_config.json @@ -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": "diamond", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-03T14:50:25.035428Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/diamond/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/diamond/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/diamond/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/diamond/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/diamond/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..f533e11 Binary files /dev/null and b/diamond/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/diamond/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/diamond/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..112375d Binary files /dev/null and b/diamond/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/diamond/.exercism/config.json b/diamond/.exercism/config.json new file mode 100644 index 0000000..fcd9a4a --- /dev/null +++ b/diamond/.exercism/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "jvarness" + ], + "contributors": [ + "Stargator", + "Zureka", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/diamond.dart" + ], + "test": [ + "test/diamond_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.", + "source": "Seb Rose", + "source_url": "https://web.archive.org/web/20220807163751/http://claysnow.co.uk/recycling-tests-in-tdd/" +} diff --git a/diamond/.exercism/metadata.json b/diamond/.exercism/metadata.json new file mode 100644 index 0000000..c36232b --- /dev/null +++ b/diamond/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"diamond","id":"66f49770a51c4a238a4cc58d29abe7b4","url":"https://exercism.org/tracks/dart/exercises/diamond","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/diamond/HELP.md b/diamond/HELP.md new file mode 100644 index 0000000..7d41d83 --- /dev/null +++ b/diamond/HELP.md @@ -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/diamond.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. \ No newline at end of file diff --git a/diamond/README.md b/diamond/README.md new file mode 100644 index 0000000..d1bc90e --- /dev/null +++ b/diamond/README.md @@ -0,0 +1,73 @@ +# Diamond + +Welcome to Diamond on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +The diamond kata takes as its input a letter, and outputs it in a diamond shape. +Given a letter, it prints a diamond starting with 'A', with the supplied letter at the widest point. + +## Requirements + +- The first row contains one 'A'. +- The last row contains one 'A'. +- All rows, except the first and last, have exactly two identical letters. +- All rows have as many trailing spaces as leading spaces. (This might be 0). +- The diamond is horizontally symmetric. +- The diamond is vertically symmetric. +- The diamond has a square shape (width equals height). +- The letters form a diamond shape. +- The top half has the letters in ascending order. +- The bottom half has the letters in descending order. +- The four corners (containing the spaces) are triangles. + +## Examples + +In the following examples, spaces are indicated by `·` characters. + +Diamond for letter 'A': + +```text +A +``` + +Diamond for letter 'C': + +```text +··A·· +·B·B· +C···C +·B·B· +··A·· +``` + +Diamond for letter 'E': + +```text +····A···· +···B·B··· +··C···C·· +·D·····D· +E·······E +·D·····D· +··C···C·· +···B·B··· +····A···· +``` + +## Source + +### Created by + +- @jvarness + +### Contributed to by + +- @Stargator +- @Zureka +- @kytrinyx + +### Based on + +Seb Rose - https://web.archive.org/web/20220807163751/http://claysnow.co.uk/recycling-tests-in-tdd/ \ No newline at end of file diff --git a/diamond/analysis_options.yaml b/diamond/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/diamond/analysis_options.yaml @@ -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 diff --git a/diamond/lib/diamond.dart b/diamond/lib/diamond.dart new file mode 100644 index 0000000..2840f38 --- /dev/null +++ b/diamond/lib/diamond.dart @@ -0,0 +1,48 @@ +class Diamond { + List rows(String input) { + List result = []; + + int rows = (input.codeUnitAt(0) - 64) * 2 - 1; + int padding = (rows / 2).floor(); + int center = 0; + bool halfWay = false; + int currentChar = 65; + + for (int i = 0; i < rows; i++) { + String x = ''; + x = addPad(x, padding, halfWay); + x += String.fromCharCode(currentChar); + if (center > 0) { + for (int i = 0; i < center; i++) { + x += ' '; + } + x += String.fromCharCode(currentChar); + } + x = addPad(x, padding, halfWay); + (halfWay) ? padding++ : padding--; + (halfWay) + ? (center > 0) + ? center = center - 2 + : center-- + : (center > 0) + ? center = center + 2 + : center++; + (halfWay) ? currentChar-- : currentChar++; + if (i > rows / 2 - 2) halfWay = true; + result.add(x); + } + + return result; + } + + String addPad(String input, int padSize, bool halfWay) { + for (int i = 0; i < padSize; i++) { + input += ' '; + } + return input; + } +} + +void main(List args) { + print(Diamond().rows('Z')); +} diff --git a/diamond/pubspec.lock b/diamond/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/diamond/pubspec.lock @@ -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" diff --git a/diamond/pubspec.yaml b/diamond/pubspec.yaml new file mode 100644 index 0000000..d63eaf5 --- /dev/null +++ b/diamond/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'diamond' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/diamond/test/diamond_test.dart b/diamond/test/diamond_test.dart new file mode 100644 index 0000000..382be7b --- /dev/null +++ b/diamond/test/diamond_test.dart @@ -0,0 +1,116 @@ +import 'package:diamond/diamond.dart'; +import 'package:test/test.dart'; + +void main() { + final diamond = Diamond(); + + group('Diamond', () { + test('Degenerate case with a single \'A\' row', () { + final result = diamond.rows('A'); + expect( + result, + equals([ + 'A', + ])); + }, skip: false); + + test('Degenerate case with no row containing 3 distinct groups of spaces', + () { + final result = diamond.rows('B'); + expect( + result, + equals([ + ' A ', + 'B B', + ' A ', + ])); + }, skip: true); + + test('Smallest non-degenerate case with odd diamond side length', () { + final result = diamond.rows('C'); + expect( + result, + equals([ + ' A ', + ' B B ', + 'C C', + ' B B ', + ' A ', + ])); + }, skip: true); + + test('Smallest non-degenerate case with even diamond side length', () { + final result = diamond.rows('D'); + expect( + result, + equals([ + ' A ', + ' B B ', + ' C C ', + 'D D', + ' C C ', + ' B B ', + ' A ', + ])); + }, skip: true); + + test('Largest possible diamond', () { + final result = diamond.rows('Z'); + expect( + result, + equals([ + ' A ', + ' B B ', + ' C C ', + ' D D ', + ' E E ', + ' F F ', + ' G G ', + ' H H ', + ' I I ', + ' J J ', + ' K K ', + ' L L ', + ' M M ', + ' N N ', + ' O O ', + ' P P ', + ' Q Q ', + ' R R ', + ' S S ', + ' T T ', + ' U U ', + ' V V ', + ' W W ', + ' X X ', + ' Y Y ', + 'Z Z', + ' Y Y ', + ' X X ', + ' W W ', + ' V V ', + ' U U ', + ' T T ', + ' S S ', + ' R R ', + ' Q Q ', + ' P P ', + ' O O ', + ' N N ', + ' M M ', + ' L L ', + ' K K ', + ' J J ', + ' I I ', + ' H H ', + ' G G ', + ' F F ', + ' E E ', + ' D D ', + ' C C ', + ' B B ', + ' A ', + ])); + }, skip: true); + }); +} diff --git a/difference-of-squares/.dart_tool/package_config.json b/difference-of-squares/.dart_tool/package_config.json new file mode 100644 index 0000000..3ef442a --- /dev/null +++ b/difference-of-squares/.dart_tool/package_config.json @@ -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": "difference_of_squares", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-09-30T19:49:23.149167Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/difference-of-squares/.exercism/config.json b/difference-of-squares/.exercism/config.json new file mode 100644 index 0000000..a5e7104 --- /dev/null +++ b/difference-of-squares/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "SuperPaintman" + ], + "contributors": [ + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/difference_of_squares.dart" + ], + "test": [ + "test/difference_of_squares_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.", + "source": "Problem 6 at Project Euler", + "source_url": "https://projecteuler.net/problem=6" +} diff --git a/difference-of-squares/.exercism/metadata.json b/difference-of-squares/.exercism/metadata.json new file mode 100644 index 0000000..ad5630e --- /dev/null +++ b/difference-of-squares/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"difference-of-squares","id":"8d7a8cc9237c47a380e23c69dd6c5c5e","url":"https://exercism.org/tracks/dart/exercises/difference-of-squares","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/difference-of-squares/HELP.md b/difference-of-squares/HELP.md new file mode 100644 index 0000000..3328cc6 --- /dev/null +++ b/difference-of-squares/HELP.md @@ -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/difference_of_squares.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. \ No newline at end of file diff --git a/difference-of-squares/README.md b/difference-of-squares/README.md new file mode 100644 index 0000000..c9ead0c --- /dev/null +++ b/difference-of-squares/README.md @@ -0,0 +1,34 @@ +# Difference of Squares + +Welcome to Difference of Squares on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. + +The square of the sum of the first ten natural numbers is +(1 + 2 + ... + 10)² = 55² = 3025. + +The sum of the squares of the first ten natural numbers is +1² + 2² + ... + 10² = 385. + +Hence the difference between the square of the sum of the first ten natural numbers and the sum of the squares of the first ten natural numbers is 3025 - 385 = 2640. + +You are not expected to discover an efficient solution to this yourself from first principles; research is allowed, indeed, encouraged. +Finding the best algorithm for the problem is a key skill in software engineering. + +## Source + +### Created by + +- @SuperPaintman + +### Contributed to by + +- @Stargator +- @kytrinyx + +### Based on + +Problem 6 at Project Euler - https://projecteuler.net/problem=6 \ No newline at end of file diff --git a/difference-of-squares/analysis_options.yaml b/difference-of-squares/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/difference-of-squares/analysis_options.yaml @@ -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 diff --git a/difference-of-squares/lib/difference_of_squares.dart b/difference-of-squares/lib/difference_of_squares.dart new file mode 100644 index 0000000..5693ded --- /dev/null +++ b/difference-of-squares/lib/difference_of_squares.dart @@ -0,0 +1,19 @@ +class DifferenceOfSquares { + int squareOfSum(int num) { + int sum = num * (num + 1) ~/ 2; + return sum * sum; + } + + int sumOfSquares(int num) { + return num * (num + 1) * (2 * num + 1) ~/ 6; + } + + int differenceOfSquares(int num) { + return squareOfSum(num) - sumOfSquares(num); + } +} + +void main(List args) { + final differenceOfSquares = DifferenceOfSquares(); + print(differenceOfSquares.differenceOfSquares(100).abs()); +} diff --git a/difference-of-squares/pubspec.lock b/difference-of-squares/pubspec.lock new file mode 100644 index 0000000..235179f --- /dev/null +++ b/difference-of-squares/pubspec.lock @@ -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" diff --git a/difference-of-squares/pubspec.yaml b/difference-of-squares/pubspec.yaml new file mode 100644 index 0000000..9601289 --- /dev/null +++ b/difference-of-squares/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'difference_of_squares' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/difference-of-squares/test/difference_of_squares_test.dart b/difference-of-squares/test/difference_of_squares_test.dart new file mode 100644 index 0000000..d689a2a --- /dev/null +++ b/difference-of-squares/test/difference_of_squares_test.dart @@ -0,0 +1,66 @@ +import 'package:difference_of_squares/difference_of_squares.dart'; +import 'package:test/test.dart'; + +final differenceOfSquares = DifferenceOfSquares(); + +void main() { + group( + 'DifferenceOfSquares: Square the sum of the numbers up to the given number - ', + squareTheSumOfTheNumbersUpToTheGivenNumber); + group( + 'DifferenceOfSquares: Sum the squares of the numbers up to the given number - ', + sumTheSquaresOfTheNumbersUpToTheGivenNumber); + group('DifferenceOfSquares: Subtract sum of squares from square of sums - ', + subtractSumOfSquaresFromSquareOfSums); +} + +void squareTheSumOfTheNumbersUpToTheGivenNumber() { + test('square of sum 1', () { + final result = differenceOfSquares.squareOfSum(1); + expect(result, equals(1)); + }, skip: false); + + test('square of sum 5', () { + final result = differenceOfSquares.squareOfSum(5); + expect(result, equals(225)); + }, skip: false); + + test('square of sum 100', () { + final result = differenceOfSquares.squareOfSum(100); + expect(result, equals(25502500)); + }, skip: false); +} + +void sumTheSquaresOfTheNumbersUpToTheGivenNumber() { + test('sum of squares 1', () { + final result = differenceOfSquares.sumOfSquares(1); + expect(result, equals(1)); + }, skip: false); + + test('sum of squares 5', () { + final result = differenceOfSquares.sumOfSquares(5); + expect(result, equals(55)); + }, skip: false); + + test('sum of squares 100', () { + final result = differenceOfSquares.sumOfSquares(100); + expect(result, equals(338350)); + }, skip: false); +} + +void subtractSumOfSquaresFromSquareOfSums() { + test('difference of squares 1', () { + final result = differenceOfSquares.differenceOfSquares(1); + expect(result, equals(0)); + }, skip: false); + + test('difference of squares 5', () { + final result = differenceOfSquares.differenceOfSquares(5); + expect(result, equals(170)); + }, skip: false); + + test('difference of squares 100', () { + final result = differenceOfSquares.differenceOfSquares(100); + expect(result, equals(25164150)); + }, skip: false); +} diff --git a/forth/.dart_tool/package_config.json b/forth/.dart_tool/package_config.json new file mode 100644 index 0000000..97c9ee3 --- /dev/null +++ b/forth/.dart_tool/package_config.json @@ -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": "forth", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-09-30T20:18:49.554722Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/forth/.exercism/config.json b/forth/.exercism/config.json new file mode 100644 index 0000000..cf776a3 --- /dev/null +++ b/forth/.exercism/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "matthewmorgan" + ], + "contributors": [ + "AlexeyBukin", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/forth.dart" + ], + "test": [ + "test/forth_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Implement an evaluator for a very simple subset of Forth." +} diff --git a/forth/.exercism/metadata.json b/forth/.exercism/metadata.json new file mode 100644 index 0000000..d9ef4ea --- /dev/null +++ b/forth/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"forth","id":"962363ff57f34196bb160ee464c6314e","url":"https://exercism.org/tracks/dart/exercises/forth","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/forth/HELP.md b/forth/HELP.md new file mode 100644 index 0000000..bac268d --- /dev/null +++ b/forth/HELP.md @@ -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/forth.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. \ No newline at end of file diff --git a/forth/README.md b/forth/README.md new file mode 100644 index 0000000..5e18aed --- /dev/null +++ b/forth/README.md @@ -0,0 +1,39 @@ +# Forth + +Welcome to Forth on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Implement an evaluator for a very simple subset of Forth. + +[Forth][forth] +is a stack-based programming language. +Implement a very basic evaluator for a small subset of Forth. + +Your evaluator has to support the following words: + +- `+`, `-`, `*`, `/` (integer arithmetic) +- `DUP`, `DROP`, `SWAP`, `OVER` (stack manipulation) + +Your evaluator also has to support defining new words using the customary syntax: `: word-name definition ;`. + +To keep things simple the only data type you need to support is signed integers of at least 16 bits size. + +You should use the following rules for the syntax: a number is a sequence of one or more (ASCII) digits, a word is a sequence of one or more letters, digits, symbols or punctuation that is not a number. +(Forth probably uses slightly different rules, but this is close enough.) + +Words are case-insensitive. + +[forth]: https://en.wikipedia.org/wiki/Forth_%28programming_language%29 + +## Source + +### Created by + +- @matthewmorgan + +### Contributed to by + +- @AlexeyBukin +- @kytrinyx \ No newline at end of file diff --git a/forth/analysis_options.yaml b/forth/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/forth/analysis_options.yaml @@ -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 diff --git a/forth/lib/forth.dart b/forth/lib/forth.dart new file mode 100644 index 0000000..dbb3b29 --- /dev/null +++ b/forth/lib/forth.dart @@ -0,0 +1,3 @@ +class Forth { + // Put your code here +} diff --git a/forth/pubspec.lock b/forth/pubspec.lock new file mode 100644 index 0000000..235179f --- /dev/null +++ b/forth/pubspec.lock @@ -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" diff --git a/forth/pubspec.yaml b/forth/pubspec.yaml new file mode 100644 index 0000000..8884329 --- /dev/null +++ b/forth/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'forth' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/forth/test/forth_test.dart b/forth/test/forth_test.dart new file mode 100644 index 0000000..858d662 --- /dev/null +++ b/forth/test/forth_test.dart @@ -0,0 +1,396 @@ +import 'package:forth/forth.dart'; +import 'package:test/test.dart'; + +final throwsEmptyStack = throwsA(isA().having((e) => e.toString(), 'message', 'Exception: Stack empty')); +final throwsInvalidDefinition = + throwsA(isA().having((e) => e.toString(), 'message', 'Exception: Invalid definition')); + +void main() { + group('Forth: parsing and numbers - ', parsingAndNumbers); + group('Forth: addition - ', addition); + group('Forth: subtraction - ', subtraction); + group('Forth: multiplication - ', multiplication); + group('Forth: division - ', division); + group('Forth: combined arithmetic - ', combinedArithmetic); + group('Forth: dup - ', dup); + group('Forth: drop - ', drop); + group('Forth: swap - ', swap); + group('Forth: over - ', over); + group('Forth: user-defined words - ', userDefinedWords); + group('Forth: case-insensitivity - ', caseInsensitivity); +} + +void parsingAndNumbers() { + test('numbers just get pushed onto the stack', () { + var forth = Forth(); + forth.evaluate('1 2 3 4 5'); + expect(forth.stack, equals([1, 2, 3, 4, 5])); + }, skip: false); + + test('pushes negative numbers onto the stack', () { + var forth = Forth(); + forth.evaluate('-1 -2 -3 -4 -5'); + expect(forth.stack, equals([-1, -2, -3, -4, -5])); + }, skip: true); +} + +void addition() { + test('can add two numbers', () { + var forth = Forth(); + forth.evaluate('1 2 +'); + expect(forth.stack, equals([3])); + }, skip: true); + + test('errors if there is nothing on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('+'), + throwsEmptyStack, + ); + }, skip: true); + + test('errors if there is only one value on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('1 +'), + throwsEmptyStack, + ); + }, skip: true); +} + +void subtraction() { + test('can subtract two numbers', () { + var forth = Forth(); + forth.evaluate('3 4 -'); + expect(forth.stack, equals([-1])); + }, skip: true); + + test('errors if there is nothing on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('-'), + throwsEmptyStack, + ); + }, skip: true); + + test('errors if there is only one value on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('1 -'), + throwsEmptyStack, + ); + }, skip: true); +} + +void multiplication() { + test('can multiply two numbers', () { + var forth = Forth(); + forth.evaluate('2 4 *'); + expect(forth.stack, equals([8])); + }, skip: true); + + test('errors if there is nothing on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('*'), + throwsEmptyStack, + ); + }, skip: true); + + test('errors if there is only one value on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('1 *'), + throwsEmptyStack, + ); + }, skip: true); +} + +void division() { + test('can divide two numbers', () { + var forth = Forth(); + forth.evaluate('12 3 /'); + expect(forth.stack, equals([4])); + }, skip: true); + + test('performs integer division', () { + var forth = Forth(); + forth.evaluate('8 3 /'); + expect(forth.stack, equals([2])); + }, skip: true); + + test('errors if dividing by zero', () { + var forth = Forth(); + expect( + () => forth.evaluate('4 0 /'), + throwsA(isA().having((e) => e.toString(), 'message', 'Exception: Division by zero')), + ); + }, skip: true); + + test('errors if there is nothing on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('/'), + throwsEmptyStack, + ); + }, skip: true); + + test('errors if there is only one value on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('1 /'), + throwsEmptyStack, + ); + }, skip: true); +} + +void combinedArithmetic() { + test('addition and subtraction', () { + var forth = Forth(); + forth.evaluate('1 2 + 4 -'); + expect(forth.stack, equals([-1])); + }, skip: true); + + test('multiplication and division', () { + var forth = Forth(); + forth.evaluate('2 4 * 3 /'); + expect(forth.stack, equals([2])); + }, skip: true); +} + +void dup() { + test('copies a value on the stack', () { + var forth = Forth(); + forth.evaluate('1 dup'); + expect(forth.stack, equals([1, 1])); + }, skip: true); + + test('copies the top value on the stack', () { + var forth = Forth(); + forth.evaluate('1 2 dup'); + expect(forth.stack, equals([1, 2, 2])); + }, skip: true); + + test('errors if there is nothing on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('dup'), + throwsEmptyStack, + ); + }, skip: true); +} + +void drop() { + test('removes the top value on the stack if it is the only one', () { + var forth = Forth(); + forth.evaluate('1 drop'); + expect(forth.stack, equals([])); + }, skip: true); + + test('removes the top value on the stack if it is not the only one', () { + var forth = Forth(); + forth.evaluate('1 2 drop'); + expect(forth.stack, equals([1])); + }, skip: true); + + test('errors if there is nothing on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('drop'), + throwsEmptyStack, + ); + }, skip: true); +} + +void swap() { + test('swaps the top two values on the stack if they are the only ones', () { + var forth = Forth(); + forth.evaluate('1 2 swap'); + expect(forth.stack, equals([2, 1])); + }, skip: true); + + test('swaps the top two values on the stack if they are not the only ones', () { + var forth = Forth(); + forth.evaluate('1 2 3 swap'); + expect(forth.stack, equals([1, 3, 2])); + }, skip: true); + + test('errors if there is nothing on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('swap'), + throwsEmptyStack, + ); + }, skip: true); + + test('errors if there is only one value on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('1 swap'), + throwsEmptyStack, + ); + }, skip: true); +} + +void over() { + test('copies the second element if there are only two', () { + var forth = Forth(); + forth.evaluate('1 2 over'); + expect(forth.stack, equals([1, 2, 1])); + }, skip: true); + + test('copies the second element if there are more than two', () { + var forth = Forth(); + forth.evaluate('1 2 3 over'); + expect(forth.stack, equals([1, 2, 3, 2])); + }, skip: true); + + test('errors if there is nothing on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('over'), + throwsEmptyStack, + ); + }, skip: true); + + test('errors if there is only one value on the stack', () { + var forth = Forth(); + expect( + () => forth.evaluate('1 over'), + throwsEmptyStack, + ); + }, skip: true); +} + +void userDefinedWords() { + test('can consist of built-in words', () { + var forth = Forth(); + forth.evaluate(': dup-twice dup dup ;'); + forth.evaluate('1 dup-twice'); + expect(forth.stack, equals([1, 1, 1])); + }, skip: true); + + test('execute in the right order', () { + var forth = Forth(); + forth.evaluate(': countup 1 2 3 ;'); + forth.evaluate('countup'); + expect(forth.stack, equals([1, 2, 3])); + }, skip: true); + + test('can override other user-defined words', () { + var forth = Forth(); + forth.evaluate(': foo dup ;'); + forth.evaluate(': foo dup dup ;'); + forth.evaluate('1 foo'); + expect(forth.stack, equals([1, 1, 1])); + }, skip: true); + + test('can override built-in words', () { + var forth = Forth(); + forth.evaluate(': swap dup ;'); + forth.evaluate('1 swap'); + expect(forth.stack, equals([1, 1])); + }, skip: true); + + test('can override built-in operators', () { + var forth = Forth(); + forth.evaluate(': + * ;'); + forth.evaluate('3 4 +'); + expect(forth.stack, equals([12])); + }, skip: true); + + test('can use different words with the same name', () { + var forth = Forth(); + forth.evaluate(': foo 5 ;'); + forth.evaluate(': bar foo ;'); + forth.evaluate(': foo 6 ;'); + forth.evaluate('bar foo'); + expect(forth.stack, equals([5, 6])); + }, skip: true); + + test('can define word that uses word with the same name', () { + var forth = Forth(); + forth.evaluate(': foo 10 ;'); + forth.evaluate(': foo foo 1 + ;'); + forth.evaluate('foo'); + expect(forth.stack, equals([11])); + }, skip: true); + + test('cannot redefine non-negative numbers', () { + var forth = Forth(); + expect( + () => forth.evaluate(': 1 2 ;'), + throwsInvalidDefinition, + ); + }, skip: true); + + test('cannot redefine negative numbers', () { + var forth = Forth(); + expect( + () => forth.evaluate(': -1 2 ;'), + throwsInvalidDefinition, + ); + }, skip: true); + + test('errors if executing a non-existent word', () { + var forth = Forth(); + expect( + () => forth.evaluate('foo'), + throwsA(isA().having((e) => e.toString(), 'message', 'Exception: Unknown command')), + ); + }, skip: true); + + test('only defines locally', () { + var first = Forth(); + var second = Forth(); + first.evaluate(': + - ;'); + first.evaluate('1 1 +'); + second.evaluate('1 1 +'); + expect( + [first.stack, second.stack], + equals(>[ + [0], + [2] + ])); + }, skip: true); +} + +void caseInsensitivity() { + test('DUP is case-insensitive', () { + var forth = Forth(); + forth.evaluate('1 DUP Dup dup'); + expect(forth.stack, equals([1, 1, 1, 1])); + }, skip: true); + + test('DROP is case-insensitive', () { + var forth = Forth(); + forth.evaluate('1 2 3 4 DROP Drop drop'); + expect(forth.stack, equals([1])); + }, skip: true); + + test('SWAP is case-insensitive', () { + var forth = Forth(); + forth.evaluate('1 2 SWAP 3 Swap 4 swap'); + expect(forth.stack, equals([2, 3, 4, 1])); + }, skip: true); + + test('OVER is case-insensitive', () { + var forth = Forth(); + forth.evaluate('1 2 OVER Over over'); + expect(forth.stack, equals([1, 2, 1, 2, 1])); + }, skip: true); + + test('user-defined words are case-insensitive', () { + var forth = Forth(); + forth.evaluate(': foo dup ;'); + forth.evaluate('1 FOO Foo foo'); + expect(forth.stack, equals([1, 1, 1, 1])); + }, skip: true); + + test('definitions are case-insensitive', () { + var forth = Forth(); + forth.evaluate(': SWAP DUP Dup dup ;'); + forth.evaluate('1 swap'); + expect(forth.stack, equals([1, 1, 1, 1])); + }, skip: true); +} diff --git a/gigasecond/.dart_tool/package_config.json b/gigasecond/.dart_tool/package_config.json new file mode 100644 index 0000000..4445352 --- /dev/null +++ b/gigasecond/.dart_tool/package_config.json @@ -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": "gigasecond", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-09T11:08:05.100492Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/gigasecond/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/gigasecond/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/gigasecond/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/gigasecond/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/gigasecond/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..146fd6a Binary files /dev/null and b/gigasecond/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/gigasecond/.exercism/config.json b/gigasecond/.exercism/config.json new file mode 100644 index 0000000..069bd8d --- /dev/null +++ b/gigasecond/.exercism/config.json @@ -0,0 +1,25 @@ +{ + "authors": [ + "SuperPaintman" + ], + "contributors": [ + "rafaelalvessa", + "Stargator", + "Zureka", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/gigasecond.dart" + ], + "test": [ + "test/gigasecond_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", + "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", + "source_url": "https://pine.fm/LearnToProgram/?Chapter=09" +} diff --git a/gigasecond/.exercism/metadata.json b/gigasecond/.exercism/metadata.json new file mode 100644 index 0000000..1799f2a --- /dev/null +++ b/gigasecond/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"gigasecond","id":"7c42c83affa9412e82ce04b2423ffbc8","url":"https://exercism.org/tracks/dart/exercises/gigasecond","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/gigasecond/HELP.md b/gigasecond/HELP.md new file mode 100644 index 0000000..8f7ca22 --- /dev/null +++ b/gigasecond/HELP.md @@ -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/gigasecond.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. \ No newline at end of file diff --git a/gigasecond/README.md b/gigasecond/README.md new file mode 100644 index 0000000..4b8e396 --- /dev/null +++ b/gigasecond/README.md @@ -0,0 +1,55 @@ +# Gigasecond + +Welcome to Gigasecond on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +The way we measure time is kind of messy. +We have 60 seconds in a minute, and 60 minutes in an hour. +This comes from ancient Babylon, where they used 60 as the basis for their number system. +We have 24 hours in a day, 7 days in a week, and how many days in a month? +Well, for days in a month it depends not only on which month it is, but also on what type of calendar is used in the country you live in. + +What if, instead, we only use seconds to express time intervals? +Then we can use metric system prefixes for writing large numbers of seconds in more easily comprehensible quantities. + +- A food recipe might explain that you need to let the brownies cook in the oven for two kiloseconds (that's two thousand seconds). +- Perhaps you and your family would travel to somewhere exotic for two megaseconds (that's two million seconds). +- And if you and your spouse were married for _a thousand million_ seconds, you would celebrate your one gigasecond anniversary. + +~~~~exercism/note +If we ever colonize Mars or some other planet, measuring time is going to get even messier. +If someone says "year" do they mean a year on Earth or a year on Mars? + +The idea for this exercise came from the science fiction novel ["A Deepness in the Sky"][vinge-novel] by author Vernor Vinge. +In it the author uses the metric system as the basis for time measurements. + +[vinge-novel]: https://www.tor.com/2017/08/03/science-fiction-with-something-for-everyone-a-deepness-in-the-sky-by-vernor-vinge/ +~~~~ + +## Instructions + +Your task is to determine the date and time one gigasecond after a certain date. + +A gigasecond is one thousand million seconds. +That is a one with nine zeros after it. + +If you were born on _January 24th, 2015 at 22:00 (10:00:00pm)_, then you would be a gigasecond old on _October 2nd, 2046 at 23:46:40 (11:46:40pm)_. + +## Source + +### Created by + +- @SuperPaintman + +### Contributed to by + +- @rafaelalvessa +- @Stargator +- @Zureka +- @kytrinyx + +### Based on + +Chapter 9 in Chris Pine's online Learn to Program tutorial. - https://pine.fm/LearnToProgram/?Chapter=09 \ No newline at end of file diff --git a/gigasecond/analysis_options.yaml b/gigasecond/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/gigasecond/analysis_options.yaml @@ -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 diff --git a/gigasecond/lib/gigasecond.dart b/gigasecond/lib/gigasecond.dart new file mode 100644 index 0000000..1da3f0e --- /dev/null +++ b/gigasecond/lib/gigasecond.dart @@ -0,0 +1,3 @@ +DateTime addGigasecondTo(final DateTime dateTime) { + return dateTime.add(Duration(seconds: 1e9 ~/ 1)); +} diff --git a/gigasecond/pubspec.lock b/gigasecond/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/gigasecond/pubspec.lock @@ -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" diff --git a/gigasecond/pubspec.yaml b/gigasecond/pubspec.yaml new file mode 100644 index 0000000..e035688 --- /dev/null +++ b/gigasecond/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'gigasecond' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/gigasecond/test/gigasecond_test.dart b/gigasecond/test/gigasecond_test.dart new file mode 100644 index 0000000..9284b43 --- /dev/null +++ b/gigasecond/test/gigasecond_test.dart @@ -0,0 +1,20 @@ +import 'package:gigasecond/gigasecond.dart'; +import 'package:test/test.dart'; + +void main() { + group('Gigasecond', () { + test('full time specified', () { + final moment = DateTime.utc(2015, DateTime.january, 24, 22, 00, 00); + final result = addGigasecondTo(moment); + final expected = DateTime.utc(2046, DateTime.october, 02, 23, 46, 40); + expect(result, equals(expected)); + }, skip: false); + + test('full time with day roll-over', () { + final moment = DateTime.utc(2015, DateTime.january, 24, 23, 59, 59); + final result = addGigasecondTo(moment); + final expected = DateTime.utc(2046, DateTime.october, 03, 01, 46, 39); + expect(result, equals(expected)); + }, skip: true); + }); +} diff --git a/hamming/.dart_tool/package_config.json b/hamming/.dart_tool/package_config.json new file mode 100644 index 0000000..351b86f --- /dev/null +++ b/hamming/.dart_tool/package_config.json @@ -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": "hamming", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-03T13:08:46.834997Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/hamming/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/hamming/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/hamming/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/hamming/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/hamming/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..f533e11 Binary files /dev/null and b/hamming/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/hamming/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/hamming/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..699d613 Binary files /dev/null and b/hamming/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/hamming/.exercism/config.json b/hamming/.exercism/config.json new file mode 100644 index 0000000..7753654 --- /dev/null +++ b/hamming/.exercism/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "SuperPaintman" + ], + "contributors": [ + "jerold", + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/hamming.dart" + ], + "test": [ + "test/hamming_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Calculate the Hamming difference between two DNA strands.", + "source": "The Calculating Point Mutations problem at Rosalind", + "source_url": "https://rosalind.info/problems/hamm/" +} diff --git a/hamming/.exercism/metadata.json b/hamming/.exercism/metadata.json new file mode 100644 index 0000000..786000d --- /dev/null +++ b/hamming/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"hamming","id":"66e55a9ae15042edba426d17518cd5d5","url":"https://exercism.org/tracks/dart/exercises/hamming","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/hamming/HELP.md b/hamming/HELP.md new file mode 100644 index 0000000..2d6d3d6 --- /dev/null +++ b/hamming/HELP.md @@ -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/hamming.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. \ No newline at end of file diff --git a/hamming/README.md b/hamming/README.md new file mode 100644 index 0000000..3b7aa9d --- /dev/null +++ b/hamming/README.md @@ -0,0 +1,48 @@ +# Hamming + +Welcome to Hamming on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Calculate the Hamming Distance between two DNA strands. + +Your body is made up of cells that contain DNA. +Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. +In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! + +When cells divide, their DNA replicates too. +Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. +If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred. +This is known as the "Hamming Distance". + +We read DNA using the letters C,A,G and T. +Two strands might look like this: + + GAGCCTACTAACGGGAT + CATCGTAATGACGGCCT + ^ ^ ^ ^ ^ ^^ + +They have 7 differences, and therefore the Hamming Distance is 7. + +The Hamming Distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :) + +## Implementation notes + +The Hamming distance is only defined for sequences of equal length, so an attempt to calculate it between sequences of different lengths should not work. + +## Source + +### Created by + +- @SuperPaintman + +### Contributed to by + +- @jerold +- @Stargator +- @kytrinyx + +### Based on + +The Calculating Point Mutations problem at Rosalind - https://rosalind.info/problems/hamm/ \ No newline at end of file diff --git a/hamming/analysis_options.yaml b/hamming/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/hamming/analysis_options.yaml @@ -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 diff --git a/hamming/lib/hamming.dart b/hamming/lib/hamming.dart new file mode 100644 index 0000000..9aa9431 --- /dev/null +++ b/hamming/lib/hamming.dart @@ -0,0 +1,12 @@ +class Hamming { + int distance(String a, String b) { + if (a.length != b.length) + throw ArgumentError('strands must be of equal length'); + if (a == b) return 0; + int difference = 0; + for (int i = 0; i < a.length; i++) { + if (a[i] != b[i]) difference++; + } + return difference; + } +} diff --git a/hamming/pubspec.lock b/hamming/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/hamming/pubspec.lock @@ -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" diff --git a/hamming/pubspec.yaml b/hamming/pubspec.yaml new file mode 100644 index 0000000..cdaac1e --- /dev/null +++ b/hamming/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'hamming' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/hamming/test/hamming_test.dart b/hamming/test/hamming_test.dart new file mode 100644 index 0000000..7d037f4 --- /dev/null +++ b/hamming/test/hamming_test.dart @@ -0,0 +1,52 @@ +import 'package:hamming/hamming.dart'; +import 'package:test/test.dart'; + +void main() { + final hamming = Hamming(); + + final mustEqual = predicate((Error e) => e is ArgumentError && e.message == 'strands must be of equal length', + 'an ArgumentError with the message "strands must be of equal length"'); + + group('Hamming', () { + test('empty strands', () { + final result = hamming.distance('', ''); + expect(result, equals(0)); + }, skip: false); + + test('single letter identical strands', () { + final result = hamming.distance('A', 'A'); + expect(result, equals(0)); + }, skip: true); + + test('single letter different strands', () { + final result = hamming.distance('G', 'T'); + expect(result, equals(1)); + }, skip: true); + + test('long identical strands', () { + final result = hamming.distance('GGACTGAAATCTG', 'GGACTGAAATCTG'); + expect(result, equals(0)); + }, skip: true); + + test('long different strands', () { + final result = hamming.distance('GGACGGATTCTG', 'AGGACGGATTCT'); + expect(result, equals(9)); + }, skip: true); + + test('disallow first strand longer', () { + expect(() => hamming.distance('AATG', 'AAA'), throwsA(mustEqual)); + }, skip: true); + + test('disallow second strand longer', () { + expect(() => hamming.distance('ATA', 'AGTG'), throwsA(mustEqual)); + }, skip: true); + + test('disallow empty first strand', () { + expect(() => hamming.distance('', 'G'), throwsA(mustEqual)); + }, skip: true); + + test('disallow empty second strand', () { + expect(() => hamming.distance('G', ''), throwsA(mustEqual)); + }, skip: true); + }); +} diff --git a/high-scores/.dart_tool/package_config.json b/high-scores/.dart_tool/package_config.json new file mode 100644 index 0000000..863dc60 --- /dev/null +++ b/high-scores/.dart_tool/package_config.json @@ -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": "high_scores", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-09-29T12:21:26.812479Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/high-scores/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/high-scores/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..07e8fe3 Binary files /dev/null and b/high-scores/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/high-scores/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/high-scores/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..82c646d Binary files /dev/null and b/high-scores/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/high-scores/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/high-scores/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..dffea4f Binary files /dev/null and b/high-scores/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/high-scores/.exercism/config.json b/high-scores/.exercism/config.json new file mode 100644 index 0000000..6217812 --- /dev/null +++ b/high-scores/.exercism/config.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "Stargator" + ], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "lib/high_scores.dart" + ], + "test": [ + "test/high_scores_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Manage a player's High Score list.", + "source": "Tribute to the eighties' arcade game Frogger" +} diff --git a/high-scores/.exercism/metadata.json b/high-scores/.exercism/metadata.json new file mode 100644 index 0000000..d22b20d --- /dev/null +++ b/high-scores/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"high-scores","id":"6ced307f11f84cba956ea60a6a2baa55","url":"https://exercism.org/tracks/dart/exercises/high-scores","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/high-scores/HELP.md b/high-scores/HELP.md new file mode 100644 index 0000000..437d16b --- /dev/null +++ b/high-scores/HELP.md @@ -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/high_scores.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. \ No newline at end of file diff --git a/high-scores/README.md b/high-scores/README.md new file mode 100644 index 0000000..496f226 --- /dev/null +++ b/high-scores/README.md @@ -0,0 +1,25 @@ +# High Scores + +Welcome to High Scores on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Manage a game player's High Score list. + +Your task is to build a high-score component of the classic Frogger game, one of the highest selling and most addictive games of all time, and a classic of the arcade era. +Your task is to write methods that return the highest score from the list, the last added score and the three highest scores. + +## Source + +### Created by + +- @Stargator + +### Contributed to by + +- @kytrinyx + +### Based on + +Tribute to the eighties' arcade game Frogger \ No newline at end of file diff --git a/high-scores/analysis_options.yaml b/high-scores/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/high-scores/analysis_options.yaml @@ -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 diff --git a/high-scores/lib/high_scores.dart b/high-scores/lib/high_scores.dart new file mode 100644 index 0000000..892ba30 --- /dev/null +++ b/high-scores/lib/high_scores.dart @@ -0,0 +1,15 @@ +class HighScores { + List scores; + late List sortedScores; + + HighScores([this.scores = const [0]]) { + sortedScores = scores.toList(); + sortedScores.sort((a, b) => b.compareTo(a)); + } + + int latest() => scores.last; + + Iterable personalTopThree() => this.sortedScores.take(3); + + int personalBest() => sortedScores.first; +} diff --git a/high-scores/pubspec.lock b/high-scores/pubspec.lock new file mode 100644 index 0000000..235179f --- /dev/null +++ b/high-scores/pubspec.lock @@ -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" diff --git a/high-scores/pubspec.yaml b/high-scores/pubspec.yaml new file mode 100644 index 0000000..7da4fc3 --- /dev/null +++ b/high-scores/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'high_scores' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/high-scores/test/high_scores_test.dart b/high-scores/test/high_scores_test.dart new file mode 100644 index 0000000..e580f4f --- /dev/null +++ b/high-scores/test/high_scores_test.dart @@ -0,0 +1,76 @@ +import 'package:high_scores/high_scores.dart'; +import 'package:test/test.dart'; + +void main() { + group('HighScores: high scores tests - ', highScoresTests); + group('HighScores: Top 3 scores - ', top3Scores); +} + +void highScoresTests() { + test('List of scores', () { + final scores = HighScores([30, 50, 20, 70]); + expect(scores.scores, equals([30, 50, 20, 70])); + }, skip: false); + + test('Latest score', () { + final scores = HighScores([100, 0, 90, 30]); + expect(scores.latest(), equals(30)); + }, skip: false); + + test('Personal best', () { + final scores = HighScores([40, 100, 70]); + expect(scores.personalBest(), equals(100)); + }, skip: false); +} + +void top3Scores() { + test('Personal top three from a list of scores', () { + final scores = + HighScores([10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]); + expect(scores.personalTopThree(), equals([100, 90, 70])); + }, skip: false); + + test('Personal top highest to lowest', () { + final scores = HighScores([20, 10, 30]); + expect(scores.personalTopThree(), equals([30, 20, 10])); + }, skip: false); + + test('Personal top when there is a tie', () { + final scores = HighScores([40, 20, 40, 30]); + expect(scores.personalTopThree(), equals([40, 40, 30])); + }, skip: false); + + test('Personal top when there are less than 3', () { + final scores = HighScores([30, 70]); + expect(scores.personalTopThree(), equals([70, 30])); + }, skip: false); + + test('Personal top when there is only one', () { + final scores = HighScores([40]); + expect(scores.personalTopThree(), equals([40])); + }, skip: false); + + test('Latest score after personal top scores', () { + final scores = HighScores([70, 50, 20, 30]); + scores.personalTopThree(); + expect(scores.latest(), equals(30)); + }, skip: false); + + test('Scores after personal top scores', () { + final scores = HighScores([30, 50, 20, 70]); + scores.personalTopThree(); + expect(scores.scores, equals([30, 50, 20, 70])); + }, skip: false); + + test('Latest score after personal best', () { + final scores = HighScores([20, 70, 15, 25, 30]); + scores.personalBest(); + expect(scores.latest(), equals(30)); + }, skip: false); + + test('Scores after personal best', () { + final scores = HighScores([20, 70, 15, 25, 30]); + scores.personalBest(); + expect(scores.scores, equals([20, 70, 15, 25, 30])); + }, skip: false); +} diff --git a/isogram/.dart_tool/package_config.json b/isogram/.dart_tool/package_config.json new file mode 100644 index 0000000..7352e48 --- /dev/null +++ b/isogram/.dart_tool/package_config.json @@ -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": "isogram", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-11-01T12:35:51.282835Z", + "generator": "pub", + "generatorVersion": "3.1.5" +} diff --git a/isogram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/isogram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..b8dbb4e Binary files /dev/null and b/isogram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/isogram/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot b/isogram/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot new file mode 100644 index 0000000..6ea874b Binary files /dev/null and b/isogram/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot differ diff --git a/isogram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/isogram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..5b1c7f6 Binary files /dev/null and b/isogram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/isogram/.exercism/config.json b/isogram/.exercism/config.json new file mode 100644 index 0000000..e65b4b9 --- /dev/null +++ b/isogram/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "jvarness" + ], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "lib/isogram.dart" + ], + "test": [ + "test/isogram_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Determine if a word or phrase is an isogram.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Isogram" +} diff --git a/isogram/.exercism/metadata.json b/isogram/.exercism/metadata.json new file mode 100644 index 0000000..e3cbc41 --- /dev/null +++ b/isogram/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"isogram","id":"4adcd041c3284bcfa63a87dccc3caab0","url":"https://exercism.org/tracks/dart/exercises/isogram","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/isogram/HELP.md b/isogram/HELP.md new file mode 100644 index 0000000..312ed41 --- /dev/null +++ b/isogram/HELP.md @@ -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/isogram.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. \ No newline at end of file diff --git a/isogram/README.md b/isogram/README.md new file mode 100644 index 0000000..5013584 --- /dev/null +++ b/isogram/README.md @@ -0,0 +1,33 @@ +# Isogram + +Welcome to Isogram on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Determine if a word or phrase is an isogram. + +An isogram (also known as a "non-pattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. + +Examples of isograms: + +- lumberjacks +- background +- downstream +- six-year-old + +The word *isograms*, however, is not an isogram, because the s repeats. + +## Source + +### Created by + +- @jvarness + +### Contributed to by + +- @kytrinyx + +### Based on + +Wikipedia - https://en.wikipedia.org/wiki/Isogram \ No newline at end of file diff --git a/isogram/analysis_options.yaml b/isogram/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/isogram/analysis_options.yaml @@ -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 diff --git a/isogram/lib/isogram.dart b/isogram/lib/isogram.dart new file mode 100644 index 0000000..ab9abaf --- /dev/null +++ b/isogram/lib/isogram.dart @@ -0,0 +1,16 @@ +class Isogram { + bool isIsogram(String isogram) { + final List allAlphabeticChars = []; + final Set uniqueAlphabeticChars = {}; + isogram = isogram.toLowerCase(); + isogram.split('').forEach((char) { + if (char == char.toLowerCase() && + char.codeUnitAt(0) >= 97 && + char.codeUnitAt(0) <= 122) { + allAlphabeticChars.add(char); + uniqueAlphabeticChars.add(char); + } + }); + return allAlphabeticChars.length == uniqueAlphabeticChars.length; + } +} diff --git a/isogram/pubspec.lock b/isogram/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/isogram/pubspec.lock @@ -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" diff --git a/isogram/pubspec.yaml b/isogram/pubspec.yaml new file mode 100644 index 0000000..de9f6ce --- /dev/null +++ b/isogram/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'isogram' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/isogram/test/isogram_test.dart b/isogram/test/isogram_test.dart new file mode 100644 index 0000000..534747a --- /dev/null +++ b/isogram/test/isogram_test.dart @@ -0,0 +1,78 @@ +import 'package:isogram/isogram.dart'; +import 'package:test/test.dart'; + +void main() { + final isogram = Isogram(); + + group('Isogram', () { + test('empty string', () { + final result = isogram.isIsogram(''); + expect(result, equals(true)); + }, skip: false); + + test('isogram with only lower case characters', () { + final result = isogram.isIsogram('isogram'); + expect(result, equals(true)); + }, skip: false); + + test('word with one duplicated character', () { + final result = isogram.isIsogram('eleven'); + expect(result, equals(false)); + }, skip: false); + + test('word with one duplicated character from the end of the alphabet', () { + final result = isogram.isIsogram('zzyzx'); + expect(result, equals(false)); + }, skip: false); + + test('longest reported english isogram', () { + final result = isogram.isIsogram('subdermatoglyphic'); + expect(result, equals(true)); + }, skip: false); + + test('word with duplicated character in mixed case', () { + final result = isogram.isIsogram('Alphabet'); + expect(result, equals(false)); + }, skip: false); + + test('word with duplicated character in mixed case, lowercase first', () { + final result = isogram.isIsogram('alphAbet'); + expect(result, equals(false)); + }, skip: false); + + test('hypothetical isogrammic word with hyphen', () { + final result = isogram.isIsogram('thumbscrew-japingly'); + expect(result, equals(true)); + }, skip: false); + + test('hypothetical word with duplicated character following hyphen', () { + final result = isogram.isIsogram('thumbscrew-jappingly'); + expect(result, equals(false)); + }, skip: false); + + test('isogram with duplicated hyphen', () { + final result = isogram.isIsogram('six-year-old'); + expect(result, equals(true)); + }, skip: false); + + test('made-up name that is an isogram', () { + final result = isogram.isIsogram('Emily Jung Schwartzkopf'); + expect(result, equals(true)); + }, skip: false); + + test('duplicated character in the middle', () { + final result = isogram.isIsogram('accentor'); + expect(result, equals(false)); + }, skip: false); + + test('same first and last characters', () { + final result = isogram.isIsogram('angola'); + expect(result, equals(false)); + }, skip: false); + + test('word with duplicated character and with two hyphens', () { + final result = isogram.isIsogram('up-to-date'); + expect(result, equals(false)); + }, skip: false); + }); +} diff --git a/leap/.dart_tool/package_config.json b/leap/.dart_tool/package_config.json new file mode 100644 index 0000000..8140429 --- /dev/null +++ b/leap/.dart_tool/package_config.json @@ -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": "leap", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-09-28T12:30:38.968255Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/leap/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/leap/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..07e8fe3 Binary files /dev/null and b/leap/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/leap/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/leap/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..82c646d Binary files /dev/null and b/leap/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/leap/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/leap/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..b801a8b Binary files /dev/null and b/leap/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/leap/.exercism/config.json b/leap/.exercism/config.json new file mode 100644 index 0000000..3979de0 --- /dev/null +++ b/leap/.exercism/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "SuperPaintman" + ], + "contributors": [ + "jvarness", + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/leap.dart" + ], + "test": [ + "test/leap_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given a year, report if it is a leap year.", + "source": "CodeRanch Cattle Drive, Assignment 3", + "source_url": "https://coderanch.com/t/718816/Leap" +} diff --git a/leap/.exercism/metadata.json b/leap/.exercism/metadata.json new file mode 100644 index 0000000..2c43b9c --- /dev/null +++ b/leap/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"leap","id":"f8a2489d1ec045c1afb6b0be473409ef","url":"https://exercism.org/tracks/dart/exercises/leap","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/leap/HELP.md b/leap/HELP.md new file mode 100644 index 0000000..b38a273 --- /dev/null +++ b/leap/HELP.md @@ -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/leap.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. \ No newline at end of file diff --git a/leap/README.md b/leap/README.md new file mode 100644 index 0000000..dec81c2 --- /dev/null +++ b/leap/README.md @@ -0,0 +1,43 @@ +# Leap + +Welcome to Leap on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a year, report if it is a leap year. + +The tricky thing here is that a leap year in the Gregorian calendar occurs: + +```text +on every year that is evenly divisible by 4 + except every year that is evenly divisible by 100 + unless the year is also evenly divisible by 400 +``` + +For example, 1997 is not a leap year, but 1996 is. +1900 is not a leap year, but 2000 is. + +## Notes + +Though our exercise adopts some very simple rules, there is more to learn! + +For a delightful, four minute explanation of the whole leap year phenomenon, go watch [this youtube video][video]. + +[video]: https://www.youtube.com/watch?v=xX96xng7sAE + +## Source + +### Created by + +- @SuperPaintman + +### Contributed to by + +- @jvarness +- @Stargator +- @kytrinyx + +### Based on + +CodeRanch Cattle Drive, Assignment 3 - https://coderanch.com/t/718816/Leap \ No newline at end of file diff --git a/leap/analysis_options.yaml b/leap/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/leap/analysis_options.yaml @@ -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 diff --git a/leap/lib/leap.dart b/leap/lib/leap.dart new file mode 100644 index 0000000..d3ed099 --- /dev/null +++ b/leap/lib/leap.dart @@ -0,0 +1,6 @@ +class Leap { + // Put your code here + bool leapYear(int year) { + return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); + } +} diff --git a/leap/pubspec.lock b/leap/pubspec.lock new file mode 100644 index 0000000..235179f --- /dev/null +++ b/leap/pubspec.lock @@ -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" diff --git a/leap/pubspec.yaml b/leap/pubspec.yaml new file mode 100644 index 0000000..b9cb647 --- /dev/null +++ b/leap/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'leap' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/leap/test/leap_test.dart b/leap/test/leap_test.dart new file mode 100644 index 0000000..61d1c2e --- /dev/null +++ b/leap/test/leap_test.dart @@ -0,0 +1,53 @@ +import 'package:leap/leap.dart'; +import 'package:test/test.dart'; + +void main() { + final leap = Leap(); + + group('Leap', () { + test('year not divisible by 4 in common year', () { + final result = leap.leapYear(2015); + expect(result, equals(false)); + }, skip: false); + + test('year divisible by 2, not divisible by 4 in common year', () { + final result = leap.leapYear(1970); + expect(result, equals(false)); + }, skip: false); + + test('year divisible by 4, not divisible by 100 in leap year', () { + final result = leap.leapYear(1996); + expect(result, equals(true)); + }, skip: false); + + test('year divisible by 4 and 5 is still a leap year', () { + final result = leap.leapYear(1960); + expect(result, equals(true)); + }, skip: false); + + test('year divisible by 100, not divisible by 400 in common year', () { + final result = leap.leapYear(2100); + expect(result, equals(false)); + }, skip: false); + + test('year divisible by 100 but not by 3 is still not a leap year', () { + final result = leap.leapYear(1900); + expect(result, equals(false)); + }, skip: false); + + test('year divisible by 400 is leap year', () { + final result = leap.leapYear(2000); + expect(result, equals(true)); + }, skip: false); + + test('year divisible by 400 but not by 125 is still a leap year', () { + final result = leap.leapYear(2400); + expect(result, equals(true)); + }, skip: false); + + test('year divisible by 200, not divisible by 400 in common year', () { + final result = leap.leapYear(1800); + expect(result, equals(false)); + }, skip: false); + }); +} diff --git a/matching-brackets/.dart_tool/package_config.json b/matching-brackets/.dart_tool/package_config.json new file mode 100644 index 0000000..3ccd602 --- /dev/null +++ b/matching-brackets/.dart_tool/package_config.json @@ -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": "matching_brackets", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-09T11:32:39.320946Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/matching-brackets/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/matching-brackets/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/matching-brackets/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/matching-brackets/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/matching-brackets/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..569e19c Binary files /dev/null and b/matching-brackets/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/matching-brackets/.exercism/config.json b/matching-brackets/.exercism/config.json new file mode 100644 index 0000000..2e9b669 --- /dev/null +++ b/matching-brackets/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "johnngugi" + ], + "contributors": [ + "amscotti", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/matching_brackets.dart" + ], + "test": [ + "test/matching_brackets_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Make sure the brackets and braces all match.", + "source": "Ginna Baker" +} diff --git a/matching-brackets/.exercism/metadata.json b/matching-brackets/.exercism/metadata.json new file mode 100644 index 0000000..454d760 --- /dev/null +++ b/matching-brackets/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"matching-brackets","id":"24fbc57fb53e48f589056f8db5b6e189","url":"https://exercism.org/tracks/dart/exercises/matching-brackets","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/matching-brackets/HELP.md b/matching-brackets/HELP.md new file mode 100644 index 0000000..5f88bf2 --- /dev/null +++ b/matching-brackets/HELP.md @@ -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/matching_brackets.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. \ No newline at end of file diff --git a/matching-brackets/README.md b/matching-brackets/README.md new file mode 100644 index 0000000..6d9492a --- /dev/null +++ b/matching-brackets/README.md @@ -0,0 +1,24 @@ +# Matching Brackets + +Welcome to Matching Brackets on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched and nested correctly. +The string may also contain other characters, which for the purposes of this exercise should be ignored. + +## Source + +### Created by + +- @johnngugi + +### Contributed to by + +- @amscotti +- @kytrinyx + +### Based on + +Ginna Baker \ No newline at end of file diff --git a/matching-brackets/analysis_options.yaml b/matching-brackets/analysis_options.yaml new file mode 100644 index 0000000..b7f4f68 --- /dev/null +++ b/matching-brackets/analysis_options.yaml @@ -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 \ No newline at end of file diff --git a/matching-brackets/lib/matching_brackets.dart b/matching-brackets/lib/matching_brackets.dart new file mode 100644 index 0000000..1ebc0e4 --- /dev/null +++ b/matching-brackets/lib/matching_brackets.dart @@ -0,0 +1,25 @@ +class MatchingBrackets { + bool isPaired(String input) { + final Map bracketPairs = { + '}': '{', + ']': '[', + ')': '(', + }; + final List openBrackets = bracketPairs.values.toList(); + final List closeBrackets = bracketPairs.keys.toList(); + final List stack = []; + + for (final char in input.runes.map((rune) => String.fromCharCode(rune))) { + if (openBrackets.contains(char)) { + stack.add(char); + } else if (closeBrackets.contains(char)) { + if (stack.isEmpty || stack.last != bracketPairs[char]) { + return false; + } + stack.removeLast(); + } + } + + return stack.isEmpty; + } +} diff --git a/matching-brackets/pubspec.lock b/matching-brackets/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/matching-brackets/pubspec.lock @@ -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" diff --git a/matching-brackets/pubspec.yaml b/matching-brackets/pubspec.yaml new file mode 100644 index 0000000..b2f9d4d --- /dev/null +++ b/matching-brackets/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'matching_brackets' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/matching-brackets/test/matching_brackets_test.dart b/matching-brackets/test/matching_brackets_test.dart new file mode 100644 index 0000000..61e15a4 --- /dev/null +++ b/matching-brackets/test/matching_brackets_test.dart @@ -0,0 +1,109 @@ +import 'package:matching_brackets/matching_brackets.dart'; +import 'package:test/test.dart'; + +void main() { + final matchingBrackets = MatchingBrackets(); + + group('MatchingBrackets', () { + test('paired square brackets', () { + final result = matchingBrackets.isPaired('[]'); + expect(result, equals(true)); + }, skip: false); + + test('empty string', () { + final result = matchingBrackets.isPaired(''); + expect(result, equals(true)); + }, skip: true); + + test('unpaired brackets', () { + final result = matchingBrackets.isPaired('[['); + expect(result, equals(false)); + }, skip: true); + + test('wrong ordered brackets', () { + final result = matchingBrackets.isPaired('}{'); + expect(result, equals(false)); + }, skip: true); + + test('wrong closing bracket', () { + final result = matchingBrackets.isPaired('{]'); + expect(result, equals(false)); + }, skip: true); + + test('paired with whitespace', () { + final result = matchingBrackets.isPaired('{ }'); + expect(result, equals(true)); + }, skip: true); + + test('partially paired brackets', () { + final result = matchingBrackets.isPaired('{[])'); + expect(result, equals(false)); + }, skip: true); + + test('simple nested brackets', () { + final result = matchingBrackets.isPaired('{[]}'); + expect(result, equals(true)); + }, skip: true); + + test('several paired brackets', () { + final result = matchingBrackets.isPaired('{}[]'); + expect(result, equals(true)); + }, skip: true); + + test('paired and nested brackets', () { + final result = matchingBrackets.isPaired('([{}({}[])])'); + expect(result, equals(true)); + }, skip: true); + + test('unopened closing brackets', () { + final result = matchingBrackets.isPaired('{[)][]}'); + expect(result, equals(false)); + }, skip: true); + + test('unpaired and nested brackets', () { + final result = matchingBrackets.isPaired('([{])'); + expect(result, equals(false)); + }, skip: true); + + test('paired and wrong nested brackets', () { + final result = matchingBrackets.isPaired('[({]})'); + expect(result, equals(false)); + }, skip: true); + + test('paired and wrong nested brackets but innermost are correct', () { + final result = matchingBrackets.isPaired('[({}])'); + expect(result, equals(false)); + }, skip: true); + + test('paired and incomplete brackets', () { + final result = matchingBrackets.isPaired('{}['); + expect(result, equals(false)); + }, skip: true); + + test('too many closing brackets', () { + final result = matchingBrackets.isPaired('[]]'); + expect(result, equals(false)); + }, skip: true); + + test('early unexpected brackets', () { + final result = matchingBrackets.isPaired(')()'); + expect(result, equals(false)); + }, skip: true); + + test('early mismatched brackets', () { + final result = matchingBrackets.isPaired('{)()'); + expect(result, equals(false)); + }, skip: true); + + test('math expression', () { + final result = matchingBrackets.isPaired('(((185 + 223.85) * 15) - 543)/2'); + expect(result, equals(true)); + }, skip: true); + + test('complex latex expression', () { + final result = matchingBrackets + .isPaired('\left(\begin{array}{cc} \frac{1}{3} & x\ \mathrm{e}^{x} &... x^2 \end{array}\right)'); + expect(result, equals(true)); + }, skip: true); + }); +} diff --git a/nth-prime/.dart_tool/package_config.json b/nth-prime/.dart_tool/package_config.json new file mode 100644 index 0000000..96d1e18 --- /dev/null +++ b/nth-prime/.dart_tool/package_config.json @@ -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": "nth_prime", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-08T16:22:44.484295Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/nth-prime/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/nth-prime/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/nth-prime/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/nth-prime/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/nth-prime/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..1c06322 Binary files /dev/null and b/nth-prime/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/nth-prime/.exercism/config.json b/nth-prime/.exercism/config.json new file mode 100644 index 0000000..1cf5bd1 --- /dev/null +++ b/nth-prime/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "lib/nth_prime.dart" + ], + "test": [ + "test/nth_prime_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given a number n, determine what the nth prime is.", + "source": "A variation on Problem 7 at Project Euler", + "source_url": "https://projecteuler.net/problem=7" +} diff --git a/nth-prime/.exercism/metadata.json b/nth-prime/.exercism/metadata.json new file mode 100644 index 0000000..4b57bb4 --- /dev/null +++ b/nth-prime/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"nth-prime","id":"7e70b7d9f01d41ce965e3a51163a6174","url":"https://exercism.org/tracks/dart/exercises/nth-prime","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/nth-prime/HELP.md b/nth-prime/HELP.md new file mode 100644 index 0000000..34abe3e --- /dev/null +++ b/nth-prime/HELP.md @@ -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/nth_prime.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. \ No newline at end of file diff --git a/nth-prime/README.md b/nth-prime/README.md new file mode 100644 index 0000000..d5d2dcf --- /dev/null +++ b/nth-prime/README.md @@ -0,0 +1,26 @@ +# Nth Prime + +Welcome to Nth Prime on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a number n, determine what the nth prime is. + +By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. + +If your language provides methods in the standard library to deal with prime numbers, pretend they don't exist and implement them yourself. + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @kytrinyx + +### Based on + +A variation on Problem 7 at Project Euler - https://projecteuler.net/problem=7 \ No newline at end of file diff --git a/nth-prime/analysis_options.yaml b/nth-prime/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/nth-prime/analysis_options.yaml @@ -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 diff --git a/nth-prime/lib/nth_prime.dart b/nth-prime/lib/nth_prime.dart new file mode 100644 index 0000000..b116236 --- /dev/null +++ b/nth-prime/lib/nth_prime.dart @@ -0,0 +1,57 @@ +// help for the implementation from: +// https://www.geeksforgeeks.org/program-to-find-the-nth-prime-number/ +// by Ujjwal Kumar Bhardwaj + +class NthPrime { + // function to check if given number is prime or not + // basic idea is number not divided by any primes are primes + // bool isPrime(int k) { + // // Corner cases + // if (k <= 1) return false; + // if (k == 2 || k == 3) return true; + + // // below 5 there are only two prime numbers 2 and 3 + // if (k % 2 == 0 || k % 3 == 0) return false; + + // // Using concept of prime number can be represented + // // in form of (6*k + 1) or (6*k - 1) + // for (int i = 5; i * i <= k; i = i + 6) + // if (k % i == 0 || k % (i + 2) == 0) return false; + + // return true; + // } + + // int prime(int n) { + // if (n == 0) throw new ArgumentError('There is no zeroth prime'); + // int i = 2; + + // while (n > 0) { + // // each time if a prime number is found decrease n + // if (isPrime(i)) n--; + + // i++; // increase the integer and go ahead + // } + // i -= 1; // since decrement of k is being done before + // // Increment of i, so i should be decreased by 1 + // return i; + // } + + bool isPrime(int n) { + for (int start = 2; start < n; start++) { + if (n % start == 0) return false; + } + return true; + } + + int prime(int n) { + if (n == 0) throw new ArgumentError('There is no zeroth prime'); + + int counter = 0, number = 2; + + for (; counter < n; number++) { + if (isPrime(number)) counter++; + } + + return --number; + } +} diff --git a/nth-prime/pubspec.lock b/nth-prime/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/nth-prime/pubspec.lock @@ -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" diff --git a/nth-prime/pubspec.yaml b/nth-prime/pubspec.yaml new file mode 100644 index 0000000..2fa0d35 --- /dev/null +++ b/nth-prime/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'nth_prime' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/nth-prime/test/nth_prime_test.dart b/nth-prime/test/nth_prime_test.dart new file mode 100644 index 0000000..efd844b --- /dev/null +++ b/nth-prime/test/nth_prime_test.dart @@ -0,0 +1,35 @@ +import 'package:nth_prime/nth_prime.dart'; +import 'package:test/test.dart'; + +void main() { + final nthPrime = NthPrime(); + + group('NthPrime', () { + test('first prime', () { + final result = nthPrime.prime(1); + expect(result, equals(2)); + }, skip: false); + + test('second prime', () { + final result = nthPrime.prime(2); + expect(result, equals(3)); + }, skip: true); + + test('sixth prime', () { + final result = nthPrime.prime(6); + expect(result, equals(13)); + }, skip: true); + + test('big prime', () { + final result = nthPrime.prime(10001); + expect(result, equals(104743)); + }, skip: true); + + test('there is no zeroth prime', () { + expect( + () => nthPrime.prime(0), + throwsA(isA() + .having((e) => e.toString(), 'message', 'Invalid argument(s): There is no zeroth prime'))); + }, skip: true); + }); +} diff --git a/pangram/.dart_tool/package_config.json b/pangram/.dart_tool/package_config.json new file mode 100644 index 0000000..8bb2f46 --- /dev/null +++ b/pangram/.dart_tool/package_config.json @@ -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": "pangram", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-11-01T16:35:05.899807Z", + "generator": "pub", + "generatorVersion": "3.1.5" +} diff --git a/pangram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/pangram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..b8dbb4e Binary files /dev/null and b/pangram/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/pangram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/pangram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..a5a41ba Binary files /dev/null and b/pangram/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/pangram/.exercism/config.json b/pangram/.exercism/config.json new file mode 100644 index 0000000..aeee285 --- /dev/null +++ b/pangram/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "lib/pangram.dart" + ], + "test": [ + "test/pangram_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Determine if a sentence is a pangram.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Pangram" +} diff --git a/pangram/.exercism/metadata.json b/pangram/.exercism/metadata.json new file mode 100644 index 0000000..196e23b --- /dev/null +++ b/pangram/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"pangram","id":"6bcae2db98c449eebb3ae0225bf1da0e","url":"https://exercism.org/tracks/dart/exercises/pangram","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/pangram/HELP.md b/pangram/HELP.md new file mode 100644 index 0000000..25f04a9 --- /dev/null +++ b/pangram/HELP.md @@ -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/pangram.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. \ No newline at end of file diff --git a/pangram/README.md b/pangram/README.md new file mode 100644 index 0000000..2748dd9 --- /dev/null +++ b/pangram/README.md @@ -0,0 +1,44 @@ +# Pangram + +Welcome to Pangram on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +You work for a company that sells fonts through their website. +They'd like to show a different sentence each time someone views a font on their website. +To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet. + +They're running a competition to get suggestions for sentences that they can use. +You're in charge of checking the submissions to see if they are valid. + +~~~~exercism/note +Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter". + +The best known English pangram is: + +> The quick brown fox jumps over the lazy dog. +~~~~ + +## Instructions + +Your task is to figure out if a sentence is a pangram. + +A pangram is a sentence using every letter of the alphabet at least once. +It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`). + +For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet. + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @kytrinyx + +### Based on + +Wikipedia - https://en.wikipedia.org/wiki/Pangram \ No newline at end of file diff --git a/pangram/analysis_options.yaml b/pangram/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/pangram/analysis_options.yaml @@ -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 diff --git a/pangram/lib/pangram.dart b/pangram/lib/pangram.dart new file mode 100644 index 0000000..c3ef3b3 --- /dev/null +++ b/pangram/lib/pangram.dart @@ -0,0 +1,10 @@ +class Pangram { + bool isPangram(String pangram) => + pangram + .toLowerCase() + .replaceAll(new RegExp(r'[^a-z]'), '') + .split('') + .toSet() + .length == + 26; +} diff --git a/pangram/pubspec.lock b/pangram/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/pangram/pubspec.lock @@ -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" diff --git a/pangram/pubspec.yaml b/pangram/pubspec.yaml new file mode 100644 index 0000000..70b02a8 --- /dev/null +++ b/pangram/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'pangram' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/pangram/test/pangram_test.dart b/pangram/test/pangram_test.dart new file mode 100644 index 0000000..3eb09af --- /dev/null +++ b/pangram/test/pangram_test.dart @@ -0,0 +1,58 @@ +import 'package:pangram/pangram.dart'; +import 'package:test/test.dart'; + +void main() { + final pangram = Pangram(); + + group('Pangram', () { + test('empty sentence', () { + final result = pangram.isPangram(''); + expect(result, equals(false)); + }, skip: false); + + test('perfect lower case', () { + final result = pangram.isPangram('abcdefghijklmnopqrstuvwxyz'); + expect(result, equals(true)); + }, skip: true); + + test('only lower case', () { + final result = pangram.isPangram('the quick brown fox jumps over the lazy dog'); + expect(result, equals(true)); + }, skip: true); + + test('missing the letter \'x\'', () { + final result = pangram.isPangram('a quick movement of the enemy will jeopardize five gunboats'); + expect(result, equals(false)); + }, skip: true); + + test('missing the letter \'h\'', () { + final result = pangram.isPangram('five boxing wizards jump quickly at it'); + expect(result, equals(false)); + }, skip: true); + + test('with underscores', () { + final result = pangram.isPangram('the_quick_brown_fox_jumps_over_the_lazy_dog'); + expect(result, equals(true)); + }, skip: true); + + test('with numbers', () { + final result = pangram.isPangram('the 1 quick brown fox jumps over the 2 lazy dogs'); + expect(result, equals(true)); + }, skip: true); + + test('missing letters replaced by numbers', () { + final result = pangram.isPangram('7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog'); + expect(result, equals(false)); + }, skip: true); + + test('mixed case and punctuation', () { + final result = pangram.isPangram('"Five quacking Zephyrs jolt my wax bed."'); + expect(result, equals(true)); + }, skip: true); + + test('a-m and A-M are 26 different characters but not a pangram', () { + final result = pangram.isPangram('abcdefghijklm ABCDEFGHIJKLM'); + expect(result, equals(false)); + }, skip: true); + }); +} diff --git a/pascals-triangle/.dart_tool/package_config.json b/pascals-triangle/.dart_tool/package_config.json new file mode 100644 index 0000000..8213038 --- /dev/null +++ b/pascals-triangle/.dart_tool/package_config.json @@ -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": "pascals_triangle", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-11T20:52:55.003032Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/pascals-triangle/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/pascals-triangle/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..e6fd0f6 Binary files /dev/null and b/pascals-triangle/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/pascals-triangle/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/pascals-triangle/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..f3b2bc7 Binary files /dev/null and b/pascals-triangle/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/pascals-triangle/.exercism/config.json b/pascals-triangle/.exercism/config.json new file mode 100644 index 0000000..8e7f8a7 --- /dev/null +++ b/pascals-triangle/.exercism/config.json @@ -0,0 +1,24 @@ +{ + "authors": [ + "jvarness" + ], + "contributors": [ + "devkabiir", + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/pascals_triangle.dart" + ], + "test": [ + "test/pascals_triangle_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Compute Pascal's triangle up to a given number of rows.", + "source": "Pascal's Triangle at Wolfram Math World", + "source_url": "https://www.wolframalpha.com/input/?i=Pascal%27s+triangle" +} diff --git a/pascals-triangle/.exercism/metadata.json b/pascals-triangle/.exercism/metadata.json new file mode 100644 index 0000000..5c20f6a --- /dev/null +++ b/pascals-triangle/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"pascals-triangle","id":"9fdc5024aea44872989499f6d673dee5","url":"https://exercism.org/tracks/dart/exercises/pascals-triangle","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/pascals-triangle/HELP.md b/pascals-triangle/HELP.md new file mode 100644 index 0000000..b63bef2 --- /dev/null +++ b/pascals-triangle/HELP.md @@ -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/pascals_triangle.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. \ No newline at end of file diff --git a/pascals-triangle/README.md b/pascals-triangle/README.md new file mode 100644 index 0000000..d2f959d --- /dev/null +++ b/pascals-triangle/README.md @@ -0,0 +1,35 @@ +# Pascal's Triangle + +Welcome to Pascal's Triangle on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Compute Pascal's triangle up to a given number of rows. + +In Pascal's Triangle each number is computed by adding the numbers to the right and left of the current position in the previous row. + +```text + 1 + 1 1 + 1 2 1 + 1 3 3 1 +1 4 6 4 1 +# ... etc +``` + +## Source + +### Created by + +- @jvarness + +### Contributed to by + +- @devkabiir +- @Stargator +- @kytrinyx + +### Based on + +Pascal's Triangle at Wolfram Math World - https://www.wolframalpha.com/input/?i=Pascal%27s+triangle \ No newline at end of file diff --git a/pascals-triangle/analysis_options.yaml b/pascals-triangle/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/pascals-triangle/analysis_options.yaml @@ -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 diff --git a/pascals-triangle/lib/pascals_triangle.dart b/pascals-triangle/lib/pascals_triangle.dart new file mode 100644 index 0000000..b2e798a --- /dev/null +++ b/pascals-triangle/lib/pascals_triangle.dart @@ -0,0 +1,13 @@ +class PascalsTriangle { + var prevRow = []; + int getElement(int index) => prevRow[index - 1] + prevRow[index]; + List generateInnerRows(int row) { + var innerRow = List.generate(row + 1, + (index) => (index == 0 || index == row) ? 1 : getElement(index)); + prevRow = [...innerRow]; + return innerRow; + } + + List> rows(int numberOfRows) => + List.generate(numberOfRows, (row) => generateInnerRows(row)); +} diff --git a/pascals-triangle/pubspec.lock b/pascals-triangle/pubspec.lock new file mode 100644 index 0000000..d5af5b2 --- /dev/null +++ b/pascals-triangle/pubspec.lock @@ -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" diff --git a/pascals-triangle/pubspec.yaml b/pascals-triangle/pubspec.yaml new file mode 100644 index 0000000..bf6c15e --- /dev/null +++ b/pascals-triangle/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'pascals_triangle' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/pascals-triangle/test/pascals_triangle_test.dart b/pascals-triangle/test/pascals_triangle_test.dart new file mode 100644 index 0000000..5623f75 --- /dev/null +++ b/pascals-triangle/test/pascals_triangle_test.dart @@ -0,0 +1,100 @@ +import 'package:pascals_triangle/pascals_triangle.dart'; +import 'package:test/test.dart'; + +void main() { + final pascalsTriangle = PascalsTriangle(); + + group('PascalsTriangle', () { + test('zero rows', () { + final result = pascalsTriangle.rows(0); + expect(result, equals(>[])); + }, skip: false); + + test('single row', () { + final result = pascalsTriangle.rows(1); + expect( + result, + equals(>[ + [1] + ])); + }, skip: true); + + test('two rows', () { + final result = pascalsTriangle.rows(2); + expect( + result, + equals(>[ + [1], + [1, 1] + ])); + }, skip: true); + + test('three rows', () { + final result = pascalsTriangle.rows(3); + expect( + result, + equals(>[ + [1], + [1, 1], + [1, 2, 1] + ])); + }, skip: true); + + test('four rows', () { + final result = pascalsTriangle.rows(4); + expect( + result, + equals(>[ + [1], + [1, 1], + [1, 2, 1], + [1, 3, 3, 1] + ])); + }, skip: true); + + test('five rows', () { + final result = pascalsTriangle.rows(5); + expect( + result, + equals(>[ + [1], + [1, 1], + [1, 2, 1], + [1, 3, 3, 1], + [1, 4, 6, 4, 1] + ])); + }, skip: true); + + test('six rows', () { + final result = pascalsTriangle.rows(6); + expect( + result, + equals(>[ + [1], + [1, 1], + [1, 2, 1], + [1, 3, 3, 1], + [1, 4, 6, 4, 1], + [1, 5, 10, 10, 5, 1] + ])); + }, skip: true); + + test('ten rows', () { + final result = pascalsTriangle.rows(10); + expect( + result, + equals(>[ + [1], + [1, 1], + [1, 2, 1], + [1, 3, 3, 1], + [1, 4, 6, 4, 1], + [1, 5, 10, 10, 5, 1], + [1, 6, 15, 20, 15, 6, 1], + [1, 7, 21, 35, 35, 21, 7, 1], + [1, 8, 28, 56, 70, 56, 28, 8, 1], + [1, 9, 36, 84, 126, 126, 84, 36, 9, 1] + ])); + }, skip: true); + }); +} diff --git a/phone-number/.dart_tool/package_config.json b/phone-number/.dart_tool/package_config.json new file mode 100644 index 0000000..8b772be --- /dev/null +++ b/phone-number/.dart_tool/package_config.json @@ -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": "phone_number", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-11-02T08:47:30.156378Z", + "generator": "pub", + "generatorVersion": "3.1.5" +} diff --git a/phone-number/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot b/phone-number/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot new file mode 100644 index 0000000..6ea874b Binary files /dev/null and b/phone-number/.dart_tool/pub/bin/test/test.dart-3.1.5.snapshot differ diff --git a/phone-number/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/phone-number/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..1432126 Binary files /dev/null and b/phone-number/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/phone-number/.exercism/config.json b/phone-number/.exercism/config.json new file mode 100644 index 0000000..a024b4c --- /dev/null +++ b/phone-number/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "devkabiir" + ], + "contributors": [ + "kytrinyx", + "Stargator" + ], + "files": { + "solution": [ + "lib/phone_number.dart" + ], + "test": [ + "test/phone_number_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Clean up user-entered phone numbers so that they can be sent SMS messages.", + "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", + "source_url": "https://turing.edu" +} diff --git a/phone-number/.exercism/metadata.json b/phone-number/.exercism/metadata.json new file mode 100644 index 0000000..13f5d0b --- /dev/null +++ b/phone-number/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"phone-number","id":"3ef03fa4a2424e2e911b5fdfeb84bf94","url":"https://exercism.org/tracks/dart/exercises/phone-number","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/phone-number/HELP.md b/phone-number/HELP.md new file mode 100644 index 0000000..ffb5070 --- /dev/null +++ b/phone-number/HELP.md @@ -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/phone_number.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. \ No newline at end of file diff --git a/phone-number/README.md b/phone-number/README.md new file mode 100644 index 0000000..5496a79 --- /dev/null +++ b/phone-number/README.md @@ -0,0 +1,75 @@ +# Phone Number + +Welcome to Phone Number on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Clean up user-entered phone numbers so that they can be sent SMS messages. + +The **North American Numbering Plan (NANP)** is a telephone numbering system used by many countries in North America like the United States, Canada or Bermuda. +All NANP-countries share the same international country code: `1`. + +NANP numbers are ten-digit numbers consisting of a three-digit Numbering Plan Area code, commonly known as *area code*, followed by a seven-digit local number. +The first three digits of the local number represent the *exchange code*, followed by the unique four-digit number which is the *subscriber number*. + +The format is usually represented as + +```text +(NXX)-NXX-XXXX +``` + +where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9. + +Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code (1) if present. + +For example, the inputs + +- `+1 (613)-995-0253` +- `613-995-0253` +- `1 613 995 0253` +- `613.995.0253` + +should all produce the output + +`6139950253` + +**Note:** As this exercise only deals with telephone numbers used in NANP-countries, only 1 is considered a valid country code. + +A function with a *return type* can only return data of that *type* and `null`. +However the function caller is only expecting one data type. + +Example: +```dart +String hello(int a){ + if ( a == 0){ + return "a"; + } else { + return null; + } +} +``` +To make it more clear that this function can also return `null` or more data types, use `dynamic`. +```dart +dynamic hello(int a){ + if ( a == 0){ + return "a"; + } else { + return null; + } +} + +## Source + +### Created by + +- @devkabiir + +### Contributed to by + +- @kytrinyx +- @Stargator + +### Based on + +Exercise by the JumpstartLab team for students at The Turing School of Software and Design. - https://turing.edu \ No newline at end of file diff --git a/phone-number/analysis_options.yaml b/phone-number/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/phone-number/analysis_options.yaml @@ -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 diff --git a/phone-number/lib/phone_number.dart b/phone-number/lib/phone_number.dart new file mode 100644 index 0000000..2b4962d --- /dev/null +++ b/phone-number/lib/phone_number.dart @@ -0,0 +1,60 @@ +class PhoneNumber { + static final RegExp _nonNumeric = RegExp(r'[^0-9]+'); + static final RegExp _letters = RegExp('[a-z]'); + static final RegExp _punctuations = RegExp('[@:!?\$%^&*_`~,;]'); + + String clean(String input) { + _checkForLetters(input); + _checkForPunctuations(input); + String cleaned = _removeNonNumeric(input); + _validateLength(cleaned); + _validateAreaCode(cleaned); + _validateExchangeCode(cleaned); + return (cleaned.length == 11) + ? cleaned = cleaned.replaceFirst('1', '') + : cleaned; + } + + void _checkForLetters(String input) { + if (input.toLowerCase().contains(_letters)) + throw FormatException('letters not permitted'); + } + + void _checkForPunctuations(String input) { + if (input.toLowerCase().contains(_punctuations)) + throw FormatException('punctuations not permitted'); + } + + String _removeNonNumeric(String input) { + return input.replaceAll(_nonNumeric, ''); + } + + void _validateLength(String number) { + if (number.length < 10) + throw FormatException('must not be fewer than 10 digits'); + if (number.length > 11) + throw FormatException('must not be greater than 11 digits'); + if (number.length == 11 && number[0] != '1') + throw FormatException('11 digits must start with 1'); + } + + void _validateAreaCode(String number) { + if (number.length == 10 && number[0] == '0' || + number.length == 11 && number[1] == '0') + throw FormatException('area code cannot start with zero'); + + if (number.length == 10 && number[0] == '1' || + number.length == 11 && number[1] == '1') + throw FormatException('area code cannot start with one'); + } + + void _validateExchangeCode(String number) { + if (number.length == 10 && number[3] == '0' || + number.length == 11 && number[4] == '0') + throw FormatException('exchange code cannot start with zero'); + + if (number.length == 10 && number[3] == '1' || + number.length == 11 && number[4] == '1') + throw FormatException('exchange code cannot start with one'); + } +} diff --git a/phone-number/pubspec.lock b/phone-number/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/phone-number/pubspec.lock @@ -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" diff --git a/phone-number/pubspec.yaml b/phone-number/pubspec.yaml new file mode 100644 index 0000000..dc0a4c5 --- /dev/null +++ b/phone-number/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'phone_number' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/phone-number/test/phone_number_test.dart b/phone-number/test/phone_number_test.dart new file mode 100644 index 0000000..7c966e1 --- /dev/null +++ b/phone-number/test/phone_number_test.dart @@ -0,0 +1,202 @@ +import 'package:phone_number/phone_number.dart'; +import 'package:test/test.dart'; + +void main() { + final phoneNumber = PhoneNumber(); + + group('PhoneNumber', () { + test('cleans the number', () { + final result = phoneNumber.clean('(223) 456-7890'); + expect(result, equals('2234567890')); + }, skip: false); + + test('cleans numbers with dots', () { + final result = phoneNumber.clean('223.456.7890'); + expect(result, equals('2234567890')); + }, skip: true); + + test('cleans numbers with multiple spaces', () { + final result = phoneNumber.clean('223 456 7890 '); + expect(result, equals('2234567890')); + }, skip: true); + + test('invalid when 9 digits', () { + expect( + () => phoneNumber.clean('123456789'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'must not be fewer than 10 digits', + ), + ), + ); + }, skip: true); + + test('invalid when 11 digits does not start with a 1', () { + expect( + () => phoneNumber.clean('22234567890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + '11 digits must start with 1', + ), + ), + ); + }, skip: true); + + test('valid when 11 digits and starting with 1', () { + final result = phoneNumber.clean('12234567890'); + expect(result, equals('2234567890')); + }, skip: true); + + test('valid when 11 digits and starting with 1 even with punctuation', () { + final result = phoneNumber.clean('+1 (223) 456-7890'); + expect(result, equals('2234567890')); + }, skip: true); + + test('invalid when more than 11 digits', () { + expect( + () => phoneNumber.clean('321234567890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'must not be greater than 11 digits', + ), + ), + ); + }, skip: true); + + test('invalid with letters', () { + expect( + () => phoneNumber.clean('523-abc-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'letters not permitted', + ), + ), + ); + }, skip: true); + + test('invalid with punctuations', () { + expect( + () => phoneNumber.clean('523-@:!-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'punctuations not permitted', + ), + ), + ); + }, skip: true); + + test('invalid if area code starts with 0', () { + expect( + () => phoneNumber.clean('(023) 456-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'area code cannot start with zero', + ), + ), + ); + }, skip: true); + + test('invalid if area code starts with 1', () { + expect( + () => phoneNumber.clean('(123) 456-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'area code cannot start with one', + ), + ), + ); + }, skip: true); + + test('invalid if exchange code starts with 0', () { + expect( + () => phoneNumber.clean('(223) 056-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'exchange code cannot start with zero', + ), + ), + ); + }, skip: true); + + test('invalid if exchange code starts with 1', () { + expect( + () => phoneNumber.clean('(223) 156-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'exchange code cannot start with one', + ), + ), + ); + }, skip: true); + + test('invalid if area code starts with 0 on valid 11-digit number', () { + expect( + () => phoneNumber.clean('1 (023) 456-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'area code cannot start with zero', + ), + ), + ); + }, skip: true); + + test('invalid if area code starts with 1 on valid 11-digit number', () { + expect( + () => phoneNumber.clean('1 (123) 456-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'area code cannot start with one', + ), + ), + ); + }, skip: true); + + test('invalid if exchange code starts with 0 on valid 11-digit number', () { + expect( + () => phoneNumber.clean('1 (223) 056-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'exchange code cannot start with zero', + ), + ), + ); + }, skip: true); + + test('invalid if exchange code starts with 1 on valid 11-digit number', () { + expect( + () => phoneNumber.clean('1 (223) 156-7890'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'exchange code cannot start with one', + ), + ), + ); + }, skip: true); + }); +} diff --git a/pig-latin/.dart_tool/package_config.json b/pig-latin/.dart_tool/package_config.json new file mode 100644 index 0000000..bb1745f --- /dev/null +++ b/pig-latin/.dart_tool/package_config.json @@ -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": "pig_latin", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.12" + } + ], + "generated": "2023-11-03T11:56:24.921324Z", + "generator": "pub", + "generatorVersion": "3.1.5" +} diff --git a/pig-latin/.exercism/config.json b/pig-latin/.exercism/config.json new file mode 100644 index 0000000..2639a4c --- /dev/null +++ b/pig-latin/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "HornMichaelS" + ], + "files": { + "solution": [ + "lib/pig_latin.dart" + ], + "test": [ + "test/pig_latin_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "forked_from": [ + "csharp/pig-latin" + ], + "blurb": "Implement a program that translates from English to Pig Latin.", + "source": "The Pig Latin exercise at Test First Teaching by Ultrasaurus", + "source_url": "https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/" +} diff --git a/pig-latin/.exercism/metadata.json b/pig-latin/.exercism/metadata.json new file mode 100644 index 0000000..3c3f1d7 --- /dev/null +++ b/pig-latin/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"pig-latin","id":"843711aec930421880770efee3b00dfb","url":"https://exercism.org/tracks/dart/exercises/pig-latin","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/pig-latin/HELP.md b/pig-latin/HELP.md new file mode 100644 index 0000000..f93bc51 --- /dev/null +++ b/pig-latin/HELP.md @@ -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/pig_latin.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. \ No newline at end of file diff --git a/pig-latin/HINTS.md b/pig-latin/HINTS.md new file mode 100644 index 0000000..ed92435 --- /dev/null +++ b/pig-latin/HINTS.md @@ -0,0 +1,11 @@ +# Hints + +## 1. Prefixed library imports + +- Notice that the test script (test/pig_latin_test.dart) imports the solution file using a prefix: + + ```dart + import 'package:pig_latin/pig_latin.dart' as pigLatin; + ``` +- Learn more: [Specifying a library prefix +](https://dart.dev/guides/language/language-tour#specifying-a-library-prefix) \ No newline at end of file diff --git a/pig-latin/README.md b/pig-latin/README.md new file mode 100644 index 0000000..168faea --- /dev/null +++ b/pig-latin/README.md @@ -0,0 +1,36 @@ +# Pig Latin + +Welcome to Pig Latin on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Instructions + +Implement a program that translates from English to Pig Latin. + +Pig Latin is a made-up children's language that's intended to be confusing. +It obeys a few simple rules (below), but when it's spoken quickly it's really difficult for non-children (and non-native speakers) to understand. + +- **Rule 1**: If a word begins with a vowel sound, add an "ay" sound to the end of the word. + Please note that "xr" and "yt" at the beginning of a word make vowel sounds (e.g. "xray" -> "xrayay", "yttria" -> "yttriaay"). +- **Rule 2**: If a word begins with a consonant sound, move it to the end of the word and then add an "ay" sound to the end of the word. + Consonant sounds can be made up of multiple consonants, such as the "ch" in "chair" or "st" in "stand" (e.g. "chair" -> "airchay"). +- **Rule 3**: If a word starts with a consonant sound followed by "qu", move it to the end of the word, and then add an "ay" sound to the end of the word (e.g. "square" -> "aresquay"). +- **Rule 4**: If a word contains a "y" after a consonant cluster or as the second letter in a two letter word it makes a vowel sound (e.g. "rhythm" -> "ythmrhay", "my" -> "ymay"). + +There are a few more rules for edge cases, and there are regional variants too. +Check the tests for all the details. + +Read more about [Pig Latin on Wikipedia][pig-latin]. + +[pig-latin]: https://en.wikipedia.org/wiki/Pig_latin + +## Source + +### Created by + +- @HornMichaelS + +### Based on + +The Pig Latin exercise at Test First Teaching by Ultrasaurus - https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/ \ No newline at end of file diff --git a/pig-latin/analysis_options.yaml b/pig-latin/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/pig-latin/analysis_options.yaml @@ -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 diff --git a/pig-latin/lib/pig_latin.dart b/pig-latin/lib/pig_latin.dart new file mode 100644 index 0000000..3a9f2e1 --- /dev/null +++ b/pig-latin/lib/pig_latin.dart @@ -0,0 +1,4 @@ +// Your code here +String translate(String input) { + return ""; +} diff --git a/pig-latin/pubspec.lock b/pig-latin/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/pig-latin/pubspec.lock @@ -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" diff --git a/pig-latin/pubspec.yaml b/pig-latin/pubspec.yaml new file mode 100644 index 0000000..083d84f --- /dev/null +++ b/pig-latin/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'pig_latin' +environment: + sdk: '>=2.12.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/pig-latin/test/pig_latin_test.dart b/pig-latin/test/pig_latin_test.dart new file mode 100644 index 0000000..fabeeb3 --- /dev/null +++ b/pig-latin/test/pig_latin_test.dart @@ -0,0 +1,128 @@ +import 'package:pig_latin/pig_latin.dart' as pigLatin; +import 'package:test/test.dart'; + +void main() { + group('PigLatin', () { + group('ay is added to words that start with vowels', () { + test('word beginning with a', () { + final result = pigLatin.translate('apple'); + expect(result, equals('appleay')); + }, skip: false); + + test('word beginning with e', () { + final result = pigLatin.translate('ear'); + expect(result, equals('earay')); + }, skip: true); + + test('word beginning with i', () { + final result = pigLatin.translate('igloo'); + expect(result, equals('iglooay')); + }, skip: true); + + test('word beginning with o', () { + final result = pigLatin.translate('object'); + expect(result, equals('objectay')); + }, skip: true); + + test('word beginning with u', () { + final result = pigLatin.translate('under'); + expect(result, equals('underay')); + }, skip: true); + + test('word beginning with a vowel and followed by a qu', () { + final result = pigLatin.translate('equal'); + expect(result, equals('equalay')); + }, skip: true); + }); + + group('first letter and ay are moved to the end of words that start with consonants', () { + test('word beginning with p', () { + final result = pigLatin.translate('pig'); + expect(result, equals('igpay')); + }, skip: true); + + test('word beginning with k', () { + final result = pigLatin.translate('koala'); + expect(result, equals('oalakay')); + }, skip: true); + + test('word beginning with x', () { + final result = pigLatin.translate('xenon'); + expect(result, equals('enonxay')); + }, skip: true); + + test('word beginning with q without a following u', () { + final result = pigLatin.translate('qat'); + expect(result, equals('atqay')); + }, skip: true); + }); + + group('some letter clusters are treated like a single consonant', () { + test('word beginning with ch', () { + final result = pigLatin.translate('chair'); + expect(result, equals('airchay')); + }, skip: true); + + test('word beginning with qu', () { + final result = pigLatin.translate('queen'); + expect(result, equals('eenquay')); + }, skip: true); + + test('word beginning with qu and a preceding consonant', () { + final result = pigLatin.translate('square'); + expect(result, equals('aresquay')); + }, skip: true); + + test('word beginning with th', () { + final result = pigLatin.translate('therapy'); + expect(result, equals('erapythay')); + }, skip: true); + + test('word beginning with thr', () { + final result = pigLatin.translate('thrush'); + expect(result, equals('ushthray')); + }, skip: true); + + test('word beginning with sch', () { + final result = pigLatin.translate('school'); + expect(result, equals('oolschay')); + }, skip: true); + }); + + group('some letter clusters are treated like a single vowel', () { + test('word beginning with yt', () { + final result = pigLatin.translate('yttria'); + expect(result, equals('yttriaay')); + }, skip: true); + + test('word beginning with xr', () { + final result = pigLatin.translate('xray'); + expect(result, equals('xrayay')); + }, skip: true); + }); + + group('position of y in a word determines if it is a consonant or a vowel', () { + test('y is treated like a consonant at the beginning of a word', () { + final result = pigLatin.translate('yellow'); + expect(result, equals('ellowyay')); + }, skip: true); + + test('y is treated like a vowel at the end of a consonant cluster', () { + final result = pigLatin.translate('rhythm'); + expect(result, equals('ythmrhay')); + }, skip: true); + + test('y as second letter in two letter word', () { + final result = pigLatin.translate('my'); + expect(result, equals('ymay')); + }, skip: true); + }); + + group('phrases are translated', () { + test('a whole phrase', () { + final result = pigLatin.translate('quick fast run'); + expect(result, equals('ickquay astfay unray')); + }, skip: true); + }); + }); +} diff --git a/prime-factors/.dart_tool/package_config.json b/prime-factors/.dart_tool/package_config.json new file mode 100644 index 0000000..e188c30 --- /dev/null +++ b/prime-factors/.dart_tool/package_config.json @@ -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": "prime_factors", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-04T09:37:13.219423Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/prime-factors/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/prime-factors/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/prime-factors/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/prime-factors/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/prime-factors/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..72560dc Binary files /dev/null and b/prime-factors/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/prime-factors/.exercism/config.json b/prime-factors/.exercism/config.json new file mode 100644 index 0000000..284821f --- /dev/null +++ b/prime-factors/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "lib/prime_factors.dart" + ], + "test": [ + "test/prime_factors_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Compute the prime factors of a given natural number.", + "source": "The Prime Factors Kata by Uncle Bob", + "source_url": "https://web.archive.org/web/20221026171801/http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" +} diff --git a/prime-factors/.exercism/metadata.json b/prime-factors/.exercism/metadata.json new file mode 100644 index 0000000..58b48d7 --- /dev/null +++ b/prime-factors/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"prime-factors","id":"de2812e5e5bb4995a6dc7e91b5307b0c","url":"https://exercism.org/tracks/dart/exercises/prime-factors","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/prime-factors/HELP.md b/prime-factors/HELP.md new file mode 100644 index 0000000..25091cc --- /dev/null +++ b/prime-factors/HELP.md @@ -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/prime_factors.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. \ No newline at end of file diff --git a/prime-factors/README.md b/prime-factors/README.md new file mode 100644 index 0000000..e329cdd --- /dev/null +++ b/prime-factors/README.md @@ -0,0 +1,55 @@ +# Prime Factors + +Welcome to Prime Factors on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Compute the prime factors of a given natural number. + +A prime number is only evenly divisible by itself and 1. + +Note that 1 is not a prime number. + +## Example + +What are the prime factors of 60? + +- Our first divisor is 2. + 2 goes into 60, leaving 30. +- 2 goes into 30, leaving 15. + - 2 doesn't go cleanly into 15. + So let's move on to our next divisor, 3. +- 3 goes cleanly into 15, leaving 5. + - 3 does not go cleanly into 5. + The next possible factor is 4. + - 4 does not go cleanly into 5. + The next possible factor is 5. +- 5 does go cleanly into 5. +- We're left only with 1, so now, we're done. + +Our successful divisors in that computation represent the list of prime factors of 60: 2, 2, 3, and 5. + +You can check this yourself: + +```text +2 * 2 * 3 * 5 += 4 * 15 += 60 +``` + +Success! + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @kytrinyx + +### Based on + +The Prime Factors Kata by Uncle Bob - https://web.archive.org/web/20221026171801/http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata \ No newline at end of file diff --git a/prime-factors/analysis_options.yaml b/prime-factors/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/prime-factors/analysis_options.yaml @@ -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 diff --git a/prime-factors/lib/prime_factors.dart b/prime-factors/lib/prime_factors.dart new file mode 100644 index 0000000..7df96cd --- /dev/null +++ b/prime-factors/lib/prime_factors.dart @@ -0,0 +1,15 @@ +class PrimeFactors { + List factors(int number) { + List primeFactors = []; + int currentFactor = 2; + while (number != 1) { + if (number % currentFactor == 0) { + number ~/= currentFactor; + primeFactors.add(currentFactor); + } else { + currentFactor++; + } + } + return primeFactors; + } +} diff --git a/prime-factors/pubspec.lock b/prime-factors/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/prime-factors/pubspec.lock @@ -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" diff --git a/prime-factors/pubspec.yaml b/prime-factors/pubspec.yaml new file mode 100644 index 0000000..1d67a45 --- /dev/null +++ b/prime-factors/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'prime_factors' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/prime-factors/test/prime_factors_test.dart b/prime-factors/test/prime_factors_test.dart new file mode 100644 index 0000000..2b9e68b --- /dev/null +++ b/prime-factors/test/prime_factors_test.dart @@ -0,0 +1,68 @@ +import 'package:prime_factors/prime_factors.dart'; +import 'package:test/test.dart'; + +void main() { + final primeFactors = PrimeFactors(); + + group('PrimeFactors', () { + test('no factors', () { + final result = primeFactors.factors(1); + expect(result, equals([])); + }, skip: false); + + test('prime number', () { + final result = primeFactors.factors(2); + expect(result, equals([2])); + }, skip: true); + + test('another prime number', () { + final result = primeFactors.factors(3); + expect(result, equals([3])); + }, skip: true); + + test('square of a prime', () { + final result = primeFactors.factors(9); + expect(result, equals([3, 3])); + }, skip: true); + + test('product of first prime', () { + final result = primeFactors.factors(4); + expect(result, equals([2, 2])); + }, skip: true); + + test('cube of a prime', () { + final result = primeFactors.factors(8); + expect(result, equals([2, 2, 2])); + }, skip: true); + + test('product of second prime', () { + final result = primeFactors.factors(27); + expect(result, equals([3, 3, 3])); + }, skip: true); + + test('product of third prime', () { + final result = primeFactors.factors(625); + expect(result, equals([5, 5, 5, 5])); + }, skip: true); + + test('product of first and second prime', () { + final result = primeFactors.factors(6); + expect(result, equals([2, 3])); + }, skip: true); + + test('product of primes and non-primes', () { + final result = primeFactors.factors(12); + expect(result, equals([2, 2, 3])); + }, skip: true); + + test('product of primes', () { + final result = primeFactors.factors(901255); + expect(result, equals([5, 17, 23, 461])); + }, skip: true); + + test('factors include a large prime', () { + final result = primeFactors.factors(93819012551); + expect(result, equals([11, 9539, 894119])); + }, skip: true); + }); +} diff --git a/raindrops/.dart_tool/package_config.json b/raindrops/.dart_tool/package_config.json new file mode 100644 index 0000000..0819132 --- /dev/null +++ b/raindrops/.dart_tool/package_config.json @@ -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": "raindrops", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-08T15:28:03.689999Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/raindrops/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/raindrops/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/raindrops/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/raindrops/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/raindrops/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..877dd46 Binary files /dev/null and b/raindrops/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/raindrops/.exercism/config.json b/raindrops/.exercism/config.json new file mode 100644 index 0000000..e184a6c --- /dev/null +++ b/raindrops/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "fwip" + ], + "contributors": [ + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/raindrops.dart" + ], + "test": [ + "test/raindrops_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Convert a number to a string, the content of which depends on the number's factors.", + "source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.", + "source_url": "https://en.wikipedia.org/wiki/Fizz_buzz" +} diff --git a/raindrops/.exercism/metadata.json b/raindrops/.exercism/metadata.json new file mode 100644 index 0000000..31dc440 --- /dev/null +++ b/raindrops/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"raindrops","id":"3ef6a8cafdee418c97517430497e3b91","url":"https://exercism.org/tracks/dart/exercises/raindrops","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/raindrops/HELP.md b/raindrops/HELP.md new file mode 100644 index 0000000..ad6eb71 --- /dev/null +++ b/raindrops/HELP.md @@ -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/raindrops.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. \ No newline at end of file diff --git a/raindrops/README.md b/raindrops/README.md new file mode 100644 index 0000000..566e969 --- /dev/null +++ b/raindrops/README.md @@ -0,0 +1,40 @@ +# Raindrops + +Welcome to Raindrops on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Your task is to convert a number into a string that contains raindrop sounds corresponding to certain potential factors. +A factor is a number that evenly divides into another number, leaving no remainder. +The simplest way to test if one number is a factor of another is to use the [modulo operation][modulo]. + +The rules of `raindrops` are that if a given number: + +- has 3 as a factor, add 'Pling' to the result. +- has 5 as a factor, add 'Plang' to the result. +- has 7 as a factor, add 'Plong' to the result. +- _does not_ have any of 3, 5, or 7 as a factor, the result should be the digits of the number. + +## Examples + +- 28 has 7 as a factor, but not 3 or 5, so the result would be "Plong". +- 30 has both 3 and 5 as factors, but not 7, so the result would be "PlingPlang". +- 34 is not factored by 3, 5, or 7, so the result would be "34". + +[modulo]: https://en.wikipedia.org/wiki/Modulo_operation + +## Source + +### Created by + +- @fwip + +### Contributed to by + +- @Stargator +- @kytrinyx + +### Based on + +A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division. - https://en.wikipedia.org/wiki/Fizz_buzz \ No newline at end of file diff --git a/raindrops/analysis_options.yaml b/raindrops/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/raindrops/analysis_options.yaml @@ -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 diff --git a/raindrops/lib/raindrops.dart b/raindrops/lib/raindrops.dart new file mode 100644 index 0000000..3e4dab3 --- /dev/null +++ b/raindrops/lib/raindrops.dart @@ -0,0 +1,9 @@ +class Raindrops { + String convert(int factor) { + final StringBuffer result = StringBuffer(); + if (factor % 3 == 0) result.write('Pling'); + if (factor % 5 == 0) result.write('Plang'); + if (factor % 7 == 0) result.write('Plong'); + return (result.isEmpty) ? factor.toString() : result.toString(); + } +} diff --git a/raindrops/pubspec.lock b/raindrops/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/raindrops/pubspec.lock @@ -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" diff --git a/raindrops/pubspec.yaml b/raindrops/pubspec.yaml new file mode 100644 index 0000000..d32c83d --- /dev/null +++ b/raindrops/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'raindrops' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/raindrops/test/raindrops_test.dart b/raindrops/test/raindrops_test.dart new file mode 100644 index 0000000..3b0eb18 --- /dev/null +++ b/raindrops/test/raindrops_test.dart @@ -0,0 +1,98 @@ +import 'package:raindrops/raindrops.dart'; +import 'package:test/test.dart'; + +void main() { + final raindrops = Raindrops(); + + group('Raindrops', () { + test('the sound for 1 is 1', () { + final result = raindrops.convert(1); + expect(result, equals('1')); + }, skip: false); + + test('the sound for 3 is Pling', () { + final result = raindrops.convert(3); + expect(result, equals('Pling')); + }, skip: true); + + test('the sound for 5 is Plang', () { + final result = raindrops.convert(5); + expect(result, equals('Plang')); + }, skip: true); + + test('the sound for 7 is Plong', () { + final result = raindrops.convert(7); + expect(result, equals('Plong')); + }, skip: true); + + test('the sound for 6 is Pling as it has a factor 3', () { + final result = raindrops.convert(6); + expect(result, equals('Pling')); + }, skip: true); + + test('2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base', () { + final result = raindrops.convert(8); + expect(result, equals('8')); + }, skip: true); + + test('the sound for 9 is Pling as it has a factor 3', () { + final result = raindrops.convert(9); + expect(result, equals('Pling')); + }, skip: true); + + test('the sound for 10 is Plang as it has a factor 5', () { + final result = raindrops.convert(10); + expect(result, equals('Plang')); + }, skip: true); + + test('the sound for 14 is Plong as it has a factor of 7', () { + final result = raindrops.convert(14); + expect(result, equals('Plong')); + }, skip: true); + + test('the sound for 15 is PlingPlang as it has factors 3 and 5', () { + final result = raindrops.convert(15); + expect(result, equals('PlingPlang')); + }, skip: true); + + test('the sound for 21 is PlingPlong as it has factors 3 and 7', () { + final result = raindrops.convert(21); + expect(result, equals('PlingPlong')); + }, skip: true); + + test('the sound for 25 is Plang as it has a factor 5', () { + final result = raindrops.convert(25); + expect(result, equals('Plang')); + }, skip: true); + + test('the sound for 27 is Pling as it has a factor 3', () { + final result = raindrops.convert(27); + expect(result, equals('Pling')); + }, skip: true); + + test('the sound for 35 is PlangPlong as it has factors 5 and 7', () { + final result = raindrops.convert(35); + expect(result, equals('PlangPlong')); + }, skip: true); + + test('the sound for 49 is Plong as it has a factor 7', () { + final result = raindrops.convert(49); + expect(result, equals('Plong')); + }, skip: true); + + test('the sound for 52 is 52', () { + final result = raindrops.convert(52); + expect(result, equals('52')); + }, skip: true); + + test('the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7', () { + final result = raindrops.convert(105); + expect(result, equals('PlingPlangPlong')); + }, skip: true); + + test('the sound for 3125 is Plang as it has a factor 5', () { + final result = raindrops.convert(3125); + expect(result, equals('Plang')); + }, skip: true); + }); +} diff --git a/resistor-color-duo/.dart_tool/package_config.json b/resistor-color-duo/.dart_tool/package_config.json new file mode 100644 index 0000000..aaa8e94 --- /dev/null +++ b/resistor-color-duo/.dart_tool/package_config.json @@ -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": "resistor_color_duo", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-09-28T09:31:57.628317Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/resistor-color-duo/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/resistor-color-duo/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..07e8fe3 Binary files /dev/null and b/resistor-color-duo/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/resistor-color-duo/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/resistor-color-duo/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..82c646d Binary files /dev/null and b/resistor-color-duo/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/resistor-color-duo/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/resistor-color-duo/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..0d52c21 Binary files /dev/null and b/resistor-color-duo/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/resistor-color-duo/.exercism/config.json b/resistor-color-duo/.exercism/config.json new file mode 100644 index 0000000..28095b2 --- /dev/null +++ b/resistor-color-duo/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/resistor_color_duo.dart" + ], + "test": [ + "test/resistor_color_duo_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Convert color codes, as used on resistors, to a numeric value.", + "source": "Maud de Vries, Erik Schierboom", + "source_url": "https://github.com/exercism/problem-specifications/issues/1464" +} diff --git a/resistor-color-duo/.exercism/metadata.json b/resistor-color-duo/.exercism/metadata.json new file mode 100644 index 0000000..1da0144 --- /dev/null +++ b/resistor-color-duo/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"resistor-color-duo","id":"81dafceaeab34cb38c1b2f24512c44e9","url":"https://exercism.org/tracks/dart/exercises/resistor-color-duo","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/resistor-color-duo/HELP.md b/resistor-color-duo/HELP.md new file mode 100644 index 0000000..18a838f --- /dev/null +++ b/resistor-color-duo/HELP.md @@ -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/resistor_color_duo.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. \ No newline at end of file diff --git a/resistor-color-duo/README.md b/resistor-color-duo/README.md new file mode 100644 index 0000000..a7b62ab --- /dev/null +++ b/resistor-color-duo/README.md @@ -0,0 +1,53 @@ +# Resistor Color Duo + +Welcome to Resistor Color Duo on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +If you want to build something using a Raspberry Pi, you'll probably use _resistors_. +For this exercise, you need to know two things about them: + +- Each resistor has a resistance value. +- Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read. + +To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. +Each band has a position and a numeric value. + +The first 2 bands of a resistor have a simple encoding scheme: each color maps to a single number. +For example, if they printed a brown band (value 1) followed by a green band (value 5), it would translate to the number 15. + +In this exercise you are going to create a helpful program so that you don't have to remember the values of the bands. +The program will take color names as input and output a two digit number, even if the input is more than two colors! + +The band colors are encoded as follows: + +- Black: 0 +- Brown: 1 +- Red: 2 +- Orange: 3 +- Yellow: 4 +- Green: 5 +- Blue: 6 +- Violet: 7 +- Grey: 8 +- White: 9 + +From the example above: +brown-green should return 15 +brown-green-violet should return 15 too, ignoring the third color. + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @Stargator +- @kytrinyx + +### Based on + +Maud de Vries, Erik Schierboom - https://github.com/exercism/problem-specifications/issues/1464 \ No newline at end of file diff --git a/resistor-color-duo/analysis_options.yaml b/resistor-color-duo/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/resistor-color-duo/analysis_options.yaml @@ -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 diff --git a/resistor-color-duo/lib/resistor_color_duo.dart b/resistor-color-duo/lib/resistor_color_duo.dart new file mode 100644 index 0000000..5514cac --- /dev/null +++ b/resistor-color-duo/lib/resistor_color_duo.dart @@ -0,0 +1,18 @@ +class ResistorColorDuo { + var colorCodes = [ + "black", + "brown", + "red", + "orange", + "yellow", + "green", + "blue", + "violet", + "grey", + "white" + ]; + + int value(List colors) { + return (colorCodes.indexOf(colors[0]) * 10) + colorCodes.indexOf(colors[1]); + } +} diff --git a/resistor-color-duo/pubspec.lock b/resistor-color-duo/pubspec.lock new file mode 100644 index 0000000..235179f --- /dev/null +++ b/resistor-color-duo/pubspec.lock @@ -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" diff --git a/resistor-color-duo/pubspec.yaml b/resistor-color-duo/pubspec.yaml new file mode 100644 index 0000000..590d5a7 --- /dev/null +++ b/resistor-color-duo/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'resistor_color_duo' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/resistor-color-duo/test/resistor_color_duo_test.dart b/resistor-color-duo/test/resistor_color_duo_test.dart new file mode 100644 index 0000000..62415f7 --- /dev/null +++ b/resistor-color-duo/test/resistor_color_duo_test.dart @@ -0,0 +1,43 @@ +import 'package:resistor_color_duo/resistor_color_duo.dart'; +import 'package:test/test.dart'; + +void main() { + final resistorColorDuo = ResistorColorDuo(); + + group('ResistorColorDuo', () { + test('Brown and black', () { + final result = resistorColorDuo.value(['brown', 'black']); + expect(result, equals(10)); + }, skip: false); + + test('Blue and grey', () { + final result = resistorColorDuo.value(['blue', 'grey']); + expect(result, equals(68)); + }, skip: true); + + test('Yellow and violet', () { + final result = resistorColorDuo.value(['yellow', 'violet']); + expect(result, equals(47)); + }, skip: true); + + test('White and red', () { + final result = resistorColorDuo.value(['white', 'red']); + expect(result, equals(92)); + }, skip: true); + + test('Orange and orange', () { + final result = resistorColorDuo.value(['orange', 'orange']); + expect(result, equals(33)); + }, skip: true); + + test('Ignore additional colors', () { + final result = resistorColorDuo.value(['green', 'brown', 'orange']); + expect(result, equals(51)); + }, skip: true); + + test('Black and brown, one-digit', () { + final result = resistorColorDuo.value(['black', 'brown']); + expect(result, equals(1)); + }, skip: true); + }); +} diff --git a/resistor-color/.dart_tool/package_config.json b/resistor-color/.dart_tool/package_config.json new file mode 100644 index 0000000..905dc2c --- /dev/null +++ b/resistor-color/.dart_tool/package_config.json @@ -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": "resistor_color", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-11-01T12:00:44.891499Z", + "generator": "pub", + "generatorVersion": "3.1.5" +} diff --git a/resistor-color/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/resistor-color/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..b8dbb4e Binary files /dev/null and b/resistor-color/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/resistor-color/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/resistor-color/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..f9eaf96 Binary files /dev/null and b/resistor-color/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/resistor-color/.exercism/config.json b/resistor-color/.exercism/config.json new file mode 100644 index 0000000..0faa5b8 --- /dev/null +++ b/resistor-color/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "lib/resistor_color.dart" + ], + "test": [ + "test/resistor_color_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Convert a resistor band's color to its numeric representation.", + "source": "Maud de Vries, Erik Schierboom", + "source_url": "https://github.com/exercism/problem-specifications/issues/1458" +} diff --git a/resistor-color/.exercism/metadata.json b/resistor-color/.exercism/metadata.json new file mode 100644 index 0000000..040508a --- /dev/null +++ b/resistor-color/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"resistor-color","id":"697edc6f78b14086b25ae09b59df3f10","url":"https://exercism.org/tracks/dart/exercises/resistor-color","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/resistor-color/HELP.md b/resistor-color/HELP.md new file mode 100644 index 0000000..d0838e2 --- /dev/null +++ b/resistor-color/HELP.md @@ -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/resistor_color.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. \ No newline at end of file diff --git a/resistor-color/README.md b/resistor-color/README.md new file mode 100644 index 0000000..196df77 --- /dev/null +++ b/resistor-color/README.md @@ -0,0 +1,58 @@ +# Resistor Color + +Welcome to Resistor Color on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +If you want to build something using a Raspberry Pi, you'll probably use _resistors_. +For this exercise, you need to know two things about them: + +- Each resistor has a resistance value. +- Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read. + +To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. +Each band has a position and a numeric value. + +The first 2 bands of a resistor have a simple encoding scheme: each color maps to a single number. + +In this exercise you are going to create a helpful program so that you don't have to remember the values of the bands. + +These colors are encoded as follows: + +- Black: 0 +- Brown: 1 +- Red: 2 +- Orange: 3 +- Yellow: 4 +- Green: 5 +- Blue: 6 +- Violet: 7 +- Grey: 8 +- White: 9 + +The goal of this exercise is to create a way: + +- to look up the numerical value associated with a particular color band +- to list the different band colors + +Mnemonics map the colors to the numbers, that, when stored as an array, happen to map to their index in the array: +Better Be Right Or Your Great Big Values Go Wrong. + +More information on the color encoding of resistors can be found in the [Electronic color code Wikipedia article][e-color-code]. + +[e-color-code]: https://en.wikipedia.org/wiki/Electronic_color_code + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @kytrinyx + +### Based on + +Maud de Vries, Erik Schierboom - https://github.com/exercism/problem-specifications/issues/1458 \ No newline at end of file diff --git a/resistor-color/analysis_options.yaml b/resistor-color/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/resistor-color/analysis_options.yaml @@ -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 diff --git a/resistor-color/lib/resistor_color.dart b/resistor-color/lib/resistor_color.dart new file mode 100644 index 0000000..18db954 --- /dev/null +++ b/resistor-color/lib/resistor_color.dart @@ -0,0 +1,16 @@ +class ResistorColor { + final List colors = [ + "black", + "brown", + "red", + "orange", + "yellow", + "green", + "blue", + "violet", + "grey", + "white", + ]; + + int colorCode(String colorName) => colors.indexOf(colorName); +} diff --git a/resistor-color/pubspec.lock b/resistor-color/pubspec.lock new file mode 100644 index 0000000..8329759 --- /dev/null +++ b/resistor-color/pubspec.lock @@ -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" diff --git a/resistor-color/pubspec.yaml b/resistor-color/pubspec.yaml new file mode 100644 index 0000000..2e26067 --- /dev/null +++ b/resistor-color/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'resistor_color' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/resistor-color/test/resistor_color_test.dart b/resistor-color/test/resistor_color_test.dart new file mode 100644 index 0000000..7418cf0 --- /dev/null +++ b/resistor-color/test/resistor_color_test.dart @@ -0,0 +1,46 @@ +import 'package:resistor_color/resistor_color.dart'; +import 'package:test/test.dart'; + +final resistorColor = ResistorColor(); + +void main() { + group('ResistorColor: resistor color tests - ', resistorColorTests); + group('ResistorColor: Color codes - ', colorCodes); +} + +void resistorColorTests() { + test('Colors', () { + final result = resistorColor.colors; + expect( + result, + equals([ + 'black', + 'brown', + 'red', + 'orange', + 'yellow', + 'green', + 'blue', + 'violet', + 'grey', + 'white' + ])); + }, skip: false); +} + +void colorCodes() { + test('Black', () { + final result = resistorColor.colorCode('black'); + expect(result, equals(0)); + }, skip: false); + + test('White', () { + final result = resistorColor.colorCode('white'); + expect(result, equals(9)); + }, skip: false); + + test('Orange', () { + final result = resistorColor.colorCode('orange'); + expect(result, equals(3)); + }, skip: false); +} diff --git a/reverse-string/.dart_tool/package_config.json b/reverse-string/.dart_tool/package_config.json new file mode 100644 index 0000000..9bd4926 --- /dev/null +++ b/reverse-string/.dart_tool/package_config.json @@ -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": "reverse_string", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-03T19:25:50.826932Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/reverse-string/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/reverse-string/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/reverse-string/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/reverse-string/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/reverse-string/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..78daa24 Binary files /dev/null and b/reverse-string/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/reverse-string/.exercism/config.json b/reverse-string/.exercism/config.json new file mode 100644 index 0000000..96dda1c --- /dev/null +++ b/reverse-string/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "Zureka", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/reverse_string.dart" + ], + "test": [ + "test/reverse_string_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Reverse a string.", + "source": "Introductory challenge to reverse an input string", + "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" +} diff --git a/reverse-string/.exercism/metadata.json b/reverse-string/.exercism/metadata.json new file mode 100644 index 0000000..4b2ce7e --- /dev/null +++ b/reverse-string/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"reverse-string","id":"bbbde57d41204f9ea79f89b96382e342","url":"https://exercism.org/tracks/dart/exercises/reverse-string","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/reverse-string/HELP.md b/reverse-string/HELP.md new file mode 100644 index 0000000..19198c6 --- /dev/null +++ b/reverse-string/HELP.md @@ -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/reverse_string.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. \ No newline at end of file diff --git a/reverse-string/README.md b/reverse-string/README.md new file mode 100644 index 0000000..5c14fe4 --- /dev/null +++ b/reverse-string/README.md @@ -0,0 +1,27 @@ +# Reverse String + +Welcome to Reverse String on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Reverse a string + +For example: +input: "cool" +output: "looc" + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @Zureka +- @kytrinyx + +### Based on + +Introductory challenge to reverse an input string - https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb \ No newline at end of file diff --git a/reverse-string/analysis_options.yaml b/reverse-string/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/reverse-string/analysis_options.yaml @@ -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 diff --git a/reverse-string/lib/reverse_string.dart b/reverse-string/lib/reverse_string.dart new file mode 100644 index 0000000..cef1600 --- /dev/null +++ b/reverse-string/lib/reverse_string.dart @@ -0,0 +1,21 @@ +// String reverse(String word) { +// StringBuffer reversed = StringBuffer(); +// for (int i = 0; i < word.length; i++) { +// reversed.write(word[word.length - 1 - i]); +// } +// return reversed.toString(); +// } + +String reverse(String word) { + List chars = word.split(''); + int left = 0; + int right = chars.length - 1; + while (left < right) { + String temp = chars[left]; + chars[left] = chars[right]; + chars[right] = temp; + left++; + right--; + } + return chars.join(''); +} diff --git a/reverse-string/pubspec.lock b/reverse-string/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/reverse-string/pubspec.lock @@ -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" diff --git a/reverse-string/pubspec.yaml b/reverse-string/pubspec.yaml new file mode 100644 index 0000000..abc87ad --- /dev/null +++ b/reverse-string/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'reverse_string' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/reverse-string/test/reverse_string_test.dart b/reverse-string/test/reverse_string_test.dart new file mode 100644 index 0000000..c84d741 --- /dev/null +++ b/reverse-string/test/reverse_string_test.dart @@ -0,0 +1,36 @@ +import 'package:reverse_string/reverse_string.dart'; +import 'package:test/test.dart'; + +void main() { + group('ReverseString', () { + test('an empty string', () { + final result = reverse(''); + expect(result, equals('')); + }, skip: false); + + test('a word', () { + final result = reverse('robot'); + expect(result, equals('tobor')); + }, skip: true); + + test('a capitalized word', () { + final result = reverse('Ramen'); + expect(result, equals('nemaR')); + }, skip: true); + + test('a sentence with punctuation', () { + final result = reverse('I\'m hungry!'); + expect(result, equals('!yrgnuh m\'I')); + }, skip: true); + + test('a palindrome', () { + final result = reverse('racecar'); + expect(result, equals('racecar')); + }, skip: true); + + test('an even-sized word', () { + final result = reverse('drawer'); + expect(result, equals('reward')); + }, skip: true); + }); +} diff --git a/rna-transcription/.dart_tool/package_config.json b/rna-transcription/.dart_tool/package_config.json new file mode 100644 index 0000000..0648672 --- /dev/null +++ b/rna-transcription/.dart_tool/package_config.json @@ -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": "rna_transcription", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-04T10:09:48.262426Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/rna-transcription/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/rna-transcription/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/rna-transcription/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/rna-transcription/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/rna-transcription/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..b8c80ac Binary files /dev/null and b/rna-transcription/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/rna-transcription/.exercism/config.json b/rna-transcription/.exercism/config.json new file mode 100644 index 0000000..3a96926 --- /dev/null +++ b/rna-transcription/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "SuperPaintman" + ], + "contributors": [ + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/rna_transcription.dart" + ], + "test": [ + "test/rna_transcription_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given a DNA strand, return its RNA Complement Transcription.", + "source": "Hyperphysics", + "source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html" +} diff --git a/rna-transcription/.exercism/metadata.json b/rna-transcription/.exercism/metadata.json new file mode 100644 index 0000000..f686120 --- /dev/null +++ b/rna-transcription/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"rna-transcription","id":"1d5c58b29da34e2a8e75c882d70ff91a","url":"https://exercism.org/tracks/dart/exercises/rna-transcription","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/rna-transcription/HELP.md b/rna-transcription/HELP.md new file mode 100644 index 0000000..9f79dd2 --- /dev/null +++ b/rna-transcription/HELP.md @@ -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/rna_transcription.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. \ No newline at end of file diff --git a/rna-transcription/README.md b/rna-transcription/README.md new file mode 100644 index 0000000..c8ddf8f --- /dev/null +++ b/rna-transcription/README.md @@ -0,0 +1,57 @@ +# RNA Transcription + +Welcome to RNA Transcription on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +You work for a bioengineering company that specializes in developing therapeutic solutions. + +Your team has just been given a new project to develop a targeted therapy for a rare type of cancer. + +~~~~exercism/note +It's all very complicated, but the basic idea is that sometimes people's bodies produce too much of a given protein. +That can cause all sorts of havoc. + +But if you can create a very specific molecule (called a micro-RNA), it can prevent the protein from being produced. + +This technique is called [RNA Interference][rnai]. + +[rnai]: https://admin.acceleratingscience.com/ask-a-scientist/what-is-rnai/ +~~~~ + +## Instructions + +Your task is determine the RNA complement of a given DNA sequence. + +Both DNA and RNA strands are a sequence of nucleotides. + +The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**) and thymine (**T**). + +The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**) and uracil (**U**). + +Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement: + +- `G` -> `C` +- `C` -> `G` +- `T` -> `A` +- `A` -> `U` + +~~~~exercism/note +If you want to look at how the inputs and outputs are structured, take a look at the examples in the test suite. +~~~~ + +## Source + +### Created by + +- @SuperPaintman + +### Contributed to by + +- @Stargator +- @kytrinyx + +### Based on + +Hyperphysics - https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html \ No newline at end of file diff --git a/rna-transcription/analysis_options.yaml b/rna-transcription/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/rna-transcription/analysis_options.yaml @@ -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 diff --git a/rna-transcription/lib/rna_transcription.dart b/rna-transcription/lib/rna_transcription.dart new file mode 100644 index 0000000..b6e71bb --- /dev/null +++ b/rna-transcription/lib/rna_transcription.dart @@ -0,0 +1,12 @@ +class RnaTranscription { + Map _rnaMap = { + 'A': 'U', + 'C': 'G', + 'G': 'C', + 'T': 'A', + }; + + String toRna(String dna) { + return dna.split("").map((dna) => _rnaMap[dna]).join(); + } +} diff --git a/rna-transcription/pubspec.lock b/rna-transcription/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/rna-transcription/pubspec.lock @@ -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" diff --git a/rna-transcription/pubspec.yaml b/rna-transcription/pubspec.yaml new file mode 100644 index 0000000..0419f62 --- /dev/null +++ b/rna-transcription/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'rna_transcription' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/rna-transcription/test/rna_transcription_test.dart b/rna-transcription/test/rna_transcription_test.dart new file mode 100644 index 0000000..6883bf8 --- /dev/null +++ b/rna-transcription/test/rna_transcription_test.dart @@ -0,0 +1,38 @@ +import 'package:rna_transcription/rna_transcription.dart'; +import 'package:test/test.dart'; + +void main() { + final rnaTranscription = RnaTranscription(); + + group('RnaTranscription', () { + test('Empty RNA sequence', () { + final result = rnaTranscription.toRna(''); + expect(result, equals('')); + }, skip: false); + + test('RNA complement of cytosine is guanine', () { + final result = rnaTranscription.toRna('C'); + expect(result, equals('G')); + }, skip: true); + + test('RNA complement of guanine is cytosine', () { + final result = rnaTranscription.toRna('G'); + expect(result, equals('C')); + }, skip: true); + + test('RNA complement of thymine is adenine', () { + final result = rnaTranscription.toRna('T'); + expect(result, equals('A')); + }, skip: true); + + test('RNA complement of adenine is uracil', () { + final result = rnaTranscription.toRna('A'); + expect(result, equals('U')); + }, skip: true); + + test('RNA complement', () { + final result = rnaTranscription.toRna('ACGTGGTCTTAA'); + expect(result, equals('UGCACCAGAAUU')); + }, skip: true); + }); +} diff --git a/scrabble-score/.dart_tool/package_config.json b/scrabble-score/.dart_tool/package_config.json new file mode 100644 index 0000000..14ee3fa --- /dev/null +++ b/scrabble-score/.dart_tool/package_config.json @@ -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": "scrabble_score", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-09-28T12:43:49.766417Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/scrabble-score/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/scrabble-score/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..07e8fe3 Binary files /dev/null and b/scrabble-score/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/scrabble-score/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/scrabble-score/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..82c646d Binary files /dev/null and b/scrabble-score/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/scrabble-score/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/scrabble-score/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..e18318f Binary files /dev/null and b/scrabble-score/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/scrabble-score/.exercism/config.json b/scrabble-score/.exercism/config.json new file mode 100644 index 0000000..c9360a1 --- /dev/null +++ b/scrabble-score/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "jvarness" + ], + "contributors": [ + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/scrabble_score.dart" + ], + "test": [ + "test/scrabble_score_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given a word, compute the Scrabble score for that word.", + "source": "Inspired by the Extreme Startup game", + "source_url": "https://github.com/rchatley/extreme_startup" +} diff --git a/scrabble-score/.exercism/metadata.json b/scrabble-score/.exercism/metadata.json new file mode 100644 index 0000000..4119682 --- /dev/null +++ b/scrabble-score/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"scrabble-score","id":"b037c03d94824157b5e524e3a18675d8","url":"https://exercism.org/tracks/dart/exercises/scrabble-score","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/scrabble-score/HELP.md b/scrabble-score/HELP.md new file mode 100644 index 0000000..e146446 --- /dev/null +++ b/scrabble-score/HELP.md @@ -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/scrabble_score.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. \ No newline at end of file diff --git a/scrabble-score/README.md b/scrabble-score/README.md new file mode 100644 index 0000000..6fbaef2 --- /dev/null +++ b/scrabble-score/README.md @@ -0,0 +1,60 @@ +# Scrabble Score + +Welcome to Scrabble Score on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a word, compute the Scrabble score for that word. + +## Letter Values + +You'll need these: + +```text +Letter Value +A, E, I, O, U, L, N, R, S, T 1 +D, G 2 +B, C, M, P 3 +F, H, V, W, Y 4 +K 5 +J, X 8 +Q, Z 10 +``` + +## Examples + +"cabbage" should be scored as worth 14 points: + +- 3 points for C +- 1 point for A, twice +- 3 points for B, twice +- 2 points for G +- 1 point for E + +And to total: + +- `3 + 2*1 + 2*3 + 2 + 1` +- = `3 + 2 + 6 + 3` +- = `5 + 9` +- = 14 + +## Extensions + +- You can play a double or a triple letter. +- You can play a double or a triple word. + +## Source + +### Created by + +- @jvarness + +### Contributed to by + +- @Stargator +- @kytrinyx + +### Based on + +Inspired by the Extreme Startup game - https://github.com/rchatley/extreme_startup \ No newline at end of file diff --git a/scrabble-score/analysis_options.yaml b/scrabble-score/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/scrabble-score/analysis_options.yaml @@ -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 diff --git a/scrabble-score/lib/scrabble_score.dart b/scrabble-score/lib/scrabble_score.dart new file mode 100644 index 0000000..a0259ba --- /dev/null +++ b/scrabble-score/lib/scrabble_score.dart @@ -0,0 +1,38 @@ +// Put your code here + +Map scoreMap = { + 'A': 1, + 'E': 1, + 'I': 1, + 'O': 1, + 'U': 1, + 'L': 1, + 'N': 1, + 'R': 1, + 'S': 1, + 'T': 1, + 'D': 2, + 'G': 2, + 'B': 3, + 'C': 3, + 'M': 3, + 'P': 3, + 'F': 4, + 'H': 4, + 'V': 4, + 'W': 4, + 'Y': 4, + 'K': 5, + 'J': 8, + 'X': 8, + 'Q': 10, + 'Z': 10, +}; + +int score(String word) { + int result = 0; + for (int i = 0; i < word.length; i++) { + result += scoreMap[word[i].toUpperCase()] ?? 0; + } + return result; +} diff --git a/scrabble-score/pubspec.lock b/scrabble-score/pubspec.lock new file mode 100644 index 0000000..235179f --- /dev/null +++ b/scrabble-score/pubspec.lock @@ -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" diff --git a/scrabble-score/pubspec.yaml b/scrabble-score/pubspec.yaml new file mode 100644 index 0000000..ab55114 --- /dev/null +++ b/scrabble-score/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'scrabble_score' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/scrabble-score/test/scrabble_score_test.dart b/scrabble-score/test/scrabble_score_test.dart new file mode 100644 index 0000000..a5dadd0 --- /dev/null +++ b/scrabble-score/test/scrabble_score_test.dart @@ -0,0 +1,61 @@ +import 'package:scrabble_score/scrabble_score.dart'; +import 'package:test/test.dart'; + +void main() { + group('ScrabbleScore', () { + test('lowercase letter', () { + final result = score('a'); + expect(result, equals(1)); + }, skip: false); + + test('uppercase letter', () { + final result = score('A'); + expect(result, equals(1)); + }, skip: true); + + test('valuable letter', () { + final result = score('f'); + expect(result, equals(4)); + }, skip: true); + + test('short word', () { + final result = score('at'); + expect(result, equals(2)); + }, skip: true); + + test('short, valuable word', () { + final result = score('zoo'); + expect(result, equals(12)); + }, skip: true); + + test('medium word', () { + final result = score('street'); + expect(result, equals(6)); + }, skip: true); + + test('medium, valuable word', () { + final result = score('quirky'); + expect(result, equals(22)); + }, skip: true); + + test('long, mixed-case word', () { + final result = score('OxyphenButazone'); + expect(result, equals(41)); + }, skip: true); + + test('english-like word', () { + final result = score('pinata'); + expect(result, equals(8)); + }, skip: true); + + test('empty input', () { + final result = score(''); + expect(result, equals(0)); + }, skip: true); + + test('entire alphabet available', () { + final result = score('abcdefghijklmnopqrstuvwxyz'); + expect(result, equals(87)); + }, skip: true); + }); +} diff --git a/space-age/.dart_tool/package_config.json b/space-age/.dart_tool/package_config.json new file mode 100644 index 0000000..2b521bc --- /dev/null +++ b/space-age/.dart_tool/package_config.json @@ -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": "space_age", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-06T08:55:42.311483Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/space-age/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/space-age/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/space-age/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/space-age/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/space-age/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..3e96658 Binary files /dev/null and b/space-age/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/space-age/.exercism/config.json b/space-age/.exercism/config.json new file mode 100644 index 0000000..0cc17d3 --- /dev/null +++ b/space-age/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "devkabiir" + ], + "contributors": [ + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/space_age.dart" + ], + "test": [ + "test/space_age_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.", + "source": "Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial.", + "source_url": "https://pine.fm/LearnToProgram/?Chapter=01" +} diff --git a/space-age/.exercism/metadata.json b/space-age/.exercism/metadata.json new file mode 100644 index 0000000..8f6af8d --- /dev/null +++ b/space-age/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"space-age","id":"64f86d4a9ef94e7dad1d9cdf35fa1978","url":"https://exercism.org/tracks/dart/exercises/space-age","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/space-age/HELP.md b/space-age/HELP.md new file mode 100644 index 0000000..daca90d --- /dev/null +++ b/space-age/HELP.md @@ -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/space_age.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. \ No newline at end of file diff --git a/space-age/README.md b/space-age/README.md new file mode 100644 index 0000000..0e64e09 --- /dev/null +++ b/space-age/README.md @@ -0,0 +1,45 @@ +# Space Age + +Welcome to Space Age on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given an age in seconds, calculate how old someone would be on: + +- Mercury: orbital period 0.2408467 Earth years +- Venus: orbital period 0.61519726 Earth years +- Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds +- Mars: orbital period 1.8808158 Earth years +- Jupiter: orbital period 11.862615 Earth years +- Saturn: orbital period 29.447498 Earth years +- Uranus: orbital period 84.016846 Earth years +- Neptune: orbital period 164.79132 Earth years + +So if you were told someone were 1,000,000,000 seconds old, you should +be able to say that they're 31.69 Earth-years old. + +If you're wondering why Pluto didn't make the cut, go watch [this YouTube video][pluto-video]. + +Note: The actual length of one complete orbit of the Earth around the sun is closer to 365.256 days (1 sidereal year). +The Gregorian calendar has, on average, 365.2425 days. +While not entirely accurate, 365.25 is the value used in this exercise. +See [Year on Wikipedia][year] for more ways to measure a year. + +[pluto-video]: https://www.youtube.com/watch?v=Z_2gbGXzFbs +[year]: https://en.wikipedia.org/wiki/Year#Summary + +## Source + +### Created by + +- @devkabiir + +### Contributed to by + +- @Stargator +- @kytrinyx + +### Based on + +Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial. - https://pine.fm/LearnToProgram/?Chapter=01 \ No newline at end of file diff --git a/space-age/analysis_options.yaml b/space-age/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/space-age/analysis_options.yaml @@ -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 diff --git a/space-age/lib/space_age.dart b/space-age/lib/space_age.dart new file mode 100644 index 0000000..be12f50 --- /dev/null +++ b/space-age/lib/space_age.dart @@ -0,0 +1,17 @@ +class SpaceAge { + final Map planets = { + 'Mercury': 0.2408467, + 'Venus': 0.61519726, + 'Mars': 1.8808158, + 'Jupiter': 11.862615, + 'Saturn': 29.447498, + 'Uranus': 84.016846, + 'Neptune': 164.79132, + 'Earth': 1, + }; + + double age({required final String planet, required final int seconds}) { + return double.parse( + (seconds / (31557600 * planets[planet]!)).toStringAsFixed(2)); + } +} diff --git a/space-age/pubspec.lock b/space-age/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/space-age/pubspec.lock @@ -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" diff --git a/space-age/pubspec.yaml b/space-age/pubspec.yaml new file mode 100644 index 0000000..21ca0a6 --- /dev/null +++ b/space-age/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'space_age' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/space-age/test/space_age_test.dart b/space-age/test/space_age_test.dart new file mode 100644 index 0000000..e95e156 --- /dev/null +++ b/space-age/test/space_age_test.dart @@ -0,0 +1,40 @@ +import 'package:space_age/space_age.dart'; +import 'package:test/test.dart'; + +void main() { + final spaceAge = SpaceAge(); + + group('SpaceAge', () { + test('age on Earth', () { + expect(spaceAge.age(planet: 'Earth', seconds: 1000000000), equals(31.69)); + }, skip: false); + + test('age on Mercury', () { + expect(spaceAge.age(planet: 'Mercury', seconds: 2134835688), equals(280.88)); + }, skip: true); + + test('age on Venus', () { + expect(spaceAge.age(planet: 'Venus', seconds: 189839836), equals(9.78)); + }, skip: true); + + test('age on Mars', () { + expect(spaceAge.age(planet: 'Mars', seconds: 2129871239), equals(35.88)); + }, skip: true); + + test('age on Jupiter', () { + expect(spaceAge.age(planet: 'Jupiter', seconds: 901876382), equals(2.41)); + }, skip: true); + + test('age on Saturn', () { + expect(spaceAge.age(planet: 'Saturn', seconds: 2000000000), equals(2.15)); + }, skip: true); + + test('age on Uranus', () { + expect(spaceAge.age(planet: 'Uranus', seconds: 1210123456), equals(0.46)); + }, skip: true); + + test('age on Neptune', () { + expect(spaceAge.age(planet: 'Neptune', seconds: 1821023456), equals(0.35)); + }, skip: true); + }); +} diff --git a/sum-of-multiples/.dart_tool/package_config.json b/sum-of-multiples/.dart_tool/package_config.json new file mode 100644 index 0000000..52ed739 --- /dev/null +++ b/sum-of-multiples/.dart_tool/package_config.json @@ -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": "sum_of_multiples", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.12" + } + ], + "generated": "2023-10-08T15:37:03.537296Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/sum-of-multiples/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/sum-of-multiples/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/sum-of-multiples/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/sum-of-multiples/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjEy b/sum-of-multiples/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjEy new file mode 100644 index 0000000..f391292 Binary files /dev/null and b/sum-of-multiples/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjEy differ diff --git a/sum-of-multiples/.exercism/config.json b/sum-of-multiples/.exercism/config.json new file mode 100644 index 0000000..7be685e --- /dev/null +++ b/sum-of-multiples/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "Stargator" + ], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "lib/sum_of_multiples.dart" + ], + "test": [ + "test/sum_of_multiples_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given a number, find the sum of all the multiples of particular numbers up to but not including that number.", + "source": "A variation on Problem 1 at Project Euler", + "source_url": "https://projecteuler.net/problem=1" +} diff --git a/sum-of-multiples/.exercism/metadata.json b/sum-of-multiples/.exercism/metadata.json new file mode 100644 index 0000000..90fc6b5 --- /dev/null +++ b/sum-of-multiples/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"sum-of-multiples","id":"09fe187c950d4520a23808b5763c5d73","url":"https://exercism.org/tracks/dart/exercises/sum-of-multiples","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/sum-of-multiples/HELP.md b/sum-of-multiples/HELP.md new file mode 100644 index 0000000..29d10bf --- /dev/null +++ b/sum-of-multiples/HELP.md @@ -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/sum_of_multiples.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. \ No newline at end of file diff --git a/sum-of-multiples/README.md b/sum-of-multiples/README.md new file mode 100644 index 0000000..a60517a --- /dev/null +++ b/sum-of-multiples/README.md @@ -0,0 +1,53 @@ +# Sum of Multiples + +Welcome to Sum of Multiples on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +You work for a company that makes an online, fantasy-survival game. + +When a player finishes a level, they are awarded energy points. +The amount of energy awarded depends on which magical items the player found while exploring that level. + +## Instructions + +Your task is to write the code that calculates the energy points that get awarded to players when they complete a level. + +The points awarded depend on two things: + +- The level (a number) that the player completed. +- The base value of each magical item collected by the player during that level. + +The energy points are awarded according to the following rules: + +1. For each magical item, take the base value and find all the multiples of that value that are less than the level number. +2. Combine the sets of numbers. +3. Remove any duplicates. +4. Calculate the sum of all the numbers that are left. + +Let's look at an example: + +**The player completed level 20 and found two magical items with base values of 3 and 5.** + +To calculate the energy points earned by the player, we need to find all the unique multiples of these base values that are less than level 20. + +- Multiples of 3 less than 20: `{3, 6, 9, 12, 15, 18}` +- Multiples of 5 less than 20: `{5, 10, 15}` +- Combine the sets and remove duplicates: `{3, 5, 6, 9, 10, 12, 15, 18}` +- Sum the unique multiples: `3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 = 78` +- Therefore, the player earns **78** energy points for completing level 20 and finding the two magical items with base values of 3 and 5. + +## Source + +### Created by + +- @Stargator + +### Contributed to by + +- @kytrinyx + +### Based on + +A variation on Problem 1 at Project Euler - https://projecteuler.net/problem=1 \ No newline at end of file diff --git a/sum-of-multiples/analysis_options.yaml b/sum-of-multiples/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/sum-of-multiples/analysis_options.yaml @@ -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 diff --git a/sum-of-multiples/lib/sum_of_multiples.dart b/sum-of-multiples/lib/sum_of_multiples.dart new file mode 100644 index 0000000..76dfe3d --- /dev/null +++ b/sum-of-multiples/lib/sum_of_multiples.dart @@ -0,0 +1,13 @@ +class SumOfMultiples { + int sum(List numbers, int level) { + Set multiples = Set(); + numbers.forEach((n) { + if (n != 0) { + for (int i = n; i < level; i += n) { + multiples.add(i); + } + } + }); + return (multiples.length > 0) ? multiples.reduce((a, b) => a + b) : 0; + } +} diff --git a/sum-of-multiples/pubspec.lock b/sum-of-multiples/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/sum-of-multiples/pubspec.lock @@ -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" diff --git a/sum-of-multiples/pubspec.yaml b/sum-of-multiples/pubspec.yaml new file mode 100644 index 0000000..ad84858 --- /dev/null +++ b/sum-of-multiples/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'sum_of_multiples' +environment: + sdk: '>=2.12.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/sum-of-multiples/test/sum_of_multiples_test.dart b/sum-of-multiples/test/sum_of_multiples_test.dart new file mode 100644 index 0000000..388c223 --- /dev/null +++ b/sum-of-multiples/test/sum_of_multiples_test.dart @@ -0,0 +1,88 @@ +import 'package:sum_of_multiples/sum_of_multiples.dart'; +import 'package:test/test.dart'; + +void main() { + final sumOfMultiples = SumOfMultiples(); + + group('SumOfMultiples', () { + test('no multiples within limit', () { + final result = sumOfMultiples.sum([3, 5], 1); + expect(result, equals(0)); + }, skip: false); + + test('one factor has multiples within limit', () { + final result = sumOfMultiples.sum([3, 5], 4); + expect(result, equals(3)); + }, skip: true); + + test('more than one multiple within limit', () { + final result = sumOfMultiples.sum([3], 7); + expect(result, equals(9)); + }, skip: true); + + test('more than one factor with multiples within limit', () { + final result = sumOfMultiples.sum([3, 5], 10); + expect(result, equals(23)); + }, skip: true); + + test('each multiple is only counted once', () { + final result = sumOfMultiples.sum([3, 5], 100); + expect(result, equals(2318)); + }, skip: true); + + test('a much larger limit', () { + final result = sumOfMultiples.sum([3, 5], 1000); + expect(result, equals(233168)); + }, skip: true); + + test('three factors', () { + final result = sumOfMultiples.sum([7, 13, 17], 20); + expect(result, equals(51)); + }, skip: true); + + test('factors not relatively prime', () { + final result = sumOfMultiples.sum([4, 6], 15); + expect(result, equals(30)); + }, skip: true); + + test('some pairs of factors relatively prime and some not', () { + final result = sumOfMultiples.sum([5, 6, 8], 150); + expect(result, equals(4419)); + }, skip: true); + + test('one factor is a multiple of another', () { + final result = sumOfMultiples.sum([5, 25], 51); + expect(result, equals(275)); + }, skip: true); + + test('much larger factors', () { + final result = sumOfMultiples.sum([43, 47], 10000); + expect(result, equals(2203160)); + }, skip: true); + + test('all numbers are multiples of 1', () { + final result = sumOfMultiples.sum([1], 100); + expect(result, equals(4950)); + }, skip: true); + + test('no factors means an empty sum', () { + final result = sumOfMultiples.sum([], 10000); + expect(result, equals(0)); + }, skip: true); + + test('the only multiple of 0 is 0', () { + final result = sumOfMultiples.sum([0], 1); + expect(result, equals(0)); + }, skip: true); + + test('the factor 0 does not affect the sum of multiples of other factors', () { + final result = sumOfMultiples.sum([3, 0], 4); + expect(result, equals(3)); + }, skip: true); + + test('solutions using include-exclude must extend to cardinality greater than 3', () { + final result = sumOfMultiples.sum([2, 3, 5, 7, 11], 10000); + expect(result, equals(39614537)); + }, skip: true); + }); +} diff --git a/triangle/.dart_tool/package_config.json b/triangle/.dart_tool/package_config.json new file mode 100644 index 0000000..be213da --- /dev/null +++ b/triangle/.dart_tool/package_config.json @@ -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": "triangle", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-09T12:33:23.379395Z", + "generator": "pub", + "generatorVersion": "3.1.0" +} diff --git a/triangle/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/triangle/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/triangle/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/triangle/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/triangle/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..447ddf7 Binary files /dev/null and b/triangle/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/triangle/.exercism/config.json b/triangle/.exercism/config.json new file mode 100644 index 0000000..76cf9e1 --- /dev/null +++ b/triangle/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "Zureka", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/triangle.dart" + ], + "test": [ + "test/triangle_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Determine if a triangle is equilateral, isosceles, or scalene.", + "source": "The Ruby Koans triangle project, parts 1 & 2", + "source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com" +} diff --git a/triangle/.exercism/metadata.json b/triangle/.exercism/metadata.json new file mode 100644 index 0000000..40eb4ae --- /dev/null +++ b/triangle/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"triangle","id":"4d05ab92c2484cab8a467032c1e48263","url":"https://exercism.org/tracks/dart/exercises/triangle","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/triangle/HELP.md b/triangle/HELP.md new file mode 100644 index 0000000..305110b --- /dev/null +++ b/triangle/HELP.md @@ -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/triangle.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. \ No newline at end of file diff --git a/triangle/README.md b/triangle/README.md new file mode 100644 index 0000000..408c6b4 --- /dev/null +++ b/triangle/README.md @@ -0,0 +1,49 @@ +# Triangle + +Welcome to Triangle on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Determine if a triangle is equilateral, isosceles, or scalene. + +An _equilateral_ triangle has all three sides the same length. + +An _isosceles_ triangle has at least two sides the same length. +(It is sometimes specified as having exactly two sides the same length, but for the purposes of this exercise we'll say at least two.) + +A _scalene_ triangle has all sides of different lengths. + +## Note + +For a shape to be a triangle at all, all sides have to be of length > 0, and the sum of the lengths of any two sides must be greater than or equal to the length of the third side. + +In equations: + +Let `a`, `b`, and `c` be sides of the triangle. +Then all three of the following expressions must be true: + +```text +a + b ≥ c +b + c ≥ a +a + c ≥ b +``` + +See [Triangle Inequality][triangle-inequality] + +[triangle-inequality]: https://en.wikipedia.org/wiki/Triangle_inequality + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @Zureka +- @kytrinyx + +### Based on + +The Ruby Koans triangle project, parts 1 & 2 - https://web.archive.org/web/20220831105330/http://rubykoans.com \ No newline at end of file diff --git a/triangle/analysis_options.yaml b/triangle/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/triangle/analysis_options.yaml @@ -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 diff --git a/triangle/lib/triangle.dart b/triangle/lib/triangle.dart new file mode 100644 index 0000000..adc3fe2 --- /dev/null +++ b/triangle/lib/triangle.dart @@ -0,0 +1,17 @@ +extension on List { + bool get isTriangle { + sort(); + return length == 3 && this[0] + this[1] > this[2]; + } +} + +class Triangle { + bool equilateral(double a, double b, double c) => + [a, b, c].isTriangle && {a, b, c}.length == 1; + + bool isosceles(double a, double b, double c) => + [a, b, c].isTriangle && {a, b, c}.length <= 2; + + bool scalene(double a, double b, double c) => + [a, b, c].isTriangle && {a, b, c}.length == 3; +} diff --git a/triangle/pubspec.lock b/triangle/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/triangle/pubspec.lock @@ -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" diff --git a/triangle/pubspec.yaml b/triangle/pubspec.yaml new file mode 100644 index 0000000..ec57bd0 --- /dev/null +++ b/triangle/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'triangle' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/triangle/test/triangle_test.dart b/triangle/test/triangle_test.dart new file mode 100644 index 0000000..a317042 --- /dev/null +++ b/triangle/test/triangle_test.dart @@ -0,0 +1,121 @@ +import 'package:test/test.dart'; +import 'package:triangle/triangle.dart'; + +final triangle = Triangle(); + +void main() { + group('Triangle: equilateral triangle - ', equilateralTriangle); + group('Triangle: isosceles triangle - ', isoscelesTriangle); + group('Triangle: scalene triangle - ', scaleneTriangle); +} + +void equilateralTriangle() { + test('all sides are equal', () { + final result = triangle.equilateral(2, 2, 2); + expect(result, equals(true)); + }, skip: false); + + test('any side is unequal', () { + final result = triangle.equilateral(2, 3, 2); + expect(result, equals(false)); + }, skip: false); + + test('no sides are equal', () { + final result = triangle.equilateral(5, 4, 6); + expect(result, equals(false)); + }, skip: false); + + test('all zero sides is not a triangle', () { + final result = triangle.equilateral(0, 0, 0); + expect(result, equals(false)); + }, skip: false); + + test('sides may be floats', () { + final result = triangle.equilateral(0.5, 0.5, 0.5); + expect(result, equals(true)); + }, skip: false); +} + +void isoscelesTriangle() { + test('last two sides are equal', () { + final result = triangle.isosceles(3, 4, 4); + expect(result, equals(true)); + }, skip: false); + + test('first two sides are equal', () { + final result = triangle.isosceles(4, 4, 3); + expect(result, equals(true)); + }, skip: false); + + test('first and last sides are equal', () { + final result = triangle.isosceles(4, 3, 4); + expect(result, equals(true)); + }, skip: false); + + test('equilateral triangles are also isosceles', () { + final result = triangle.isosceles(4, 4, 4); + expect(result, equals(true)); + }, skip: false); + + test('no sides are equal', () { + final result = triangle.isosceles(2, 3, 4); + expect(result, equals(false)); + }, skip: false); + + test('first triangle inequality violation', () { + final result = triangle.isosceles(1, 1, 3); + expect(result, equals(false)); + }, skip: false); + + test('second triangle inequality violation', () { + final result = triangle.isosceles(1, 3, 1); + expect(result, equals(false)); + }, skip: false); + + test('third triangle inequality violation', () { + final result = triangle.isosceles(3, 1, 1); + expect(result, equals(false)); + }, skip: false); + + test('sides may be floats', () { + final result = triangle.isosceles(0.5, 0.4, 0.5); + expect(result, equals(true)); + }, skip: false); +} + +void scaleneTriangle() { + test('no sides are equal', () { + final result = triangle.scalene(5, 4, 6); + expect(result, equals(true)); + }, skip: false); + + test('all sides are equal', () { + final result = triangle.scalene(4, 4, 4); + expect(result, equals(false)); + }, skip: false); + + test('first and second sides are equal', () { + final result = triangle.scalene(4, 4, 3); + expect(result, equals(false)); + }, skip: false); + + test('first and third sides are equal', () { + final result = triangle.scalene(3, 4, 3); + expect(result, equals(false)); + }, skip: false); + + test('second and third sides are equal', () { + final result = triangle.scalene(4, 3, 3); + expect(result, equals(false)); + }, skip: false); + + test('may not violate triangle inequality', () { + final result = triangle.scalene(7, 3, 2); + expect(result, equals(false)); + }, skip: false); + + test('sides may be floats', () { + final result = triangle.scalene(0.5, 0.4, 0.6); + expect(result, equals(true)); + }, skip: false); +} diff --git a/two-fer/.dart_tool/package_config.json b/two-fer/.dart_tool/package_config.json new file mode 100644 index 0000000..bd98e57 --- /dev/null +++ b/two-fer/.dart_tool/package_config.json @@ -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": "two_fer", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-09-28T09:59:23.266506Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/two-fer/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/two-fer/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..07e8fe3 Binary files /dev/null and b/two-fer/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/two-fer/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/two-fer/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..82c646d Binary files /dev/null and b/two-fer/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/two-fer/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/two-fer/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..cc575d2 Binary files /dev/null and b/two-fer/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/two-fer/.exercism/config.json b/two-fer/.exercism/config.json new file mode 100644 index 0000000..80bc79f --- /dev/null +++ b/two-fer/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "amscotti" + ], + "contributors": [ + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/two_fer.dart" + ], + "test": [ + "test/two_fer_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Create a sentence of the form \"One for X, one for me.\".", + "source_url": "https://github.com/exercism/problem-specifications/issues/757" +} diff --git a/two-fer/.exercism/metadata.json b/two-fer/.exercism/metadata.json new file mode 100644 index 0000000..747c9ff --- /dev/null +++ b/two-fer/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"two-fer","id":"19ca3fbdb6fc42f4b83341928bc4e000","url":"https://exercism.org/tracks/dart/exercises/two-fer","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/two-fer/HELP.md b/two-fer/HELP.md new file mode 100644 index 0000000..5236ebb --- /dev/null +++ b/two-fer/HELP.md @@ -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/two_fer.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. \ No newline at end of file diff --git a/two-fer/README.md b/two-fer/README.md new file mode 100644 index 0000000..7d3e18d --- /dev/null +++ b/two-fer/README.md @@ -0,0 +1,54 @@ +# Two Fer + +Welcome to Two Fer on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +In some English accents, when you say "two for" quickly, it sounds like "two fer". +Two-for-one is a way of saying that if you buy one, you also get one for free. +So the phrase "two-fer" often implies a two-for-one offer. + +Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). +You go for the offer and (very generously) decide to give the extra cookie to a friend. + +## Instructions + +Your task is to determine what you will say as you give away the extra cookie. + +If your friend likes cookies, and is named Do-yun, then you will say: + +```text +One for Do-yun, one for me. +``` + +If your friend doesn't like cookies, you give the cookie to the next person in line at the bakery. +Since you don't know their name, you will say _you_ instead. + +```text +One for you, one for me. +``` + +Here are some examples: + +|Name |Dialogue +|:-------|:------------------ +|Alice |One for Alice, one for me. +|Bohdan |One for Bohdan, one for me. +| |One for you, one for me. +|Zaphod |One for Zaphod, one for me. + +## Source + +### Created by + +- @amscotti + +### Contributed to by + +- @Stargator +- @kytrinyx + +### Based on + +https://github.com/exercism/problem-specifications/issues/757 \ No newline at end of file diff --git a/two-fer/analysis_options.yaml b/two-fer/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/two-fer/analysis_options.yaml @@ -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 diff --git a/two-fer/lib/two_fer.dart b/two-fer/lib/two_fer.dart new file mode 100644 index 0000000..4dd4b5f --- /dev/null +++ b/two-fer/lib/two_fer.dart @@ -0,0 +1 @@ +String twoFer([String? name = 'you']) => 'One for $name, one for me.'; diff --git a/two-fer/pubspec.lock b/two-fer/pubspec.lock new file mode 100644 index 0000000..235179f --- /dev/null +++ b/two-fer/pubspec.lock @@ -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" diff --git a/two-fer/pubspec.yaml b/two-fer/pubspec.yaml new file mode 100644 index 0000000..7537152 --- /dev/null +++ b/two-fer/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'two_fer' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/two-fer/test/two_fer_test.dart b/two-fer/test/two_fer_test.dart new file mode 100644 index 0000000..f9dc4e4 --- /dev/null +++ b/two-fer/test/two_fer_test.dart @@ -0,0 +1,21 @@ +import 'package:test/test.dart'; +import 'package:two_fer/two_fer.dart'; + +void main() { + group('TwoFer', () { + test('no name given', () { + final result = twoFer(); + expect(result, equals('One for you, one for me.')); + }, skip: false); + + test('a name given', () { + final result = twoFer('Alice'); + expect(result, equals('One for Alice, one for me.')); + }, skip: true); + + test('another name given', () { + final result = twoFer('Bob'); + expect(result, equals('One for Bob, one for me.')); + }, skip: true); + }); +} diff --git a/word-count/.dart_tool/package_config.json b/word-count/.dart_tool/package_config.json new file mode 100644 index 0000000..f685616 --- /dev/null +++ b/word-count/.dart_tool/package_config.json @@ -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": "word_count", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.18" + } + ], + "generated": "2023-10-02T21:35:56.209475Z", + "generator": "pub", + "generatorVersion": "3.1.3" +} diff --git a/word-count/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot b/word-count/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot new file mode 100644 index 0000000..ac38879 Binary files /dev/null and b/word-count/.dart_tool/pub/bin/test/test.dart-3.1.0.snapshot differ diff --git a/word-count/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot b/word-count/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot new file mode 100644 index 0000000..f533e11 Binary files /dev/null and b/word-count/.dart_tool/pub/bin/test/test.dart-3.1.3.snapshot differ diff --git a/word-count/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 b/word-count/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 new file mode 100644 index 0000000..e4909a0 Binary files /dev/null and b/word-count/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE4 differ diff --git a/word-count/.exercism/config.json b/word-count/.exercism/config.json new file mode 100644 index 0000000..16ba595 --- /dev/null +++ b/word-count/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "devkabiir" + ], + "contributors": [ + "Stargator", + "kytrinyx" + ], + "files": { + "solution": [ + "lib/word_count.dart" + ], + "test": [ + "test/word_count_test.dart" + ], + "example": [ + ".meta/lib/example.dart" + ] + }, + "blurb": "Given a phrase, count the occurrences of each word in that phrase.", + "source": "This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour." +} diff --git a/word-count/.exercism/metadata.json b/word-count/.exercism/metadata.json new file mode 100644 index 0000000..ec8e1fb --- /dev/null +++ b/word-count/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"dart","exercise":"word-count","id":"ba9af77f17774e7ca837ac244e4a3175","url":"https://exercism.org/tracks/dart/exercises/word-count","handle":"plan9fromouterspace","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/word-count/HELP.md b/word-count/HELP.md new file mode 100644 index 0000000..9df7736 --- /dev/null +++ b/word-count/HELP.md @@ -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/word_count.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. \ No newline at end of file diff --git a/word-count/README.md b/word-count/README.md new file mode 100644 index 0000000..5f79ca3 --- /dev/null +++ b/word-count/README.md @@ -0,0 +1,76 @@ +# Word Count + +Welcome to Word Count on Exercism's Dart Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Introduction + +You teach English as a foreign language to high school students. + +You've decided to base your entire curriculum on TV shows. +You need to analyze which words are used, and how often they're repeated. + +This will let you choose the simplest shows to start with, and to gradually increase the difficulty as time passes. + +## Instructions + +Your task is to count how many times each word occurs in a subtitle of a drama. + +The subtitles from these dramas use only ASCII characters. + +The characters often speak in casual English, using contractions like _they're_ or _it's_. +Though these contractions come from two words (e.g. _we are_), the contraction (_we're_) is considered a single word. + +Words can be separated by any form of punctuation (e.g. ":", "!", or "?") or whitespace (e.g. "\t", "\n", or " "). +The only punctuation that does not separate words is the apostrophe in contractions. + +Numbers are considered words. +If the subtitles say _It costs 100 dollars._ then _100_ will be its own word. + +Words are case insensitive. +For example, the word _you_ occurs three times in the following sentence: + +> You come back, you hear me? DO YOU HEAR ME? + +The ordering of the word counts in the results doesn't matter. + +Here's an example that incorporates several of the elements discussed above: + +- simple words +- contractions +- numbers +- case insensitive words +- punctuation (including apostrophes) to separate words +- different forms of whitespace to separate words + +`"That's the password: 'PASSWORD 123'!", cried the Special Agent.\nSo I fled.` + +The mapping for this subtitle would be: + +```text +123: 1 +agent: 1 +cried: 1 +fled: 1 +i: 1 +password: 2 +so: 1 +special: 1 +that's: 1 +the: 2 +``` + +## Source + +### Created by + +- @devkabiir + +### Contributed to by + +- @Stargator +- @kytrinyx + +### Based on + +This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour. \ No newline at end of file diff --git a/word-count/analysis_options.yaml b/word-count/analysis_options.yaml new file mode 100644 index 0000000..c06363d --- /dev/null +++ b/word-count/analysis_options.yaml @@ -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 diff --git a/word-count/lib/word_count.dart b/word-count/lib/word_count.dart new file mode 100644 index 0000000..367418a --- /dev/null +++ b/word-count/lib/word_count.dart @@ -0,0 +1,16 @@ +class WordCount { + Map countWords(String input) { + var exp = new RegExp(r"(\w+('\w+)?)"); + return exp + .allMatches(input) + .map((e) => e.group(0)!.toLowerCase()) + .fold(new Map(), (Map counts, String word) { + if (counts.containsKey(word)) { + counts[word] = counts[word]! + 1; + } else { + counts[word] = 1; + } + return counts; + }); + } +} diff --git a/word-count/pubspec.lock b/word-count/pubspec.lock new file mode 100644 index 0000000..272fbae --- /dev/null +++ b/word-count/pubspec.lock @@ -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" diff --git a/word-count/pubspec.yaml b/word-count/pubspec.yaml new file mode 100644 index 0000000..ed8549b --- /dev/null +++ b/word-count/pubspec.yaml @@ -0,0 +1,5 @@ +name: 'word_count' +environment: + sdk: '>=2.18.0 <3.0.0' +dev_dependencies: + test: '<2.0.0' diff --git a/word-count/test/word_count_test.dart b/word-count/test/word_count_test.dart new file mode 100644 index 0000000..aa5a2c3 --- /dev/null +++ b/word-count/test/word_count_test.dart @@ -0,0 +1,130 @@ +import 'package:test/test.dart'; +import 'package:word_count/word_count.dart'; + +void main() { + final wordCount = WordCount(); + + group('WordCount', () { + test('count one word', () { + final result = wordCount.countWords('word'); + expect(result, equals({'word': 1})); + }, skip: false); + + test('count one of each word', () { + final result = wordCount.countWords('one of each'); + expect(result, equals({'one': 1, 'of': 1, 'each': 1})); + }, skip: false); + + test('multiple occurrences of a word', () { + final result = + wordCount.countWords('one fish two fish red fish blue fish'); + expect( + result, + equals({ + 'one': 1, + 'fish': 4, + 'two': 1, + 'red': 1, + 'blue': 1 + })); + }, skip: false); + + test('handles cramped lists', () { + final result = wordCount.countWords('one,two,three'); + expect(result, equals({'one': 1, 'two': 1, 'three': 1})); + }, skip: false); + + test('handles expanded lists', () { + final result = wordCount.countWords('one,\ntwo,\nthree'); + expect(result, equals({'one': 1, 'two': 1, 'three': 1})); + }, skip: false); + + test('ignore punctuation', () { + final result = + wordCount.countWords('car: carpet as java: javascript!!&@\$%^&'); + expect( + result, + equals({ + 'car': 1, + 'carpet': 1, + 'as': 1, + 'java': 1, + 'javascript': 1 + })); + }, skip: false); + + test('include numbers', () { + final result = wordCount.countWords('testing, 1, 2 testing'); + expect(result, equals({'testing': 2, '1': 1, '2': 1})); + }, skip: false); + + test('normalize case', () { + final result = wordCount.countWords('go Go GO Stop stop'); + expect(result, equals({'go': 3, 'stop': 2})); + }, skip: false); + + test('with apostrophes', () { + final result = wordCount.countWords( + '\'First: don\'t laugh. Then: don\'t cry. You\'re getting it.\''); + expect( + result, + equals({ + 'first': 1, + 'don\'t': 2, + 'laugh': 1, + 'then': 1, + 'cry': 1, + 'you\'re': 1, + 'getting': 1, + 'it': 1 + })); + }, skip: false); + + test('with quotations', () { + final result = + wordCount.countWords('Joe can\'t tell between \'large\' and large.'); + expect( + result, + equals({ + 'joe': 1, + 'can\'t': 1, + 'tell': 1, + 'between': 1, + 'large': 2, + 'and': 1 + })); + }, skip: false); + + test('substrings from the beginning', () { + final result = + wordCount.countWords('Joe can\'t tell between app, apple and a.'); + expect( + result, + equals({ + 'joe': 1, + 'can\'t': 1, + 'tell': 1, + 'between': 1, + 'app': 1, + 'apple': 1, + 'and': 1, + 'a': 1 + })); + }, skip: false); + + test('multiple spaces not detected as a word', () { + final result = wordCount.countWords(' multiple whitespaces'); + expect(result, equals({'multiple': 1, 'whitespaces': 1})); + }, skip: false); + + test('alternating word separators not detected as a word', () { + final result = wordCount.countWords(',\n,one,\n ,two \n \'three\''); + expect(result, equals({'one': 1, 'two': 1, 'three': 1})); + }, skip: false); + + test('quotation for word with apostrophe', () { + final result = wordCount.countWords('can, can\'t, \'can\'t\''); + expect(result, equals({'can': 1, 'can\'t': 2})); + }, skip: false); + }); +}