Skip to content

Instantly share code, notes, and snippets.

@rhyn0bytes
rhyn0bytes / 2019-Day4.py
Created December 4, 2019 20:12
Advent of Code 2019 Day 4 solution in Python
import re
start = 387638
finish = 919123
count1 = 0
count2 = 0
def isAscending(num):
prev = 10
@rhyn0bytes
rhyn0bytes / 2019-Day4.rb
Created December 4, 2019 20:08
Advent of Code 2019 Day 4 solution in Ruby
count1 = 0
count2 = 0
for i in 245318..765747 # loop through rang of problem to solve 6-digit and range inclusion requirements
validFound = false
digits = i.to_s.split('') # Converting number to array of digits for easier sorting
if digits == digits.sort # Validate number is in ascending order
if i.to_s.match(/(\d)\1/) # If at least 1 pair of consecutive digits, valid for part one
count1 += 1
i.to_s.scan(/(\d)\1/).each do |m| # Iterate through all pairs of matching digits
if !i.to_s.match(/(#{m[0]})\1{2,}/) # Reject code if pair is part of a large match
@rhyn0bytes
rhyn0bytes / keybase.md
Last active May 31, 2020 04:00
Verify myself on github and keybase

Keybase proof

I hereby claim:

  • I am rhyn0bytes on github.
  • I am rhyno (https://keybase.io/rhyno) on keybase.
  • I have a public key whose fingerprint is E37C FEE0 6987 30AD FE50 7CE7 31B2 43A2 88B8 37C8

To claim this, I am signing this object: