Skip to content

Commit c35a034

Browse files
authored
Add bottle-song (#359)
* Add IDE files to .gitignore * Add `bottle-song`
1 parent 8af434e commit c35a034

File tree

10 files changed

+363
-29
lines changed

10 files changed

+363
-29
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ bld/
4444
# Visual Studio 2015/2017 cache/options directory
4545
.vs/
4646

47+
# IDE files
48+
.vscode/
49+
.idea/
50+
4751
# Visual Studio 2017 auto generated files
4852
Generated\ Files/
4953

Diff for: config.json

+35-29
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88
"representer": false,
99
"analyzer": false
1010
},
11-
"test_runner": {
12-
"average_run_time": 7
13-
},
1411
"blurb": "Visual Basic is an object-oriented programming language implemented on the .NET Framework.",
1512
"version": 3,
1613
"online_editor": {
1714
"indent_style": "space",
1815
"indent_size": 2,
1916
"highlightjs_language": "vbnet"
2017
},
21-
"checklist_issue": 3,
18+
"test_runner": {
19+
"average_run_time": 7
20+
},
2221
"files": {
2322
"solution": [
2423
"%{pascal_slug}.vb"
@@ -37,7 +36,6 @@
3736
]
3837
},
3938
"exercises": {
40-
"concept": [],
4139
"practice": [
4240
{
4341
"slug": "hello-world",
@@ -1037,6 +1035,15 @@
10371035
"slug": "beer-song",
10381036
"name": "Beer Song",
10391037
"uuid": "2523e11e-3a9e-4936-9cbb-37f53a6d90cb",
1038+
"practices": [],
1039+
"prerequisites": [],
1040+
"difficulty": 3,
1041+
"status": "deprecated"
1042+
},
1043+
{
1044+
"slug": "bottle-song",
1045+
"name": "Bottle Song",
1046+
"uuid": "7495b54e-0c0c-4e1f-af6a-f367402483b2",
10401047
"practices": [
10411048
"switch-statements",
10421049
"string-formatting"
@@ -1528,14 +1535,14 @@
15281535
"uuid": "2273d375-590c-44fb-bdcb-e67dcf64dfeb",
15291536
"practices": [
15301537
"for-loops",
1531-
"foreach-loops"
1538+
"foreach-loops"
15321539
],
15331540
"prerequisites": [
15341541
"strings",
15351542
"numbers",
15361543
"exceptions"
15371544
],
1538-
"difficulty": 4
1545+
"difficulty": 4
15391546
},
15401547
{
15411548
"slug": "zipper",
@@ -1609,55 +1616,54 @@
16091616
}
16101617
]
16111618
},
1612-
"concepts": [],
16131619
"key_features": [
16141620
{
1615-
"icon": "powerful",
16161621
"title": "Modern",
1617-
"content": "Visual Basic is a modern, powerful language."
1622+
"content": "Visual Basic is a modern, powerful language.",
1623+
"icon": "powerful"
16181624
},
16191625
{
1620-
"icon": "cross-platform",
16211626
"title": "Cross-platform",
1622-
"content": "Visual Basic runs on almost any platform and chipset."
1627+
"content": "Visual Basic runs on almost any platform and chipset.",
1628+
"icon": "cross-platform"
16231629
},
16241630
{
1625-
"icon": "multi-paradigm",
16261631
"title": "Multi-paradigm",
1627-
"content": "Visual Basic is primarily an object-oriented language, but also has lots of functional features."
1632+
"content": "Visual Basic is primarily an object-oriented language, but also has lots of functional features.",
1633+
"icon": "multi-paradigm"
16281634
},
16291635
{
1630-
"icon": "general-purpose",
16311636
"title": "General purpose",
1632-
"content": "Visual Basic is used for a wide variety of workloads, like websites, gui and console applications."
1637+
"content": "Visual Basic is used for a wide variety of workloads, like websites, gui and console applications.",
1638+
"icon": "general-purpose"
16331639
},
16341640
{
1635-
"icon": "tooling",
16361641
"title": "Tooling",
1637-
"content": "Visual Basic has excellent tooling, with linting and advanced refactoring options built-in."
1642+
"content": "Visual Basic has excellent tooling, with linting and advanced refactoring options built-in.",
1643+
"icon": "tooling"
16381644
},
16391645
{
1640-
"icon": "documentation",
16411646
"title": "Documentation",
1642-
"content": "Documentation is excellent and exhaustive, making it easy to get started with Visual Basic."
1647+
"content": "Documentation is excellent and exhaustive, making it easy to get started with Visual Basic.",
1648+
"icon": "documentation"
16431649
}
16441650
],
16451651
"tags": [
1652+
"execution_mode/compiled",
16461653
"paradigm/functional",
16471654
"paradigm/imperative",
16481655
"paradigm/object_oriented",
1649-
"typing/static",
1650-
"typing/strong",
1651-
"typing/dynamic",
1652-
"typing/weak",
1653-
"execution_mode/compiled",
1654-
"platform/windows",
1655-
"platform/mac",
1656-
"platform/linux",
1657-
"platform/ios",
16581656
"platform/android",
1657+
"platform/ios",
1658+
"platform/linux",
1659+
"platform/mac",
16591660
"platform/web",
1661+
"platform/windows",
16601662
"runtime/clr",
1663+
"typing/dynamic",
1664+
"typing/static",
1665+
"typing/strong",
1666+
"typing/weak",
16611667
"used_for/backends",
16621668
"used_for/cross_platform_development",
16631669
"used_for/frontends",

Diff for: exercises/Exercises.sln

+7
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TwoBucket", "practice\two-b
207207
EndProject
208208
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Tournament", "practice\tournament\Tournament.vbproj", "{7E2F5148-8DD5-4A9F-AA88-AB3FA83E7B5E}"
209209
EndProject
210+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BottleSong", "practice\bottle-song\BottleSong.vbproj", "{0624D9E6-2BC8-4B99-8836-762D2B426C28}"
211+
EndProject
210212
Global
211213
GlobalSection(SolutionConfigurationPlatforms) = preSolution
212214
Debug|Any CPU = Debug|Any CPU
@@ -620,6 +622,10 @@ Global
620622
{7E2F5148-8DD5-4A9F-AA88-AB3FA83E7B5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
621623
{7E2F5148-8DD5-4A9F-AA88-AB3FA83E7B5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
622624
{7E2F5148-8DD5-4A9F-AA88-AB3FA83E7B5E}.Release|Any CPU.Build.0 = Release|Any CPU
625+
{0624D9E6-2BC8-4B99-8836-762D2B426C28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
626+
{0624D9E6-2BC8-4B99-8836-762D2B426C28}.Debug|Any CPU.Build.0 = Debug|Any CPU
627+
{0624D9E6-2BC8-4B99-8836-762D2B426C28}.Release|Any CPU.ActiveCfg = Release|Any CPU
628+
{0624D9E6-2BC8-4B99-8836-762D2B426C28}.Release|Any CPU.Build.0 = Release|Any CPU
623629
EndGlobalSection
624630
GlobalSection(NestedProjects) = preSolution
625631
{ED3FEEC3-83E9-4C7F-BD51-0ABA9BCC102A} = {B161412A-37BB-42B7-9D8F-F4B238E3CFFA}
@@ -723,5 +729,6 @@ Global
723729
{96476D25-FEAC-44A8-BA8D-D2C80DC2B680} = {B161412A-37BB-42B7-9D8F-F4B238E3CFFA}
724730
{8C192C5E-8B2D-44ED-82B0-7ECF1D03DBB0} = {B161412A-37BB-42B7-9D8F-F4B238E3CFFA}
725731
{7E2F5148-8DD5-4A9F-AA88-AB3FA83E7B5E} = {B161412A-37BB-42B7-9D8F-F4B238E3CFFA}
732+
{0624D9E6-2BC8-4B99-8836-762D2B426C28} = {B161412A-37BB-42B7-9D8F-F4B238E3CFFA}
726733
EndGlobalSection
727734
EndGlobal

Diff for: exercises/practice/bottle-song/.docs/instructions.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Instructions
2+
3+
Recite the lyrics to that popular children's repetitive song: Ten Green Bottles.
4+
5+
Note that not all verses are identical.
6+
7+
```text
8+
Ten green bottles hanging on the wall,
9+
Ten green bottles hanging on the wall,
10+
And if one green bottle should accidentally fall,
11+
There'll be nine green bottles hanging on the wall.
12+
13+
Nine green bottles hanging on the wall,
14+
Nine green bottles hanging on the wall,
15+
And if one green bottle should accidentally fall,
16+
There'll be eight green bottles hanging on the wall.
17+
18+
Eight green bottles hanging on the wall,
19+
Eight green bottles hanging on the wall,
20+
And if one green bottle should accidentally fall,
21+
There'll be seven green bottles hanging on the wall.
22+
23+
Seven green bottles hanging on the wall,
24+
Seven green bottles hanging on the wall,
25+
And if one green bottle should accidentally fall,
26+
There'll be six green bottles hanging on the wall.
27+
28+
Six green bottles hanging on the wall,
29+
Six green bottles hanging on the wall,
30+
And if one green bottle should accidentally fall,
31+
There'll be five green bottles hanging on the wall.
32+
33+
Five green bottles hanging on the wall,
34+
Five green bottles hanging on the wall,
35+
And if one green bottle should accidentally fall,
36+
There'll be four green bottles hanging on the wall.
37+
38+
Four green bottles hanging on the wall,
39+
Four green bottles hanging on the wall,
40+
And if one green bottle should accidentally fall,
41+
There'll be three green bottles hanging on the wall.
42+
43+
Three green bottles hanging on the wall,
44+
Three green bottles hanging on the wall,
45+
And if one green bottle should accidentally fall,
46+
There'll be two green bottles hanging on the wall.
47+
48+
Two green bottles hanging on the wall,
49+
Two green bottles hanging on the wall,
50+
And if one green bottle should accidentally fall,
51+
There'll be one green bottle hanging on the wall.
52+
53+
One green bottle hanging on the wall,
54+
One green bottle hanging on the wall,
55+
And if one green bottle should accidentally fall,
56+
There'll be no green bottles hanging on the wall.
57+
```

Diff for: exercises/practice/bottle-song/.meta/Example.vb

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Imports System
2+
Imports System.Collections.Generic
3+
Imports System.Linq
4+
5+
Public Module BottleSong
6+
Public Function Recite(ByVal startBottles As Integer, ByVal takeDown As Integer) As String
7+
Return String.Join(Environment.NewLine & Environment.NewLine, _
8+
Enumerable.Range(startBottles - takeDown + 1, takeDown) _
9+
.Reverse() _
10+
.Select(Function(n) String.Join(Environment.NewLine, Verse(n))))
11+
End Function
12+
13+
Private Function Verse(ByVal number As Integer) As List(Of String)
14+
Dim bottles As String = If(number = 1, "bottle", "bottles")
15+
Dim nextBottles As String = If((number - 1) = 1, "bottle", "bottles")
16+
Dim currCount As String = DecimalToOrdinal(number)
17+
Dim nextCount As String = DecimalToOrdinal(number - 1)
18+
Return New List(Of String) From {
19+
$"{currCount} green {bottles} hanging on the wall,",
20+
$"{currCount} green {bottles} hanging on the wall,",
21+
"And if one green bottle should accidentally fall,",
22+
$"There'll be {nextCount.ToLowerInvariant()} green {nextBottles} hanging on the wall."
23+
}
24+
End Function
25+
26+
Private Function DecimalToOrdinal(ByVal number As Integer) As String
27+
Select Case number
28+
Case 0
29+
Return "No"
30+
Case 1
31+
Return "One"
32+
Case 2
33+
Return "Two"
34+
Case 3
35+
Return "Three"
36+
Case 4
37+
Return "Four"
38+
Case 5
39+
Return "Five"
40+
Case 6
41+
Return "Six"
42+
Case 7
43+
Return "Seven"
44+
Case 8
45+
Return "Eight"
46+
Case 9
47+
Return "Nine"
48+
Case 10
49+
Return "Ten"
50+
Case Else
51+
Throw New NotImplementedException()
52+
End Select
53+
End Function
54+
End Module

Diff for: exercises/practice/bottle-song/.meta/config.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"authors": [
3+
"BNAndras"
4+
],
5+
"files": {
6+
"solution": [
7+
"BottleSong.vb"
8+
],
9+
"test": [
10+
"BottleSongTests.vb"
11+
],
12+
"example": [
13+
".meta/Example.vb"
14+
]
15+
},
16+
"blurb": "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles.",
17+
"source": "Wikipedia",
18+
"source_url": "https://en.wikipedia.org/wiki/Ten_Green_Bottles"
19+
}

Diff for: exercises/practice/bottle-song/.meta/tests.toml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[d4ccf8fc-01dc-48c0-a201-4fbeb30f2d03]
13+
description = "verse -> single verse -> first generic verse"
14+
15+
[0f0aded3-472a-4c64-b842-18d4f1f5f030]
16+
description = "verse -> single verse -> last generic verse"
17+
18+
[f61f3c97-131f-459e-b40a-7428f3ed99d9]
19+
description = "verse -> single verse -> verse with 2 bottles"
20+
21+
[05eadba9-5dbd-401e-a7e8-d17cc9baa8e0]
22+
description = "verse -> single verse -> verse with 1 bottle"
23+
24+
[a4a28170-83d6-4dc1-bd8b-319b6abb6a80]
25+
description = "lyrics -> multiple verses -> first two verses"
26+
27+
[3185d438-c5ac-4ce6-bcd3-02c9ff1ed8db]
28+
description = "lyrics -> multiple verses -> last three verses"
29+
30+
[28c1584a-0e51-4b65-9ae2-fbc0bf4bbb28]
31+
description = "lyrics -> multiple verses -> all verses"

Diff for: exercises/practice/bottle-song/BottleSong.vb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Imports System
2+
3+
Public Module BottleSong
4+
Public Function Recite(ByVal startBottles As Integer, ByVal takeDown As Integer) As String
5+
Throw New NotImplementedException("You need to implement this function.")
6+
End Function
7+
End Module

Diff for: exercises/practice/bottle-song/BottleSong.vbproj

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
9+
<PackageReference Include="xunit" Version="2.4.2" />
10+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
13+
</PackageReference>
14+
</ItemGroup>
15+
16+
</Project>

0 commit comments

Comments
 (0)