The instructor's kids love playing with LEGO. Just give them a box of these magical bricks and everything is awesome1.
Lately, they have been working on organizing their gigantic collection of
bricks 2. As they were sorting their 1x1
, 2x1
, 3x1
and 4x1
bricks,
however, they got side-tracked with the following problem:
Given a collection of
1x1
,2x1
, and3x1
, and4x1
bricks, at least how many4x1
rows are required to hold all the pieces?Note, the kids are very particular and only want the bricks in a horizontal orientation.
For example, given 3
1x1
bricks, 2
2x1
bricks, 2
3x1
bricks,
and 3
4x1
bricks, we would need 7
4x1
rows as shown on the right.
Because they have a lot of bricks, the kids want "daddy's students" to help
them by writing a program that will compute the minimum number of rows
needed to arrange their Nx1
bricks in 4x1
rows.
Each line of input will consist of four numbers corresponding to the number
of 1x1
, 2x1
, 3x1
, and 4x1
bricks.
You should read and process each line of input until the end of the file.
3 2 2 3
For each collection of bricks, you should output the minimum number of
4x1
rows required to hold all the bricks as described above.
7
This is based on the 311 - Packets problem on the UVa Online Judge.
To submit your work, follow the same procedure you used for Reading 00:
$ cd path/to/cse-30872-fa18-assignments # Go to assignments repository $ git checkout master # Make sure we are on master $ git pull --rebase # Pull any changes from GitLab $ git checkout -b challenge09 # Create and checkout challenge09 branch $ $EDITOR challenge09/program.cpp # Edit your code $ git add challenge09/program.cpp # Stage your changes $ git commit -m "challenge09: done" # Commit your changes $ git push -u origin challenge09 # Send changes to GitLab
To check your code, you can use the .scripts/submit.py
script or curl:
$ .scripts/submit.py Submitting challenge09 assignment ... Submitting challenge09 code ... Result Success Score 6.00 Time 0.02 $ curl -F source=@challenge09/program.cpp https://dredd.h4x0r.space/code/cse-30872-fa18/challenge09 {"score": 6, "result": "Success"}
Once you have commited your work and pushed it to GitLab, member to create a merge request. Refer to the Reading 05 TA List to determine your corresponding TA for the merge request.