forked from exercism/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblems.json
More file actions
41 lines (41 loc) · 6.74 KB
/
problems.json
File metadata and controls
41 lines (41 loc) · 6.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
"problems": [
{
"files": {
"README.md": "# Gigasecond\n\nWrite a program that will calculate the date that someone turned or will celebrate their 1 Gs anniversary.\n\nA gigasecond is one billion (10**9) seconds.\n\n\n## Source\n\nChapter 9 in Chris Pine's online Learn to Program tutorial. [view source](http://pine.fm/LearnToProgram/?Chapter=09)\n",
"cases_test.go": "package gigasecond\n\n// Source: exercism/x-common\n// Commit: f362340 Merge pull request #36 from soniakeys/gigasecond-test-data\n\n// Add one gigasecond to the input.\nvar addCases = []struct {\n\tin string\n\twant string\n}{\n\t{\n\t\t\"2011-04-25\",\n\t\t\"2043-01-01T01:46:40\",\n\t},\n\t{\n\t\t\"1977-06-13\",\n\t\t\"2009-02-19T01:46:40\",\n\t},\n\t{\n\t\t\"1959-07-19\",\n\t\t\"1991-03-27T01:46:40\",\n\t},\n}\n",
"gigasecond_test.go": "package gigasecond\n\n// Write a function AddGigasecond that works with time.Time.\n// Also define a variable Birthday set to your (or someone else's) birthday.\n// Run go test -v to see your gigasecond anniversary.\n\nimport (\n\t\"os\"\n\t\"testing\"\n\t\"time\"\n)\n\nconst testVersion = 1\n\n// Retired testVersions\n// (none) 98807b314216ff27492378a00df60410cc971d32\n\n// date formats used in test data\nconst (\n\tfmtD = \"2006-01-02\"\n\tfmtDT = \"2006-01-02T15:04:05\"\n)\n\nfunc TestAddGigasecond(t *testing.T) {\n\tif TestVersion != testVersion {\n\t\tt.Fatalf(\"Found TestVersion = %v, want %v.\", TestVersion, testVersion)\n\t}\n\tfor _, tc := range addCases {\n\t\tin := parse(tc.in, fmtD, t)\n\t\twant := parse(tc.want, fmtDT, t)\n\t\tgot := AddGigasecond(in)\n\t\tif !got.Equal(want) {\n\t\t\tt.Fatalf(`AddGigasecond(%s)\n = %s\nwant %s`, in, got, want)\n\t\t}\n\t}\n\tt.Log(\"Tested\", len(addCases), \"cases.\")\n}\n\nfunc TestYourAnniversary(t *testing.T) {\n\tt.Logf(`\nYour birthday: %s\nYour gigasecond anniversary: %s`, Birthday, AddGigasecond(Birthday))\n}\n\nfunc parse(s string, f string, t *testing.T) time.Time {\n\ttt, err := time.Parse(f, s)\n\tif err != nil {\n\t\t// can't run tests if input won't parse. if this seems to be a\n\t\t// development or ci environment, raise an error. if this condition\n\t\t// makes it to the solver though, ask for a bug report.\n\t\t_, statErr := os.Stat(\"example_gen.go\")\n\t\tif statErr == nil || os.Getenv(\"TRAVIS_GO_VERSION\") > \"\" {\n\t\t\tt.Fatal(err)\n\t\t} else {\n\t\t\tt.Log(err)\n\t\t\tt.Skip(\"(Not your problem. \" +\n\t\t\t\t\"please file issue at https://github.com/exercism/xgo.)\")\n\t\t}\n\t}\n\treturn tt\n}\n\nfunc BenchmarkAddGigasecond(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tAddGigasecond(time.Time{})\n\t}\n}\n"
},
"fresh": false,
"id": "go/gigasecond",
"language": "go",
"name": "Gigasecond",
"slug": "gigasecond",
"track_id": "go"
},
{
"files": {
"README.md": "# Leap\n\nWrite a program that will take a year and report if it is a leap year.\n\nThe tricky thing here is that a leap year occurs:\n\n```plain\non every year that is evenly divisible by 4\n except every year that is evenly divisible by 100\n unless the year is also evenly divisible by 400\n```\n\nFor example, 1997 is not a leap year, but 1996 is. 1900 is not a leap\nyear, but 2000 is.\n\nIf your language provides a method in the standard library that does\nthis look-up, pretend it doesn't exist and implement it yourself.\n\n## Notes\n\nFor a delightful, four minute explanation of the whole leap year\nphenomenon, go watch [this youtube video][video].\n\n[video]: http://www.youtube.com/watch?v=xX96xng7sAE\n\n\n## Source\n\nJavaRanch Cattle Drive, exercise 3 [view source](http://www.javaranch.com/leap.jsp)\n",
"leap_test.go": "package leap\n\nimport (\n\t\"testing\"\n)\n\nvar testCases = []struct {\n\tyear int\n\texpected bool\n\tdescription string\n}{\n\t{1996, true, \"vanilla leap year\"},\n\t{1997, false, \"normal year\"},\n\t{1900, false, \"century\"},\n\t{2400, true, \"exceptional century\"},\n}\n\nfunc TestLeapYears(t *testing.T) {\n\tfor _, test := range testCases {\n\t\tobserved := IsLeapYear(test.year)\n\t\tif observed != test.expected {\n\t\t\tt.Fatalf(\"IsLeapYear(%d) = %t, want %t (%s)\",\n\t\t\t\ttest.year, observed, test.expected, test.description)\n\t\t}\n\t}\n}\n\nfunc BenchmarkLeapYears(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tfor _, test := range testCases {\n\t\t\tIsLeapYear(test.year)\n\t\t}\n\t}\n}\n"
},
"fresh": false,
"id": "go/leap",
"language": "go",
"name": "Leap",
"slug": "leap",
"track_id": "go"
},
{
"files": {
"README.md": "# Raindrops\n\nWrite a program that converts a number to a string, the contents of which depends on the number's prime factors.\n\n- If the number contains 3 as a prime factor, output 'Pling'.\n- If the number contains 5 as a prime factor, output 'Plang'.\n- If the number contains 7 as a prime factor, output 'Plong'.\n- If the number does not contain 3, 5, or 7 as a prime factor,\n just pass the number's digits straight through.\n\n## Examples\n\n- 28's prime-factorization is 2, 2, 7.\n - In raindrop-speak, this would be a simple \"Plong\".\n- 1755 prime-factorization is 3, 3, 3, 5, 13.\n - In raindrop-speak, this would be a \"PlingPlang\".\n- The prime factors of 34 are 2 and 17.\n - Raindrop-speak doesn't know what to make of that,\n so it just goes with the straightforward \"34\".\n\n\n## Source\n\nA variation on a famous interview question intended to weed out potential candidates. [view source](http://jumpstartlab.com)\n",
"raindrops_test.go": "package raindrops\n\nimport \"testing\"\n\nvar tests = []struct {\n\tinput int\n\texpected string\n}{\n\t{1, \"1\"},\n\t{3, \"Pling\"},\n\t{5, \"Plang\"},\n\t{7, \"Plong\"},\n\t{6, \"Pling\"},\n\t{9, \"Pling\"},\n\t{10, \"Plang\"},\n\t{14, \"Plong\"},\n\t{15, \"PlingPlang\"},\n\t{21, \"PlingPlong\"},\n\t{25, \"Plang\"},\n\t{35, \"PlangPlong\"},\n\t{49, \"Plong\"},\n\t{52, \"52\"},\n\t{105, \"PlingPlangPlong\"},\n\t{12121, \"12121\"},\n}\n\nfunc TestConvert(t *testing.T) {\n\tfor _, test := range tests {\n\t\tif actual := Convert(test.input); actual != test.expected {\n\t\t\tt.Errorf(\"Convert(%d) = %q, expected %q.\",\n\t\t\t\ttest.input, actual, test.expected)\n\t\t}\n\t}\n}\n\nfunc BenchmarkConvert(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tfor _, test := range tests {\n\t\t\tConvert(test.input)\n\t\t}\n\t}\n}\n"
},
"fresh": false,
"id": "go/raindrops",
"language": "go",
"name": "Raindrops",
"slug": "raindrops",
"track_id": "go"
}
]
}