This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* file.h: */ | |
| char thisIsAMethod(int arg1, char *arg2); | |
| /* file.c: */ | |
| char thisIsAMethod(int arg1, char *arg2) | |
| { | |
| return arg2[arg1]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const char _buf[64] = { 0x02, 0x0b, 0x02, 0x04, 0x42, 0x40, 0x10, 0x42, | |
| 0x62, 0x10, 0x42, 0x42, 0x03, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn sum(vector: Vec<i32>) -> i32 { | |
| let mut sum = 0; | |
| for item in vector { | |
| sum = sum + item | |
| } | |
| sum | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn sum(vector: &Vec<i32>) -> i32 { | |
| let mut sum = 0; | |
| // vector.iter_mut().map(|e| e.add(1)); | |
| // ERROR: cannot borrow `*vector` as mutable, as it is behind a `&` reference | |
| for item in vector { | |
| sum = sum + item | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn sum(vector: &mut Vec<i32>) -> i32 { | |
| let mut sum = 0; | |
| vector.iter_mut().map(|e| e.add(1)); | |
| for item in vector { | |
| sum = sum + *item | |
| } | |
| sum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @group(0) @binding(0) var<storage, read_write> moon_height_data: MoonHeightData; | |
| fn smooth_min(a: f32, b: f32, t: f32) -> f32 { | |
| let h: f32 = clamp(0.5 + 0.5 * (b - a) / t, 0.0, 1.0); | |
| return mix(b, a, h) - t * h * (1.0 - h); | |
| } | |
| fn smooth_max(a: f32, b: f32, t: f32) -> f32 { | |
| return smooth_min(a, b, -t); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn find_side_digit(digits: &[&str], line: &str, left: bool) -> usize { | |
| let map = digits.iter().enumerate().flat_map(|(i, d)| { | |
| if left { | |
| if let Some(min_index) = line.find(d) { | |
| Some((min_index, i % 9 + 1)) | |
| } else { | |
| None | |
| } | |
| } else { | |
| if let Some(max_index) = line.rfind(d) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn compute_result(input: &str) -> u32 { | |
| input | |
| .replace(char::is_alphabetic, "") | |
| .lines() | |
| .map(|l| { | |
| let mut iter = l.chars().flat_map(|c| char::to_digit(c, 10)).peekable(); | |
| let first = *iter.peek().expect("no first numerical character"); | |
| let last = iter.last().expect("no last numerical character"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Game { | |
| game_index: i32, | |
| subsets: Vec<(i32, i32, i32)>, | |
| } | |
| impl TryFrom<&str> for Game { | |
| type Error = anyhow::Error; | |
| fn try_from(value: &str) -> Result<Self, Self::Error> { | |
| let mut subsets = vec![]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn process_input(input: &str) -> Vec<Vec<char>> { | |
| input | |
| .trim_end() | |
| .lines() | |
| .map(|l| l.chars().collect()) | |
| .collect() | |
| } | |
| fn is_symbol(c: char) -> bool { | |
| !c.is_alphanumeric() && c != '.' |
OlderNewer