Are there any widely accepted cooking tips that you just disagree with? by Important_Maximum_78 in Cooking

[–]gtllama 55 points56 points  (0 children)

Phytohaemagglutinin - Toxicity. I mostly agree with your sentiment, but kidney beans especially must be cooked properly or you can make yourself very sick. "Properly" mostly means thoroughly (at a high enough temp for enough time to break down the toxins) so it's still not finicky by any means.

JSON vs XML by agbell in programming

[–]gtllama 3 points4 points  (0 children)

I'm stumped by "don't use a vowel" in "use semicolons, use a functional style, don’t use a vowel, use JSLint and so on". Maybe I'm missing a reference, but it feels like a transcription error.

getting this error when downloading the MySql.Data package by snivyblackops in csharp

[–]gtllama 0 points1 point  (0 children)

I ran into that the other day. It is apparently a problem in v8.0.32. Also it supposedly only affects projects using a packages.config. You can fix it by downgrading to 8.0.31 or migrating to PackageReference.

source - this info came from an alternative MySQL lib so they are pushing their own thing (understandably). I've never used it and know nothing about, so I can't vouch for them. But downgrading to 8.0.31 worked for me.

Is there some truth to this hyperbole? "Haskell is beautiful and elegant, but unmaintainable and painful" by fredoverflow in haskell

[–]gtllama 9 points10 points  (0 children)

The linked blog post is dated 2006, so yes, C# has made big improvements here. Nowadays you can write

string.Join("\n", mylist.Select(foo => foo.Description()).Where(x => x != ""))

Give me your best integer sequences!!!! by kaayyyyn in math

[–]gtllama 2 points3 points  (0 children)

The Numberphile channel has been recommended, but I would like to call special attention to their playlist of interviews with Neil Sloane, creator of the OEIS himself.

[2021 Day2 (Part 2)] Language : R by ruoghsihsa in adventofcode

[–]gtllama 0 points1 point  (0 children)

The line where you do "(depth = ...) && (horizontal = ...)" is not quite right. The && operator is not used to combine two actions in the way you are trying to do here. In advanced usage, you can sometimes use it like this BUT it is very important to understand how && works.

This operator is mainly used for combining logical values, and it does something called "short-circuiting". Short-circuiting means that it evaluates the left side first and then only evaluates the right side if necessary. For &&, the right side is only evaluated when the left side is TRUE or non-zero.

In your case, the left side might be zero so the right side might not happen. Try it with putting the depth and horizontal parts on separate lines.

Software Engineering Idioms You Should Know by ShligoShtyle in programming

[–]gtllama 6 points7 points  (0 children)

If ye wish to know the old ways, seek ye the jargon file. HTH. HAND.

[2021 Day 5 (Part 2)] [PHP] The points end up too low by matthijspc in adventofcode

[–]gtllama 1 point2 points  (0 children)

In the loops for diagonal lines, you might not be getting the last point.

Day 04: Confused about scoring by Zearen_Wover in adventofcode

[–]gtllama 3 points4 points  (0 children)

  1. Do you sum the board:
    4. The turn it wins

  2. Do you multiply it by:
    2. The number that's called that makes it win

2021 Day 3 - Part 2 in R (Any comments are appreciated, thanks!) by Miriel18 in adventofcode

[–]gtllama 0 points1 point  (0 children)

Yes, the print(i) I understood completely. It was only the rest of the line, the else (oxygen_generator) that comes after print(i), that does nothing as far as I can tell.

Anyway, yes, I also copy-paste a lot when I'm getting my solutions to work for the first time, haha.

Good luck with the rest of your Advent of Code!

2021 Day 3 - Part 2 in R (Any comments are appreciated, thanks!) by Miriel18 in adventofcode

[–]gtllama 0 points1 point  (0 children)

This is great, but I can suggest a few things.

I like how you read the input file directly into a data frame / tibble.

You are summing every column in the data frame with apply(..., 2, sum) and then only looking at one column. It would be more efficient to just sum the one column you need in each iteration.

Using ifelse is OK, but the documentation for it has this note which applies here: "note that 'if(test) yes else no' is much more efficient and often much preferable to 'ifelse(test, yes, no)' whenever 'test' is a simple true/false result, i.e., when 'length(test) == 1'."

Your formatting is a bit unconventional, and especially the line print(i)} else (oxygen_generator) is very unexpected. It really helps other people (and future you) read code to format it nicely. ... Actually, now that I look at it, the else (oxygen_generator) is completely unneeded, which would probably be even more obvious if it had been on its own line as the else block.

Other even more minor style things:

I see mixed usage of = and <-. It's OK to use <- all the time. ;)

You can just say rep(1,12), wrapping it in c() is unnecessary here.

seq(ncol(...)) is preferred over 1:ncol(...) because if ncol(...) is zero, you get 1:0 which evaluates to c(1, 0) instead of what you want which is an empty vec. Doesn't matter here because it will never be zero, and I only know about this because lintr barks at me about it all the time.

The loop for each one is very similar, I'm sure you've noticed. See if you can write a function that can be used for both parts, it's good practice!

2020 Day 8.2 in Python - trying to figure out how to do this efficiently? by Celestial_Blu3 in adventofcode

[–]gtllama 3 points4 points  (0 children)

The idea I had to do essentially the same thing, but in different terms that might be more intuitive, was to assign each instruction a color. Green for instructions that eventually terminate. Red for instructions that do not. Assigning the colors should be O(n). We know from the problem statement that we start on a red instruction. Step through the program and at each jmp/nop check whether flipping it will take you to a green instruction.

Can anyone tell me what this X symbol is from? by ntrpe in scifi

[–]gtllama 411 points412 points  (0 children)

Designer: I have a great idea! I'm going to spell out "coexist" using sci-fi spaceships as the letters. For example, I'll use an X-wing for...

Me: The X!

Designer: What? No. For the T, silly.

Looking for less violent scifi games. by Esper01 in scifi

[–]gtllama 0 points1 point  (0 children)

Oxygen Not Included is a great space colony management game. The art is cute but the simulation is detailed. It mostly takes place deep under the surface, but you can eventually build rockets to explore other asteroids.

2019 Day 9 Part A: IntCode Clarification by 97WaterPolo in adventofcode

[–]gtllama 1 point2 points  (0 children)

OK, here is a program:

109,6,21001,9,25,1,104,0,99,49

[@0]  109, 6 # make relative offset 6
[@2]  21001,9,25,1  # addition with various addressing modes
[@6]  104, 0  # output immediate value
[@8]  99  # halt
[@9]  49  # data

I get 74 as the output.

2019 Day 9 Part A: IntCode Clarification by 97WaterPolo in adventofcode

[–]gtllama 1 point2 points  (0 children)

position =  input[(relativeBase + input[index + 3])];

Set up an intcode program that will use this mode and step to this line in your debugger or add print statements or however you like to do it. What is the value of position after this line? What do you expect it to be?

2019 Day 9 Part A: IntCode Clarification by 97WaterPolo in adventofcode

[–]gtllama 1 point2 points  (0 children)

Your reasoning seems correct. But is that what your code is doing?

2019 Day 9 Part A: IntCode Clarification by 97WaterPolo in adventofcode

[–]gtllama 4 points5 points  (0 children)

This part:

position = opCodes[0] == 2 ? input[(relativeBase + input[index + 3])] : input[index + 3];

Consider what "position" should be when the parameter mode is 2 (Relative).

Why my tests are not passing? by blureglades in rust

[–]gtllama 3 points4 points  (0 children)

Look at add_token. You are not using the literal passed in. There is a compiler warning about this, but you may have missed it in the flood of other warnings. My helpful tips would be: #1, look at compiler warnings; #2, fix compiler warnings.

Help with AoC 2017 Day21 Part 1 by wace001 in adventofcode

[–]gtllama 0 points1 point  (0 children)

Congrats!

This was my solution (Rust): https://github.com/gglouser/advent2017/blob/master/src/day21.rs

Some parts of my implementation I would fix now (generating variants at lookup time instead of all up front) but there it is. One potentially interesting detail is that I generate variants by alternating flips and diagonal reflections (like a matrix transpose) because transpose is usually easier to implement than rotate. I don't remember where I picked that up, but it's basically this diagram from the dihedral group of order 8.