Skip to content

Instantly share code, notes, and snippets.

View KamilaBorowska's full-sized avatar

Kamila Borowska KamilaBorowska

View GitHub Profile
#[macro_use]
extern crate cpp;
cpp! {{
#include <numeric>
#include <vector>
}}
fn main() {
let y = 3;
import java.util.Arrays;
public class Sorting {
private final static int[] runLengths = new int[]{
76405736, 74830360, 1181532, 787688, 1575376, 2363064, 3938440, 6301504,
1181532, 393844, 15753760, 1575376, 787688, 393844, 1969220, 3150752, 1181532, 787688, 5513816, 3938440,
1181532, 787688, 1575376, 18116824, 1181532, 787688, 1575376, 2363064, 3938440, 787688, 26781392, 1181532,
787688, 1575376, 2363064, 393844, 4332284, 1181532, 787688, 1575376, 12209164, 1181532, 787688, 1575376,
2363064, 787688, 393844, 4726128, 1575376, 787688, 1969220, 76405758, 53168940, 1181532, 787688, 1575376,
2363064, 3938440, 1575376, 787688, 393844, 10633788, 1181532, 787688, 1575376, 2363064, 4332284, 1181532,
struct X {
int x[100];
};
X hi() {
return {0};
}
import java.util.List;
public class Main {
public static void main(String[] args) {
apply(List.of(5, 5.0));
}
static <T extends Number & Comparable<? extends U>, U extends Number & Comparable<? extends V>, V extends Number & Comparable<? extends W>, W extends Number & Comparable<?>> void apply(List<T> value) {
}
}

I'm surprised that everyone in this question claims that std::cout is way better than printf, even if the question just asked for differences. Now, there is a difference - std::cout is C++, and printf is C (however, you can use it in C++, just like almost anything else from C). Now, I'll be honest here; both printf and std::cout have their advantages.

Disclaimer: I'm more experienced with C than C++, so if there is a problem with my answer, feel free to edit or comment.

Real differences

Extensibility

import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Objects;
import java.util.function.IntConsumer;
public class Lambdas {
private static <F, T> F createLambda(
Level Difficulty
Classic World 1-1 ★☆☆☆☆
Classic World 1-2 ★★☆☆☆
Classic World 1-3 ★☆☆☆☆
Classic World 1-4 ★★☆☆☆
Classic World 2-2 ★★☆☆☆
Wild Ride in the Sky ★★★☆☆
Slidin' the Slopes ★★☆☆☆
Vegetable Volley ★★☆☆☆
Doors o' Plenty ★★★★☆
use List::Util qw(max min);
my %x;
sub print_biggest {
print max(values %x);
}
$x{oui} += 550 if $x{p} <= 3;print_biggest;
$x{abh} += -189 if $x{g} == 0;print_biggest;
$x{kq} += 164 if $x{znl} != 7;print_biggest;
$x{kq} -= 827 if $x{oui} == 550;print_biggest;
$x{z} += 469 if $x{znl} != -9;print_biggest;
>>> def a(b=[]):
... return b
...
>>> x = a()
>>> y = a()
>>> x
[]
>>> y
[]
>>> x.append(3)
@KamilaBorowska
KamilaBorowska / bf.rs
Last active November 5, 2017 21:09
Compile time Brainfuck evaluation
// Did you ever want to have a compile-time evaluated string and didn't
// want to use so called "procedural macros" because it's too easy to
// have that with those? Well, now you can.
//
// ... Oh, right, there is a small catch. The computation has to be in
// Brainfuck. But I mean, it's Turing complete, so you can do any
// computation you like, so it's not a big deal, is it?
//
// Scroll down to the end to see usage, but essentially this file
// defines `bf!` macro to which you can pass whatever Brainfuck code