Sha256: 761ab5c7cbe9ab06bf0d6596ae42d32873404ed9fbbfa3bc1988094d5b12b176

Contents?: true

Size: 351 Bytes

Versions: 4

Compression:

Stored size: 351 Bytes

Contents

#
# https://adventofcode.com/2018/day/5 Part 1
#
# Does not use any cem functions \o/ but did you know:
#
#  - String#swapcase turns "Hello" into "hELLO"?
# 

out = []

File.read("inputs/day5_input.txt").each_char { |c|
  
  if out.empty? || out.last != c.swapcase
    out << c
  else
    out.pop
  end

}

puts out.join.size

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cem-0.1.7 examples/aoc2018/day5.rb
cem-0.1.6 examples/aoc2018/day5.rb
cem-0.1.5 examples/aoc2018/day5.rb
cem-0.1.4 examples/aoc2018/day5.rb