Skip to content

Instantly share code, notes, and snippets.

View TechieGenie's full-sized avatar

Barath Vutukuri TechieGenie

View GitHub Profile
@TechieGenie
TechieGenie / AdventOfCode_2023_Dec_6.md
Created December 6, 2023 07:09
Solution for AdventOfCode 2023 Dec 6
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}' 
@TechieGenie
TechieGenie / AdventOfCode_2023_Dec_5.md
Created December 6, 2023 05:17
Solution for AdventOfCode 2023 Dec 5
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}'
@TechieGenie
TechieGenie / AdventOfCode_2023_Dec_4.md
Created December 4, 2023 12:25
Solution for AdventOfCode 2023 Dec 4

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+ - | bc

Part-2 cat part2.awk

@TechieGenie
TechieGenie / AdventOfCode_2023_Dec_3.md
Created December 3, 2023 16:31
Solution for AdventOfCode 2023 Dec 3

Pre-Process the input file using a shell script to create boundary and never encounter -ve scenario.

abc
def

becomes

#####
#abc# 
@TechieGenie
TechieGenie / AdventOfCode_2023_Dec_2.md
Created December 2, 2023 09:49
Solution for AdventOfCode 2023 Dec 2

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 &lt; "$1"
@TechieGenie
TechieGenie / AdventOfCode_2023_Dec_1.md
Created December 1, 2023 12:44
Solution for AdventOfCode 2023 Dec 1
@TechieGenie
TechieGenie / wordle_words_list.txt
Created February 9, 2022 06:50
Wordle words list
cigar
rebut
sissy
humph
awake
blush
focal
evade
naval
serve
@TechieGenie
TechieGenie / passwordStrengthChecker.sh
Created June 17, 2021 20:14
Check the strength of passwords and print count of strong passwords
#!/bin/bash
digits='[[:digit:]].*[[:digit:]]'
upper='[[:upper:]].*[[:upper:]]'
lower='[[:lower:]].*[[:lower:]]'
punct='[[:punct:]].*[[:punct:]]'
stringPasswordCounter=0
weakPasswordCounter=0
@TechieGenie
TechieGenie / LearnGoIn5mins.md
Created January 5, 2021 18:40 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins
@TechieGenie
TechieGenie / evenodd.py
Created August 28, 2019 17:59
segregate even odd numbers
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