Skip to content

Instantly share code, notes, and snippets.

@danbarua
Last active March 16, 2016 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbarua/bea5e380579b1e2200ef to your computer and use it in GitHub Desktop.
Save danbarua/bea5e380579b1e2200ef to your computer and use it in GitHub Desktop.
Digits to Speech Kata
# Given a Directory with the following files
# Implement Digits.ToFileString(input) where input is a positive integer
# Such that it outputs a "!" delimited list of file names to play
# in order to read out the number
0.wav
1.wav
10.wav
11.wav
12.wav
13.wav
14.wav
15.wav
16.wav
17.wav
18.wav
19.wav
2.wav
20.wav
3.wav
30.wav
4.wav
40.wav
5.wav
50.wav
6.wav
60.wav
7.wav
70.wav
8.wav
80.wav
9.wav
90.wav
hundred.wav
million.wav
thousand.wav
using System;
using FluentAssertions;
using Xunit;
using Xunit.Extensions;
[Theory]
[InlineData(0, "0")]
[InlineData(1, "1")]
[InlineData(2, "2")]
[InlineData(10, "10")]
[InlineData(11, "11")] //special case: 'eleven', 'twelve' etc
[InlineData(12, "12")]
[InlineData(20, "20")]
[InlineData(23, "20!3")]
[InlineData(36, "30!6")]
[InlineData(100, "1!hundred")]
[InlineData(110, "1!hundred!10")]
[InlineData(116, "1!hundred!16")]
[InlineData(123, "1!hundred!20!3")]
[InlineData(199, "1!hundred!90!9")]
[InlineData(1000, "1!thousand")]
[InlineData(1005, "1!thousand!5")]
[InlineData(1010, "1!thousand!10")]
[InlineData(1016, "1!thousand!16")]
[InlineData(1023, "1!thousand!20!3")]
[InlineData(1099, "1!thousand!90!9")]
[InlineData(1200, "1!thousand!2!hundred")]
[InlineData(1305, "1!thousand!3!hundred!5")]
[InlineData(1310, "1!thousand!3!hundred!10")]
[InlineData(2316, "2!thousand!3!hundred!16")]
[InlineData(2323, "2!thousand!3!hundred!20!3")]
[InlineData(2399, "2!thousand!3!hundred!90!9")]
[InlineData(20009, "20!thousand!9")]
[InlineData(21239, "20!1!thousand!2!hundred!30!9")]
[InlineData(123456, "1!hundred!20!3!thousand!4!hundred!50!6")]
[InlineData(999999, "9!hundred!90!9!thousand!9!hundred!90!9")]
[InlineData(2123456, "2!million!1!hundred!20!3!thousand!4!hundred!50!6")]
[InlineData(9999999, "9!million!9!hundred!90!9!thousand!9!hundred!90!9")]
[InlineData(1000023, "1!million!20!3")]
[InlineData(123000000, "1!hundred!20!3!million")]
public void convert_digits_to_file_strings(int input, string expectedOutput)
{
var output = Digits.ToFileString(input);
output.Should().Be(expectedOutput);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment