Skip to content

Commit

Permalink
Update ccc-Firehose.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
SansPapyrus683 committed Sep 20, 2024
1 parent 02c5a3d commit 0726ad3
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions solutions/silver/ccc-Firehose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,17 @@ import java.io.*;
import java.util.*;

public class Firehose {
static final int MAX_H = 1000;
static final int STREET_SIZE = 1000000;
private static final int MAX_H = 1000;
private static final int STREET_SIZE = 1000000;

static boolean possible(int length, int numHydrants, int[] houses) {
private static boolean possible(int length, int numHydrants, int[] houses) {
for (int i = 0; i < houses.length; i++) {

// Number of fire hydrants that are needed.
int needed = 0;

int needed = 0; // Number of fire hydrants that are needed.
// The house that we need to connect a fire hydrant to.
int start = houses[i];

for (int j = 1; j < houses.length; j++) {
// Address of house at index j.
int end = houses[(i + j) % houses.length];

/*
* If the distance between the start and end houses is greater than
* two times the length of the hose, a single fire hydrant will not
Expand Down Expand Up @@ -174,13 +169,10 @@ STREET_SIZE = 1000000

def possible(length: int, num_hydrants: int, houses: list) -> bool:
for i in range(len(houses)):

# Number of fire hydrants that are needed.
needed = 0

# The house that we need to connect a fire hydrant to.
start = houses[i]

for j in range(1, len(houses)):
# Address of house at index j.
end = houses[(i + j) % len(houses)]
Expand All @@ -200,6 +192,7 @@ def possible(length: int, num_hydrants: int, houses: list) -> bool:

if needed <= num_hydrants:
return True

return False


Expand Down

0 comments on commit 0726ad3

Please sign in to comment.