Skip to content

Instantly share code, notes, and snippets.

var count = 10;
var numAnts = 3;
var randomAntIndex = [3, 6, 9];
var alpha = 1.0;
var beta = 5.0;
var Q = 100;
var V = 0.01;
var randomFactor = 0.07;
var count = 10;
var numAnts = 5;
var randomAntIndex = [1, 2, 3, 6, 9];
var alpha = 1.0;
var beta = 5.0;
var Q = 100;
var V = 0.01
var cities = [];
@halitanildonmez
halitanildonmez / sol.java
Last active March 26, 2024 21:07
Another implementation for fast file reading
private static void readFile() throws IOException {
List<StartEndRecord> records = new ArrayList<>();
long numberOfChunks = 3l;
try (RandomAccessFile file = new RandomAccessFile(TEST_FILE_PATH, "r")) {
FileChannel channel = file.getChannel();
long fileSize = channel.size();
MemorySegment map = channel.map(FileChannel.MapMode.READ_ONLY, 0, fileSize, Arena.global());
long start = 0;
long chunkSize = fileSize / numberOfChunks;
@halitanildonmez
halitanildonmez / FastFileReader.java
Last active March 26, 2024 19:55
A file reader that reads the large file to memory
private static final Unsafe UNSAFE = initUnsafe();
private static Unsafe initUnsafe() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
return (Unsafe) theUnsafe.get(Unsafe.class);
}
catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
@halitanildonmez
halitanildonmez / sol.py
Created December 15, 2022 04:43
Advent of Code 2020 day 16 all
import math
import collections
import itertools
import re
import ast
import functools
import numpy as np
from collections import defaultdict
T = "bb.txt"
@halitanildonmez
halitanildonmez / sol.py
Created December 14, 2022 17:24
Advent of Code 2020 day 16
import math
import collections
import itertools
import re
import ast
import functools
import numpy as np
from collections import defaultdict
T = "bb.txt"
@halitanildonmez
halitanildonmez / sol.py
Created December 13, 2022 16:06
Advent of Code 2020 day 15
import math
import collections
import itertools
import re
import ast
import functools
T = "bb.txt"
M = "aa.txt"
@halitanildonmez
halitanildonmez / sol.py
Created December 12, 2022 15:57
Advent of Code 2020 day 14 pt1,2
import math
import collections
import itertools
T = "bb.txt"
M = "aa.txt"
file1 = open(M, 'r')
Lines = file1.read().splitlines()
@halitanildonmez
halitanildonmez / sol.py
Created December 12, 2022 09:36
Advent of Code 2020 day 13 pt1,2
import math
import collections
T = "bb.txt"
M = "aa.txt"
file1 = open(M, 'r')
Lines = file1.read().splitlines()
input_grid = []
@halitanildonmez
halitanildonmez / aoc2020-day12-pt2.py
Created December 11, 2022 16:00
Advent of Code 2020 day 12 pt 2
import math
T = "bb.txt"
M = "aa.txt"
file1 = open(M, 'r')
Lines = file1.read().splitlines()
sx, sy = 0, 0
wx, wy = 10, 1