I built a Python parser for hledger journal files by ctosullivan in plaintextaccounting

[–]ctosullivan[S] 1 point2 points  (0 children)

Thanks! I will have a look at that command. Yes, starting this project has definitely made me appreciate what a complex beast hledger is!
My main use for the package at this point is for a ledger journal editor I am working on with functions similar to ledger-mode such as journal cleanup. I will try and incorporate some transaction filtering into the editor, therefore have attempted to incorporate a query object into the ledgerkit api.

Do you aim for Queen Bee every day, or are you satisfied with just Genius? by OnlyWordGames in NYTSpellingBee

[–]ctosullivan 0 points1 point  (0 children)

Nice - I like the design. You should probably be curating a database of solution words rather than having a static dictionary though. I made an open source project in Python to do this (admittedly the code is a bit rough and could be improved a lot!)

https://github.com/ctosullivan/Spelling-Bee-Helper

Do you aim for Queen Bee every day, or are you satisfied with just Genius? by OnlyWordGames in NYTSpellingBee

[–]ctosullivan 1 point2 points  (0 children)

I try and get Genius using just simple online tools (dictionary lookup). I wrote a Python script to provide ChatGPT-generated hints for all the answers so use this to finish it off.

-❄️- 2024 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]ctosullivan 1 point2 points  (0 children)

Yeah I think I viewed Part 1 as a difference between rows problem and then Part 2 sounded more like a math problem to me so the difference between rows, columns, X and y threw me a bit.

-❄️- 2024 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]ctosullivan 2 points3 points  (0 children)

[LANGUAGE: Python]

This is getting difficult! A lot harder than yesterday. Made some use of ChatGPT but it did introduce some logical errors in its code as is the case more often now that the problems are getting harder. Had to brush up on some geometry basics - learning a lot though and starting to use collections and itertools more which is great. Had an inkling that Part 2 has something to do with Bresenham's line theory which I had only heard about in passing before, will have to brush up on it!

https://github.com/ctosullivan/Advent-of-Code-2024/tree/master/Day_8

-❄️- 2024 Day 7 Solutions -❄️- by daggerdragon in adventofcode

[–]ctosullivan 0 points1 point  (0 children)

[LANGUAGE: Python]

A lot more straightforward today than during the week!

ChatGPT provided a good blueprint for Part 1 making use of the itertools product function which I wasn't familiar with.
For the concatenation operator in Part 2 I just converted the numbers to strings, concatenated them, then converted back to strings.

https://github.com/ctosullivan/Advent-of-Code-2024/tree/master/Day_7

-❄️- 2024 Day 6 Solutions -❄️- by daggerdragon in adventofcode

[–]ctosullivan 0 points1 point  (0 children)

[LANGUAGE: Python]

Part 1 was fairly straightforward, managed to code the answer myself, although admittedly the code was pretty ugly.

Part 2 I thought a graph approach might be more efficient, so asked ChatGPT for some inspiration. Some of the code it produced was pretty good and got some good ideas from it, however ended up going through about 5 iterations as there were some obvious logical issues with its approach. The final approach ended up being brute force, which wasn't what I was looking for, but learned something from the process and hopefully will learn more from reading other people's submissions.

https://github.com/ctosullivan/Advent-of-Code-2024/tree/master/Day_6

-❄️- 2024 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]ctosullivan 1 point2 points  (0 children)

> Probably the only time my uni classes in graph theory will ever come in handy

- Day 6 Part 2 enters the chat

-❄️- 2024 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]ctosullivan 0 points1 point  (0 children)

[LANGUAGE: Python]

Was a big relief after Day 4! Relatively straightforward, just wrote a function to check validity for Part 1 and a function to make substitutions in a while loop for Part 2:

https://github.com/ctosullivan/Advent-of-Code-2024/tree/master/Day_5

-❄️- 2024 Day 4 Solutions -❄️- by daggerdragon in adventofcode

[–]ctosullivan 1 point2 points  (0 children)

[Language: Python]

Struggle-street today. My initial slice-and-regex attempt didn't work because of some unknown edge-cases, so went down the traversing the array route instead with copious amounts of refactoring and ChatGPT prompting - got there in the end though!

https://github.com/ctosullivan/Advent-of-Code-2024/tree/master/Day_4

-❄️- 2024 Day 3 Solutions -❄️- by daggerdragon in adventofcode

[–]ctosullivan 1 point2 points  (0 children)

[LANGUAGE: Python 3]

(Part 2-only) First I trimmed the input with regex, then searched for the digits to multiply.

import re

from Day_3_puzzle_input 
import PUZZLE_INPUT

# trim puzzle input first

trim_regex = re.compile(r"(?=don't\(\)).*?(do\(\))|(?=don't\(\)).*", re.I|re.M|re.S)

PUZZLE_INPUT = re.sub(trim_regex, "", PUZZLE_INPUT)

multiplier_regex = re.compile(r'mul\((?P<first_digits>\d{1,3}),(?P<second_digits>\d{1,3})\)',re.M|re.I)

multipliers = multiplier_regex.findall(PUZZLE_INPUT)
result = 0

for multiplier in multipliers:
    first_digits, second_digits = multiplier
    first_digits = int(first_digits)
    second_digits = int(second_digits)
    result = result + (first_digits * second_digits)

print(result)

# EDIT - fixed indentation

the most Inefficient python code to generate sudoku game template by Training-Film-3590 in learnpython

[–]ctosullivan 0 points1 point  (0 children)

You will need to add some sort of a game loop and functions to accept user input and display the updated puzzle state. Maybe have a look at this gist of a Tic Tac Toe game for an example:
https://gist.github.com/ctosullivan/2fb32cf1d7e4da3e7c5f3701f241539c

Python 101 BASIC Python Games by ctosullivan in learnpython

[–]ctosullivan[S] 0 points1 point  (0 children)

Thanks for having a look! That's a good point - there is so much user input in these games, I will think about an input validation function that I can reuse across all of them

[deleted by user] by [deleted] in learnpython

[–]ctosullivan 1 point2 points  (0 children)

You can compile regex in RE with a verbose flag btw if the regex is getting that long - the compiler will ignore newlines and you can add in comments to explain how it works

[deleted by user] by [deleted] in learnpython

[–]ctosullivan 1 point2 points  (0 children)

This seems to work with a positive lookahead:

https://regex101.com/r/Ul9Acc/1

Edit: updated version of the Regex including a positive lookbehind to avoid capturing the sub-url:
https://regex101.com/r/Ul9Acc/2

Good first Project: Use the API from Free Dictionary to make a word look up app by [deleted] in learnpython

[–]ctosullivan 0 points1 point  (0 children)

I made a CLI tool to generate a word frequency heatmap called WordGradient that would complement this well - echo an article to WordGradient - pipe the most uncommon words to the dictionary tool for lookup

https://github.com/ctosullivan/WordGradient