aoc_utils 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/aoc_utils.rb +5 -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: 040c3095a812f3c14566d221b44acb53bd2f2f1787c7881ccd9a75061f37730a
|
4
|
+
data.tar.gz: 70f8f5953faed22acf404ddac8fb030024290121e24f46a6983032b511f154b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f965e4c23e79da146e0b711521247de292cfc8b7851e5b802a474c143b3765ae49f40e49e23747c65ccbe48786b09d99a06ec64f4262745a31c0b3c8dca163e2
|
7
|
+
data.tar.gz: 81f93a2d5ceb77c270f644e2d39c2ee4c6a2ddf0f99829abfc4049214ba8b83c1d3f1fd7cd6ebe5b42b7c5e3854db3e03fefc4c7a8379605e4616cc8dba25d1f
|
data/lib/aoc_utils.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Desc: Utility functions for Advent of Code problems
|
2
|
-
|
2
|
+
class AocUtils
|
3
3
|
# extracts all integers from the specified file
|
4
4
|
# @param filename [String] the name of the file to read from
|
5
5
|
# @param other_characters [Array<String>] will save the first non integer character in the line for further usage
|
6
6
|
# @return [Array<Array<Integer>>] an array of all the lines read from the file, with each line being an array of the integers read from that line
|
7
|
-
def read_ints(filename, other_characters = [])
|
7
|
+
def self.read_ints(filename, other_characters = [])
|
8
8
|
ints = []
|
9
9
|
File.open(filename).each_line do |line|
|
10
10
|
ints << line.scan(/-?\d+/).map(&:to_i)
|
@@ -16,7 +16,7 @@ module AocUtils
|
|
16
16
|
# extracts all strings from the specified file
|
17
17
|
# @param filename [String] the name of the file to read from
|
18
18
|
# @return [Array<String>] an array of all the lines read from the file as strings with no leading or trailing whitespace
|
19
|
-
def read_strings(filename)
|
19
|
+
def self.read_strings(filename)
|
20
20
|
strings = []
|
21
21
|
File.open(filename).each_line do |line|
|
22
22
|
strings << line.strip
|
@@ -27,7 +27,7 @@ module AocUtils
|
|
27
27
|
# extracts all characters from the specified file
|
28
28
|
# @param filename [String] the name of the file to read from
|
29
29
|
# @return [Array<Array<String>>] an array of all the lines read from the file, with each line being an array of the characters read from that line with no leading or trailing whitespace
|
30
|
-
def read_chars(filename)
|
30
|
+
def self.read_chars(filename)
|
31
31
|
chars = []
|
32
32
|
File.open(filename).each_line do |line|
|
33
33
|
chars << line.strip.chars
|
@@ -40,7 +40,7 @@ module AocUtils
|
|
40
40
|
# @param datatype1 [String] the datatype of the first part of the file, either "Integer", "String", or "Char"
|
41
41
|
# @param datatype2 [String] the datatype of the second part of the file, either "Integer", "String", or "Char"
|
42
42
|
# @return [Array<Array>] an array containing two arrays, the first being the first part of the file and the second being the second part of the file
|
43
|
-
def read_two_parts(filename, datatype1, datatype2)
|
43
|
+
def self.read_two_parts(filename, datatype1, datatype2)
|
44
44
|
lines = File.open(filename).readlines.map(&:strip)
|
45
45
|
index = lines.index("")
|
46
46
|
part1 = lines[0...index]
|
metadata
CHANGED