Skip to content

Instantly share code, notes, and snippets.

@Trard
Trard / hello.rs
Last active September 9, 2022 21:41
Hello world
#![no_main]
extern {
fn puts(src: *const i8) -> i32;
fn getchar() -> *const i8;
}
#[no_mangle]
unsafe extern fn main(argc: isize, argv: *const *const u8) -> isize {
puts("Hello, World!\0".as_ptr() as *const i8);
@Trard
Trard / .Rust gold gists
Last active September 11, 2022 16:52
Rust gold gists
Rust gold gists
@Trard
Trard / amazon_challenge.rs
Last active September 15, 2022 20:08
https://www.youtube.com/watch?v=JtMuXmmDl9s. I coded it myself without any hints.
use std::cmp;
pub fn find_pairs(numbers: &[i32], k: i32) -> Option<(i32, i32)> {
let math_mid = numbers.len()/2;
let mut large_numbers = numbers[math_mid as usize..].iter();
let mut small_numbers = numbers[..math_mid as usize].iter().rev();
let mut small_numbers_to_larger = large_numbers.clone();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.