aoc_utils 0.1.1 → 0.1.3
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 +4 -4
- 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: 4670d22399c334352f749fb796e8c716c744f61f9f2e72bf5b29f42c8bfe5085
|
4
|
+
data.tar.gz: 3aae281d8b3dc3f79d9ddf7a5aec236ddeb4e32b5c4dce69d703b8ed0ff1d489
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ebf25e5a9fd9456e7e6a31d7c97a1b956fecf654252639cf8ce266fe01c4d1d58ef81740145a03f387779e97802069f26ee42ea0a435af22b419bbe1f815883
|
7
|
+
data.tar.gz: 852c5342561f289945ec55039ed0ea236fab3797e9cb3f6223f0cdb9fa82cca8d17cdd5feece379efbdd7acce0d8fc25450b7a0eba894f88ffa76a32b882f1bc
|
data/lib/aoc_utils.rb
CHANGED
@@ -4,7 +4,7 @@ module AocUtils
|
|
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