Mayan pyramids were (and are) an important part of ancient architecture, that were generally used for religious purposes.
They were usually step pyramids, but the steps on each were too steep to climb. Priests would climb to the tops of them via alternative staircases to perform ceremonies. The pyramids were also used as landmarks because of their height, and sometimes even used as burial sites for high ranking officials.
The Challenge
Write a program that can print out a pyramid schematic based on user specifications (see below).
Requirements
Take an input of two space-separated variables.
Input must be accepted through STDIN (or closest alternative).
Output must be through STDOUT (or closest alternative).
Input
Height as any positive integer. This is used as the base level's width (in blocks). Each succeeding level of the pyramid has the width
n - 1
wheren
is the previous floor's width (in blocks).Block size which will be 1 or any odd, positive integer ≤ (less than) 10.
Blocks
The given block size determines the width (and height) of each individual piece. Essentially, there are i^2
spaces inside the visible box where i
is the block size.
A 1x1 block would look like this:
+++
| |
+++
While a 5x5 block would look like this:
+++++++
| |
| |
| |
| |
| |
+++++++
Horizontally Adjacent Blocks
Horizontally side-by-side blocks must have their middle walls merged into one.
You must have this:
+++++
| | |
+++++
Instead of something like this:
++++++
| || |
++++++
Vertically Adjacent Blocks (-5% bonus)
Vertically side-by-side blocks have a special exception: the middle wall can be merged into one.
So, instead of 1x1 blocks looking like this:
+++
| |
+++
+++++
| | |
+++++
They could look like this:
+++
| |
+++++
| | |
+++++
Examples
Input: 3 1
Output:
+++
| |
+++
+++++
| | |
+++++
+++++++
| | | |
+++++++
OR
+++
| |
+++++
| | |
+++++++
| | | |
+++++++
Input: 2 3
Output:
+++++
| |
| |
| |
+++++
+++++++++
| | |
| | |
| | |
+++++++++
OR
+++++
| |
| |
| |
+++++++++
| | |
| | |
| | |
+++++++++
Scoreboard
To be ranked on the scoreboard, put your answer in this format:
# Language, Score
Or if you get the bonus -5%:
# Language, Score (Bytes - 5%)
function getURL(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:getURL(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),useData(answers)}})}function getOwnerName(e){return e.owner.display_name}function useData(e){var s=[];e.forEach(function(e){var a=e.body.replace(/<s>.*<\/s>/,"").replace(/<strike>.*<\/strike>/,"");console.log(a),VALID_HEAD.test(a)&&s.push({user:getOwnerName(e),language:a.match(VALID_HEAD)[1],score:+a.match(VALID_HEAD)[2],link:e.share_link})}),s.sort(function(e,s){var a=e.score,r=s.score;return a-r}),s.forEach(function(e,s){var a=$("#score-template").html();a=a.replace("{{RANK}}",s+1+"").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SCORE}}",e.score),a=$(a),$("#scores").append(a)})}var QUESTION_ID=57939,ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",answers=[],answer_ids,answers_hash,answer_page=1;getAnswers();var VALID_HEAD=/<h\d>([^\n,]*)[, ]*(\d+).*<\/h\d>/;
body{text-align:left!important}table thead{font-weight:700}table td{padding:10px 0 0 30px}#scores-cont{padding:10px;width:600px}#scores tr td:first-of-type{padding-left:0}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><div id="scores-cont"><h2>Scores</h2> <table class="score-table"> <thead><tr><td></td><td>User</td><td>Language</td><td>Score</td></tr></thead><tbody id="scores"></tbody> </table></div><table style="display: none"> <tbody id="score-template"><tr><td>{{RANK}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SCORE}}</td></tr></tbody></table>
1 1
? \$\endgroup\$3 2
produce? \$\endgroup\$2 3
, it would exit whenn - 1 = 0
wheren
is the previous floor's width in blocks. \$\endgroup\$