This file contains hidden or 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
def partition(partition_count, id_range): | |
""" | |
Partitions an integer range into partition_count partitions of uniform size. | |
id_range specifies the integer range to partition (a tuple (from, to)). | |
""" | |
partition_size = ceil((id_range[1] - id_range[0]) / partition_count) + 1 | |
for x in range(0, partition_count): | |
from_ = int(x * partition_size) + id_range[0] | |
to = min(int(from_ + partition_size - 1), id_range[1]) | |
yield (from_, to) |
This file contains hidden or 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
public class ArrayToIntUtil { | |
public static int a2i(int... a) { | |
int result = 0; | |
int f = (int) Math.pow(10, a.length); | |
for (int i : a) result += i * (f /= 10); | |
return result; | |
} | |
public static void main(String... args) { |
NewerOlder