This file contains 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
/// Tower equaliser: givern list of tower heights return the minimum number | |
/// of moves required to obtain tower of the same height or return "No solution" | |
fn towers(t: &[u32]) -> Option<u32> { | |
let mut moves: u32 = 0; | |
let mut n = t.to_vec(); | |
let max_moves: u32 = n.iter().sum(); | |
loop { | |
let imax = match n.iter().enumerate().max_by(|&(_, x), &(_, y)| x.cmp(&y)) { | |
Some((m, _)) => m, | |
_ => usize::MIN, |
This file contains 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
[package] | |
name = "rocket_reqw" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
rocket = "0.4" | |
serde = {version = "1", features = ["derive"]} |
This file contains 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
// Author: Ugo Varetto | |
// Implementation of task-based concurrency (similar to Java's Executor) | |
// and wrapper for concurrent access | |
// g++ task-based-executor-concurrent-generic.cpp -std=c++11 -pthread | |
#include <algorithm> | |
#include <chrono> | |
#include <condition_variable> | |
#include <cstdlib> //EXIT_* |
This file contains 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
let offset = 20000; | |
let chunk_size = 10000; | |
// File handle: | |
let mut handle = BufReader::new(File::open("data.bin").await?); | |
// Set cursor to needed chunk: | |
let mut chunk_stream = handle | |
.bytes() | |
.skip(offset) |
This file contains 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
#include <chrono> | |
#include <condition_variable> | |
#include <iostream> | |
#include <thread> | |
class Barrier { | |
public: | |
Barrier(uint32_t count) : threadCount(count), counter(0), waiting(0) {} | |
void wait() { |
This file contains 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
// Author: Ugo Varetto | |
// buffer allocation performance tests: vector, vector+pod allocator (same as | |
// vector), raw aligned buffer (faster) | |
#include <sys/mman.h> | |
#include <unistd.h> | |
#include <cstdlib> | |
#include <ctime> | |
#include <iostream> |
This file contains 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
/******************************************************************************* | |
* BSD 3-Clause License | |
* | |
* Copyright (c) 2020, Ugo Varetto | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* 1. Redistributions inputFile source code must retain the above copyright |
This file contains 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
/******************************************************************************* | |
* BSD 3-Clause License | |
* | |
* Copyright (c) 2020, Ugo Varetto | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* 1. Redistributions inputFile source code must retain the above copyright |
This file contains 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
CSIRO Open Source Software License Agreement (variation of the BSD / MIT License) | |
Copyright (c) 2016, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. | |
All rights reserved. CSIRO is willing to grant you a license to this tool named PSL:Proof Strategy Language on the following terms, except where otherwise indicated for third party material. | |
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | |
* Neither the name of CSIRO nor the names of its contributors may be used to endorse or promote products derived from this software without specific p |