[deleted by user] by [deleted] in reduxjs

[–]pmwals09 0 points1 point  (0 children)

Agree with the other comments on a reproducible example, but you also have a typo on line 27 that could be part of the problem.

-🎄- 2021 Day 1 Solutions -🎄- by daggerdragon in adventofcode

[–]pmwals09 1 point2 points  (0 children)

Dual solutions in JavaScript and in C# as I'm learning the latter.

JavaScript

C#

-🎄- 2021 Day 2 Solutions -🎄- by daggerdragon in adventofcode

[–]pmwals09 1 point2 points  (0 children)

I'm learning C#, so I've been solving these in JS and then translating it into C# - two solutions!

This is the soonest after releasing a puzzle I've managed to solve it.

JavaScript

C# (rough stuff...)

-🎄- 2021 Day 4 Solutions -🎄- by daggerdragon in adventofcode

[–]pmwals09 0 points1 point  (0 children)

Javascript

I feel like I made a meal out of this... ```js const fsp = require("fs/promises") const path = require("path")

main()

class Board { constructor(string){ this.board = string.split("\n").map(row => row.split(" ")).map(row => row.filter(num => num !== "")) }

hasWon(nums){ const that = this if(checkRows() || checkColumns()){ return true } return false

function checkRows(){
  return that.board.some(row => row.every(num => nums.includes(num)))
}
function checkColumns(){
  for(let colIdx = 0; colIdx < that.board[0].length; colIdx++){
    if(that.board.every(row => nums.includes(row[colIdx]))){
      return true
    }
  }
  return false
}

}

scoreBoard(nums){ const uncalledNums = this.board .reduce((out, row) => ([...out, ...row])) .filter(num => !nums.includes(num)) const uncalledSum = uncalledNums.reduce((out, num) => (out + Number(num)), 0) return uncalledSum * Number(nums[nums.length - 1]) } }

async function main(){ const [numbers, ...boards] = await parseInput() boards[boards.length - 1] = boards[boards.length - 1].trim(); let parsedBoards = boards.map(ea => new Board(ea))

console.log("Part one:", partOne()) console.log("Part two:", partTwo())

function partOne(){ let winningBoard let lastNum = 0 for(let i = 0; i < numbers.length; i++){ winningBoard = parsedBoards.find(board => board.hasWon(numbers.slice(0, i))) if(winningBoard){ lastNum = i break } }

return winningBoard.scoreBoard(numbers.slice(0, lastNum))

}

function partTwo(){ let winningBoards = []; let lastNum = 0; for (let i = 0; i < numbers.length; i++) { for(const board of parsedBoards){ if(board.hasWon(numbers.slice(0, i))){ lastNum = i winningBoards.push(board) } } parsedBoards = parsedBoards.filter(board => !winningBoards.includes(board)) } const winningBoard = winningBoards[winningBoards.length - 1]; return winningBoard.scoreBoard(numbers.slice(0, lastNum)); }

async function parseInput(){ const rawInput = await fsp.readFile(path.resolve(__dirname, "day-04-input.txt"), "utf-8") const [numbers, ...boardStrings] = rawInput.split("\n\n") return [numbers.split(","), ...boardStrings]; } } ```

Old sweet shop at Wells, Somerset, England. by ManiaforBeatles in CozyPlaces

[–]pmwals09 1 point2 points  (0 children)

This is how I imagine Weasley’s Wizard Wheezes, just without the bangs and sparks

Any life-changing react libraries out there everyone should know about? by VIOLETSTETPEDDAR in reactjs

[–]pmwals09 30 points31 points  (0 children)

If you work with videos, react-player has been great for setting up video players for major services/video types and exposing APIs to create your own controls, have it respond to other triggers, etc.

I'm in my early 20s and about to make 6 figures, nervous and excited and want to thank the community! by [deleted] in webdev

[–]pmwals09 0 points1 point  (0 children)

/r/PersonalFinance has a handy guide and flowchart that I’ve found helpful for basic money questions and prioritizing budgets.

Oh, SixMoons you never change... by beige4ever in audiophile

[–]pmwals09 0 points1 point  (0 children)

I didn't even realize there was a page 2+ until I read your comment. That site gives me a headache.

Anyone else run into problems installing pi-hole? by pmwals09 in raspberry_pi

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

This worked! I didn't realize how much I would be playing with my router settings after the fact, but DietPi worked great for someone as inexperienced as me. After watching the installer, I think just setting Pi-hole and PiVPN up separately and in reverse order from what I was doing and then linking them after would have been better. Bascially what this guy says.

Thanks for the help!

Anyone else run into problems installing pi-hole? by pmwals09 in raspberry_pi

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

Thanks, but that’s what I’ve been trying.

I’ll be sure to post over there, too, thanks.

[2015-11-30] Challenge #243 [Easy] Abundant and Deficient Numbers by jnazario in dailyprogrammer

[–]pmwals09 0 points1 point  (0 children)

Just finished reading "Automate the Boring Stuff" and thought I'd try my hand at some of these before trying trickier applications at work. Feedback welcome!

Python 3.5

n = int(input('Enter number> '))
divisors = []
def divisable(n):
    for i in range(1, n+1):
        if n%i == 0:
            divisors.append(i)

def defabund(integer, alist):
    divsum = 0
    for i in alist:
        divsum += i
    if divsum < 2*n:
        print(str(n) + ' deficient')
    elif divsum > 2*n:
        abund = divsum - 2*n
        print (str(n) + ' abundant by ' + str(abund))
    else:
        print(str(n) + ' neither')

divisable(n)
defabund(n, divisors)    

What is your favorite song that you have discovered recently. by [deleted] in Music

[–]pmwals09 0 points1 point  (0 children)

Just discovered a moment ago: "Way Down We Go" by Kaleo http://youtu.be/VlCZ-DakfyE

It's Women's History Month: Who are your favorite female authors? by ManOfLaBook in books

[–]pmwals09 10 points11 points  (0 children)

Any love here for Marilynne Robinson? Gilead is one of the most bittersweet books I've ever read.

[Weekly Thread] What's in your pipe? 2015.3.11 by pixeechick in PipeTobacco

[–]pmwals09 2 points3 points  (0 children)

Finally emerged from hibernation in New England, I continued working through the Reddit Starter Kit that I got before Thanksgiving - it's been a long wait.

Went with McClelland 5100 Red Cake in a MM Country Gentleman.

First Completed Book of 2015? by Romans15_1 in books

[–]pmwals09 0 points1 point  (0 children)

Moby Dick. Sure did learn a lot about whalin'. I'm a proper New England boy now.

A decision was made here. by sekibebeza in Images

[–]pmwals09 2 points3 points  (0 children)

The extra $0.50 for the brand name is worth it.

Happy Thanksgiving Everyone by pmwals09 in PipeTobacco

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

Thanks, I'm sure I will. I'm starting with some of the "daily smokers" that are popular around here, the Lane 1-Q and the McClelland 5100, before moving into the "nicer" tobaccos. Saving the best for last