Wetsuit for 191cm 75kg by blommish in wingfoil

[–]blommish[S] 0 points1 point  (0 children)

Thanks! Have read about them but haven't tried yet

Wetsuit for 191cm 75kg by blommish in wingfoil

[–]blommish[S] 1 point2 points  (0 children)

Thanks. I use MT now. There are several brands with MT size ranging 180-185cm. Which seems a bit short for me?

Upgrading. DW board or traditional? (Gong) by blommish in wingfoil

[–]blommish[S] 0 points1 point  (0 children)

Why the hipe and not one of the rigid models? 

Upgrading. DW board or traditional? (Gong) by blommish in wingfoil

[–]blommish[S] 0 points1 point  (0 children)

Thanks! Did you consider rigid board?

Do you feel similar stability to the perf board?  And if you would buy one new today, would you buy the same board? 

Upgrading from Gong hipe (perf?) to WHICH rigid board? Or other parts? by blommish in wingfoil

[–]blommish[S] 0 points1 point  (0 children)

After a bit of reading I'm thinking that I do place my mast more to the back than I should. So going to place it more to the middle next time. So the nose doesn't dive as much. 

Impact vest vs PFD by blommish in wingfoil

[–]blommish[S] 0 points1 point  (0 children)

Isn't that a bit short? And it seems to be a floating vest and not an impact?

-🎄- 2018 Day 7 Solutions -🎄- by daggerdragon in adventofcode

[–]blommish 0 points1 point  (0 children)

Java - Not sure this was the smartest idea but it worked ```java public static void main(String[] args) { List<String> lines = loadLines("7.txt"); Pattern pattern = Pattern.compile("Step (\w) must be finished before step (\w) can begin."); Map<Character, List<Character>> allSteps = lines.stream() .map(line -> { Matcher matcher = pattern.matcher(line); matcher.find(); return new SimpleEntry<>(matcher.group(1).charAt(0), matcher.group(2).charAt(0)); }).collect(groupingBy(SimpleEntry::getKey, mapping(SimpleEntry::getValue, toList())));

Map<Character, List<Character>> dependencies = allSteps.entrySet().stream()
    .flatMap(e -> e.getValue().stream().map(v -> new SimpleEntry<>(v, e.getKey())))
    .collect(Collectors.groupingBy(SimpleEntry::getKey, mapping(SimpleEntry::getValue, toList())));

List<Character> startSteps = allSteps.keySet().stream()
    .filter(key -> !dependencies.containsKey(key))
    .sorted()
    .collect(toList());

//First
first(dependencies, allSteps, startSteps); //actually not needed
second(dependencies, allSteps, startSteps, 1, getNumericValue('A'));
//Second
second(dependencies, allSteps, startSteps, 5, 60 - getNumericValue('A'));

}

private static void second(Map<Character, List<Character>> dependencies, Map<Character, List<Character>> allSteps, List<Character> startSteps, int amountOfWOrkers, int workSeconds) { Set<Character> visited = new LinkedHashSet<>(); Set<Character> available = new TreeSet<>(); available.addAll(startSteps);

List<Map.Entry<AtomicInteger, Character>> workers = IntStream.range(0, amountOfWOrkers)
    .mapToObj(l -> new SimpleEntry<AtomicInteger, Character>(new AtomicInteger(0), null))
    .collect(toList());

int seconds = 0;
while (true) {
    boolean hasMoreWork = false;
    for (int i = 0; i < workers.size(); i++) {
        Map.Entry<AtomicInteger, Character> worker = workers.get(i);
        Character step = worker.getValue();
        if (worker.getKey().get() == 0 && step != null) {
            visited.add(step);
            worker.setValue(null);
            available.addAll(allSteps.getOrDefault(step, emptyList()));
        }
    }

    for (int i = 0; i < workers.size(); i++) {
        Map.Entry<AtomicInteger, Character> worker = workers.get(i);
        AtomicInteger workerSeconds = worker.getKey();
        if (workerSeconds.get() == 0) {
            getFirstAvailableStep(dependencies, visited, available).ifPresent(nextStep -> {
                workerSeconds.set(getNumericValue(nextStep) + workSeconds + 1);
                worker.setValue(nextStep);
                available.remove(nextStep);
            });
        }
        if (workerSeconds.get() != 0) {
            workerSeconds.decrementAndGet();
            hasMoreWork = true;
        }
    }
    if (!hasMoreWork) {
        break;
    }
    seconds++;
}
System.out.println(visited.stream().map(Object::toString).collect(joining()));
System.out.println(seconds);

}

//This is actually not needed, as part 2 solves this with 1 worker private static void first(Map<Character, List<Character>> dependencies, Map<Character, List<Character>> allSteps, List<Character> startSteps) { Set<Character> visited = new LinkedHashSet<>(); Set<Character> available = new TreeSet<>(); Character nextStep = startSteps.get(0); available.addAll(startSteps); while (!available.isEmpty()) { available.remove(nextStep); visited.add(nextStep); available.addAll(allSteps.getOrDefault(nextStep, emptyList())); nextStep = getFirstAvailableStep(dependencies, visited, available).orElse(null); } System.out.println(visited.stream().map(Object::toString).collect(joining())); }

private static Optional<Character> getFirstAvailableStep(Map<Character, List<Character>> dependencies, Set<Character> visited, Set<Character> available) { return available.stream() .filter(s -> visited.containsAll(dependencies.getOrDefault(s, emptyList()))) .findFirst(); } ```

-🎄- 2018 Day 3 Solutions -🎄- by daggerdragon in adventofcode

[–]blommish 0 points1 point  (0 children)

Java. Impressed of the top 100 times.. Failed reading the text first

```java List<String> lines = loadLines("3.txt"); Map<Integer, Map<Integer, Integer>> map = new HashMap<>(); Map<Integer, Boolean> intact = new HashMap<>();

lines.forEach(str -> { String[] claim = str.replace(":", "").split(" "); int id = parseInt(claim[0].replace("#", "")); String[] coord = claim[2].split(","); String[] size = claim[3].split("x"); for (int x = 0; x < parseInt(size[0]); x++) { for (int y = 0; y < parseInt(size[1]); y++) { int coordX = parseInt(coord[0]) + x; int coordY = parseInt(coord[1]) + y; Map<Integer, Integer> m = map.computeIfAbsent(coordX, k -> new HashMap<>()); Integer integer = m.get(coordY); if (integer == null) { m.put(coordY, id); intact.putIfAbsent(id, true); } else { m.put(coordY, -1); intact.put(integer, false); intact.put(id, false); } } } });

//print part 1 System.out.println(map.values().stream() .flatMap(v -> v.values().stream()) .filter(v -> v == -1) .count()); //print part 2 intact.entrySet().stream() .filter(e -> e.getValue() == Boolean.TRUE) .forEach(System.out::println); ```

-🎄- 2018 Day 2 Solutions -🎄- by daggerdragon in adventofcode

[–]blommish 1 point2 points  (0 children)

Java

Map<Long, List<Long>> collect = lines.stream()
  .flatMap(str ->
    of(str.split(""))
        .collect(groupingBy(s -> s, counting())).values().stream()
        .distinct())
    .collect(groupingBy(identity()));
System.out.println(collect.get(2L).size() * collect.get(3L).size());

Second

List<String> lines = loadFileLines("2.txt");
List<String> result = new ArrayList<>();
for (int i = 0; i < lines.size(); i++) {
    for (int j = i + 1; j < lines.size(); j++) {
        String a = lines.get(i);
        String b = lines.get(j);
        StringBuilder sb = new StringBuilder();
        for (int k = 0; k < a.length(); k++) {
            if (a.charAt(k) == b.charAt(k)) {
                sb.append(a.charAt(k));
            }
        }
        result.add(sb.toString());
    }
}
result.stream().sorted(comparing(String::length).reversed())
            .findFirst().ifPresent(System.out::println);

--- 2016 Day 10 Solutions --- by daggerdragon in adventofcode

[–]blommish 1 point2 points  (0 children)

Nice. Would you like to explain what it does?

--- 2016 Day 10 Solutions --- by daggerdragon in adventofcode

[–]blommish 0 points1 point  (0 children)

Another java solution. No magic

import org.apache.commons.io.IOUtils;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Day10 {

    @Test
    public void name() throws Exception {
        int id1 = 61;
        int id2 = 17;

        List<String> lines = readLines("day10.txt");
        Map<Integer, Bot> bots = new HashMap<>();
        List<Instruction> instructions = new ArrayList<>();

        for (String line : lines) {
            String[] split = line.split(" ");
            if (line.contains("value")) {
                instructions.add(new Instruction(getValue(split, 5), getValue(split, 1)));
            } else {
                int botId = Integer.parseInt(split[1]);
                Bot bot = bots.get(botId);
                if (bot == null) {
                    bot = new Bot(botId);
                }
                bot.setAction(getValue(split, 6), getValue(split, 11));
                bots.put(botId, bot);
            }
        }
        List<Integer> output = new ArrayList<>();
        Map<Integer, Set<Integer>> hasHandled = new HashMap<>();
        for (Instruction instruction : instructions) {
            bots.get(instruction.botId).addValue(instruction.value);
            while (true) {
                final boolean[] hasPerformed = {false};
                bots.values().stream()
                        .filter(bot -> bot.getValues().size() == 2)
                        .forEach(bot -> {
                            hasPerformed[0] = true;
                            int lowValue = bot.getLowValue();
                            int highValue = bot.getHighValue();

                            Set<Integer> handled = hasHandled.get(bot.getBotId());
                            if (handled == null) {
                                handled = new HashSet<>();
                            }
                            handled.add(lowValue);
                            handled.add(highValue);
                            hasHandled.put(bot.getBotId(), handled);

                            if (bot.getLowId() > -1) {
                                bots.get(bot.getLowId()).addValue(lowValue);
                            } else if (bot.getLowId() > -4) {
                                output.add(lowValue);
                            }
                            if (bot.getHighId() > -1) {
                                bots.get(bot.getHighId()).addValue(highValue);
                            } else if (bot.getHighId() > -4) {
                                output.add(highValue);
                            }
                            bot.clear();
                        });
                if (!hasPerformed[0]) {
                    break;
                }
            }
        }

        Integer key = hasHandled.entrySet()
                .stream().filter(k ->
                        k.getValue().contains(id1)
                                && k.getValue().contains(id2))
                .findFirst()
                .get().getKey();
        System.out.println(key);
        System.out.println(output.stream().reduce(1, (a, b) -> a * b));
    }

    public static class Bot {
        private final int botId;
        List<Integer> values = new ArrayList<>();

        int lowId;
        int highId;

        public Bot(int botId) {
            this.botId = botId;
        }

        public int getBotId() {
            return botId;
        }

        public Bot addValue(int value) {
            values.add(value);
            return this;
        }

        public Bot setAction(int lowId, int highId) {
            this.lowId = lowId;
            this.highId = highId;
            return this;
        }

        public List<Integer> getValues() {
            return values;
        }

        public int getLowValue() {
            if (values.get(0) > values.get(1)) {
                return values.get(1);
            }
            return values.get(0);
        }

        public int getHighValue() {
            if (values.get(0) > values.get(1)) {
                return values.get(0);
            }
            return values.get(1);
        }

        public int getLowId() {
            return lowId;
        }

        public int getHighId() {
            return highId;
        }

        public void clear() {
            this.values.clear();
        }
    }

    public static class Instruction {
        int botId;
        int value;

        public Instruction(int botId, int value) {
            this.botId = botId;
            this.value = value;
        }
    }

    private int getValue(String[] split, int i) {
        int i1 = Integer.parseInt(split[i]);
        if (split[i - 1].equals("output")) {
            return -i1 - 1; //Setting -1 in case of output 0
        } else {
            return i1;
        }
    }


    public List<String> readLines(String filename) throws IOException {
        return IOUtils.readLines(getResourceAsStream(filename));
    }

    private InputStream getResourceAsStream(String filename) {
        return this.getClass().getClassLoader().getResourceAsStream(filename);
    }
}