Skip to content

Instantly share code, notes, and snippets.

@nicholaslemay
nicholaslemay / .rb
Created December 2, 2023 21:58
Day01 part 01
class Calibration
def self.calibration_of_instruction(instruction)
"#{self.first_digit_of(instruction).to_i}#{self.last_digit_of(instruction)}".to_i
end
def self.first_digit_of(instruction)
self.get_match_from_regex_or_empty(instruction, /^\D*(\d)/)
end
@nicholaslemay
nicholaslemay / .rb
Created December 2, 2023 21:54
Day 01 Part 02
class Calibration
def self.calibration_of_instruction(instruction)
sanitized_instruction = self.sanitize(instruction)
"#{self.first_digit_of(sanitized_instruction).to_i}#{self.last_digit_of(sanitized_instruction)}".to_i
end
def self.first_digit_of(instruction)
self.get_match_from_regex_or_empty(instruction, /^\D*(\d)/)

Il y a de ça très longtemps, les boulangers devaient marquer leurs miches de pain.

  • Pour les différencier des autres dans les fours partagés.
  • Comme une des première forme de branding avec leur clientèle.
  • Mais aussi par la loi. Si un client se faisait flouer par un boulanger malhonnête, les autorités savaient à qui s'adresser.

Ce sceau était donc utile, gage de reconnaissance et pour la protection du public à la fois.

Un exemple de pain retrouvé à Pompeii et une étampe:

@nicholaslemay
nicholaslemay / gist:3181611
Created July 26, 2012 11:46
Holy cyclomatic complexity Batman !
/* Check the insns before INSN to see if there is a suitable register
6660 containing the same value as GOAL.
6661 If OTHER is -1, look for a register in class RCLASS.
6662 Otherwise, just see if register number OTHER shares GOAL's value.
6663
6664 Return an rtx for the register found, or zero if none is found.
6665
6666 If RELOAD_REG_P is (short *)1,
6667 we reject any hard reg that appears in reload_reg_rtx
6668 because such a hard reg is also needed coming into this insn.
require File.dirname(__FILE__) + '/acts_as_archive/gems'
ActsAsArchive::Gems.activate %w(also_migrate mover)
require 'also_migrate'
require 'mover'
require 'yaml'
$:.unshift File.dirname(__FILE__)