← Blog Home

# Snack Break Problem #28

It's been quite awhile since Scripting Helpers hosted its last Snack Break challenge but I'm excited to breath some life into this three-year tradition! For those of you who are unfamiliar, the goal of a Snack Break is to provide a quick and thought provoking challenge that programmers of all skill levels can get something out of.

## Challenge over!

Unfortunately, it seems either that this challenge was too hard or there was not a lot of interest in it and as a result I have received no completed solutions. I have to say I'm a bit disappointed as I thought challenge levels one and two were quite reasonable, but I guess I'll just have to tone it down in the future.

Regardless, I promised I would provide my solutions to all there challenges so here you go.

## The challenge

In this challenge we're going to be celebrating the recently released new CSG API by trying to solve some problems that it makes trivial, but here’s the catch, you’re not allowed to use the CSG API!

This challenge consists of three levels of varying difficulty that all build on top of each other.

The rules are as follows:

• You can not use the CSG API in any capacity.
• You may not submit duplicates of somebody else's answers.
• You should not use any pre-written libraries for this. i.e. no CSG modules written in Lua, etc.

## Challenge: Level One

In this challenge the goal is to slice an axis-aligned part in half given an axis-aligned plane that represents where the slice will be.

The blue part represents the plane that slices the grey part in half

A few things you can note:

• Axis-aligned means no rotation.
• The plane should be able to cut on any aligned axis (x, y, or z).
• The planes are to represented as infinite, but your solution should also account for when the plane does not intersect the shape and no cuts should be made.

## Challenge: Level Two

This challenge is quite like the previous with the exception that it should now be able to use multiple planes to make multiple "cuts" to the same part. Again, the part and planes should be axis-aligned.

Four parts are created!

## Challenge: Level Three

This challenge is by far the most difficult but reaps the largest reward! The first three people who manage to complete this will receive the Snack Break badge on their SH account!

The goal of this challenge is once again to split a part using a single plane except now both parts can be rotated!

This one is quite a toughie so I'm excited to see solutions (if any!).

Discussion of the problem is welcome in the Scripting Helpers Discord (so make sure to join!). You can post your answers either as a free model or as an uncopylocked place. The links can either be posted in the comments or DM'd to me (EgoMoose) on discord.

I'm going to give you guys approximately a week to solve this one so by 10:00pm UTC September 22nd I want your answers in! Soon after I’ll announce those who completed each challenge along with my own solutions.

Good luck!

### Commentary

EgoMoose says: September 13, 2018
Good luck everyone! I'll be checking the comments and discord daily so if you have any questions you know where I'm looking :)
DjMusa2 says: September 13, 2018
Wow, nice challenge! Keep up the good work with those amazing challenges, and I will try to make the level 1, since I am basicallly level 1. But guess what? I finally made it, I made a start menu!
birdeater11 says: October 30, 2018
Ugh cant believe I missed this snack-break *cries* well there is always the next one
supercoolboy8804 says: November 12, 2018
oof idek tthe first thing about makin this >->
ScriptAbyss says: January 2, 2019
It's the first time that I'm seeing one and the concept looks really interesting so far r!
turquoise_monkeyman says: August 9, 2019
breathe not breath sorry
AZDev says: September 14, 2019
I missed this one but definitely would have been able to complete challenge 1 and 2. Challenge 3 beats me though. That's well beyond my math comprehension.