{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": ["# Scrabble Score\n", "\n", "Given a word, compute the Scrabble score for that word.\n", "\n", "## Letter Values\n", "\n", "You'll need these:\n", "\n", "```text\n", "Letter Value\n", "A, E, I, O, U, L, N, R, S, T 1\n", "D, G 2\n", "B, C, M, P 3\n", "F, H, V, W, Y 4\n", "K 5\n", "J, X 8\n", "Q, Z 10\n", "```\n", "\n", "## Examples\n", "\n", "\"cabbage\" should be scored as worth 14 points:\n", "\n", "- 3 points for C\n", "- 1 point for A, twice\n", "- 3 points for B, twice\n", "- 2 points for G\n", "- 1 point for E\n", "\n", "And to total:\n", "\n", "- `3 + 2*1 + 2*3 + 2 + 1`\n", "- = `3 + 2 + 6 + 3`\n", "- = `5 + 9`\n", "- = 14\n", "\n", "## Extensions\n", "\n", "- You can play a double or a triple letter.\n", "- You can play a double or a triple word.\n", "\n", "## Source\n", "\n", "Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup)\n", "\n", "## Version compatibility\n", "This exercise has been tested on Julia versions >=1.0.\n", "\n", "## Submitting Incomplete Solutions\n", "It's possible to submit an incomplete solution so you can see how others have completed the exercise."] }, { "cell_type": "markdown", "metadata": {}, "source": ["## Your solution"] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["# submit\n", "function score(str)\n", "\n", "end"] }, { "cell_type": "markdown", "metadata": {}, "source": ["## Test suite"] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["using Test\n", "\n", "# include(\"scrabble-score.jl\")\n", "\n", "@testset \"lowercase letter\" begin\n", " @test score(\"a\") == 1\n", "end\n", "\n", "@testset \"uppercase letter\" begin\n", " @test score(\"A\") == 1\n", "end\n", "\n", "@testset \"valuable letter\" begin\n", " @test score(\"f\") == 4\n", "end\n", "\n", "@testset \"short word\" begin\n", " @test score(\"at\") == 2\n", "end\n", "\n", "@testset \"short, valuable word\" begin\n", " @test score(\"zoo\") == 12\n", "end\n", "\n", "@testset \"medium word\" begin\n", " @test score(\"street\") == 6\n", "end\n", "\n", "@testset \"medium, valuable word\" begin\n", " @test score(\"quirky\") == 22\n", "end\n", "\n", "@testset \"long, mixed-case word\" begin\n", " @test score(\"OxyphenButazone\") == 41\n", "end\n", "\n", "@testset \"english-like word\" begin\n", " @test score(\"pinata\") == 8\n", "end\n", "\n", "@testset \"non-english letter is not scored\" begin\n", " @test score(\"piƱata\") == 7\n", "end\n", "\n", "@testset \"empty input\" begin\n", " @test score(\"\") == 0\n", "end\n", "\n", "@testset \"entire alphabet available\" begin\n", " @test score(\"abcdefghijklmnopqrstuvwxyz\") == 87\n", "end"] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Prepare submission\n", "To submit your exercise, you need to save your solution in a file called `scrabble-score.jl` before using the CLI.\n", "You can either create it manually or use the following functions, which will automatically write every notebook cell that starts with `# submit` to the file `scrabble-score.jl`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# using Pkg; Pkg.add(\"Exercism\")\n", "# using Exercism\n", "# Exercism.create_submission(\"scrabble-score\")" ] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.3.0", "language": "julia", "name": "julia-1.3" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.3.0" } }, "nbformat": 4, "nbformat_minor": 2 }