7
2
This challenge is entirely fictional. There is no time limit for this challenge.
My little brother is terrible with computers! He saved up all of his money to buy a new one, and within half an hour the hard drive was wiped and the only software left is a lousy BF interpreter. The worst part of it is, he has a huge Geometry test tomorrow and needs help!
The Challenge
There's no way I'm going to let him touch my machine, so I'm going to need a fast way to write BF programs that solve his problem. He's learning about finding the area of regular polygons, and writing a new BF program for every calculation is a massive task. I need a fast way to generate BF programs! That's where you come in...
The Input
Your program or function will receive an integer 2 < N <= 100
which shall represent the number of sides of a regular polygon. You may receive input from function arguments, command line arguments, STDIN, or your language's closest alternative. If necessary, you may additionally require trailing or leading whitespace.
The Output
Your program should generate a separate BF program that takes input of a single positive integer 0 < a <= 10^10
that shall represent the length of the apothem of a regular polygon. When run, the BF program should output the area of a polygon with N
sides and an apothem of a
. More specifically:
- Assume that the BF interpreter is set up such that
,
takes a number as input and.
outputs a value as a number, not a character. An input of12
does not translate to the characters'1' '2'
in memory, rather the literal number12
. Similarly, when a value of48
is output, it outputs'48'
, not the character'0'
. - Assume also that each value on the tape of the BF program may contain an infinitely large integer -- the value will never wrap to 0.
- Assume that the tape of the BF spans infinitely to the right, but has no negative indices. The pointer starts at
0
. - My brother is as careless with numbers as he is with computers. As such, the BF code should output the area rounded to the nearest integer.
The Rules
In a separate and unrelated incident, my brother downloaded so much garbage onto my primary programming machine that I have virtually no hard drive space left. As such, your original program may not exceed 512 bytes.
Your score in this challenge is the length of all BF programs generated by your program for values of N
from 3
to 100
inclusive.
Standard loopholes are disallowed.
So, you don't allow him to touch your computer, but he somehow clugged up your computer with garbage? Maybe clean it up. – Bálint – 2016-06-05T11:46:23.627
@Bálint If this is not humorous, then you're wrong. He might have installed all that garbage there before bying the new PC. – Erik the Outgolfer – 2016-06-06T18:33:53.243
@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Don't worry, I was – Bálint – 2016-06-06T18:59:00.320
@Bálint You were wrong or the comment was humorous? – Erik the Outgolfer – 2016-06-06T19:00:53.017
@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ The comment was humorous – Bálint – 2016-06-06T19:47:39.683
@Bálint Typo + Spellchecker = MESS! – Erik the Outgolfer – 2016-06-06T19:51:50.393