Skip to content

Commit 2834055

Browse files
committed
Update templates to use standard
1 parent db43e71 commit 2834055

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

templates/Gemfile.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ source "https://rubygems.org"
44

55
gem "activesupport"
66
gem "benchmark"
7+
gem "standard"

templates/a.rb.tmpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
require "byebug"
4-
require "active_support/all"
53
require_relative "../aoc_solution"
64

75
class Day < AOCSolution

templates/aoc_solution.rb.tmpl

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
require "byebug"
2+
require "active_support/all"
3+
14
class AOCSolution
25
def initialize(filename, params: {})
36
@data = File.read(filename)
@@ -13,7 +16,7 @@ class AOCSolution
1316
end
1417

1518
def twod_arr(input)
16-
input.split("\n").map {|l| l.split("") }
19+
input.split("\n").map { |l| l.chars }
1720
end
1821

1922
class Node
@@ -38,38 +41,38 @@ class AOCSolution
3841
def self.build!(root, nodes, raw_data)
3942
nodes[root.val] = root
4043

41-
root_i = raw_data.index {|rt,l,r| rt == root.val }
44+
root_i = raw_data.index { |rt, l, r| rt == root.val }
4245
return root if root_i.nil?
4346

44-
rt, l, r = raw_data[root_i]
45-
root.left = nodes.key?(l) ? root.left = nodes[l] : root.left = Graph.build!(Node.new(l), nodes, raw_data)
46-
root.right = nodes.key?(r) ? root.right = nodes[r] : root.right = Graph.build!(Node.new(r), nodes, raw_data)
47+
_, l, r = raw_data[root_i]
48+
root.left = root.left = (nodes.key?(l) ? nodes[l] : Graph.build!(Node.new(l), nodes, raw_data))
49+
root.right = root.right = (nodes.key?(r) ? nodes[r] : Graph.build!(Node.new(r), nodes, raw_data))
4750

48-
return root
51+
root
4952
end
5053
end
5154

52-
def within_bounds?(twod_arr, r,c)
55+
def within_bounds?(twod_arr, r, c)
5356
return false if r < 0
5457
return false if c < 0
5558
return false if r >= twod_arr.size
5659
return false if c >= twod_arr[0].size
5760

58-
return true
61+
true
5962
end
6063

6164
def extract_digits(str, single_digit: false, exclude_negative: false)
6265
regex = if single_digit && exclude_negative
63-
/\d/
64-
elsif single_digit
65-
/-?\d/
66-
elsif exclude_negative
67-
/\d+/
68-
else
69-
/-?\d+/
70-
end
71-
72-
return str.scan(regex).map(&:to_i)
66+
/\d/
67+
elsif single_digit
68+
/-?\d/
69+
elsif exclude_negative
70+
/\d+/
71+
else
72+
/-?\d+/
73+
end
74+
75+
str.scan(regex).map(&:to_i)
7376
end
7477

7578
def solve!

0 commit comments

Comments
 (0)