git bisect
, have to use --first-parent
for thatdef sum_calibration_values(calibration_document):
total_sum = 0
for line in calibration_document:
digits = [char for char in line if char.isdigit()]
if digits:
first_digit = digits[0]
last_digit = digits[-1]
two_digit_number = int(first_digit + last_digit)
total_sum += two_digit_number
return total_sum
# Example usage:
calibration_document = [
"1abc2",
"pqr3stu8vwx",
"a1b2c3d4e5f",
"treb7uchet"
]
result = sum_calibration_values(calibration_document)
print("Total sum of calibration values:", result)
let result = input.lines().fold(0u32, |acc, line| {
let indices: BTreeMap<_, _> = numbers
.keys()
.flat_map(|x| line.match_indices(*x))
.collect();
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
acc + first * 10 + last
});
let mut result = 0;
let mut indices = BTreeMap::new();
for line in input.lines() {
for x in numbers.keys() {
indices.extend(line.match_indices(x));
}
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
result += first * 10 + last;
indices.clear();
}
let result = input.lines().fold(0u32, |acc, line| {
let indices: BTreeMap<_, _> = numbers
.keys()
.flat_map(|x| line.match_indices(*x))
.collect();
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
acc + first * 10 + last
});
let mut result = 0;
let mut indices = BTreeMap::new();
for line in input.lines() {
for x in numbers.keys() {
indices.extend(line.match_indices(x));
}
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
result += first * 10 + last;
indices.clear();
}
puts("54277")
beat this one nerd let mut numbers = HashMap::with_capacity(18);
numbers.insert("one", 1);
numbers.insert("two", 2);
numbers.insert("three", 3);
numbers.insert("four", 4);
numbers.insert("five", 5);
numbers.insert("six", 6);
numbers.insert("seven", 7);
numbers.insert("eight", 8);
numbers.insert("nine", 9);
numbers.insert("1", 1);
numbers.insert("2", 2);
numbers.insert("3", 3);
numbers.insert("4", 4);
numbers.insert("5", 5);
numbers.insert("6", 6);
numbers.insert("7", 7);
numbers.insert("8", 8);
numbers.insert("9", 9);
use std::{
collections::{BTreeMap, HashMap},
error::Error,
};
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
fn main() -> Result<(), Box<dyn Error>> {
let input = std::fs::read_to_string("input.txt")?;
let mut numbers = HashMap::with_capacity(18);
numbers.insert("one", 1);
numbers.insert("two", 2);
numbers.insert("three", 3);
numbers.insert("four", 4);
numbers.insert("five", 5);
numbers.insert("six", 6);
numbers.insert("seven", 7);
numbers.insert("eight", 8);
numbers.insert("nine", 9);
numbers.insert("1", 1);
numbers.insert("2", 2);
numbers.insert("3", 3);
numbers.insert("4", 4);
numbers.insert("5", 5);
numbers.insert("6", 6);
numbers.insert("7", 7);
numbers.insert("8", 8);
numbers.insert("9", 9);
/*
let result = input.lines().fold(0u32, |acc, line| {
let indices: BTreeMap<_, _> = numbers
.keys()
.flat_map(|x| line.match_indices(*x))
.collect();
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
acc + first * 10 + last
});
*/
let mut result = 0;
let mut indices = BTreeMap::new();
for line in input.lines() {
for x in numbers.keys() {
indices.extend(line.match_indices(x));
}
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
result += first * 10 + last;
indices.clear();
}
println!("{result}");
Ok(())
}
let result = input.lines().fold(0u32, |acc, line| {
let indices: BTreeMap<_, _> = numbers
.keys()
.flat_map(|x| line.match_indices(*x))
.collect();
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
acc + first * 10 + last
});
let result: u32 = input.lines().par_bridge().fold(|| 0u32, |acc, line| {
let indices: BTreeMap<_, _> = numbers
.keys()
.flat_map(|x| line.match_indices(*x))
.collect();
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
first * 10 + last
}).sum();
let result: u32 = input.lines().par_bridge().map(|line| {
let indices: BTreeMap<_, _> = numbers
.keys()
.flat_map(|x| line.match_indices(*x))
.collect();
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
first * 10 + last
}).sum();
let result: u32 = input.lines().par_bridge().map(|line| {
let indices: BTreeMap<_, _> = numbers
.keys()
.flat_map(|x| line.match_indices(*x))
.collect();
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
first * 10 + last
}).sum();
let result: u32 = input.lines().par_bridge().map(|line| {
let indices: BTreeMap<_, _> = numbers
.keys()
.flat_map(|x| line.match_indices(*x))
.collect();
let first = numbers.get(indices.first_key_value().unwrap().1).unwrap();
let last = numbers.get(indices.last_key_value().unwrap().1).unwrap();
first * 10 + last
}).sum();
let result: i32 = input
.par_lines()
.map(|line| {
let matches = numbers.keys().map(|x| line.match_indices(x));
let m = matches.flatten().peekable();
let (min, max) = match m.minmax_by_key(|x| x.0) {
MinMaxResult::NoElements => todo!(),
MinMaxResult::OneElement(min) => (min, min),
MinMaxResult::MinMax(min, max) => (min, max),
};
let first = numbers.get(min.1).unwrap();
let last = numbers.get(max.1).unwrap();
first * 10 + last
})
.sum();
i wonder if that makes any difference at all[profile.release]
lto = true
codegen-units = 1
hyperfine -N -w 5 -r 10000 ./target/release/aoc
UUID=8E37-E91C /boot vfat defaults,noatime 0 2
UUID=6739c2cc-4a15-4a30-b223-bafcdff6688f / ext4 defaults,noatime 0 1
# sda1 is the 2tb ssd partition for linux
UUID=c598fbd0-b87c-4e69-9fb6-8b2fd0624f24 /data1 ext4 defaults,noatime 0 2
UUID=f0146921-8313-4099-bb81-7c87675cbbfe /data2 ext4 defaults,noatime 0 2
UUID=d2359c6c-99c0-4f4f-9225-5605bed37399 none swap sw 0 0
/dev/cdrom /mnt/cdrom auto noauto,user 0 0
tmpfs /tmp tmpfs rw,nosuid,noatime,nodev,size=16G,mode=1777 0 0
tmpfs /var/tmp/portage tmpfs size=14G,uid=portage,gid=portage,mode=775,nosuid,noatime,nodev 0 0
UUID=8E37-E91C /boot vfat defaults,noatime 0 2
UUID=6739c2cc-4a15-4a30-b223-bafcdff6688f / ext4 defaults,noatime 0 1
# sda1 is the 2tb ssd partition for linux
UUID=c598fbd0-b87c-4e69-9fb6-8b2fd0624f24 /data1 ext4 defaults,noatime 0 2
UUID=f0146921-8313-4099-bb81-7c87675cbbfe /data2 ext4 defaults,noatime 0 2
UUID=d2359c6c-99c0-4f4f-9225-5605bed37399 none swap sw 0 0
/dev/cdrom /mnt/cdrom auto noauto,user 0 0
tmpfs /tmp tmpfs rw,nosuid,noatime,nodev,size=16G,mode=1777 0 0
tmpfs /var/tmp/portage tmpfs size=14G,uid=portage,gid=portage,mode=775,nosuid,noatime,nodev 0 0
cc -O3
I didn't think much about itget1()
function doesn't actually check for buffer overflow: it checks for bufsz > 0
but bufsz doesn't get updated. I'd change the while-loop line to while ((c = getc(f)) != EOF && c != '\n' && bufsz-- > 1)
get1()
function doesn't actually check for buffer overflow: it checks for bufsz > 0
but bufsz doesn't get updated. I'd change the while-loop line to while ((c = getc(f)) != EOF && c != '\n' && bufsz-- > 1)
fn some_helper_function(haystack: &str) -> bool {
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"...").unwrap());
RE.is_match(haystack)
}
use {
once_cell::sync::Lazy,
regex::Regex,
};
windows_wide_to_utf8
function now returns an std::optional
, which will be empty if the argument contains invalid UTF-16. Files/folders with names containing invalid UTF-16 are now ignored on Windows. It was previously not possible to use these files either, as converting their names to UTF-8 changed the invalid codepoints to unicode replacement characters.
The `windows...record a; record a
The assert seems a bit strict since a small human error of starting a demo twice results in the server shutting down.
https://github.com/ddnet/ddnet/blob/eba86204db87db93c67f2851a1f44c5428b36960/src/engine/shared/demo.cpp#L53
Maybe the assert should be turned into a warning instead or the "record" command should abort if a demo is already running.rust
uname -a
Linux me-GF65-Thin-10UE 6.2.0-37-generic #38~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 2 18:01:13 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
I just pulled the 17.4 version. And when i press Q
or P
spec mode. There are no tees (me included). But sometimes they are spuriously appears for a short amount of time.
I checked out back to 17.3 all works fine.
I could provide more info if you ask me :) ../DDNet-Server "record a; record a"
)
8b589f3
Check for invalid unicode in filenames etc. on Windows - Robyt3
0e684e1
Added check if demo recorder is already active. Closes #7568. - BurnyLlama
d452372
Merge pull request #7567 from Robyt3/Windows-Ignore-Invalid-UTF16 - def-
0184745
Merge pull request #7571 from BurnyLlama/fix-demo-record - def-