This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -sf https://raw.githubusercontent.com/aws/aws-sdk-java/master/CHANGELOG.md |\ | |
sed \ | |
-e 's/Amazon Simple Storage Service/Amazon S3/' \ | |
-e 's/^# /- /' \ | |
-e 's/^## / - ## /' \ | |
-e "s/#.*/'&'/" \ | |
-e 's/: / - /g' \ | |
-e 's/^ \(.*\)/ \1/' \ | |
-e 's/^ -/ -/' \ | |
-e 's/^ -/ -/' \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
tasks: | |
- name: Read input | |
set_fact: | |
input: "{{ lookup('file', 'input').splitlines() | map('int') | list }}" | |
- name: Prune impossible values from input | |
set_fact: | |
pruned_input: "{{ input | map('int') | reject('gt', 2020 - input | min | int) | reject('lt', 2020 - input | max | int) | list }}" | |
- name: Find items which sum to 2020 | |
set_fact: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
tasks: | |
- name: Calculate fuel per item | |
debug: msg="{{ ((item | int) / 3) | int - 2 }}" | |
loop: "{{ lookup('file', 'input').splitlines() }}" | |
register: output_things | |
- name: Calculate total fuel | |
debug: msg="{{ output_things.results | map(attribute='msg') | map('int') | sum }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
bootcmd: | |
- echo this is very unsafe >> /root/helloworld | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
set -o pipefail | |
thisisfine=$(seq 0 9 | sed 's/.*/^&&[^&]|[^&]&&[^&]|[^&]&&$/' | xargs | tr \ \|) | |
seq "${1%-*}" "${1#*-}" \ | |
| grep -Ev '10|2[01]|3[0-2]|4[0-3]|5[0-4]|6[0-5]|7[0-6]|8[0-7]|9[0-8]' \ | |
| grep -cE "$thisisfine" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
seq ${1%-*} ${1#*-} \ | |
| grep -E '(00|11|22|33|44|55|66|77|88|99)' \ | |
| grep -cEv '(10|2[01]|3[0-2]|4[0-3]|5[0-4]|6[0-5]|7[0-6]|8[0-7]|9[0-8])' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
IFS=, read -r -a program | |
for noun in $(seq 0 99); do | |
for verb in $(seq 0 99); do | |
program[1]=$noun | |
program[2]=$verb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
total=0 | |
while read -r val; do | |
xtra=$((val / 3 - 2)) | |
while [ "$xtra" -gt 0 ]; do | |
total=$((total + xtra)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sed -e 's#$#/3-2#' |xargs |tr \ +| bc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
declare -ai ram | |
declare -i addrmode1 addrmode2 arg1 arg2 pc=0 rb=0 | |
IFS=, read -r -a program < input | |
shift | |
ops=(x '+' '*' x x '-eq' '-ne' '<' '==') |
NewerOlder