回答編集履歴
4
修正
test
CHANGED
@@ -16,15 +16,13 @@
|
|
16
16
|
|
17
17
|
str.each do |element|
|
18
18
|
|
19
|
-
|
19
|
+
if element.empty?
|
20
20
|
|
21
|
-
puts element
|
22
|
-
|
23
|
-
else
|
24
|
-
|
25
|
-
|
21
|
+
element = "<blank>"
|
26
22
|
|
27
23
|
end
|
24
|
+
|
25
|
+
puts element
|
28
26
|
|
29
27
|
end
|
30
28
|
|
3
修正
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
else
|
24
24
|
|
25
|
-
puts "<b
|
25
|
+
puts "<blank>"
|
26
26
|
|
27
27
|
end
|
28
28
|
|
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
Bread
|
38
38
|
|
39
|
-
<b
|
39
|
+
<blank>
|
40
40
|
|
41
41
|
```
|
42
42
|
|
2
修正
test
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
```Ruby
|
2
|
-
|
3
|
-
|
4
2
|
|
5
3
|
input = "<Banana> <Cupcake> ".split("\s")
|
6
4
|
|
@@ -12,7 +10,7 @@
|
|
12
10
|
|
13
11
|
line = "ApplePie<Banana>Bread<Cupcake>Apple<Banana><Cupcake> "
|
14
12
|
|
15
|
-
str = line.scan(/#{a}(\w*)#{b}/)
|
13
|
+
str = line.scan(/#{a}(\w*)#{b}/).flatten
|
16
14
|
|
17
15
|
|
18
16
|
|
@@ -32,4 +30,16 @@
|
|
32
30
|
|
33
31
|
```
|
34
32
|
|
33
|
+
実行結果例
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
Bread
|
38
|
+
|
39
|
+
<brank>
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
|
35
45
|
考えてみました。
|
1
修正
test
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
```Ruby
|
2
|
-
|
3
|
-
#encoding: utf-8
|
4
2
|
|
5
3
|
|
6
4
|
|
7
|
-
input = "<Banana> <Cupcake>".split("\s")
|
5
|
+
input = "<Banana> <Cupcake> ".split("\s")
|
6
|
+
|
7
|
+
a = input[0]
|
8
|
+
|
9
|
+
b = input[1]
|
8
10
|
|
9
11
|
|
10
12
|
|
11
|
-
|
13
|
+
line = "ApplePie<Banana>Bread<Cupcake>Apple<Banana><Cupcake> "
|
14
|
+
|
15
|
+
str = line.scan(/#{a}(\w*)#{b}/)
|
12
16
|
|
13
17
|
|
14
18
|
|
15
|
-
data = str.scan(%r|#{input[0]}(\w*)#{input[1]}|).flatten
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
str.each do |element|
|
20
20
|
|
21
21
|
unless element.length.zero?
|
22
22
|
|