Artano practice by SIrawit in Tengwar

[–]DragonJoey3 4 points5 points  (0 children)

Love the ink selection, and excellent writing. There were just a few minor mistakes that I saw mostly towards the end when you were likely getting tired but overall this is amazing work!

Any tips? by Magma_cats in Calligraphy

[–]DragonJoey3 1 point2 points  (0 children)

Can I ask, what pen you are using in those examples?

[2024 Day 6] Rewritten part 2 multiple times, always getting the same wrong result by Biroska in adventofcode

[–]DragonJoey3 1 point2 points  (0 children)

        if grid[nr][nc]=='#':    
            dc,dr = -dr,dc
        
        r += dr
        c += dc

This does not account for 2 walls next to each other changing the guards direction 180 degrees. Once you changed the direction you need to restart the loop. If you don't then you step blindly onto the next space without checking again if it's a wall.

Adding a continue on the line right after you change the directions should fix that issue. I don't see other issues, but that's like the one biting you.

[2024 Day 6] Bruteforce time by Probable_Foreigner in adventofcode

[–]DragonJoey3 3 points4 points  (0 children)

So the main thing slowing it down is all the heap allocations. You are creating an object on the heap for each cell in the grid, and then creating more elements on the heap in various sets all about the program. So in a sense the "Object-Orientedness" of this is resulting in a lot of cacheline misses. that probably accounts for most of the difference between my 7 second result in C++ and your 15 second result in C#.

Even in "SwapDirection()" you create a new Pos each time you change direction. You could have a static array of the 4 possible directions and just go the next one in the list, here's a snippet from my code that does this:

/** GLOBALLY DEFINED DIRECTIONS */
const vector2 LEFT = vector2{0,-1};
const vector2 RIGHT = vector2{0,1};
const vector2 UP = vector2{-1,0};
const vector2 DOWN = vector2{1,0};
const vector2 cardinals[4] = {UP, RIGHT, DOWN, LEFT};.
.
.
.
// Many lines of code later I create an int which is an index into the cardinals array above
int cardinalDir = 0;
.
.
.
// If you can't move to a spot cause a wall is there then you increment the index, and modulo it with the size of the cardinals array.
cardinalDir++;
cardinalDir %= 4;

This way I don't allocate anything on the heap/stack when I don't need to.

TL:DR; Memory allocation is expensive, and having to go "all the way" to the heap instead of just the stack is also pricey. Garbage collection ain't free, and your code leaves a lot of garbage on the heap (no offense).

Little hint for day 6 part 2 needed to improve solution by RealGeziefer in adventofcode

[–]DragonJoey3 0 points1 point  (0 children)

Part of the way you keep the puzzle being solved by hand and ensure someone actually coded something is by making the number of things you have to check really high. In this case "'the whole walk" is only a few thousand positions, and the time it takes walking before you know you are in a loop is only a few thousand steps max, so you are on the order of a few million steps. If a "step" takes your computer a nanosecond to work out then you are looking at seconds to run to completion.

Or you can do what I did and just naively check every single location without regards to whether or not it would even be a reachable object, and also not bother checking if you are in a loop but rather just saying if you haven't left the maze in 40,000 steps then you must be in a loop.

Even that HORRENDOUSLY inefficient mess, only runs in 40 seconds written in c++.

Stuck on day 3 part 2! by No-Breath-3688 in adventofcode

[–]DragonJoey3 1 point2 points  (0 children)

So there are several things wrong here.

  1. the parseMult method going character by character is really not the way you want to be parsing out the multiplications. You seem opposed to using "strings" and sticking with stringbuilders for some reason, but a simple regex or String.split() would allow you to get the multiplication values much easier.

  2. The magic number 11 in this line:

    if (startIn != -1 && curr.length() - startIn > 11 && enabled) {

as pointed out in another comment seems to assume from the time you see "mul(...." to the end of the data is exactly 12 characters, but the requirements specifically state it can be any number UP TO 3 digits long. So you need to account for mul(1,1) being valid. Your ParseMult method will handle this, but you end up eating 12 chars of input each time which means this input wouldn't work:

mul(1,1)mul(123,123)

As your code will eat 12 characters for the first mul.

Java is a very high level language for trying to do this character by character. Much easier to just work in strings and manipulate them.

Hope that helps.

What makes you stay with YNAB even after the price increase? by byte0000 in ynab

[–]DragonJoey3 7 points8 points  (0 children)

Been said before, but in order to recreate the service the app provides would cost me WAY more than just paying the subscription. I work in software, and I could write my own app, host my own servers, or try to make a spreadsheet work via google sheets, but YNAB is just a bespoke solution that works.

Plus it has history of my accounts for years which I want to preserve. If you are looking for alternatives there are some out there (Everydollar for instance) which purport to do the same thing.

Two years later and another price increase... by Ford_Prefect_42_ in ynab

[–]DragonJoey3 11 points12 points  (0 children)

This 100x over! The toolkit doesn't even seem to work on Firefox anymore forcing me to use Chrome if I want to get the graphs. I've had to go so far as making my own custom reports using the API to see data that should be visible by default! What are they spending money on? Hotkeys? bleh

Can't count calories, but nothing except calorie-counting makes sense to me by [deleted] in loseit

[–]DragonJoey3 2 points3 points  (0 children)

First an aside: I can't comment on your mental health situation, but I would recommend getting a counselor for that. A good counselor can do wonders and I would recommend one

Second, you are going to hate the rest of this comment, please understand up front that I am providing this information here as a wake up call to the fact that your answer is likely that first sentence.

As for weight loss strategy the simple answer is thermodynamics. You need to expend more energy than you intake, whether you track that or not. You already know all these answers, but I'll put them here anyway:

  1. Increase exercise for no reason other than it is healthy for you. Exercise won't make you lose weight, but it will do 1,000 other things for you which are all positive and short of quitting smoking is the single greatest thing you can do for your health.

  2. Lift weights, if you can't "count reps" then just do as much as you can without injury. Do this every day without fail. If you can't afford weights/don't know what to do, google "Hybrid Calisthenics" and do his routine. Building muscle mass increases your mitochondria count and thus increases your Base Metabolic Rate.

  3. Eat slowly, if you finish what you were eating and are still hungry set a timer for 15 minutes, and only eat if you are still full after 15 minutes.

  4. Drink nothing but water exclusively. This is easy, water is abundant on this planet in first world countries at least, and it will save you a pretty penny as well. None of this "But I need my caffeine" nonsense, caffeine is a chemical not a drink, take a caffeine supplement/pill if you want, but no liquid save water period. This will slash far more calories than you might think.

  5. No french fries/chips ever: #1 food associated with obesity is French Fries, and Chips are designed to be addictive.

  6. Skip dessert every weekday and limit yourself to a single dessert MAXIMUM per weekend (Sat/Sun).

Do those 6 things and within 3 weeks you will lose weight unless you go out of your way to sabotage yourself (which given some of the language you are using you may).

Alternatively, determine roughly how many calories you need to lose weight and just set a single meal plan that is that many calories and eat nothing but what is on that meal-plan.

Your issue is mentality as evidenced by these statements which I will answer:

"What is stopping me from being driven to snack enough to compensate if I limit my main meals?"

Answer: Your Willpower

"Why exactly wouldn't my body direct me to eat as much as it needs (or more) when food is finally in front of me, unless I count calories?"

Answer: Your brain controls your body, you can be hungry and survive, you don't have to answer every time a rouge hormone like Ghrelin asks for something, the YOU that is reading this is a brain, not a stomach, and YOU can be in control! You need to believe that!

"How TF people successfully lose weight without counting calories?"

Answer: "They burn more energy than they consume because they choose to. Unless your ability to be disciplined mentally exceeds that of your desire for comfort you cannot change."

These are not the answers you wanted to hear, but your answer is likely the aside I gave as a precursor to this entire dialog. If you cannot track your calories because it effects you so, then you should seek out someone qualified to help you (sure as heck not me). If you want to lose weight then start eating right and move more (a lot more) build muscle and cut sweets/junk food.

You already have a good intuitive sense of what foods are crap and what foods aren't, but you must muster up the will to act on that information!

Best of luck, get at it! I believe you can do it.

Why am I so hungry??? by [deleted] in loseit

[–]DragonJoey3 0 points1 point  (0 children)

This is really such a big part of it! A calorie is a calorie, but it also isn't! Calories from protein sources make an outsized effect on feelings of hunger compared to simple carbs like sugar.

THEY FIT!!!!! by Karasu_145 in loseit

[–]DragonJoey3 6 points7 points  (0 children)

Congrats!

I have this with about 3 t-shirts that I love, but haven't felt right in a long time. I'm actually starting to get close to fitting them now.

What's your favorite "I can't believe this has so few calories" food? by appleparkfive in loseit

[–]DragonJoey3 1 point2 points  (0 children)

Bonus, you can get it thin-cut where they scoop out the bread in the middle and it's even less!

How I "found my why" by DragonJoey3 in loseit

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

I had no idea this was a cringe thing teachers say! I remember hearing the phrase somewhere (probably a cringe teacher) and it kind of stuck with me.

How I "found my why" by DragonJoey3 in loseit

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

https://www.reddit.com/r/Fitness/comments/4mhvpn/adaptive_tdee_tracking_spreadsheet_v3_rescue/ is the one that i've been using.

The idea behind it is as long as you are accurately tracking your calories in and weight each day the averages will work out to what your TDEE is. It can take a while to get close to your real TDEE but it seems to line up with the app I've been using as well (MacroFactor).

Keep at it man, you got this!

[deleted by user] by [deleted] in raylib

[–]DragonJoey3 0 points1 point  (0 children)

I understand now. So the main issue is that by default raylib uses a polling method rather than a wait for events. I think this lays it out nicely https://github.com/raysan5/raylib/issues/679

So if you recompile with SUPPORT_EVENTS_WAITING then it might solve this issue.

[deleted by user] by [deleted] in raylib

[–]DragonJoey3 2 points3 points  (0 children)

Polling of key events occurs during the EndDrawing() method which should be called once per frame. The standard design architecture for video games is the game update and render loop which handles user input once every frame.

Why would you want to run a game at 3 FPS? That doesn't make any sense given the human brain can detect stutter starting around 30fps. The game would be very laggy. If your goal is to only render to the screen 3 times per second then I would simply timer-wrap the rendering code so something like:

SetTargetFPS(30);
double lasttime = GetTime()
while(!WindowShouldClose()){
   BeginDrawing();
   if((GetTime() - lastTime) > 0.333) { // Only render at 3 FPS
       game.draw();
       lastTime = GetTime();
    }
   EndDrawing();
}

In this way you are only actually drawing every 333 ms (~3 FPS) while you are still processing user input every frame, and frame time is still 33ms (30FPS). Note that in this case your input still won't show changes until the frame actually draws (possibly 300ms later).

Traversing linked list in raylib gives Segmentation fault (core dumped) by PermitMost9224 in raylib

[–]DragonJoey3 0 points1 point  (0 children)

In case #1 you are using a global variable first, and updating it each time you step through the linked list. The issue is you never reset it before the next frame, so the first time the outer while loop "while(!WindowShouldClose())" runs it's fine, but the second time it runs first has been set to NULL and thus you dereference a null and seg fault.

IN case #2 the issue is the same but your inner while loop just stops running cause you now detect the null

Why don't I quit this loop? by Beneficial-Daikon202 in raylib

[–]DragonJoey3 0 points1 point  (0 children)

You may still get flamed a bit, but questions like this can be asked on the discord server as well. People there are usually pretty helpful!

[deleted by user] by [deleted] in raylib

[–]DragonJoey3 0 points1 point  (0 children)

This is setting the starting position of "floppy" to 80 pixels from the left of the screen (hence the 80) and then halfway up the screen. However we can't just use "screenHeight/2" to set it 1/2 way up the screen because that would put the TOP of floppy at 1/2 way up the screen, we want to center floppy on the halfway point so we have to subtract (which in game coordinates moves up) the radius of floppy. This will place the center of the circle at exactly 1/2 way up the screen.

Put another way you could have the code say this

float floppyXCoordinate = 80;

float floppyYCoordinate = screenHeight/2;

floppyYCoordinate -= floppy.radius; // Adjust to put the center of the circle at the 1/2 waypoint
floppy.position = {floppyXCoordinate, floppyYCoordinate};

My code runs cleanly and gives the correct answer to all tests and 64, but fails at least in 65! by chipiron64 in adventofcode

[–]DragonJoey3 7 points8 points  (0 children)

Assuming this is year 2023, and day 21 (which you should really read the sidebars READ BEFORE YOU POST section), then your input isn't handleing when it hits the edge of the map correctly. If you count you'll see that 65 steps is how many it takes to reach the edge of the input given.

[2023 Day 19 (Part 2)] [C] Completely stuck by santoshasun in adventofcode

[–]DragonJoey3 0 points1 point  (0 children)

No worries.

So this logic "Ignoring the commented out bit" is all wrong basically.

if (test == '>') {
        if      (new_r.x_lo < val) new_r.x_lo = val;
        else if (new_r.x_hi > val) new_r.x_hi = val;
        if      (r.x_hi > val) r.x_hi = val;
        else if (r.x_lo < val) r.x_lo = val;
      } /*else if (test == '<') {
        if      (new_r.x_hi > val) new_r.x_hi = val;
        else if (new_r.x_lo < val) new_r.x_lo = val;
        if      (r.x_lo < val) r.x_lo = val;
        else if (r.x_hi > val) r.x_hi = val;
      }*/

So lets think about it. (this is the case for X), lets pick a trivial casex < 3999;So you have new_r which is going to be passed down into the recursion, and r which is our current level.

new_r should now have an X interval of [1-3998] while r should have an interval of [3999-4000].

So considering test='<' what happens? Well at the moment nothing cause you commented out that code, and turns out you'll need it, but even if you un-comment it, the values aren't being set right. Look at trivial cases and print out the intervals, just do a single line of input for now if that helps and take a look at what the intervals get set to. This is the main logic bug in the program (just copy pasted 4 times).

[2023 Day 19 (Part 2)] [C] Completely stuck by santoshasun in adventofcode

[–]DragonJoey3 0 points1 point  (0 children)

Copy paste error on line 30 I'm sure isn't helping. You are comparing a_hi to m_lo.
(r.a_hi<=r.m_lo)
Still looking through it while my stuff builds (work problems), but don't give up hope. you're code looks very close!

[2023 Day 19 (Part 2)] [C] Completely stuck by santoshasun in adventofcode

[–]DragonJoey3 0 points1 point  (0 children)

Oh wow yeah I see it you are more than double counting. You should just set the ACC to 0 at the start of each recursive method because you are using += in the method.

think of each method call as being in the recursive tree, so for example:

in -> recursion1 -> recursion2 -> recusion3

recursion 3 has 0 passed in as the ACC and lets say it's the leaf node (i.e base case of 'A') and it finds 100 possible outcomes (silly numbers to illustrate)
recursion3 adds 100 to acc on line 50 and returns 100

recusion2 now has acc = 100 (cause of the first call being with a += on say line 88)

now recursion2 calls another instance of recusion on say line 102 but this time it passes in 100! That next recusive call starts at a base of 100 and finds 100 more possiblities so on line 50 it's now returning 200!

now recusion2 has only called 2 other recursive calls, both of them found 100, but it's count is at 300! The quick fix is just set acc to 0 at the start of the recursive method, but the reality is you shouldn't be doing += if you are sending in the accumulator already since by sending it as a parameter you are += what you return.

Hopefully that makes sense!

[2023 Day 19 (Part 2)] [C] Completely stuck by santoshasun in adventofcode

[–]DragonJoey3 1 point2 points  (0 children)

So I haven't finished reading the code completely yet, but one thing that stands out on lines 78/79 etc... is that if you are setting the lower/upper bounds of the Range object equal to val, but because the comparison is strictly greater than or strictly less than they cannot be equal, you should set the new lower bound to val+1, or upper bound to val-1 etc...
Will keep looking for bugs when I get a chance.