7
2
I'd like to see you create code (in any programming language) that output working BF (Brain***k) code. Your program have a single character input on stdin. The input should be one digit ("0", "1", "2", "3", "4", "5", "6", "7", "8" or "9").
Your code should output BF-code that when interpreted with a normal BF-interpreter outputs a 5*5 ascii version of the digit. The generated BF-code should not accept any input. The resulting output from the generated BF-code should be exactly this:
Input: '0'
Output BF-code that when interpreted generates the following output:
.---.
| /|
| / |
|/ |
'---'
Input: '1'
Output BF-code that when interpreted generates the following output:
.
/|
|
|
'
Input: '2'
Output BF-code that when interpreted generates the following output:
.---.
|
.---'
|
'---'
Input: '3'
Output BF-code that when interpreted generates the following output:
.---.
|
---|
|
'---'
Input: '4'
Output BF-code that when interpreted generates the following output:
. .
| |
'---|
|
'
Input: '5'
Output BF-code that when interpreted generates the following output:
.---
|
'---.
|
'---'
Input: '6'
Output BF-code that when interpreted generates the following output:
.---
|
|---.
| |
'---'
Input: '7'
Output BF-code that when interpreted generates the following output:
----.
/
/
/
'
Input: '8'
Output BF-code that when interpreted generates the following output:
.---.
| |
|---|
| |
'---'
Input: '9'
Output BF-code that when interpreted generates the following output:
.---.
| |
'---|
|
'---'
The output from your code must be 10 different BF sourcecodes, one for each digit you input. Your program should not output all 10 BF in one run, it must ask for a digit and output BF code for that and only that ascii representation.
The BF-code requirements:
- cell size: 8bit unsigned.
- Overflow is undefined.
- Array size: Max 30000 bytes (not circled)
- It can contain other characters than [],.+-<>, but they should all be ignored. It is only - the standard BF code without any extensions that counts.
- The EOF return 0
- Linefeed is chr(10)
The winning answer will be the one that scores that lowest code using this formula:
your code in number of bytes * 5 + sum of the 10 generated BF codes
So keep in mind that you need to generate GOLF'd BF-code to score better.
Edit/Add (2011-08-25): You may omit or supply trailing spaces, as long as the digits displays the ASCII representation on a 80 column output, so the limit is 80 chars rows. Honor to the answers to generates exactly 5*5 output for all digits.
@user unknown : Thanks for spotting that unneccesary irregularity, I have updated the shape and tried to make it as uniform to the other digits as possible – Plarsen – 2011-08-11T04:43:43.287
Am I correct that the trailing spaces in the 5 are unintentional and not necessary? My solution does not include them. – PleaseStand – 2011-08-25T00:36:31.757
@PleaseStand that is correct, you can omit or supply trailing spaces, as long as the digits displays the ASCII representation on a 80 column output, so the limit is 80 chars rows. I Will edit the question later today and include this info – Plarsen – 2011-08-25T05:13:50.970
And does the "EOF return 0" part mean I have to end my output with a null byte or does it mean
,
can substitute for[-]
? – PleaseStand – 2011-08-25T18:33:41.357well, the EOF part is about how the bf-interpreter reads the bf sourcecode, so I guess it is not really applicable. Your output from your code or the output from the bf-code does not need to end with 0. – Plarsen – 2011-08-26T15:55:34.510