Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

largest-series-product: Do not test digits/slices #145

Merged
merged 1 commit into from
Mar 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions exercises/largest-series-product/example.exs
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@ defmodule Series do
Splits up the given string of numbers into an array of integers.
"""
@spec digits(String.t) :: [non_neg_integer]
def digits("") do
defp digits("") do
[]
end

def digits(number_string) do
defp digits(number_string) do
String.split(number_string, "", trim: true)
|> Enum.reduce([], fn(char, acc) -> [String.to_integer(char)|acc] end)
|> Enum.reverse
@@ -18,7 +18,7 @@ defmodule Series do
Generates sublists of a given size from a given string of numbers.
"""
@spec slices(String.t, non_neg_integer) :: [list(non_neg_integer)]
def slices(number_string, size) do
defp slices(number_string, size) do
digits = digits(number_string)
chunk(digits, size, 1)
end
16 changes: 0 additions & 16 deletions exercises/largest-series-product/largest_series_product.exs
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
defmodule Series do

@doc """
Splits up the given string of numbers into an array of integers.
"""
@spec digits(String.t) :: [non_neg_integer]
def digits(number_string) do

end

@doc """
Generates sublists of a given size from a given string of numbers.
"""
@spec slices(String.t, non_neg_integer) :: [list(non_neg_integer)]
def slices(number_string, size) do

end

@doc """
Finds the largest product of a given number of consecutive numbers in a given string of numbers.
"""
45 changes: 0 additions & 45 deletions exercises/largest-series-product/largest_series_product_test.exs
Original file line number Diff line number Diff line change
@@ -8,51 +8,6 @@ ExUnit.configure exclude: :pending, trace: true
defmodule LargestSeriesProductTest do
use ExUnit.Case

# @tag :pending
test "digits" do
assert Series.digits("0123456789") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
end

@tag :pending
test "same digits reversed" do
assert Series.digits("9876543210") == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
end

@tag :pending
test "fewer digits" do
assert Series.digits("87654") == [8, 7, 6, 5, 4]
end

@tag :pending
test "some other digits" do
assert Series.digits("936923468") == [9, 3, 6, 9, 2, 3, 4, 6, 8]
end

@tag :pending
test "slices of zero" do
assert Series.digits("") == []
end

@tag :pending
test "slices of two" do
assert Series.slices("01234", 2) == [[0, 1], [1, 2], [2, 3], [3, 4]]
end

@tag :pending
test "other slices of two" do
assert Series.slices("98273463", 2) == [[9, 8], [8, 2], [2, 7], [7, 3], [3, 4], [4, 6], [6, 3]]
end

@tag :pending
test "slices of three" do
assert Series.slices("01234", 3) == [[0, 1, 2], [1, 2, 3], [2, 3, 4]]
end

@tag :pending
test "other slices of three" do
assert Series.slices("982347", 3) == [[9, 8, 2], [8, 2, 3], [2, 3, 4], [3, 4, 7]]
end

@tag :pending
test "largest product of 2" do
assert Series.largest_product("0123456789", 2) == 72