Inlägg

Inlägg som Elvarg har skrivit i forumet
Av Elvarg

Jag bjuder 600kr för lego + frakt givetvis!

Av Elvarg
Nytt bud: 125 kr + frakt
Gå till annonsen för att lägga ett bud.
Av Elvarg

Jag skippar 1kr och kör på 100kr + frakt direkt!

Av Elvarg

Jag skulle väldigt gärna vilja ha Guitar Hero gitarren, så om inte @pehrnow tar den så kontakta gärna mig!

Av Elvarg

Finns den kvar? Bjuder annars 1100kr!

Av Elvarg

Jag är också väldigt intresserad ifall du kan skicka, så ställer mig på kö!

Av Elvarg

Annonsen är avslutad

Av Elvarg

Nämen se där @Oliver91, det låter väldigt intressant. Om du skicka över lite bilder i PM till mig så kan vi säkert lösa något, är intresserad utav både spel och konsollen!

Av Elvarg

New Nintendo 3DS XL

Jag söker en New Nintendo 3DS XL i gott skick. Det vore ett stort plus om originalförpackning och tillbehör finns kvar, men det är inget krav – jag är öppen för alla erbjudanden.

Har du spel till konsolen är det också av intresse!

Skicka gärna bilder och en beskrivning av vad du har att erbjuda, så tar vi det därifrån. Jag kan hämta eller ordna frakt beroende på överenskommelse.

Läs hela annonsen här

Av Elvarg

1250kr + frakt!

Av Elvarg

120kr + frakt för PSP spelen

Av Elvarg

Jag köper gärna PSP spelen, 100kr + frakt!

Av Elvarg

5100kr + upphämtning

Av Elvarg
Nytt bud: 4 500 kr + frakt
Gå till annonsen för att lägga ett bud.
Av Elvarg

Mini-ITX: 5900X, B550-I, 3060Ti, 32GB RAM, NR200, Dark Rock TF 2, SF750

Säljer följande komponenter då jag tänkt påbörja ett ATX bygge:

AMD Ryzen 5900X:
https://www.amd.com/en/products/cpu/amd-ryzen-9-5900x

ROG STRIX B550-I GAMING:
https://rog.asus.com/motherboards/rog-strix/rog-strix-b550-i-...

Corsair VENGEANCE RGB PRO SL 32GB (2x16GB) DDR4 DRAM 3600MHz C18:
https://www.corsair.com/ww/en/p/memory/cmh32gx4m2z3600c18/ven...

be quiet! DARK ROCK TF 2:
https://www.bequiet.com/en/cpucooler/3351

MSI GeForce RTX 3060 Ti GAMING X TRIO (8GB)
https://www.msi.com/Graphics-Card/GeForce-RTX-3060-Ti-GAMING-...

Corsiar SF750 750W:
https://www.corsair.com/us/en/p/psu/cp-9020186-na/sf-series-s...

Cooler Master NR200:
https://www.coolermaster.com/catalog/cases/mini-itx/masterbox...

---

Alla komponenter är lite över två år gamla och bilder kan fixas vid efterfrågan. Bud är det som gäller och givetvis billigare vid köp av hela datorn!

Läs hela annonsen här

Av Elvarg

Dag: 4 (del 1)
Språk: Python 3.10

from __future__ import annotations import pathlib def solve(path: pathlib.Path) -> int: points: list[int] = list() with open(path) as file: for line in file: _, rest = line.split(":") left, right = rest.split("|") left = set([int(x) for x in left.split()]) right = set([int(x) for x in right.split()]) intersection = right.intersection(left) if len(intersection) > 0: points.append(2 ** (len(intersection) - 1)) return sum(points) if __name__ == "__main__": print(f"Result: {solve(...)}")

Dold text

Dag: 4 (del 2)
Språk: Python 3.10

from __future__ import annotations import dataclasses import enum import functools import itertools import pathlib import typing @dataclasses.dataclass class Card: id: int left: set[int] right: set[int] def scratch(card: Card, cards: list) -> list[int]: intersection = card.right.intersection(card.left) start, end = card.id + 1, card.id + 1 + len(intersection) return functools.reduce( lambda x, y: x + y, [ scratch(card, cards) for card in cards[start:end] ] + [[card.id]]) def solve(path: pathlib.Path) -> int: cards: list[Card] = list() with open(path) as file: for line in file: identity, rest = line.split(":") _, identity = identity.split() index = int(identity) - 1 left, right = rest.split("|") left = {int(x) for x in left.split()} right = {int(x) for x in right.split()} cards.append(Card(index, left, right)) return sum([len(scratch(card, cards)) for card in cards]) if __name__ == "__main__": print(f"Result: {solve(...)}")

Dold text
Av Elvarg

Dag: 3 (del 1)
Språk: Python 3.10

from __future__ import annotations import dataclasses import enum import itertools import pathlib import typing class OutOfBoundsError(Exception): pass @dataclasses.dataclass class Cell: x: int y: int character: str @classmethod def create(cls, x: int, y: int, character: str) -> Cell: if character.isdigit(): return Digit(x, y, character, None) if character == "*": return Cogwheel(x, y, character) if character in ("+", "%", "=", "-", "#", "/", "&", "@", "$"): return Symbol(x, y, character) if character == ".": return Whitespace(x, y, character) else: return Cell(x, y, character) def __eq__(self, other: Cell): return (self.x, self.y, self.character) == (other.x, other.y, other.character) def __hash__(self): return hash(str(self.x) + str(self.y) + self.character) @dataclasses.dataclass class Digit(Cell): belongs_to: typing.Optional[Part] def __hash__(self): return super().__hash__() @dataclasses.dataclass class Cogwheel(Cell): pass @dataclasses.dataclass class Symbol(Cell): pass @dataclasses.dataclass class Whitespace(Cell): pass class Part(int): _cells: list[Digit] @property def cells(self) -> tuple[Digit, ...]: return tuple(self._cells) def __init__(self, cells: list[Digit]): self._cells = cells for cell in self._cells: cell.belongs_to = self def __new__(cls, cells: list[Digit]): value = str().join((cell.character for cell in cells)) value = int(value) if value else 0 return super().__new__(cls, value) def __hash__(self): return hash(tuple(self._cells)) class Direction(enum.Flag): NORTH = enum.auto() SOUTH = enum.auto() WEST = enum.auto() EAST = enum.auto() class Schematic: _cells: list[list[Cell | None]] _parts: list[Part] def __init__(self, columns: int, rows: int): self._cells = list() self._cells = [[None for _ in range(columns)] for _ in range(rows)] self._gears = list() self._parts = list() @property def columns(self) -> int: return len(self._cells[0]) @property def rows(self) -> int: return len(self._cells) @property def parts(self) -> list[Part]: return self._parts def set_cell(self, cell: Cell): if cell.x < 0 or cell.x > self.columns: raise OutOfBoundsError() if cell.y < 0 or cell.y > self.rows: raise OutOfBoundsError() self._cells[cell.x][cell.y] = cell def get_cell( self, x: int, y: int, direction: typing.Optional[Direction] = None ) -> Cell: if direction: if Direction.NORTH in direction: y -= 1 elif Direction.SOUTH in direction: y += 1 if Direction.WEST in direction: x -= 1 elif Direction.EAST in direction: x += 1 if x < 0 or x >= self.columns: raise OutOfBoundsError() if y < 0 or y >= self.rows: raise OutOfBoundsError() return self._cells[x][y] def get_neighbours(self, x: int, y: int): neighbours = list() for direction in [ Direction.NORTH, Direction.NORTH | Direction.WEST, Direction.NORTH | Direction.EAST, Direction.SOUTH, Direction.SOUTH | Direction.WEST, Direction.SOUTH | Direction.EAST, Direction.WEST, Direction.EAST ]: try: cell = self.get_cell(x, y, direction) neighbours.append(cell) except OutOfBoundsError: continue return neighbours @classmethod def create(cls, array: list[list[str]]): schematic = cls(len(array[0]), len(array)) digits = list() for x, y in itertools.product( range(schematic.columns), range(schematic.rows) ): cell = Cell.create(x, y, array[x][y]) schematic.set_cell(cell) if isinstance(cell, Digit): digits.append(cell) else: if digits: schematic.parts.append(Part(digits)) digits = list() parts = list() for part in schematic.parts: for cell in part.cells: cells = schematic.get_neighbours(cell.x, cell.y) cells = [cell for cell in cells if isinstance(cell, (Cogwheel, Symbol))] if cells: parts.append(part) break schematic.parts.clear() schematic.parts.extend(parts) return schematic def solve(path: pathlib.Path) -> int: array = list() with open(path) as file: for line in file: row = [character for character in line.strip()] array.append(row) schematic = Schematic.create(array) return sum(schematic.parts) if __name__ == "__main__": print(f"Result: {solve(...)}")

Dold text

Dag: 3 (del 2)
Språk: Python 3.10

from __future__ import annotations import dataclasses import enum import itertools import pathlib import typing class OutOfBoundsError(Exception): pass @dataclasses.dataclass class Cell: x: int y: int character: str @classmethod def create(cls, x: int, y: int, character: str) -> Cell: if character.isdigit(): return Digit(x, y, character, None) if character == "*": return Cogwheel(x, y, character) if character in ("+", "%", "=", "-", "#", "/", "&", "@", "$"): return Symbol(x, y, character) if character == ".": return Whitespace(x, y, character) else: return Cell(x, y, character) def __eq__(self, other: Cell): return (self.x, self.y, self.character) == (other.x, other.y, other.character) def __hash__(self): return hash(str(self.x) + str(self.y) + self.character) @dataclasses.dataclass class Digit(Cell): belongs_to: typing.Optional[Part] def __hash__(self): return super().__hash__() @dataclasses.dataclass class Cogwheel(Cell): pass @dataclasses.dataclass class Symbol(Cell): pass @dataclasses.dataclass class Whitespace(Cell): pass class Part(int): _cells: list[Digit] @property def cells(self) -> tuple[Digit, ...]: return tuple(self._cells) def __init__(self, cells: list[Digit]): self._cells = cells for cell in self._cells: cell.belongs_to = self def __new__(cls, cells: list[Digit]): value = str().join((cell.character for cell in cells)) value = int(value) if value else 0 return super().__new__(cls, value) def __hash__(self): return hash(tuple(self._cells)) class Gear(int): cell: Cogwheel n1: Part n2: Part def __new__(cls, cell: Cogwheel, p1: Part, p2: Part): return super().__new__(cls, p1 * p2) class Direction(enum.Flag): NORTH = enum.auto() SOUTH = enum.auto() WEST = enum.auto() EAST = enum.auto() class Schematic: _cells: list[list[Cell | None]] _gears: list[Gear] _parts: list[Part] def __init__(self, columns: int, rows: int): self._cells = list() self._cells = [[None for _ in range(columns)] for _ in range(rows)] self._gears = list() self._parts = list() @property def columns(self) -> int: return len(self._cells[0]) @property def rows(self) -> int: return len(self._cells) @property def gears(self) -> list[Gear]: return self._gears @property def parts(self) -> list[Part]: return self._parts def set_cell(self, cell: Cell): if cell.x < 0 or cell.x > self.columns: raise OutOfBoundsError() if cell.y < 0 or cell.y > self.rows: raise OutOfBoundsError() self._cells[cell.x][cell.y] = cell def get_cell( self, x: int, y: int, direction: typing.Optional[Direction] = None ) -> Cell: if direction: if Direction.NORTH in direction: y -= 1 elif Direction.SOUTH in direction: y += 1 if Direction.WEST in direction: x -= 1 elif Direction.EAST in direction: x += 1 if x < 0 or x >= self.columns: raise OutOfBoundsError() if y < 0 or y >= self.rows: raise OutOfBoundsError() return self._cells[x][y] def get_neighbours(self, x: int, y: int): neighbours = list() for direction in [ Direction.NORTH, Direction.NORTH | Direction.WEST, Direction.NORTH | Direction.EAST, Direction.SOUTH, Direction.SOUTH | Direction.WEST, Direction.SOUTH | Direction.EAST, Direction.WEST, Direction.EAST ]: try: cell = self.get_cell(x, y, direction) neighbours.append(cell) except OutOfBoundsError: continue return neighbours @classmethod def create(cls, array: list[list[str]]): schematic = cls(len(array[0]), len(array)) digits = list() for x, y in itertools.product( range(schematic.columns), range(schematic.rows) ): cell = Cell.create(x, y, array[x][y]) schematic.set_cell(cell) if isinstance(cell, Digit): digits.append(cell) else: if digits: schematic.parts.append(Part(digits)) digits = list() parts = list() for part in schematic.parts: for cell in part.cells: cells = schematic.get_neighbours(cell.x, cell.y) cells = [cell for cell in cells if isinstance(cell, (Cogwheel, Symbol))] if cells: parts.append(part) break schematic.parts.clear() schematic.parts.extend(parts) gears = list() for x, y in itertools.product( range(schematic.columns), range(schematic.rows) ): cell = schematic.get_cell(x, y) if isinstance(cell, Cogwheel): cells = schematic.get_neighbours(cell.x, cell.y) cells = [cell for cell in cells if isinstance(cell, Digit)] parts = set(cell.belongs_to for cell in cells) if len(parts) == 2: gears.append(Gear(cell, *parts)) schematic.gears.clear() schematic.gears.extend(gears) return schematic def solve(path: pathlib.Path) -> int: array = list() with open(path) as file: for line in file: row = [character for character in line.strip()] array.append(row) schematic = Schematic.create(array) return sum(schematic.gears) if __name__ == "__main__": print(f"Result: {solve(...)}")

Dold text
Av Elvarg

Dag: 1 (del 1)
Språk: Python 3.10

import pathlib import typing def solve(path: pathlib.Path) -> int: with open(path) as file: entries = [line.rstrip() for line in file] calibrations: list[int] = list() for entry in entries: first: typing.Optional[str] = None last: typing.Optional[str] = None for character in entry: if not first and character.isdigit(): first = character last = character continue if character.isdigit(): last = character calibrations.append(int(first + last)) return sum(calibrations) if __name__ == "__main__": print(f"Result: {solve(...)}")

Dold text

Dag: 1 (del 2)
Språk: Python 3.10

import pathlib import typing WORD_TO_NUMBERS = { "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9, } def solve(path: pathlib.Path) -> int: with open(path) as file: entries = [line.rstrip() for line in file] calibrations: list[int] = list() for entry in entries: first: typing.Optional[str] = None first_index: typing.Optional[int] = None last: typing.Optional[str] = None last_index: typing.Optional[int] = None for number, index in [ (number, entry.find(word)) for word, number in WORD_TO_NUMBERS.items() ]: if index == -1: continue if first: if index < first_index: first = str(number) first_index = index else: continue else: first = str(number) first_index = index for word, number, index in [ (word, number, entry.rfind(word)) for word, number in WORD_TO_NUMBERS.items() ]: if index == -1: continue if last: if index > last_index: last = str(number) last_index = index else: continue else: last = str(number) last_index = index for index, character in enumerate(entry): if not first and character.isdigit(): first = character first_index = index if not last and character.isdigit(): last = character last_index = index if character.isdigit(): if index < first_index: first = character first_index = index if index > last_index: last = character last_index = index calibrations.append(int(first + last)) return sum(calibrations) if __name__ == "__main__": print(f"Result: {solve(...)}")

Dold text

Dag: 2 (del 1)
Språk: Python 3.10

import dataclasses import pathlib import enum import re class Cube(str, enum.Enum): RED = "red" GREEN = "green" BLUE = "blue" @dataclasses.dataclass class HypotheticalBag: red_cubes: int green_cubes: int blue_cubes: int @dataclasses.dataclass(frozen=True) class RuleSet: max_red_cubes: int max_green_cubes: int max_blue_cubes: int @dataclasses.dataclass class Game: id: int bag: HypotheticalBag rule_set: RuleSet = dataclasses.field( default=RuleSet( max_blue_cubes=14, max_green_cubes=13, max_red_cubes=12 ) ) def is_possible(self) -> bool: ok = True ok &= self.bag.blue_cubes <= self.rule_set.max_blue_cubes ok &= self.bag.green_cubes <= self.rule_set.max_green_cubes ok &= self.bag.red_cubes <= self.rule_set.max_red_cubes return ok def extract_game(line: str) -> Game: x, rest = line.split(":") pattern = r'\s*(\d+)' game_id, *_ = re.findall(pattern, x) game_id = int(game_id) return Game(game_id, HypotheticalBag(0, 0, 0)) def extract_max_rgb(line: str) -> tuple[int, int, int]: _, rest = line.split(":") pattern = r'(\d+)\s*([a-zA-Z]+)' r_max, g_max, b_max = 0, 0, 0 for match in re.findall(pattern, rest): amount, color = match amount = int(amount) cube = Cube(color) if cube is Cube.RED: r_max = amount if amount > r_max else r_max continue if cube is Cube.GREEN: g_max = amount if amount > g_max else g_max continue if cube is Cube.BLUE: b_max = amount if amount > b_max else b_max continue return r_max, g_max, b_max def create_games(path: pathlib.Path) -> list[Game]: games: list[Game] = list() with open(path) as file: for line in file: line = line.rstrip() game = extract_game(line) max_r, max_g, max_b = extract_max_rgb(line) game.bag.red_cubes = max_r game.bag.green_cubes = max_g game.bag.blue_cubes = max_b games.append(game) return games def solve(path: pathlib.Path) -> int: games = create_games(path) return sum((game.id for game in games if game.is_possible())) if __name__ == "__main__": print(f"Result: {solve(...)}")

Dold text

Dag: 2 (del 2)
Språk: Python 3.10

import dataclasses import pathlib import enum import re class Cube(str, enum.Enum): RED = "red" GREEN = "green" BLUE = "blue" @dataclasses.dataclass class HypotheticalBag: red_cubes: int green_cubes: int blue_cubes: int @property def power(self) -> int: return self.red_cubes * self.green_cubes * self.blue_cubes @dataclasses.dataclass(frozen=True) class RuleSet: max_red_cubes: int max_green_cubes: int max_blue_cubes: int @dataclasses.dataclass class Game: id: int bag: HypotheticalBag rule_set: RuleSet = dataclasses.field( default=RuleSet( max_blue_cubes=14, max_green_cubes=13, max_red_cubes=12 ) ) def is_possible(self) -> bool: ok = True ok &= self.bag.blue_cubes <= self.rule_set.max_blue_cubes ok &= self.bag.green_cubes <= self.rule_set.max_green_cubes ok &= self.bag.red_cubes <= self.rule_set.max_red_cubes return ok def extract_game(line: str) -> Game: x, rest = line.split(":") pattern = r'\s*(\d+)' game_id, *_ = re.findall(pattern, x) game_id = int(game_id) return Game(game_id, HypotheticalBag(0, 0, 0)) def extract_max_rgb(line: str) -> tuple[int, int, int]: _, rest = line.split(":") pattern = r'(\d+)\s*([a-zA-Z]+)' r_max, g_max, b_max = 0, 0, 0 for match in re.findall(pattern, rest): amount, color = match amount = int(amount) cube = Cube(color) if cube is Cube.RED: r_max = amount if amount > r_max else r_max continue if cube is Cube.GREEN: g_max = amount if amount > g_max else g_max continue if cube is Cube.BLUE: b_max = amount if amount > b_max else b_max continue return r_max, g_max, b_max def create_games(path: pathlib.Path) -> list[Game]: games: list[Game] = list() with open(path) as file: for line in file: line = line.rstrip() game = extract_game(line) max_r, max_g, max_b = extract_max_rgb(line) game.bag.red_cubes = max_r game.bag.green_cubes = max_g game.bag.blue_cubes = max_b games.append(game) return games def solve(path: pathlib.Path) -> int: games = create_games(path) return sum((game.bag.power for game in games)) if __name__ == "__main__": print(f"Result: {solve(...)}")

Dold text
Av Elvarg

Jag är intresserad utav armen!

Av Elvarg

1500kr + frakt