好笑的是,雖然 using 語法來自 C# ,但用 Rust 的 lifetime 機制來解釋反而更清楚
- 至少一個有開啓 Replica Set 功能的 MongoDB instance
於 Docker 中搭建環境
本機須先安裝
mongosh
| localhost:~# fastfetch | |
| /\ root@localhost | |
| / \ --------------- | |
| / \ OS: postmarketOS edge aarch64 | |
| / \ Host: Apple iPhone X (GSM) | |
| / \ Kernel: Linux 7.0.12 | |
| / \ Uptime: 21 mins | |
| \ \ Packages: 760 (apk) | |
| /\ \____ \ Shell: bash 5.3.9 | |
| / \____ \ \ Display (Unknown-1): 1125x2346 in 27", 60 Hz |
| Types: deb | |
| URIs: https://havoc.app/ | |
| Suites: ./ | |
| Components: | |
| Types: deb | |
| URIs: https://repo.chariz.com/ | |
| Suites: ./ | |
| Components: |
| #![feature(portable_simd)] | |
| use rand::random; | |
| use std::{array::from_fn, simd::Simd, time::Instant}; | |
| #[inline] | |
| fn main() { | |
| let test: [f32; 64] = from_fn(|_| random()); | |
| let random_magic: f32 = random(); | |
| let test_2: [f32; 64] = [random_magic; 64]; | |
| println!("Data for test: {test:?}"); |
| #![feature(async_closure)] | |
| use futures_util::future::join_all; | |
| use std::{iter::zip, time::Duration}; | |
| use tokio::time::sleep; | |
| #[tokio::main] | |
| async fn main() { | |
| let ids = [1, 2, 3, 4]; | |
| let durations = [200, 100, 300, 250]; |
好笑的是,雖然 using 語法來自 C# ,但用 Rust 的 lifetime 機制來解釋反而更清楚
於 Docker 中搭建環境
本機須先安裝
mongosh
def part1(input: String) = {
val index = input
.toCharArray()
.sliding(4)
.zipWithIndex
.map((chars, i) => (chars, i + 4))
.find((chars, _) => chars.distinct.length == 4)def parseInput(input: String): List[ArrayBuffer[String]] = {
val result = List(
ArrayBuffer[String](),
ArrayBuffer[String](),
ArrayBuffer[String](),
ArrayBuffer[String](),
ArrayBuffer[String](),@main def main = {
part1(input)
}
def part1(input: String) = {
var count = 0;
input.linesIterator.foreach((line) => {@main def main = {
part1(input)
}
def part1(input: String) = {
val result = input.linesIterator.map((line) => {
val (first, second) = line.splitAt(line.length() / 2);