- Ubuntu 14.04, 16.04, or 16.10
- Open up terminal
- Install core deps:
sudo apt-get install clang libicu-dev git
public protocol RandomSource { | |
static var shared: RandomSource { get } | |
func next<T : FixedWidthInteger>(_ type: T.Type) -> T | |
func nextUniform<T : BinaryFloatingPoint>(_ type: T.Type) -> T | |
} | |
// Utilizes /dev/urandom | |
public class DevRandom: RandomSource { | |
public static let shared = DevRandom() | |
import Darwin | |
public protocol RandomGenerator { | |
func next<T : FixedWidthInteger>(_ type: T.Type) -> T | |
func next<T : FixedWidthInteger>(_ type: T.Type, upperBound: T) -> T | |
} | |
public enum Random : RandomGenerator { | |
case `default` | |
struct Date : Randomizable, Strideable { | |
typealias Stride = Int | |
let timestamp: UInt32 | |
static func random<T: RandomNumberGenerator>(using generator: T) -> Date { | |
return Date(timestamp: (0 ... UInt32.max).random!) | |
} | |
func distance(to other: Date) -> Int { |
#include <iostream> | |
#include <string> | |
int solve_capcha(int *ptr, int size) { | |
int tmp = 0; | |
for (int i = 0; i < size; i++) { | |
int index = i - 1; | |
if (i == 0) { | |
index = size - 1; |
This proposal aims to add a new method, fillBuffer(_:)
, to RandomNumberGenerator
, and aims to move an already defaulted method into a requirement.
Hello Evolution,
I want to discuss where we are with the current memberwise initializer for structures and where I wish to see this initializer evolve.
Refer to SE-0018 and SE-0018 Rationale. I do not speak for the author here, but I'm rathering pulling ideas and references from SE-0018 to formulate this post.
// Part one | |
let input = """ | |
""" | |
print(input.split(separator: "\n").map { | |
Int($0)! | |
}.reduce(0, +)) | |
// Part Two |
// macOS x86_64 syscall works as follows: | |
// Syscall id is moved into rax | |
// 1st argument is moved into rdi | |
// 2nd argument is moved into rsi | |
// 3rd argument is moved into rdx | |
// ... plus some more | |
// Return value is stored in rax (where we put syscall value) | |
// Mac syscall enum that contains the value to correctly call it | |
enum Syscall: Int { |