#!/usr/bin/env python3
#Advent of Code
#2025 Day 1, Part 1
#Solution by James C. (https://github.com/JamesMCo)
importos,syssys.path.append(os.path.abspath("../.."))importunittest,util.readfromutil.testsimportrundefsolve(puzzle_input:list[str])->int:pointing=50count=0forinstructioninpuzzle_input:rotation=int(instruction[1:])*(1ifinstruction[0]=="R"else-1)pointing=(pointing+rotation)%100ifpointing==0:count+=1returncountdefmain()->tuple[str,int]:puzzle_input=util.read.as_lines()return"The password to open the door is {}.",solve(puzzle_input)classAOC_Tests(unittest.TestCase):deftest_ex1(self):returnself.assertEqual(solve(["L68","L30","R48","L5","R60","L55","L1","L99","R14","L82"]),3)if__name__=="__main__":run(main)
#!/usr/bin/env python3
#Advent of Code
#2025 Day 1, Part 2
#Solution by James C. (https://github.com/JamesMCo)
importos,syssys.path.append(os.path.abspath("../.."))importunittest,util.readfromutil.testsimportrundefsolve(puzzle_input:list[str])->int:pointing=50count=0forinstructioninpuzzle_input:rotation=int(instruction[1:])ifrotation>=100:count+=rotation//100rotation%=100rotation*=1ifinstruction[0]=="R"else-1ifpointing==0:# Only want to count clicks that enter the 0 state, not leave it
pointing=(pointing+rotation)%100else:pointing+=rotationifrotation<0andpointing<=0:count+=1elifrotation>0andpointing>=100:count+=1pointing%=100returncountdefmain()->tuple[str,int]:puzzle_input=util.read.as_lines()return"The password to open the door is {}.",solve(puzzle_input)classAOC_Tests(unittest.TestCase):deftest_ex1(self):returnself.assertEqual(solve(["L68","L30","R48","L5","R60","L55","L1","L99","R14","L82"]),6)if__name__=="__main__":run(main)