Skip to content

Commit

Permalink
Update Dockerfile and .gitpod.yml, add timestamp to PairSum.java
Browse files Browse the repository at this point in the history
  • Loading branch information
faermanj committed Jan 29, 2024
1 parent c588326 commit 2e66e5e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# docker build -f .gitpod.Dockerfile .
FROM gitpod/workspace-full

USER root
RUN bash -c "sudo install-packages mysql-client"
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh && sdk install java 22.1.0.r17-grl && sdk default java 22.1.0.r17-grl && gu install native-image && sdk install quarkus"

USER gitpod
RUN bash -c "brew install hurl"

ARG JAVA_SDK="21.0.2-amzn"
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \
&& sdk install java $JAVA_SDK \
&& sdk default java $JAVA_SDK \
&& sdk install quarkus"

RUN bash -c "curl 'https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip' -o 'awscliv2.zip' && unzip awscliv2.zip && sudo ./aws/install"
RUN bash -c "npm install -g aws-cdk"
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ image:
file: .gitpod.Dockerfile

tasks:
- init: ./mvnw install -DskipTests=true
- init: ./mvnw install -fn -B -ntp && java -version
command: echo "Welcome to JavaInterviews on GitPod"
29 changes: 29 additions & 0 deletions src/main/java/cloud/caravana/algo/pairsum/PairSum.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

import static cloud.caravana.Util.*;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Random;
import java.util.function.BiFunction;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -75,4 +81,27 @@ public static Integer[] tunnelPairSum(Integer[] xs, Integer target) {
var result = tunnelTwoNumberSum(_xs, target);
return intsToIntegers(result);
}

static final DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm:ss.SSS");
public static void main(String[] args) {
var xs = new Random()
.ints(50_000_000, 0, 100000)
.boxed()
.toArray(Integer[]::new);
var target = 1337;
timestamp("Initial: ");
var result = iterPairSum(xs, target);
System.out.println(Arrays.toString(result));
timestamp("Iterative: ");
result = memoPairSum(xs, target);
System.out.println(Arrays.toString(result));
timestamp("Memoized: ");
result = tunnelPairSum(xs, target);
System.out.println(Arrays.toString(result));
timestamp("Tunnel:");
}

private static void timestamp(String msg) {
System.out.println(msg + LocalDateTime.now().format(df));
}
}

0 comments on commit 2e66e5e

Please sign in to comment.