Part-1
cat day6 | cut -d: -f2 | awk 'NR==1{for(i=1;i<=NF;i++){time[i]=$i}} NR==2{for(j=1;j<=NF;j++){dist[j]=$j}} END{total=1;for(i=1;i<=length(time);i++){ways=0;for(t=1;t<time[i];t++){if((time[i]-t)*t>dist[i]){ways++}}total=total*ways;}print total}'
Part-2
cat day6 | cut -d: -f2 | tr -dc '0-9\n' | awk 'NR==1{for(i=1;i<=NF;i++){time[i]=$i}} NR==2{for(j=1;j<=NF;j++){dist[j]=$j}} END{total=1;for(i=1;i<=length(time);i++){ways=0;for(t=1;t<time[i];t++){if((time[i]-t)*t>dist[i]){ways++}}total=total*ways;}print total}'
Part-1
cat day5 | awk '/^[[:alpha:]]/{if (NR>1) close(file); file=NR ".txt"; next} {print > file}';rm 1.txt; for i in $(cat day5 | head -1 | cut -d: -f2); do y=$i; for file in $(ls *.txt | sort -V); do y=$(cat $file | awk '{print $2,$1,$3}' | sort -V | awk -v x="$y" '{flag=0;if(x < $1) {print x;flag=1; exit} else if(x <= $1+$3-1) {print $2+x-$1; flag=1;exit} else {next}} END{if(flag){}else{print x}}') ; done; echo $i"\t"$y; done | sort -k2 -V | head -1 | awk '{print $2}'Part-1
cat input | cut -d: -f2 | tr -d '|' | xargs -I {} sh -c "echo {} | tr ' ' '\n' | sort | uniq -d | wc -l " | awk '$1>0 {print 2^($1-1)}' | paste -sd+ - | bcPart-2
cat part2.awk
https://adventofcode.com/2023/day/2
cat process.sh
#!/bin/bash
while read -r line; do
echo "$line" | grep -oE 'Game \d+|\d+ green|\d+ blue|\d+ red' | sort -nr | awk '!a[$2]++' | xargs
done < "$1"https://adventofcode.com/2023/day/1
Part-1
cat input.txt | tr -dc '0-9\n' | gawk -F '' '{print $1$NF}' | paste -sd+ - | bcPart-2
This file contains hidden or 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
| cigar | |
| rebut | |
| sissy | |
| humph | |
| awake | |
| blush | |
| focal | |
| evade | |
| naval | |
| serve |
This file contains hidden or 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 | |
| digits='[[:digit:]].*[[:digit:]]' | |
| upper='[[:upper:]].*[[:upper:]]' | |
| lower='[[:lower:]].*[[:lower:]]' | |
| punct='[[:punct:]].*[[:punct:]]' | |
| stringPasswordCounter=0 | |
| weakPasswordCounter=0 |
This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
This file contains hidden or 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
| import random | |
| randList = [random.randrange(1,100) for _ in range(10)] | |
| print(randList) | |
| i=0 | |
| j=len(randList)-1 | |
| while i<j: | |
| if randList[i]%2==1: | |
| swap=False |
NewerOlder