You are here:   ArielOrtiz.com > Programming Languages > Brainf*ck Exercises

Brainf*ck Exercises

Objectives

During this activity, students should be able to:

This activity helps the student develop the following skills, values and attitudes: ability to analyze and synthesize, capacity for identifying and solving problems, and efficient use of computer systems.

Activity Description

Solve the following set of programming exercises using the brainf*ck programming language.

  1. Write a program called first.bf that reads a digit d (0 to 9) from the keyboard and prints the first d lowercase letters of the English alphabet. Example (user input is in bold):

    6
    abcdef
    
  2. Write a program called dup.bf that reads a digit d (0 to 9) followed by any character c from the keyboard and prints a total of d consecutive c characters. If d is zero, nothing should be printed. Example (user input is in bold):

    6a
    aaaaaa
  3. Write a program called tri.bf that reads a digit character d (0 to 9) from the keyboard and prints a triangle made out of d rows of asterisks as shown in the example (user input is in bold):

    6
    *
    **
    ***
    ****
    *****
    ******
    
  4. Write a program called count.bf that reads a series of characters from the keyboard (minimum 0, maximum 9 characters) followed by the Enter key, and displays how many characters were actually typed (excluding the enter character). The ASCII code for the Enter key is 10. Example (user input is in bold):

    hello
    5

Deliverables

Nothing. These are just practice exercises.

© 1996-2010 by Ariel Ortiz (ariel.ortiz@itesm.mx)
Made with Django | Licensed under Creative Commons | Valid XHTML | Valid CSS