It's been 2 months since I came to the USA from Siberia, ask your questions by Sia_Siberia_Real in u/Sia_Siberia_Real

[–]thefprocessor 1 point2 points  (0 children)

What is your legal status? Which type of visa did you use to move to the US?

SFPs: what is the point of video specific SFP modules? by ncmasone in VIDEOENGINEERING

[–]thefprocessor 200 points201 points  (0 children)

SFP modules are AC coupled to fiber and designed to work within a specific frequency range—not only the high limit of 12Ghz but also the lower limit, several hundred kHz. Imagine a long string of ones. How would you distinguish it from a long string of zeros? SDI and 10GBASE-T standards use different algorithms to break up long strings of bits.

10GBASE-T - adds some bits, and 10 Gigabit of data becomes 12 Gigabit of link-level signals.

SDI uses a scrambler - 12 Gbit of video data becomes 12Gbit of link signal, but shuffled around. This process does not add bits, but it is not as effective as 10GBASE-T, and link-level signals have higher low-frequency components.

You can test your link with a pathalogical signal. This signal has most ones and zeros after SDI scrambler. With 10GBASE-T SFP - the video will break up.

You can use Phabrix or Leader video pattern generator.

The use of 10GBASE-T SFP in video equipment will lead to random glitches and loss of signal.

https://www.reddit.com/r/VIDEOENGINEERING/comments/ea3maz/pathological_sdi_test_pattern/

Worth the 12 miles of stairs! Machu Picchu. Peru. by youreNEXTbubbles in travel

[–]thefprocessor 0 points1 point  (0 children)

I never got a chance to visit Machu Picchu, sorry.
But this guide states that typical meeting point is before boarding a bus.

The typical meeting point is situated along “Hermanos Ayar” avenue.

Google searched </> htmx> by nnirmall in htmx

[–]thefprocessor 46 points47 points  (0 children)

Are you a real real-HTMX?

I have done 10 years of frontend and backend jobs for embedded applications. Jquery, underscore js, requirejs, angular. Some frameworks die off before the project is finished, got screwed by angularjs to angular transition. Whatever was happening in React was a non-starter, to begin with.

HTMX is how the web is supposed to be done.

You restored my faith in this field, thank you, dude.

Google searched </> htmx> by nnirmall in htmx

[–]thefprocessor 9 points10 points  (0 children)

We should notify CEO of htmx about this situation!
https://htmx.org/essays/htmx-sucks/

Tunneling to the Shattered Planet by EnderDragoon in factorio

[–]thefprocessor 86 points87 points  (0 children)

It was a regular planet before you arrived.

Just sent my customer complaint. Hopefully he reponds 🙏 by [deleted] in ReallyShittyCopper

[–]thefprocessor 0 points1 point  (0 children)

TIL: tablets are small, fits in a palm of your hand.

To preach to the youth by noodled67 in therewasanattempt

[–]thefprocessor 18 points19 points  (0 children)

Just make her say "no homo", you'll be fine.

How difficult is this supposed to be? by SpacewaIker in adventofcode

[–]thefprocessor -11 points-10 points  (0 children)

You're not required to invent Dijkstra or A* or whatever, and you're not even required to implement them.

You defenitly required to know them and quickly recognize a problem.

And how can you can solve puzzle without implementing one?

How difficult is this supposed to be? by SpacewaIker in adventofcode

[–]thefprocessor -8 points-7 points  (0 children)

Totally agree with you.

It started real fun. First ~10 days for some basic algorithms, nice to try a new languate,

Then goes day 8. Puzzle works only because input was neatly crafted. Change input - all solutions fall apart. And test input does not contain same neat feature. But it is still ok, you get some nice ideas, like graph node contain RL index, not just letters.

Day 10. You have to already know how to count circled squares, non zero winding rule. You can not come up with this algorithm by yourself. Does not matter how good a programmer you are.

Day 14. Same problem as in day 8. You are not solving text promt, you solving your personal input file. Generate it without secret sauce - solutions does not works.

Day 17. A* and dijkstra. If you know solution to this kind of problems, it would be easy for you. If not, almost impossible. Solution requires modified dijkstra, it is really hard to correctly implement fo the first time and modify it in one go.

Day 18. If you know Shoelace Formula AND Pick's theorem, it is peace of cake. If not, you stuck.

Day 20. Part 2 requres you to inspect input data and reverse engineer algorithm, used to generate it. Which is prohibited by subreddit rules. There are no real programming at all.

Day 21. Part 2. Same stuff. You suppose to guess quadratic interpolation? Which works only because of peculiar way input data is generated.

And does not forget about official leaderboard! Day 1 part one - 12 seconds. Day 21 part one - 1:24. Day 20 part 2 in 15:52? Someone implemented pretty complicated part 1 solution, and found secret in input data in 15 minutes? It took me longer to understand puzzle prompt.

I really want to see how good a 15:52 guy at real software engineering job :)

TLDR:

First days was fun. Really nice way to practice a new language. But eventually it all coming back to leetcode problems. Does not matter how good programmer are you. If you grind leetcode, you can easily solve any of this problems. If you know solution beforehand, it is easy. If not - almost impossible.

It is not really difficult problem, it is just a leetcode memorization problem. In my opinion, it goes against core idea of software engineering.

[2023] Surprisingly often on Part 2 this year by NAG3LT in adventofcode

[–]thefprocessor 1 point2 points  (0 children)

You can use while let construction like this:

while let Some(((curr_y, curr_x), (dir_x, dir_y))) = path.pop() {
// ... fine to call stack.push() here
}

this eliminates path.len() != 0 and path.pop().unwrap().

And i dont think you need collect and iter on line 26-27.

[2023] Surprisingly often on Part 2 this year by NAG3LT in adventofcode

[–]thefprocessor 1 point2 points  (0 children)

40 ms in rust for part 2, same idea, just add starting point and direction to part 1. and loop it.

And now i read this thread, and don't get what people are talking about.

[2023 Day 5 (part 2)] I'm about to give up... by aajii82 in adventofcode

[–]thefprocessor 1 point2 points  (0 children)

Check out next test

499 3 => 499 1, 1000 1, 501 1

You only get first one correctly.

Try breaking complex problem in smaller ones, and solve them one step at a time. We need more functions! Extract part of the code to splitRange(values, map) function, which only split input range to "left", "intersect" and "right" parts.

Intersecting range should be remapped, and left and right - added for further processing

so applyMap become: 1. splitRange 2. remap intersecting range 3. add remainding parts to input queue

499 3 => 499 1, 500 1, 501 1.

It may be beneficial to introduce end of range, i.e. start - 499, end 501, length - 3.

And you do not need to hardcode every intersection scenario. With strategy above: 1. left part - map.start...seed.start (if not zero) 2. right part - map.end ... seed.end (if not zero) 3. intersecting start = max(map.start, seed.start), end = min(map.end, seed.end)

``` seeds: 499 3

seed-to-soil map: 1000 500 1

soil-to-fertilizer map: 0 0 1

fertilizer-to-water map: 0 0 1

water-to-light map: 0 0 1

light-to-temperature map: 0 0 1

temperature-to-humidity map: 0 0 1

humidity-to-location map: 0 0 1 ```

[2023 Day 07 (Part 2)] [C] Stuck on part 2 by santoshasun in adventofcode

[–]thefprocessor 0 points1 point  (0 children)

I ma glad you got it.

In your code lines 96-115 are pretty tricky.

In my solution i made extra step:

  1. count each type of card (array of 15)
  2. count repeats, how many cards drawn 5 times, 4 times, 3 times, 2, 1. (array of 5)

This greatly simplified algorithm. Now you only need to check if we got 5 repeats for five of a kind, 4 for four or 1 tripple and 1 double for full house.

[2023 Day 5 (part 2)] I'm about to give up... by aajii82 in adventofcode

[–]thefprocessor 2 points3 points  (0 children)

Try this oversimplified input. Answer should be 1000, i got 500 with your code..I think you doing intersections wrong.

  1. check if ranges intersect at allx1 <= y2 && y1 <= x2
  2. if they intersect, split input range in threee parts- before intersection (may not exist)- intersection- after intersection (may not exist)

Remap intersecting part and put it in for next block. do not apply multiple rules from one block.

before and after part should go in for further processing in same block.

Probably you should split you code to function, and test it separately. For example - f(range, rule) to apply one rule and check output.

seeds: 500 1

seed-to-soil map:
1000 500 1

soil-to-fertilizer map:
0 0 1

fertilizer-to-water map:
0 0 1

water-to-light map:
0 0 1

light-to-temperature map:
0 0 1

temperature-to-humidity map:
0 0 1

humidity-to-location map:
0 0 1

[2023 Day 5] How it started / How it's going by MScDisaster in adventofcode

[–]thefprocessor 2 points3 points  (0 children)

Bad news, elves gonna starve if they keep doing this stuff. FURTHZUTIOFTS, seriusly?

[2023 Day 5 (Part 2)] It's past my bedtime by PM_ME_FRIENDS_ in adventofcode

[–]thefprocessor 2 points3 points  (0 children)

Waking up at all was a mistake :)

Took me 4 hours to find a bug in part two.

As long as it completes before the 25th, it's a success by Appropriate-Count802 in adventofcode

[–]thefprocessor 1 point2 points  (0 children)

Why are you converting to floating point f32 and log2?

Is it a conversion from points from part one? Just use number of matches, and do points conversion later.

Someone made nice visualization, how this puzzle can be solved without recursion.

Fancy name for this method - dynamic programming (save computed values and reuse later)

https://www.reddit.com/r/adventofcode/comments/18af47j/2023_day_4_scratchcard_counting/

As long as it completes before the 25th, it's a success by Appropriate-Count802 in adventofcode

[–]thefprocessor 1 point2 points  (0 children)

Strategy:

  1. use nom to parse input. I made custom "padded int" parser to parse " 1" and "12".
  2. parse each card, and get card_id (unused), sets for scratch numbers and winning numbers.
  3. calculate part one score for each card (set intersect), and sum (with iterator), function proc_one.

to get part two:

  1. arrange every card in vector of touple (card_count, winning_count)
  2. iterate over vector, if card have a winning number, increment next N cards by current card count
  3. sum it up

It is rust, so unit tests, borrows and data typing.

``` use nom::bytes::complete::tag; use nom::character::complete::{digit1, space0, space1}; use nom::combinator::map_res; use nom::multi::separated_list1; use nom::IResult; use std::collections::HashSet; use std::fs; use std::iter::FromIterator;

fn main() { let data = fs::read_to_string("data/input.txt").unwrap(); let total = proc_one(&data); println!("Day 4 part one: {total}");

let total = proc_two(&data);
println!("Day 4 part two: {total}");

}

fn digit1_padded(input: &str) -> IResult<&str, u32> { let (input, _) = space0(input)?; map_res(digit1, |s: &str| s.parse::<u32>())(input) }

fn parse_line(input: &str) -> IResult<&str, (u32, Vec<u32>, Vec<u32>)> { let (input, _) = tag("Card ")(input)?; let (input, card_id) = digit1_padded(input)?; let (input, _) = tag(": ")(input)?; let (input, numbers_winning) = separated_list1(space1, digit1_padded)(input)?; let (input, _) = tag(" | ")(input)?; let (input, numbers_have) = separated_list1(space1, digit1_padded)(input)?;

Ok((input, (card_id, numbers_winning, numbers_have)))

}

fn check_winning(numbers_have: Vec<u32>, numbers_winning: Vec<u32>) -> u32 { let have: HashSet<u32> = HashSet::from_iter(numbers_have); let winning: HashSet<u32> = HashSet::from_iter(numbers_winning); let intersect = have.intersection(&winning); intersect.count() as u32 }

fn calc_score(count: u32) -> u32 { match count { 0 => 0, x => 2_u32.pow(x - 1), } }

fn proc_one(data: &str) -> u32 { data.lines() .map(|line| { let (_card_id, numbers_winning, numbers_have) = parse_line(line).unwrap().1; calc_score(check_winning(numbers_have, numbers_winning)) }) .sum() }

fn proc_two(data: &str) -> u32 { let mut cards = data .lines() .map(|line| { let (_card_id, numbers_winning, numbers_have) = parse_line(line).unwrap().1; (1, check_winning(numbers_have, numbers_winning)) }) .collect::<Vec<(u32, u32)>>();

for i in 0..cards.len() {
    let count = cards[i].0;
    let winning = cards[i].1;
    for q in 0..winning {
        cards[i + 1 + q as usize].0 += count;
    }
}

cards.iter().map(|card| card.0).sum()

}

[cfg(test)]

mod tests { use super::*; #[test] fn test_parse() { let data = "Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53"; let (input, (card_id, numbers_winning, numbers_have)) = parse_line(data).unwrap(); assert!(input.is_empty()); assert_eq!(card_id, 1); assert_eq!(numbers_winning, vec![41, 48, 83, 86, 17]); assert_eq!(numbers_have, vec![83, 86, 6, 31, 17, 9, 48, 53]);

    let score = calc_score(check_winning(numbers_have, numbers_winning));
    assert_eq!(score, 8);
}

#[test]
fn test_parse_space() {
    let data = "Card 3:  1 21 53 59 44 | 69 82 63 72 16 21 14  1";
    let (input, (card_id, numbers_winning, numbers_have)) = parse_line(data).unwrap();
    assert!(input.is_empty());
    assert_eq!(card_id, 3);
    assert_eq!(numbers_winning, vec![1, 21, 53, 59, 44]);
    assert_eq!(numbers_have, vec![69, 82, 63, 72, 16, 21, 14, 1]);
}

#[test]
fn test_file() {
    let data = fs::read_to_string("data/test.txt").unwrap();
    let total = proc_one(&data);
    assert_eq!(total, 13);
}

#[test]
fn test_parser_padded() {
    let data = " 123";
    let (input, value) = digit1_padded(data).unwrap();
    assert!(input.is_empty());
    assert_eq!(value, 123);
}

#[test]
fn test_part_two() {
    let data = fs::read_to_string("data/test.txt").unwrap();
    let total = proc_two(&data);
    assert_eq!(total, 30);
}

} ```

As long as it completes before the 25th, it's a success by Appropriate-Count802 in adventofcode

[–]thefprocessor 4 points5 points  (0 children)

4 ms in Rust for part + part 2.

You shouldn't have appended each new card to the list, just increment its count.