If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
+/ (+./ 0 = 3 5 |/ i. 1000) # i. 1000
233168
#!/usr/bin/env awk -f | |
BEGIN { RS = ""; FS = "\n"; } | |
{ | |
for (i=1; i<=NF; i++) { | |
sum += $i | |
} | |
if (sum > max) { | |
max = sum |
[package] | |
name = "example" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
actix-web = "4.0" | |
anyhow = { version = "1.0", features = ["backtrace"] } | |
listenfd = "0.5" | |
log = "0.4" |
// Unix Domain Socket Peer Credentials | |
// | |
// This program demonstrates setting up a HTTP server over a Unix Domain Socket | |
// and subsequently obtaining connecting clients credentials. The credentials | |
// contain the User ID, Group ID, and Process ID of the incoming connection (as | |
// connections are made by some local system user as opposed to a network | |
// connection). | |
// | |
// This has interesting use cases around local process security. For example, | |
// a server listening on a Unix Domain Socket can choose to allow or reject |
let print_row row = | |
Array.map print_char row |> ignore; | |
print_newline () | |
let rule n = function | |
| ('_', '_', '_') -> if n land 0b00000001 = 0 then '_' else '*' | |
| ('_', '_', '*') -> if n land 0b00000010 = 0 then '_' else '*' | |
| ('_', '*', '_') -> if n land 0b00000100 = 0 then '_' else '*' | |
| ('_', '*', '*') -> if n land 0b00001000 = 0 then '_' else '*' |