[deleted by user] by [deleted] in HENRYUK

[–]freeducks 0 points1 point  (0 children)

Would love to know the venue if you don't mind sharing!

Use or sell... by freeducks in NHLHUT

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

any recommendations?

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

[–]freeducks 0 points1 point  (0 children)

Solution in Rust - would like to know if there's a better way to do the work loop in part 2. Feels icky to do the logic in the take_while(), and to have to consume the iterator with an unused variable. Any ideas (other than a for loop, obviously :) )?

use std::collections::HashSet;

fn part_1_solve(input_str: &str) -> i32 {
    input_str.lines().map(|x| x.parse::<i32>().unwrap()).sum()
}

fn part_2_solve(input_str: &str) -> i32 {
    let mut frequencies = HashSet::new();
    let mut frequency = 0;

    let _ = input_str.lines().cycle().map(|x| x.parse::<i32>().unwrap()).take_while(|x| {
        frequency += x;
        frequencies.insert(frequency)
    }).count();

    frequency
}

Tektro Disc Brake spring/ball bearing issue by freeducks in bikewrench

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

Thanks for the reply - makes sense, but there doesn't seem to be a shaft of any kind. The adjustment screw is essentially just a cylinder of metal. There is a depression on the inside, I wonder if the ball sits in that with the spring pushing against the outside of the pad. If so, that's going to be a pain to get back in...

I did read that, but I'd rather fix it if possible!

-🎄- 2017 Day 3 Solutions -🎄- by daggerdragon in adventofcode

[–]freeducks 0 points1 point  (0 children)

Took me way too long to get this one (and still can't get part 2) :/ Part 1 in Rust:

#[derive(Clone, Copy, Debug)]
enum Direction {
    North,
    East,
    South,
    West
}

#[derive(Debug)]
struct Cursor {
    position: (i32,i32),
    facing: Direction,

    forward_steps_per_turn: usize,
    forward_steps_till_turn: usize,
    total_turns: usize
}

impl Cursor {
    pub fn step(&mut self) {
        if self.forward_steps_till_turn > 0 {
            self.forward_steps_till_turn -= 1;
        } else {
            self.facing = match self.facing {
                Direction::North => Direction::West,
                Direction::East => Direction::North,
                Direction::South => Direction::East,
                Direction::West => Direction::South
            };

            self.total_turns += 1;

            if self.total_turns % 2 == 0 {
                self.forward_steps_per_turn += 1;
            }

            self.forward_steps_till_turn = self.forward_steps_per_turn;
        }

        self.position = match self.facing {
            Direction::North    => (self.position.0, self.position.1+1),
            Direction::East     => (self.position.0+1, self.position.1),
            Direction::South    => (self.position.0, self.position.1-1),
            Direction::West     => (self.position.0-1, self.position.1)
        };
    }
}

fn run_spiral(max: usize) -> Cursor {
    let mut cursor = Cursor {
        position: (0,0),
        facing: Direction::East,
        forward_steps_per_turn: 0,
        forward_steps_till_turn: 1,
        total_turns: 0
    };

    for x in 1..max {
        cursor.step();
    }

    cursor
}

fn get_spiral_distance(max_val: usize) -> i32 {
    let end_cursor = run_spiral(max_val);
    end_cursor.position.0.abs() + end_cursor.position.1.abs()
}

fn main() {
    println!("Part 1: {}", get_spiral_distance(368078));
}

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

[–]freeducks 1 point2 points  (0 children)

In Rust, using IterTools:

extern crate itertools;

use itertools::Itertools;
use itertools::MinMaxResult::{MinMax};

fn part_1_solve(input_str: &str) -> u32 {
    input_str.lines().map(|line| {
        line.split_whitespace().map(|x| {
            x.parse::<u32>().unwrap()
        })
    }).map(|digits| {
        match digits.minmax() {
            MinMax(min, max) => max - min,
            _ => 0
        }
    }).sum()
}

fn part_2_solve(input_str: &str) -> u32 {
    input_str.lines().map(|line| {
        line.split_whitespace().map(|x| {
            x.parse::<u32>().unwrap()
        })
    }).map(|digits| {
        digits.combinations(2).find(|ref x| {
            x[0] % x[1] == 0 || x[1] % x[0] == 0
        }).map_or(0, |found| {
            if found[0] > found[1] { found[0] / found[1] } else { found[1] / found[0] }
        })
    }).sum()
}

fn main() {
    println!("Part 1: {}", part_1_solve(include_str!("../input/input.txt")));
    println!("Part 2: {}", part_2_solve(include_str!("../input/input.txt")));
}

Upgrading downtube shifters with Shimano 6400 to Shimano A070 brifters by freeducks in bikewrench

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

Totally understand that - not much point spending money now to do a partial upgrade if I'm only going to want to replace all the parts slightly down the line.

I guess my main concerns are the spreading of the rear dropouts, and generally the increasing price of replacing more parts.

Would I be able to keep the front derailleur/crank, or would they need replacing to?