Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

71%
+3 −0
Challenges How many umbrellas to cover the beach?

You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few ...

2 answers  ·  posted 1y ago by WheatWizard‭  ·  last activity 12mo ago by justhalf‭

Question code-golf array
#3: Post edited by user avatar WheatWizard‭ · 2023-10-17T14:05:02Z (about 1 year ago)
  • You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few umbrellas as possible.
  • Umbrellas come in many sizes. However, larger umbrellas are susceptible to being pulled away by the wind, so in the morning you have to go to the beach and do a soil test. The soil test tells you, for each spot on the beach, the size of the largest umbrella that could be safely placed.
  • So after your soil test, you get back a list of positive integers. For example:
  • ```
  • [2,1,3,1,3,1,1,2,1]
  • ```
  • Each number represents the maximum radius of an umbrella that can be placed at that location. A radius $r$ umbrella covers itself, and $r-1$ spots to both its left and right.
  • For example a radius 3 umbrella covers:
  • - itself
  • - the two spaces directly adjacent to it,
  • - the two further spaces adjacent to those,
  • Your task is to write a computer program which takes the results of the soil test as a list of positive integers, and gives back the minimum number of umbrellas required to cover all the spots on the beach.
  • For example if the soil test gives back `[2,1,3,1,3,1,1,2,1]`, then you can cover the beach with 2 umbrellas:
  • ```
  • X X X X X
  • X X X X X X X |
  • | |
  • [_,_,3,_,_,_,_,2,_]
  • ```
  • So the output of the program should be 2.
  • This is code-golf so the goal is to minimize the size of your source code as measured in bytes.
  • ## Test cases
  • ```
  • [9,2,1,3,2,4,2,1] -> 1
  • [1,1,1,1,1,1,1,1] -> 8
  • [2,1,3,1,3,1,1,2,1] -> 2
  • [5,1,3,1,3,1,1,1,6] -> 2
  • ```
  • You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few umbrellas as possible.
  • Umbrellas come in many sizes. However, larger umbrellas are susceptible to being pulled away by the wind, so in the morning you have to go to the beach and do a soil test. The soil test tells you, for each spot on the beach, the size of the largest umbrella that could be safely placed.
  • So after your soil test, you get back a list of positive integers. For example:
  • ```
  • [2,1,3,1,3,1,1,2,1]
  • ```
  • Each number represents the maximum radius of an umbrella that can be placed at that location. A radius $r$ umbrella covers itself, and $r-1$ spots to both its left and right.
  • For example a radius 3 umbrella covers:
  • - itself
  • - the two spaces directly adjacent to it,
  • - the two further spaces adjacent to those,
  • Your task is to write a computer program which takes the results of the soil test as a list of positive integers, and gives back the minimum number of umbrellas required to cover all the spots on the beach.
  • For example if the soil test gives back `[2,1,4,1,4,1,1,3,1]`, then you can cover the beach with 2 umbrellas:
  • ```
  • X X X X X
  • X X X X X X X |
  • | |
  • [_,_,4,_,_,_,_,3,_]
  • ```
  • So the output of the program should be 2.
  • This is code-golf so the goal is to minimize the size of your source code as measured in bytes.
  • ## Test cases
  • ```
  • [9,2,1,3,2,4,2,1] -> 1
  • [1,1,1,1,1,1,1,1] -> 8
  • [2,1,4,1,4,1,1,3,1] -> 2
  • [5,1,3,1,3,1,1,1,6] -> 2
  • ```
#2: Post edited by user avatar WheatWizard‭ · 2023-10-17T14:03:17Z (about 1 year ago)
  • You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few umbrellas as possible.
  • Umbrellas come in many sizes. However, larger umbrellas are susceptible to being pulled away by the wind, so in the morning you have to go to the beach and do a soil test. The soil test tells you, for each spot on the beach, the size of the largest umbrella that could be safely placed.
  • So after your soil test, you get back a list of positive integers. For example:
  • ```
  • [2,1,3,1,3,1,1,2,1]
  • ```
  • Each number represents the maximum radius of an umbrella that can be placed at that location. A radius $r$ umbrella covers itself, and $r-1$ spots to both its left and right.
  • For example a radius 3 umbrella covers:
  • - itself
  • - the two spaces directly adjacent to it,
  • - the two further spaces adjacent to those,
  • - and the two further spaces adjacent to those.
  • Your task is to write a computer program which takes the results of the soil test as a list of positive integers, and gives back the minimum number of umbrellas required to cover all the spots on the beach.
  • For example if the soil test gives back `[2,1,3,1,3,1,1,2,1]`, then you can cover the beach with 2 umbrellas:
  • ```
  • X X X X X
  • X X X X X X X |
  • | |
  • [_,_,3,_,_,_,_,2,_]
  • ```
  • So the output of the program should be 2.
  • This is code-golf so the goal is to minimize the size of your source code as measured in bytes.
  • ## Test cases
  • ```
  • [9,2,1,3,2,4,2,1] -> 1
  • [1,1,1,1,1,1,1,1] -> 8
  • [2,1,3,1,3,1,1,2,1] -> 2
  • [5,1,3,1,3,1,1,1,6] -> 2
  • ```
  • You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few umbrellas as possible.
  • Umbrellas come in many sizes. However, larger umbrellas are susceptible to being pulled away by the wind, so in the morning you have to go to the beach and do a soil test. The soil test tells you, for each spot on the beach, the size of the largest umbrella that could be safely placed.
  • So after your soil test, you get back a list of positive integers. For example:
  • ```
  • [2,1,3,1,3,1,1,2,1]
  • ```
  • Each number represents the maximum radius of an umbrella that can be placed at that location. A radius $r$ umbrella covers itself, and $r-1$ spots to both its left and right.
  • For example a radius 3 umbrella covers:
  • - itself
  • - the two spaces directly adjacent to it,
  • - the two further spaces adjacent to those,
  • Your task is to write a computer program which takes the results of the soil test as a list of positive integers, and gives back the minimum number of umbrellas required to cover all the spots on the beach.
  • For example if the soil test gives back `[2,1,3,1,3,1,1,2,1]`, then you can cover the beach with 2 umbrellas:
  • ```
  • X X X X X
  • X X X X X X X |
  • | |
  • [_,_,3,_,_,_,_,2,_]
  • ```
  • So the output of the program should be 2.
  • This is code-golf so the goal is to minimize the size of your source code as measured in bytes.
  • ## Test cases
  • ```
  • [9,2,1,3,2,4,2,1] -> 1
  • [1,1,1,1,1,1,1,1] -> 8
  • [2,1,3,1,3,1,1,2,1] -> 2
  • [5,1,3,1,3,1,1,1,6] -> 2
  • ```
#1: Initial revision by user avatar WheatWizard‭ · 2023-10-16T19:23:32Z (about 1 year ago)
How many umbrellas to cover the beach?
You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few umbrellas as possible.

Umbrellas come in many sizes. However, larger umbrellas are susceptible to being pulled away by the wind, so in the morning you have to go to the beach and do a soil test. The soil test tells you, for each spot on the beach, the size of the largest umbrella that could be safely placed.

So after your soil test, you get back a list of positive integers. For example:

```
[2,1,3,1,3,1,1,2,1]
```

Each number represents the maximum radius of an umbrella that can be placed at that location. A radius $r$ umbrella covers itself, and $r-1$ spots to both its left and right.

For example a radius 3 umbrella covers:
- itself
- the two spaces directly adjacent to it,
- the two further spaces adjacent to those,
- and the two further spaces adjacent to those.

Your task is to write a computer program which takes the results of the soil test as a list of positive integers, and gives back the minimum number of umbrellas required to cover all the spots on the beach.

For example if the soil test gives back `[2,1,3,1,3,1,1,2,1]`, then you can cover the beach with 2 umbrellas:

```
            X X X X X
X X X X X X X   |
      |         |
 [_,_,3,_,_,_,_,2,_]
```

So the output of the program should be 2.

This is code-golf so the goal is to minimize the size of your source code as measured in bytes.

## Test cases

```
[9,2,1,3,2,4,2,1] -> 1
[1,1,1,1,1,1,1,1] -> 8
[2,1,3,1,3,1,1,2,1] -> 2
[5,1,3,1,3,1,1,1,6] -> 2
```