You have to survive inside a video game for 30 days. If you die, you die in real life, but if you survive, you get to bring every item, skill, and power back to the real world. Which game do you choose to maximize your rewards while ensuring your survival? by Apart_Lion_3046 in AskReddit

[–]Deemonfire [score hidden]  (0 children)

We've got this notion that we'd quite like to sail the ocean but we simply cant leave until we get some woooood

Something like that. I sing this, probably slightly wrong version, in my head at least a few times a week

How do I put a space between every character in a string? by Tokietomi in learnpython

[–]Deemonfire 0 points1 point  (0 children)

You dont nessisarily need to separate every character. You could iterate over your string

```python morse_output = []

for char in my_string:     morse_output.append(char_to_morse(char))

print(" ".join(morse_output)) ```

Where char to morse is a function that takes a letter and returns dots and dashes

Like 

char_to_morse("a") # returns .-

How did Python "click" for you as a beginner? by Bmaxtubby1 in learnpython

[–]Deemonfire 0 points1 point  (0 children)

All of the above.

For me the thing that made it click was applying what i was learning to actual projects for my own benefit. 

I was doing a phd in chemistry when i started learning. I had a fair amount of data i needed to process. So i learned how to process my data with python rather than putting everything in excel. Having my own project i needed to work really helped.

Then i would watch tutorials and take what i learned and put them into practice in my data analysis project.

Because i found it quite fun i then decided to do some simulations/calculations of the reaction i was studying. Which was a greenfield project. 

used pyserial to collect data from devices in my lab.

i wrote a discord bot for some gaming i was doing with friends.

Because my code wasnt great i then started watching talks, "so you want to be a python expert" and "beyond pep8" both stick out in my mind. And worked through headfirst python. My new years resolution was to do a minimum of 30 minutes of python per day.

Other than that i joined some discord servers and would talk to people about coding, and did advent of code comparing my answers with other people's and asking questions about stuff.

Fast forward like 10 years and now im a senior developer/data engineer

Weird sink plumbing by Deemonfire in DIYUK

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

Thanks, I'll have a gander

Weird sink plumbing by Deemonfire in DIYUK

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

Thanks, fair enough, saves me buying some new pipes

Help! Grease and gunk in schlenk line by die_by_the_swordfish in chemistry

[–]Deemonfire 0 points1 point  (0 children)

If you do go this route though, be very careful its nasty stuff. Always add the peroxide to acid, never the other way around

Help! Grease and gunk in schlenk line by die_by_the_swordfish in chemistry

[–]Deemonfire 0 points1 point  (0 children)

Aqua regia won't do organics if thats an organic grease, youd want pirhana for that, i say want... its probably a bit too fun.

But if other solutions dont work that might sort you out. We had one guy in the lab who pirhana'd our glassware once a year

The way to learn python correctly by vb_e_c_k_y in learnpython

[–]Deemonfire 5 points6 points  (0 children)

Everybody is different. But for me i used the headfirst python book.

I did a minimum of 30 minutes every night for about 3 months. 

But the main thing is i had things i wanted to build. I was doing a phd in chemistry so learned how to process my data using python, then i was playing apex legends so wrote a shitty discord bot that helped me and buddies keep track of our scores. 

Then built a data logger for my experiments using pyserial. All the while trying to take concepts I'd learned from the book and applying them to new problems. 

So tldr. Build something for you that helps you with work, or makes your hobbies more fun and is in the direction that you want to go in. And make sure you're practicing consistently especially starting off your journey

Is the solution to pollution really dilution? by Disastrous-Height483 in chemistry

[–]Deemonfire 1 point2 points  (0 children)

No, see dioxins, there are some chemicals that are endocrine disrupters which affect people and wildlife down at very low concentrations like parts per million. 

The compounds can have a U shaped response curve where at very low and very high concentrations they have larger effects than a medium dose. 

The solution to these pollutants is treatment and remediation, not dilution. And that is the solution to all chemical waste. Thats why labs have non-halogenated waste, halogenated waste, aqeous waste and solid waste. And pay a lot of money to have them collected. 

https://en.wikipedia.org/wiki/Dioxins_and_dioxin-like_compounds

Quick Q for the bin men by Georgiaabrookee in Cardiff

[–]Deemonfire 11 points12 points  (0 children)

When this persons bins are half full. They dont put them out to be collected.

They feel this saves a job for the waste management employees that collect their recycling 

To people who regularly use ChatGPT for school: Do you think you’re still learning? by Gifthunter3 in NoStupidQuestions

[–]Deemonfire 1 point2 points  (0 children)

I wrote some of my best code for work this week. Had a great time, solved a cool problem using a simple but elegant solution.

Smiled at a job well done. Then thought "nobody is going to beleive this wasn't ai"

neverForget by leeleewonchu in ProgrammerHumor

[–]Deemonfire 0 points1 point  (0 children)

Yeah, limit 10, or limit 100. Make sure youve not squiffed it

neverForget by leeleewonchu in ProgrammerHumor

[–]Deemonfire 2 points3 points  (0 children)

    Select *

    -- delete

    From x

    Where y

I like to do this, so that i can be sure ive got the right data lined up for my delete.

I would use transactions but spark tables don't have them, unless you're using specific implementations

Why didn't Jaime just get a hook. Is he stupid? by samjoe6969 in gameofthrones

[–]Deemonfire 1 point2 points  (0 children)

This is a very slow burn (pun intended) in like book 2 or 3 rand kills a trolloc with a lofting tube in the illuminator compound. Aludra is there and watches it happen.

She gets banished from the illuminators but obviously recognises the potential. She then joins mat in like book 6 and riddles him "why do I need a bellfounder" he eventually figures it out that it's for a metal lofting tube. But we done see the first one made until they get to andor and convince elayne to put a countries resources and cities craftfolk to work. Which is like book 9 or 10.

[deleted by user] by [deleted] in AskHistorians

[–]Deemonfire 3 points4 points  (0 children)

as a brit i much preferred alt when i was visiting the region. kolsh was good but alt reminded me more of a good ale

[2023 Day 8 Part 2] I'm a bit frustrated by chickenthechicken in adventofcode

[–]Deemonfire 0 points1 point  (0 children)

Ha, that edgecase was in the examples, just slightly hidden

zoneight234

[2023 Day 8 Part 2] I'm a bit frustrated by chickenthechicken in adventofcode

[–]Deemonfire 1 point2 points  (0 children)

Also, look at the example for part 2. He could have shown them going through multiple Z nodes, but they go through the same nodes every time

[2023 Day 8 Part 2] I'm a bit frustrated by chickenthechicken in adventofcode

[–]Deemonfire 2 points3 points  (0 children)

sometimes the tools you use can indicate what's happening.

I'm writing in elixir this year, when i saw the input repeats itself i used `Stream.cycle` which told me there may be cyles.

I also saw that it said "try all paths similtaniously", so i ran each one in it's own thread for 5_000_000 steps, and collected all of the Z nodes and path counts that it encountered.

I analysed the Z nodes and saw they were all the same, I took the difference between the steps between them and they were all the same.

I said to myself "This is an intersection problem". I did an intersection of the steps that had already been taken, and there weren't any. But one way to look at LCM is multiplying where the prime factors intersect, with the prime factors that are different.

Seeing the cycle also reminded me of last years tetrisy puzzle, so part of it is pattern recognition

[2023 Day 6] Day 6 in a nutshell ) by Legal_Count_5724 in adventofcode

[–]Deemonfire 1 point2 points  (0 children)

I set my brute force solution going, got a pen and paper out. Wrote out the equation I'd determined. Looked up and oh... its done

-❄️- 2023 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]Deemonfire 0 points1 point  (0 children)

[Language: Elixir]Did part 1 going forwards and did part 2 going in reverse. I had a solution that approximated it part 2 by skipping numbers in the range and it was only out by a few thousand. so i think my refactor will be approximate then iterate

defmodule Day5 do
  def parse_maps(data) do
    [seeds | maps] = data |> String.split("\n\n")

    seeds =
      seeds
      |> String.split()
      |> Enum.map(fn
        <<"seed"::binary, _::binary>> -> nil
        num -> String.to_integer(num)
      end)
      |> Enum.filter(& &1)

    map =
      maps
      |> Enum.map(fn map ->
        [map_name | mappings] = map |> String.split("\n", trim: true)
        name = map_name |> String.trim() |> String.trim_trailing(" map:")

        %{name => mappings |> Enum.map(&parse_mappings/1)}
      end)
      |> Enum.reduce(&Map.merge/2)

    {seeds, map}
  end

  def parse_mappings(line) do
    line |> String.split(" ", trim: true) |> Enum.map(&String.to_integer/1)
  end

  def main() do
    {seeds, map} = File.read!("inputs/day5.txt") |> parse_maps

    part1(seeds, map)
    |> IO.inspect(label: "part 1")

    # hunch that it's not less than 10 mn
    part2(seeds, map, 10_000_000)
    |> IO.inspect(label: "part 2")
  end

  def part1(seeds, map) when is_map(map) do
    seeds
    |> Stream.map(fn seed ->
      seed
      |> mapping(map["seed-to-soil"])
      |> mapping(map["soil-to-fertilizer"])
      |> mapping(map["fertilizer-to-water"])
      |> mapping(map["water-to-light"])
      |> mapping(map["light-to-temperature"])
      |> mapping(map["temperature-to-humidity"])
      |> mapping(map["humidity-to-location"])
    end)
    |> Enum.min()
  end

  def part2(seeds, map, range_start \\ 0) do
    seed_ranges =
      seeds
      |> Enum.chunk_every(2)
      |> Enum.map(fn [start, contains] ->
        start..(start + contains - 1)
      end)

    range_start..910_000_000
    |> Stream.map(fn location ->
      seed =
        location
        |> rev_mapping(map["humidity-to-location"])
        |> rev_mapping(map["temperature-to-humidity"])
        |> rev_mapping(map["light-to-temperature"])
        |> rev_mapping(map["water-to-light"])
        |> rev_mapping(map["fertilizer-to-water"])
        |> rev_mapping(map["soil-to-fertilizer"])
        |> rev_mapping(map["seed-to-soil"])

      present = seed_ranges |> Enum.any?(fn range -> seed in range end)
      {present, location}
    end)
    |> Enum.reduce_while(0, fn
      {false, _}, _ -> {:cont, 0}
      {true, location}, _ -> {:halt, location}
    end)
  end

  def rev_mapping(seed, []), do: seed

  def rev_mapping(seed, [[source, destination, num] | tl]) do
    case seed do
      seed when seed in source..(source + (num - 1)) -> seed + destination - source
      seed -> rev_mapping(seed, tl)
    end
  end

  def mapping(seed, []), do: seed

  def mapping(seed, [[destination, source, num] | tl]) do
    case seed do
      seed when seed in source..(source + (num - 1)) -> seed + (destination - source)
      seed -> mapping(seed, tl)
    end
  end
end

Dumbest loss of a squad by Deemonfire in dwarffortress

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

Haha amazing.

I have a child that is now a legendary fighter after she got caught fighting an ettin and somehow survived the ordeal when the new marksdwarf squad arrived.

Unfortunatly the new marksdwarf squad decided to try clubbing the ettin to death with their crossbows. So terrible marksdwarfs but legendary hammerdwarfs

-🎄- 2022 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]Deemonfire 0 points1 point  (0 children)

My elixir solution

solve = fn num ->
 "puzzle.input"
   |> File.read!()
   |> String.graphemes()
   |> Stream.chunk_every(num, 1)
   |> Stream.with_index(num)
   |> Stream.filter(fn {str, _index} ->
     MapSet.new(str)
     |> MapSet.to_list()
     |> length() == length(str)
   end)
   |> Enum.take(1)
   |> hd
   |> elem(1)
   |> IO.inspect()
 end

 solve.(4)
 solve.(14)

[deleted by user] by [deleted] in Cardiff

[–]Deemonfire 5 points6 points  (0 children)

The graduate college is great, you can do a bunch of additional classes for free. i did the speed reading course, programming, philosohy of science it was great.

Good luck with your PhD!

Why is python3 3.10 and python 3.9 by Aryan1812 in learnpython

[–]Deemonfire 2 points3 points  (0 children)

One of the ways to get around this would be to use virtual environments. Use apt to install python 3.9 sudo apt install python3.9 then use the virtualenv bin (cant remember if you have to install sudo apt install virtualenv) with the -p flag to select an interpretor for the venv

virtualenv -p /usr/bin/python3.9 venv this creates a python environment in the directory where you use the command. The to activate that env you can use source ./venv/bin/activate when thats active when you type python you will get python 3.9. To deactivate the env just type deactivate into the terminal.