Skip to content

Commit d278534

Browse files
authored
Merge branch 'main' into add-new-generator
2 parents 8e3afbe + 1a6a28c commit d278534

17 files changed

+416
-81
lines changed

.github/workflows/exercise-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
ruby-version: [3.2, 3.3]
2020

2121
steps:
22-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
22+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2323

2424
- name: Set up Ruby
25-
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999
25+
uses: ruby/setup-ruby@7d3497fd78c07c0d84ebafa58d8dac60cd1f0763
2626
with:
2727
ruby-version: ${{ matrix.ruby-version }}
2828
bundler-cache: true

.ruby-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.2
1+
3.3.0

Gemfile.lock

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ GEM
1616
rainbow (3.1.1)
1717
rake (13.2.1)
1818
regexp_parser (2.9.0)
19-
rexml (3.3.6)
20-
strscan
19+
rexml (3.3.9)
2120
rubocop (1.50.2)
2221
json (~> 2.3)
2322
parallel (~> 1.10)

config.json

+14
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,20 @@
978978
],
979979
"difficulty": 6
980980
},
981+
{
982+
"slug": "bottle-song",
983+
"name": "Bottle Song",
984+
"uuid": "fb29b743-0f2d-46fe-8a2a-14973259bb2b",
985+
"practices": [
986+
"strings"
987+
],
988+
"prerequisites": [
989+
"strings",
990+
"numbers",
991+
"loops"
992+
],
993+
"difficulty": 3
994+
},
981995
{
982996
"slug": "beer-song",
983997
"name": "Beer Song",
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+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"authors": ["meatball133"],
3+
"files": {
4+
"solution": [
5+
"bottle_song.rb"
6+
],
7+
"test": [
8+
"bottle_song_test.rb"
9+
],
10+
"example": [
11+
".meta/example.rb"
12+
]
13+
},
14+
"blurb": "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles.",
15+
"source": "Wikipedia",
16+
"source_url": "https://en.wikipedia.org/wiki/Ten_Green_Bottles"
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module BottleSong
2+
3+
TRANSLATE = {
4+
0 => "no", 1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five",
5+
6 => "six", 7 => "seven", 8 => "eight", 9 => "nine", 10 => "ten"
6+
}
7+
8+
def self.recite(start, amount)
9+
((start - amount + 1)..(start)).to_a.reverse.map do |current|
10+
<<~TEXT
11+
#{TRANSLATE[current].capitalize} green #{current == 1 ? "bottle" : "bottles"} hanging on the wall,
12+
#{TRANSLATE[current].capitalize} green #{current == 1 ? "bottle" : "bottles"} hanging on the wall,
13+
And if one green bottle should accidentally fall,
14+
There'll be #{TRANSLATE[current - 1]} green #{current - 1 == 1 ? "bottle" : "bottles"} hanging on the wall.
15+
TEXT
16+
end.join("\n")
17+
end
18+
end
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"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=begin
2+
Write your code for the 'BottleSong' exercise in this file. Make the tests in
3+
`bottle_song_test.rb` pass.
4+
5+
To get started with TDD, see the `README.md` file in your
6+
`ruby/bottle-song` directory.
7+
=end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
require 'minitest/autorun'
2+
require_relative 'bottle_song'
3+
4+
class BottleSongTest < Minitest::Test
5+
def test_single_verse
6+
# skip
7+
expected = <<~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+
TEXT
13+
assert_equal expected, BottleSong.recite(10, 1)
14+
end
15+
16+
def test_last_generic_verse
17+
skip
18+
expected = <<~TEXT
19+
Three green bottles hanging on the wall,
20+
Three green bottles hanging on the wall,
21+
And if one green bottle should accidentally fall,
22+
There'll be two green bottles hanging on the wall.
23+
TEXT
24+
assert_equal expected, BottleSong.recite(3, 1)
25+
end
26+
27+
def test_verse_with_2_bottles
28+
skip
29+
expected = <<~TEXT
30+
Two green bottles hanging on the wall,
31+
Two green bottles hanging on the wall,
32+
And if one green bottle should accidentally fall,
33+
There'll be one green bottle hanging on the wall.
34+
TEXT
35+
assert_equal expected, BottleSong.recite(2, 1)
36+
end
37+
38+
def test_verse_with_1_bottle
39+
skip
40+
expected = <<~TEXT
41+
One green bottle hanging on the wall,
42+
One green bottle hanging on the wall,
43+
And if one green bottle should accidentally fall,
44+
There'll be no green bottles hanging on the wall.
45+
TEXT
46+
assert_equal expected, BottleSong.recite(1, 1)
47+
end
48+
49+
def test_first_two_verses
50+
skip
51+
expected = <<~TEXT
52+
Ten green bottles hanging on the wall,
53+
Ten green bottles hanging on the wall,
54+
And if one green bottle should accidentally fall,
55+
There'll be nine green bottles hanging on the wall.
56+
57+
Nine green bottles hanging on the wall,
58+
Nine green bottles hanging on the wall,
59+
And if one green bottle should accidentally fall,
60+
There'll be eight green bottles hanging on the wall.
61+
TEXT
62+
assert_equal expected, BottleSong.recite(10, 2)
63+
end
64+
65+
def test_last_three_verses
66+
skip
67+
expected = <<~TEXT
68+
Three green bottles hanging on the wall,
69+
Three green bottles hanging on the wall,
70+
And if one green bottle should accidentally fall,
71+
There'll be two green bottles hanging on the wall.
72+
73+
Two green bottles hanging on the wall,
74+
Two green bottles hanging on the wall,
75+
And if one green bottle should accidentally fall,
76+
There'll be one green bottle hanging on the wall.
77+
78+
One green bottle hanging on the wall,
79+
One green bottle hanging on the wall,
80+
And if one green bottle should accidentally fall,
81+
There'll be no green bottles hanging on the wall.
82+
TEXT
83+
assert_equal expected, BottleSong.recite(3, 3)
84+
end
85+
86+
def test_all_verses
87+
skip
88+
expected = <<~TEXT
89+
Ten green bottles hanging on the wall,
90+
Ten green bottles hanging on the wall,
91+
And if one green bottle should accidentally fall,
92+
There'll be nine green bottles hanging on the wall.
93+
94+
Nine green bottles hanging on the wall,
95+
Nine green bottles hanging on the wall,
96+
And if one green bottle should accidentally fall,
97+
There'll be eight green bottles hanging on the wall.
98+
99+
Eight green bottles hanging on the wall,
100+
Eight green bottles hanging on the wall,
101+
And if one green bottle should accidentally fall,
102+
There'll be seven green bottles hanging on the wall.
103+
104+
Seven green bottles hanging on the wall,
105+
Seven green bottles hanging on the wall,
106+
And if one green bottle should accidentally fall,
107+
There'll be six green bottles hanging on the wall.
108+
109+
Six green bottles hanging on the wall,
110+
Six green bottles hanging on the wall,
111+
And if one green bottle should accidentally fall,
112+
There'll be five green bottles hanging on the wall.
113+
114+
Five green bottles hanging on the wall,
115+
Five green bottles hanging on the wall,
116+
And if one green bottle should accidentally fall,
117+
There'll be four green bottles hanging on the wall.
118+
119+
Four green bottles hanging on the wall,
120+
Four green bottles hanging on the wall,
121+
And if one green bottle should accidentally fall,
122+
There'll be three green bottles hanging on the wall.
123+
124+
Three green bottles hanging on the wall,
125+
Three green bottles hanging on the wall,
126+
And if one green bottle should accidentally fall,
127+
There'll be two green bottles hanging on the wall.
128+
129+
Two green bottles hanging on the wall,
130+
Two green bottles hanging on the wall,
131+
And if one green bottle should accidentally fall,
132+
There'll be one green bottle hanging on the wall.
133+
134+
One green bottle hanging on the wall,
135+
One green bottle hanging on the wall,
136+
And if one green bottle should accidentally fall,
137+
There'll be no green bottles hanging on the wall.
138+
TEXT
139+
assert_equal expected, BottleSong.recite(10, 10)
140+
end
141+
end

exercises/practice/palindrome-products/.meta/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"Insti",
1313
"kotp",
1414
"markijbema",
15-
"tryantwit"
15+
"tryantwit",
16+
"themetar"
1617
],
1718
"files": {
1819
"solution": [

0 commit comments

Comments
 (0)