Carter
Carter
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by Trzech Polaków w teamie? on 10/30/2024 in #java-help
How to find the biggest island in the file
can you send the original problem?
7 replies
JCHJava Community | Help. Code. Learn.
Created by Trzech Polaków w teamie? on 10/30/2024 in #java-help
How to find the biggest island in the file
public static int findLargestIsland(int x, int y) {

if (x < 0 x >= columnsAmount y < 0 y >= rowsAmount map[x][y] != 'x') {
return 0;
}


map[x][y] = '?';

int size = 1;


size += findLargestIsland(x - 1, y);
size += findLargestIsland(x + 1, y);
size += findLargestIsland(x, y - 1);
size += findLargestIsland(x, y + 1);
size += findLargestIsland(x - 1, y - 1);
size += findLargestIsland(x - 1, y + 1);
size += findLargestIsland(x + 1, y - 1);
size += findLargestIsland(x + 1, y + 1);

return size;
}


public static int findLargestIslandInMap() {
int largestIsland = 0;

for (int i = 0; i < columnsAmount; i++) {
for (int j = 0; j < rowsAmount; j++) {
if (map[i][j] == 'x') {
int currentIslandSize = findLargestIsland(i, j);
largestIsland = Math.max(largestIsland, currentIslandSize);
}
}
}

return largestIsland;
}
public static int findLargestIsland(int x, int y) {

if (x < 0 x >= columnsAmount y < 0 y >= rowsAmount map[x][y] != 'x') {
return 0;
}


map[x][y] = '?';

int size = 1;


size += findLargestIsland(x - 1, y);
size += findLargestIsland(x + 1, y);
size += findLargestIsland(x, y - 1);
size += findLargestIsland(x, y + 1);
size += findLargestIsland(x - 1, y - 1);
size += findLargestIsland(x - 1, y + 1);
size += findLargestIsland(x + 1, y - 1);
size += findLargestIsland(x + 1, y + 1);

return size;
}


public static int findLargestIslandInMap() {
int largestIsland = 0;

for (int i = 0; i < columnsAmount; i++) {
for (int j = 0; j < rowsAmount; j++) {
if (map[i][j] == 'x') {
int currentIslandSize = findLargestIsland(i, j);
largestIsland = Math.max(largestIsland, currentIslandSize);
}
}
}

return largestIsland;
}
7 replies
JCHJava Community | Help. Code. Learn.
Created by OMIDD on 10/11/2024 in #java-help
recursion
if you don't understand recursion, I would try to visualize the call stack of a java program. When you call methods inside methods, the context of the original method is saved in a stack data structure. When a recently called method returns, it's popped off the stack. There is nothing special about recursion, it's just calling a method and that method call happens to be in the same method called.
13 replies
JCHJava Community | Help. Code. Learn.
Created by rainymc_ on 9/15/2024 in #java-help
No response.
it should be scanner.nextDouble() you're calling scanner.next()
21 replies
JCHJava Community | Help. Code. Learn.
Created by rainymc_ on 9/15/2024 in #java-help
No response.
look up how to take in a Double
21 replies
SSolidJS
Created by Carter on 7/30/2024 in #support
How can I publish to github pages?
can I deploy to github with ssr turned off?
4 replies
SSolidJS
Created by Carter on 7/29/2024 in #support
How can i run some dom manip before rendering?
thank youuu
10 replies
SSolidJS
Created by Carter on 7/29/2024 in #support
How can i run some dom manip before rendering?
holy cow it works
10 replies
SSolidJS
Created by Carter on 7/29/2024 in #support
How can i run some dom manip before rendering?
idk how to do that
10 replies
SSolidJS
Created by Carter on 7/29/2024 in #support
How can i run some dom manip before rendering?
can you help me make it client only?
10 replies
SSolidJS
Created by Carter on 7/29/2024 in #support
How can i run some dom manip before rendering?
basically I have a localStorage value that determines if the site will be dark or light themed, but for some reason this code runs after it has already rendered leading to a flickering effect.
10 replies
SSolidJS
Created by Carter on 7/29/2024 in #support
How can i run some dom manip before rendering?
// @refresh reload
//
import { mount, StartClient } from "@solidjs/start/client";
const theme = JSON.parse(localStorage.getItem("theme")!!)
if (theme) {
document.body.classList.add("dark")
} else {
document.body.classList.remove("dark")
}
mount(() => <StartClient />, document.getElementById("app")!);
// @refresh reload
//
import { mount, StartClient } from "@solidjs/start/client";
const theme = JSON.parse(localStorage.getItem("theme")!!)
if (theme) {
document.body.classList.add("dark")
} else {
document.body.classList.remove("dark")
}
mount(() => <StartClient />, document.getElementById("app")!);
10 replies
SSolidJS
Created by Carter on 7/27/2024 in #support
How can I persist state across page refreshes?
I see scripts assets and children where are scripts and assets located at?
47 replies
SSolidJS
Created by Carter on 7/27/2024 in #support
How can I persist state across page refreshes?
No description
47 replies
SSolidJS
Created by Carter on 7/27/2024 in #support
How can I persist state across page refreshes?
thank you so much that worked
47 replies
SSolidJS
Created by Carter on 7/27/2024 in #support
How can I persist state across page refreshes?
okay
47 replies
SSolidJS
Created by Carter on 7/27/2024 in #support
How can I persist state across page refreshes?
the issue is createEffect is called at the beginning once as well
47 replies
SSolidJS
Created by Carter on 7/27/2024 in #support
How can I persist state across page refreshes?
well the logic in onMount should be called once, then for each change to the values we would persist it
47 replies
SSolidJS
Created by Carter on 7/27/2024 in #support
How can I persist state across page refreshes?
when createEffect is called it persists the initial values and so nothing is displayed
47 replies
SSolidJS
Created by Carter on 7/27/2024 in #support
How can I persist state across page refreshes?
No description
47 replies