aoc_utils 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aoc_utils.rb +7 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf1755d4a9c53efe1b50f38047add2e446268b87e2e4233861fd44af9fcd9137
|
4
|
+
data.tar.gz: da702aaf7e05bccc4cdba5f3da55594e09ba6c404a4a8c28ec71ed02026a7dff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f91aa0cb65a4d5c846432703ee26dd59c5088707f16276754cadf8e4a3279cf035311cc3fc29ce95b478c3f5d586ea5b333367aed779812c26c569053f01b70
|
7
|
+
data.tar.gz: 11b070763fc4f304cb1c308e39fbc95e3caab046b44c2b8b8e0f114c0167d4f3e428fbcbe84395f555d7556ce10c8bd45df49ee0ac25e8a2a06f6e3ad71638d6
|
data/lib/aoc_utils.rb
CHANGED
@@ -15,11 +15,11 @@ module AocUtils
|
|
15
15
|
|
16
16
|
# extracts all strings from the specified file
|
17
17
|
# @param filename [String] the name of the file to read from
|
18
|
-
# @return [Array<String>] an array of all the lines read from the file as strings with no leading or trailing whitespace
|
18
|
+
# @return [Array<String>] an array of all the lines read from the file as an array of strings with no leading or trailing whitespace split by commas in the original file
|
19
19
|
def self.read_strings(filename)
|
20
20
|
strings = []
|
21
21
|
File.open(filename).each_line do |line|
|
22
|
-
strings << line.strip
|
22
|
+
strings << line.strip.split(",").map(&:strip)
|
23
23
|
end
|
24
24
|
strings
|
25
25
|
end
|
@@ -49,9 +49,10 @@ module AocUtils
|
|
49
49
|
when "Integer"
|
50
50
|
part1 = part1.map { |line| line.scan(/-?\d+/).map(&:to_i) }
|
51
51
|
when "String"
|
52
|
-
part1 = part1.map(&:strip)
|
52
|
+
part1 = part1.map { |string| string.split(",").map(&:strip) }
|
53
53
|
when "Char"
|
54
|
-
part1
|
54
|
+
part1.strip!
|
55
|
+
part1 = part1.map(&:chars)
|
55
56
|
else
|
56
57
|
raise "Invalid datatype"
|
57
58
|
end
|
@@ -59,8 +60,9 @@ module AocUtils
|
|
59
60
|
when "Integer"
|
60
61
|
part2 = part2.map { |line| line.scan(/-?\d+/).map(&:to_i) }
|
61
62
|
when "String"
|
62
|
-
part2 = part2.map(&:strip)
|
63
|
+
part2 = part2.map { |string| string.split(",").map(&:strip) }
|
63
64
|
when "Char"
|
65
|
+
part2.strip!
|
64
66
|
part2 = part2.map(&:chars)
|
65
67
|
end
|
66
68
|
[part1, part2]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aoc_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lennard Clicque
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A collection of utility methods for Advent of Code
|
14
14
|
email: l.clicque@gmail.com
|