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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aoc_utils.rb +7 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4670d22399c334352f749fb796e8c716c744f61f9f2e72bf5b29f42c8bfe5085
4
- data.tar.gz: 3aae281d8b3dc3f79d9ddf7a5aec236ddeb4e32b5c4dce69d703b8ed0ff1d489
3
+ metadata.gz: bf1755d4a9c53efe1b50f38047add2e446268b87e2e4233861fd44af9fcd9137
4
+ data.tar.gz: da702aaf7e05bccc4cdba5f3da55594e09ba6c404a4a8c28ec71ed02026a7dff
5
5
  SHA512:
6
- metadata.gz: 3ebf25e5a9fd9456e7e6a31d7c97a1b956fecf654252639cf8ce266fe01c4d1d58ef81740145a03f387779e97802069f26ee42ea0a435af22b419bbe1f815883
7
- data.tar.gz: 852c5342561f289945ec55039ed0ea236fab3797e9cb3f6223f0cdb9fa82cca8d17cdd5feece379efbdd7acce0d8fc25450b7a0eba894f88ffa76a32b882f1bc
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 = part1.map(&:strip.chars)
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.3
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-17 00:00:00.000000000 Z
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