This year, I am doing three “languages” for AoC. I am doing JS, Python, and Bash. I selected JS as I have students who will want help, so I want to make sure I can guide them. Python is my own personal choice. Bash is something my husband wanted to do so I can learn it as he just knocks em out the ball park.
Here are a few things I have learned from each language that I want to remember
JavaScript
- In regex for JS,
/\d/is the same as/[0-9]/ - This is cursed:
list.split("").reverse().join("").match('/\d/[...]').split('').reverse().join('');…but it works. (Also massive thank you to Nicholas and Menno as they totally showed me a cursed style.)
Python
.isDigit()is a thing.
Bash
- Bash scripts need
chmod +xso it can be called:./script.sh - mapfile is powerful when trying to put values into an array from a file
- Arrays are declared with spaces between the values
list=("value1" "valut2" "value3") - For Loops are weird. Not at all how I expected the syntax.
CODE
for value in "${list[@]}"; do
# do some stuff
done