У нас вы можете посмотреть бесплатно ASCII values with ord and delete_if - Day 15 - Advent of Code 2023 или скачать в максимальном доступном качестве, которое было загружено на ютуб. Для скачивания выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса savevideohd.ru
In this video, you’ll learn how to solve day 15 of the Advent of Code 2023. The first part involves writing a hash function to convert initialization sequences like "rn=1" into decimal values between 0-255. The hash function works by: 1. Getting the ASCII code for each character using .ord 2. Multiplying the current value by 17 3. Taking modulo 256 to get the final hash value For part 2, the initialization sequences now can contain "=" to add lenses or "-" to remove them from "boxes", which are arrays. The boxes are stored in a hash keyed by the hash value of the label on the lense. We’ll parse the complex input into easier-to-work with structures. Then we’ll iterate through the instructions, either adding/updating lenses or removing them if the instruction contains "-". At the end, we’ll sum each lens's "focusing power" based on the box number and slot number. After getting the right answer, we’ll spend some time refactoring some of the code, showing useful Ruby idioms like inject, delete_if, and pattern matching. Advent of Code: https://adventofcode.com/ My Solutions: https://gist.github.com/cjavdev/d15a2... Playlist • Advent of Code #adventofcode #ruby