-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathadd
More file actions
28 lines (25 loc) · 722 Bytes
/
add
File metadata and controls
28 lines (25 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
#
#
# Copyright @ DestructHub Authors
#
#
# usage: add <problem-num> <answer>
if [ -x "$(command -v md5)" ]; then
alias md5sum='xargs md5 -s'
elif [ ! -x "$(command -v md5sum)" ]; then
echo "None of 'md5' and 'md5sum' cmd line are not found"
echo "Try install coretuils before using this script"
exit 1
fi
num=$(expr $1 + 0)
dir="Problem"$(printf "%03d" $num)
readme="[The original source of problem](https://projecteuler.net/problem=$num)"
hash=$(printf $2 | md5sum)
mkdir -p $dir
echo "Created folder $dir."
echo $hash > $dir/.hash
echo "$dir/.hash => $hash"
echo $readme > $dir/README.md
echo "Created file $dir/README.md"
echo "Added solution template for problem $num of ProjectEuler"