Skip to content

Instantly share code, notes, and snippets.

@lackofcheese
lackofcheese / ip.py
Created December 7, 2016 22:21
AoC Day 5 in Python: the power of regex
#! /usr/bin/env python
import sys
import re
ABBA_REGEX = re.compile(r'(.)(?!\1)(.)\2\1')
ABA_REGEX = re.compile(r'(?=(.)(?!\1)(.)\1)')
def contains_abba(s):
return ABBA_REGEX.search(s) is not None