Ruby STDIN conversion

This commit is contained in:
Bill Rossi 2024-12-27 12:19:28 -05:00
parent 5cc6c76ac1
commit c619806f7b
2 changed files with 10 additions and 2 deletions
ruby
2015/1
bin

View File

@ -1,4 +1,4 @@
input = File.read("../data/2015/1/input.txt").split("")
input = STDIN.read.split("")
counts = input.tally
final_floor = counts["("] - counts[")"]
puts "Part 1: #{final_floor}"

View File

@ -3,4 +3,12 @@
year=$1
day=$2
time ruby $year/$day/problem.rb
mkdir -p $year/$day
source_file=$(ls $year/$day/*.rb)
if [[ -z $source_file ]] ; then
echo "No ruby source file found in $year/$day"
exit 1
fi
time (cat ../data/$year/$day/input.txt | ruby $source_file)