Skip to content

Commit 6d4a8ab

Browse files
committed
Update file generator to use new template file
1 parent 681f39f commit 6d4a8ab

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby 3.1.3

create_files.sh

+14-8
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22

33
DIR=$(dirname $(readlink -f $0))
44

5-
for y in `seq -w 2021 2021`; do
5+
for y in `seq -w 2015 2022`; do
66
mkdir $DIR/$y
77

88
for i in `seq -w 1 25`; do
99
mkdir $DIR/$y/day-$i
10-
touch $DIR/$y/day-$i/README.txt
11-
touch $DIR/$y/day-$i/day-$i-part-1.rb
12-
if [ $i -ne '25' ]
13-
then
14-
touch $DIR/$y/day-$i/day-$i-part-2.rb
10+
11+
if [ -z "$(ls -A $DIR/$y/day-$i)" ]; then
12+
cp template.rb $DIR/$y/day-$i/day-$i-part-1.rb
13+
14+
if [ $i -ne '25' ]
15+
then
16+
cp template.rb $DIR/$y/day-$i/day-$i-part-2.rb
17+
fi
18+
sed -i "s/\\$/${i}/g" $DIR/$y/day-$i/*.rb
19+
20+
touch $DIR/$y/day-$i/README.txt
21+
touch $DIR/$y/day-$i/day-$i-input.txt
22+
chmod +x $y/day-$i/*.rb
1523
fi
16-
touch $DIR/$y/day-$i/day-$i-input.txt
17-
chmod +x $y/day-$i/*.rb
1824
done
1925
done

template.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
3+
file_path = File.expand_path("../day-$-input.txt", __FILE__)
4+
input = File.read(file_path)

0 commit comments

Comments
 (0)