Giter Site home page Giter Site logo

bf-crunch's Introduction

BF Crunch

Crunches BF programs of the form

{...s2}<{s1}<{s0}[{k0}[<{j0}>{j1}>{c0}>{c1}>{c2...}<<<]{h}>{k1}]

of the given length. Programs of this form fill the tape with simple recurrence relations.

The shortest useful program of this type has length 14:

+[[<+>->++<]>]

which computes the powers of 2 as fn = 2*fn-1, f0 = 1

Usage

Usage: bfcrunch [--options] text [limit]

Crunches BF programs to produce a given text.

Arguments
------------------------------------------------------------
  text              The text to produce.
  limit             The maximum BF program length to search for. If empty, the length of the
                    shortest program found so far will be used (-r). Default = (empty)

Options
------------------------------------------------------------
  -i, --max-init=#  The maximum length of the initialization segment. If empty, the program
                    will run indefinitely. Default = (empty)
  -I, --min-init=#  The minimum length of the initialization segment. Default = 14
  -t, --max-tape=#  The maximum tape size to consider. Programs that utilize more tape than
                    this will be ignored. Default = 1250
  -T, --min-tape=#  The minimum tape size to consider. Programs that utilize less tape than
                    this will be ignored. Default = 1
  -n, --max-node-cost=#
                    The maximum cost for any node. Default = 20
  -l, --max-loops=#
                    The maximum number of iterations of the main loop. Default = 30000
  -s, --max-slen=#  The maximum length of the s-segment. Default = (empty)
  -S, --min-slen=#  The minimum length of the s-segment. Default = 1
  -c, --max-clen=#  The maximum length of the c-segment. Default = (empty)
  -C, --min-clen=#  The minimum length of the c-segment. Default = 1
  -r, --rolling-limit
                    If set, the limit will be adjusted whenever a shorter program is found.
  -u, --unique-cells
                    If set, each used cell used for output will be unique.
  -?, --help        Display this help text.

Output

Output is given in three lines:

  1. Total length of the program found, and the initialization segment.
  2. Path taken, starting with the current tape pointer. Each node corresponds to one character of output, represented as (pointer, cost).
  3. Utilized tape segment.

For example, the final result for bfcrunch "hello world" 70 -r -i23 is:

64: ++++[[<+>->+++++>+<<]>]
49, (45, 5), (44, 3), (45, 6), (45, 1), (45, 4), (42, 4), (43, 5), (45, 3), (45, 4), (46, 2), (44, 4)
32, 116, 100, 104, 108, 132, 0, 0, 132, 0

This corresponds to the full program:

++++[[<+>->+++++>+<<]>]<<<<.<+.>++++..+++.<<<.>+++.>>.+++.>.<<-.

bf-crunch's People

Contributors

primo-ppcg avatar

Stargazers

Hugo Rivera Calzadillas avatar E O avatar Florian Cassayre avatar Space avatar Qaziquza avatar  avatar Rodrigo Girão Serrão avatar  avatar  avatar Chris avatar Conor O'Brien avatar

Watchers

James Cloos avatar  avatar

Forkers

michalmarsalek

bf-crunch's Issues

code golf question

Hi @primo-ppcg , there is no issue pertaining to this repo, but rather I'm using this issue tracker to establish contact with you. I've been working hard on the C# 99 problem. I'm making good progress but have run out of ideas. Was hoping you could mentor me as to what concepts I might need to further explore to get down to 211. Would you be willing to reach out to me at my personal email gerald lee thomas at hot mail dot com

-Kind Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.