{"id":22335509,"url":"https://github.com/pacso/aoc_rb_helpers","last_synced_at":"2026-02-10T00:32:39.262Z","repository":{"id":265988396,"uuid":"896994481","full_name":"pacso/aoc_rb_helpers","owner":"pacso","description":"Helper methods to simplify solving Advent of Code puzzles","archived":false,"fork":false,"pushed_at":"2024-12-24T07:54:37.000Z","size":58,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-15T01:41:42.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pacso.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-01T19:59:03.000Z","updated_at":"2024-12-11T08:49:43.000Z","dependencies_parsed_at":"2024-12-02T00:35:21.077Z","dependency_job_id":null,"html_url":"https://github.com/pacso/aoc_rb_helpers","commit_stats":null,"previous_names":["pacso/aoc_rb_helpers"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacso%2Faoc_rb_helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacso%2Faoc_rb_helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacso%2Faoc_rb_helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacso%2Faoc_rb_helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pacso","download_url":"https://codeload.github.com/pacso/aoc_rb_helpers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234139428,"owners_count":18785562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T05:13:35.919Z","updated_at":"2025-09-24T23:31:32.778Z","avatar_url":"https://github.com/pacso.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AocRbHelpers\n\n[![Gem Version](https://badge.fury.io/rb/aoc_rb_helpers.svg)](https://badge.fury.io/rb/aoc_rb_helpers)\n\nThis gem provides helper classes and functions to simplify solving [Advent of Code](https://adventofcode.com) puzzles. \nIt is a companion gem to the [aoc_rb](https://github.com/pacso/aoc_rb) gem.\n\nBe warned - using this gem might suck the fun out of solving the puzzles yourself!\n\n## Getting Started\n\nFirst of all, install the [aoc_rb](https://github.com/pacso/aoc_rb) gem and set up your project.\n\nNext, add this gem to your project Gemfile, and run `bundle install`.\n\nOpen up `challenges/shared/solution.rb` in your project and require this gem at the top:\n\n```ruby\n# frozen_string_literal: true\n\nrequire \"aoc_rb_helpers\"     # \u003c-- Add this line\n\nclass Solution\n  ...\nend\n```\n\nYou're good to go!\n\nThis gem additionally installs the excellent [puts_debuggerer](https://github.com/AndyObtiva/puts_debuggerer) gem, which you can use like this:\n\n```ruby\npd some_object\n```\n\nYou can read more on how you can use `pd` in their [README](https://github.com/AndyObtiva/puts_debuggerer/blob/master/README.md).\n\n## Provided Helper Classes\n\nAll documentation is available here - https://rubydoc.info/github/pacso/aoc_rb_helpers.\n\nThe provided helper classes are as follows:\n\n### [AocInput](https://rubydoc.info/github/pacso/aoc_rb_helpers/AocInput)\nProvides input manipulation helper methods. Methods are chainable, and directly modify the parsed view of the input data within the `@data` instance variable.\n\n### [DotMatrix](https://rubydoc.info/github/pacso/aoc_rb_helpers/DotMatrix)\nParses and decodes ASCII art text from puzzles. Can output to STDOUT or return the result to your code.\n\nWill turn an input like:\n```ruby\n XX  XXXX X    XXXX X     XX  X   XXXXX  XX   XXX\nX  X X    X    X    X    X  X X   XX    X  X X   \nX    XXX  X    XXX  X    X  X  X X XXX  X    X   \nX    X    X    X    X    X  X   X  X    X     XX \nX  X X    X    X    X    X  X   X  X    X  X    X\n XX  X    XXXX XXXX XXXX  XX    X  X     XX  XXX \n```\nInto the string `CFLELOYFCS`.\n\n### [Grid](https://rubydoc.info/github/pacso/aoc_rb_helpers/Grid)\nProvides helper methods for manipulating end querying two-dimensional grids.\n\n```ruby\ngrid = Grid.new([[0, 1], [2, 3]])\ngrid.rotate! # =\u003e #\u003cGrid:0x0000ffff8f42f8f8 @grid=[[2, 0], [3, 1]]\u003e\n```\n\n## Examples\n\nBelow are some examples of how you can use the features of this gem.\n\n### Input manipulation\n\nThis example solution for 2024 Day 1 shows how the convenience methods can be used to format the puzzle input:\n\n```ruby\n# frozen_string_literal: true\n\nmodule Year2024\n  class Day01 \u003c Solution\n    def part_1\n      list_1, list_2 = data\n      list_1.each_with_index.sum { |item, index| (item - list_2[index]).abs }\n    end\n\n    def part_2\n      list_1, list_2 = data\n      list_1.each.sum { |item| item * list_2.count(item) }\n    end\n\n    private\n\n    def data\n      aoc_input\n        .multiple_lines\n        .columns_of_numbers\n        .transpose\n        .sort_arrays\n        .data\n    end\n  end\nend\n```\n\nWhere you have different sections of input which need to be handled differently, you can quickly split them into independent instances of `AocInput`, such as with the pussle from 2024, Day 5:\n\n```ruby\n  page_rules, page_updates = aoc_input.sections\n  page_rules_data = page_rules.multiple_lines.columns_of_numbers(\"|\").data\n  page_updates_data = page_updates.multiple_lines.columns_of_numbers(\",\").data\n```\n\n### Decoding printed text\n\n```ruby\ntext_input = \u003c\u003c~EOF\n  X  X XXXX X    X     XX  \n  X  X X    X    X    X  X \n  XXXX XXX  X    X    X  X \n  X  X X    X    X    X  X \n  X  X X    X    X    X  X \n  X  X XXXX XXXX XXXX  XX  \nEOF\n\ninput_array = text_input.lines(chomp: true).map(\u0026:chars)\nDotMatrix.decode(input_array) # returns the string \"HELLO\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpacso%2Faoc_rb_helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpacso%2Faoc_rb_helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpacso%2Faoc_rb_helpers/lists"}