-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"authors": [ | ||
"BNAndras" | ||
], | ||
"files": { | ||
"solution": [ | ||
"src/high-scores.lfe" | ||
], | ||
"test": [ | ||
"test/high-scores-tests.lfe" | ||
], | ||
"example": [ | ||
".meta/example.lfe" | ||
] | ||
}, | ||
"blurb": "Manage a player's High Score list.", | ||
"source": "Tribute to the eighties' arcade game Frogger" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(defmodule high-scores | ||
(export (latest 1) | ||
(personal-best 1) | ||
(personal-top-three 1))) | ||
|
||
(defun latest (scores) | ||
(car (lists:reverse scores))) | ||
|
||
(defun personal-best (scores) | ||
(lists:max scores)) | ||
|
||
(defun personal-top-three (scores) | ||
(lists:sublist (lists:sort (lambda (a b) (> a b)) scores) 3)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This is an auto-generated file. | ||
# | ||
# Regenerating this file via `configlet sync` will: | ||
# - Recreate every `description` key/value pair | ||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications | ||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) | ||
# - Preserve any other key/value pair | ||
# | ||
# As user-added comments (using the # character) will be removed when this file | ||
# is regenerated, comments can be added via a `comment` key. | ||
|
||
[1035eb93-2208-4c22-bab8-fef06769a73c] | ||
description = "List of scores" | ||
include = false | ||
|
||
[6aa5dbf5-78fa-4375-b22c-ffaa989732d2] | ||
description = "Latest score" | ||
|
||
[b661a2e1-aebf-4f50-9139-0fb817dd12c6] | ||
description = "Personal best" | ||
|
||
[3d996a97-c81c-4642-9afc-80b80dc14015] | ||
description = "Top 3 scores -> Personal top three from a list of scores" | ||
|
||
[1084ecb5-3eb4-46fe-a816-e40331a4e83a] | ||
description = "Top 3 scores -> Personal top highest to lowest" | ||
|
||
[e6465b6b-5a11-4936-bfe3-35241c4f4f16] | ||
description = "Top 3 scores -> Personal top when there is a tie" | ||
|
||
[f73b02af-c8fd-41c9-91b9-c86eaa86bce2] | ||
description = "Top 3 scores -> Personal top when there are less than 3" | ||
|
||
[16608eae-f60f-4a88-800e-aabce5df2865] | ||
description = "Top 3 scores -> Personal top when there is only one" | ||
|
||
[2df075f9-fec9-4756-8f40-98c52a11504f] | ||
description = "Top 3 scores -> Latest score after personal top scores" | ||
include = false | ||
|
||
[809c4058-7eb1-4206-b01e-79238b9b71bc] | ||
description = "Top 3 scores -> Scores after personal top scores" | ||
include = false | ||
|
||
[ddb0efc0-9a86-4f82-bc30-21ae0bdc6418] | ||
description = "Top 3 scores -> Latest score after personal best" | ||
include = false | ||
|
||
[6a0fd2d1-4cc4-46b9-a5bb-2fb667ca2364] | ||
description = "Top 3 scores -> Scores after personal best" | ||
include = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
ERL := $(shell which erl) | ||
REBAR3 := $(shell which rebar3) | ||
|
||
null := | ||
space := $(null) # | ||
comma := , | ||
|
||
ifeq ($(ERL),) | ||
$(error Can't find Erlang executable 'erl') | ||
else ifeq ($(REBAR3),) | ||
$(error Can't find rebar3) | ||
endif | ||
|
||
compile: ; $(REBAR3) compile | ||
|
||
clean: ; $(REBAR3) clean | ||
|
||
.PHONY: test | ||
test: | ||
$(REBAR3) eunit \ | ||
-m $(subst $(space),$(comma),$(basename $(notdir $(wildcard test/*.lfe)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{plugins, [{rebar3_lfe, "0.4.10"}]}. | ||
|
||
{provider_hooks, [{post, [{compile, {lfe, compile}}]}]}. | ||
|
||
{deps, [{lfe, "2.1.3"}]}. | ||
|
||
{profiles, | ||
[{test, | ||
[{eunit_compile_opts, [{src_dirs, ["src", "test"]}]}, | ||
{deps, | ||
[{ltest, "0.13.8"}]}]}]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{"1.2.0", | ||
[{<<"lfe">>,{pkg,<<"lfe">>,<<"2.1.3">>},0}]}. | ||
[ | ||
{pkg_hash,[ | ||
{<<"lfe">>, <<"6EFCB2BBC1FFC21DC5D1C092F00EFDB397EAC889474AC5C86EDF78A3557CC730">>}]}, | ||
{pkg_hash_ext,[ | ||
{<<"lfe">>, <<"4E4BAD515A169AE418FEB7374EA1C8D741FAEA9D95E266CE343B45BCC377F55B">>}]} | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%% -*- erlang -*- | ||
{application, 'high-scores', | ||
[{description, ""}, | ||
{vsn, "0.0.1"}, | ||
{modules, | ||
['high-scores']}, | ||
{registered, []}, | ||
{applications, | ||
[kernel, stdlib]}, | ||
{included_applications, []}, | ||
{env, []}]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(defmodule high-scores | ||
(export (latest 1) | ||
(personal-best 1) | ||
(personal-top-three 1))) | ||
|
||
; Please implement the exported functions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(defmodule high-scores-tests | ||
(behaviour ltest-unit) | ||
(export all)) | ||
|
||
(include-lib "ltest/include/ltest-macros.lfe") | ||
|
||
(deftest latest-score | ||
(is-equal 30 (high-scores:latest '(100 0 90 30)))) | ||
|
||
(deftest personal-best | ||
(is-equal 100 (high-scores:personal-best '(40 100 70)))) | ||
|
||
(deftest personal-top-three-from-a-list-of-scores | ||
(is-equal '(100 90 70) | ||
(high-scores:personal-top-three '(10 30 90 30 100 20 10 0 30 40 40 70 70)))) | ||
|
||
(deftest personal-top-highest-to-lowest | ||
(is-equal '(30 20 10) (high-scores:personal-top-three '(20 10 30)))) | ||
|
||
(deftest personal-top-when-there-is-a-tie | ||
(is-equal '(40 40 30) (high-scores:personal-top-three '(40 20 40 30)))) | ||
|
||
(deftest personal-top-when-there-are-less-than-three | ||
(is-equal '(70 30) (high-scores:personal-top-three '(30 70)))) | ||
|
||
(deftest personal-top-when-there-is-only-one | ||
(is-equal '(40) (high-scores:personal-top-three '(40)))) | ||
|