lokeg
https://www.reddit.com/r/gamedev/comments/qeqn3b/despite_hav...
Essentially stating that Linux users disproportionately care to actually report bugs they encounter rather than ignoring them. I find that very plausible.
use bumpalo::Bump;
use std::io::Read;
fn main() {
let mut arena = Bump::new();
loop {
read_and_process_lines(&mut arena);
arena.reset();
}
}
#[derive(Debug)]
enum AstNode<'a> {
Leaf(&'a str),
Branch {
line: &'a str,
meta: usize,
cons: &'a mut AstNode<'a>
},
}
fn read_and_process_lines(arena: &Bump) {
let cap = 40;
let buf: &mut [u8] = arena.alloc_slice_fill_default(cap);
let l = std::io::stdin().lock().read(buf).expect("reading stdin");
let content: &str = str::from_utf8(&buf[..l]).unwrap();
dbg!(content);
let mut lines = content.lines();
let mut latest: &mut AstNode<'_> = arena.alloc(AstNode::Leaf(lines.next().unwrap()));
for line in lines {
latest = arena.alloc(AstNode::Branch{line, meta:0, cons: latest});
}
println!("{latest:?}");
}But implementing a comprehensive cap-and-trade system is superior to a fixed carbon price in that the it directly limits emissions without fiddling with the exact price (which instead is discovered by the market), and therefore can be planned long term.
(What should the carbon price be 2050? That depends on inflation and many other factors, but the allowed net emissions should clearly be zero or negative)
I recommend everyone to take a look at the EU ETS which unfortunately is surprisingly unknown
My point is, this would leave you in a really bad position if it turns out after 10 years nothing really happened
I would not call this trivial. The code in your post is incorrect. For example, it cannot find "ababc" within "abababc", since after the first mismatch we skip too much of the haystack.
The real solution to this is Knuth-Morris-Pratt, where we must precompute for every index in the needle the longest needle prefix that fits before it. I would not expect your average interviewee to derive or implement this.
An easier linear time solution (in my opinion) is rolling polynomial hashing. But if you actually expect solutions in an interview you should settle for the naive quadratic algorithm.
Rust Quiz
Apache Log4j RCE Zero Day
Almost always when I use python libraries I have to get used to a new documentation format, learn how to navigate it and so on. And then it has to be detailed enough to make up for the lack of type signatures. I cannot tell you how often I have to skim a significant portion of my dependencies' source just to use them. (Though there are counterexamples, stdlib and numpy in particular actually have okay docs)