That’s just a comment
- 22 Posts
- 134 Comments
Hammerheart@programming.devto swaywm@programming.dev•A quick guide to setting session-wide environment variables in SwayEnglish1·12 days agoVery informative. Thank you!
It does. Empty collections, 0, None
Hammerheart@programming.devto Programmer Humor@programming.dev•Are IDEs really like this ?1·1 month agoWhat do you think it is?
How does that work?
Hammerheart@programming.devOPto Learn Programming@programming.dev•[Java] Is my code functionally equivalent to the example code?1·2 months agoThis is amazing, thank you! You’ve given me a lot to think about, not just with respect to this program, but what sort of things to consider when analyzing the behavior of any program. Describing the classes of input like you did was enlightening.
Hammerheart@programming.devOPto Learn Programming@programming.dev•[Java] Is my code functionally equivalent to the example code?1·2 months agoI added a description to OP.
Gambler (PROGRAM 1.3.8) is a simulation that can help answer these questions. It does a sequence of trials, using Math.random() to simulate the sequence of bets, continuing until the gambler is broke or the goal is reached, and keeping track of the number of wins and the number of bets.
Hammerheart@programming.devto Learn Programming@programming.dev•i want to learn/use functional programming language2·2 months agoWere you able to transfer those concepts you learned from clojure to other languages?
Hammerheart@programming.devOPto Linux@programming.dev•Help! My bash script isn't executing in my sway config1·4 months agothank you! your command worked like a charm once i prepended it with exec. i even added a final command taking me back to workspace 1. tested it with exec_always and it seems to be good, crossing fingers it will actually work on boot.
maybe you can answer another question for me: is the config file executed asynchronously? What i mean is, does it run through each line, or is there a chance that, say, line 25 might execute before line 13?
The jank is kind of severe, but I like what they’re trying to do. Still, I keep meaning to make a bug report, because I cant right click on the tab bare without the browser crashing more than half the time.
Hammerheart@programming.devto Programmer Humor@programming.dev•(How to trigger programmers (and make them irrationally angry)19·4 months agoshort variable names, and the only vowel is ‘i’
Hammerheart@programming.devto Programmer Humor@programming.dev•What's next? Picoservices?1·4 months agoMetaservices.
Hammerheart@programming.devto Linux@programming.dev•Christoph Hellwig Steps Down From One Of His Kernel Roles Following Rust Drama15·4 months agoRust is a psyop
I think the default mod key is the ‘super’ key (formerly known as the windows key). It might be alt actually, I don’t remember. Super + 1-9 switches between workspaces, which hold your windows. Shift + super + 1-9 moves a window to another workspace. you can find more key bindings by viewing $XDG_CONFIG_HOME/sway/config (or wherever config files go on your system).
Hammerheart@programming.devto Programming@programming.dev•To people making shitty guides/tutorials.6·4 months agoI think those are more interesting. I like seeing the process.
Hammerheart@programming.devto Programming@programming.dev•What are some good resources to learn to write very reliable/formally verifiable software?9·4 months agoThat’s kindeof poetic tbh
Hammerheart@programming.devto Advent Of Code@programming.dev•🖨️ - 2024 DAY 5 SOLUTIONS - 🖨️1·6 months agoPython
(Part 1) omg I can’t believe this actually worked first try!
with open('input') as data: parts = data.read().rstrip().split("\n\n") ordering_rules = parts[0].split("\n") updates = parts[1].split("\n") correct_updates = [] middle_updates = [] def find_relevant_rules(pg_num: str, rules: list[str]) -> list[str] | None: for rule in rules: return list(filter(lambda x: x.split("|")[0] == pg_num, rules)) def interpret_rule(rule: str) -> list[str]: return rule.split("|") def interpret_update(update: str) -> list[str]: return update.split(",") def find_middle_update_index(update: list[str]) -> int: num_of_elements = len(update) return num_of_elements // 2 for update in updates: is_correct = True for i, page in enumerate(interpret_update(update)): rules_to_check = find_relevant_rules(page, ordering_rules) for rule in rules_to_check: if rule.split("|")[1] in interpret_update(update)[:i]: is_correct = False if is_correct: correct_updates.append(update) for update in correct_updates: split_update = update.split(",") middle_updates.append(int(split_update[find_middle_update_index(split_update)])) print(sum(middle_updates))
Hammerheart@programming.devto Advent Of Code@programming.dev•🌚 - 2024 DAY 4 SOLUTIONS - 🌚1·6 months agoPart 1:
with open('input') as data: lines = [l.strip() for l in data.readlines()] # Remove empty line class Result(): def __init__(self): self.count = 0 def analyze_lines(lines: list[str]): ans.count += get_rights(lines) ans.count += get_ups(lines) ans.count += get_downs(lines) ans.count += get_down_rights(lines) ans.count += get_down_lefts(lines) ans.count += get_up_lefts(lines) ans.count += get_up_rights(lines) for line in lines: ans.count += get_lefts(line) def get_ups(lines: list[str]) -> int: up_count = 0 for i_l, line in enumerate(lines): result = "" if i_l < 3: continue for i_c, char in enumerate(line): if char == "X": result = char result += "".join([lines[i_l - n][i_c] for n in range(1, 4)]) if result == "XMAS": up_count += 1 else: result = "" return up_count def get_downs(lines: list[str]) -> int: down_count = 0 for i_l, l in enumerate(lines): result = "" for i_c, c in enumerate(l): if c == "X": result += c try: result += "".join([lines[i_l + n][i_c] for n in range(1, 4)]) except IndexError: result = "" continue finally: if result == "XMAS": down_count += 1 result = "" return down_count def get_lefts(line: str) -> int: left_count = 0 for i, char in enumerate(line): if i < 3: continue elif char == "X" and line[i-1] == "M" and line[i-2] == "A" and line[i-3] == "S": left_count += 1 return left_count def get_rights(lines: list[str]) -> int: right_counts = 0 for l in lines: right_counts += l.count("XMAS") return right_counts def get_down_rights(lines: list[str]) -> int: down_right_count = 0 for i_l, l in enumerate(lines): result = "" for i_c, c in enumerate(l): if c == "X": result += c try: result += "".join( [lines[i_l + n][i_c + n] for n in range(1,4)] ) except IndexError: result = "" continue finally: if result == "XMAS": down_right_count += 1 result = "" return down_right_count def get_down_lefts(lines: list[str]) -> int: down_left_count = 0 for i_l, l in enumerate(lines): result = "" for i_c, c in enumerate(l): if i_c < 3: continue if c == "X": result += c try: result += "".join( [lines[i_l + n][i_c - n] for n in range(1,4)] ) except IndexError: result = "" continue finally: if result == "XMAS": down_left_count += 1 result = "" return down_left_count def get_up_rights(lines: list[str]) -> int: up_right_count = 0 for i_l, l in enumerate(lines): result = "" if i_l < 3: continue for i_c, c in enumerate(l): if c == "X": result += c try: result += "".join( [lines[i_l - n][i_c + n] for n in range(1,4)] ) except IndexError: result = "" continue finally: if result == "XMAS": up_right_count += 1 result = "" return up_right_count def get_up_lefts(lines: list[str]) -> int: up_left_count = 0 for i_l, l in enumerate(lines): result = "" if i_l < 3: continue for i_c, c in enumerate(l): if i_c < 3: continue if c == "X": result = c try: result += "".join( [lines[i_l - n][i_c - n] for n in range(1,4)] ) except IndexError as e: result = "" continue finally: if result == "XMAS": up_left_count += 1 result = "" return up_left_count ans = Result() analyze_lines(lines) print(ans.count)
Part 2:
with open('input') as data: lines = list(filter(lambda x: x != '', [l.strip() for l in data.readlines()])) xmases = 0 for i in range(1, len(lines)): for j in range(1, len(lines[i])): if lines[i][j] == "A": try: up_back = lines[i-1][j-1] down_over = lines[i+1][j+1] up_over = lines[i-1][j+1] down_back = lines[i+1][j-1] except IndexError: continue else: if {up_back, down_over} == set("MS") and {up_over, down_back} == set("MS"): xmases += 1 print(xmases)
I actually found part two A LOT easier than part 1.
I needed to read this. Thank you.
Could you elaborate on how information is the noumena?