Menu

NatUnit Tutorial

Markus Wessjohann

NatUnit Tutorial

A little tutorial to get used to NatUnit.

Step 0

Write a Natural program thats prints out FizzBuzz.
There are no restrictions for the implemantion.

Example:
Output:
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, FizzBuzz, 31, 32, Fizz, 34, Buzz, Fizz, ...

Step 1

Implentent FizzBuzz in a Natural subprogram.

  1. Start writing a NatUnit testcase which check the FizzBuzz implentation.
  2. Hint: Maybe https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/FIZZP.NSIWA is a good PDA to check.
  3. Write a Natural subprogram thats returns FizzBuzz.

Example:
Input:
Size: 36

Output:
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, FizzBuzz, 31, 32, Fizz, 34, Buzz, Fizz

Solution:
Testcase: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/TCFIZZB1.NSN
Subprogram: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/FIZZB1.NSN

Step 2

Based on solution in Step 1.Implement FizzBuzz in a Natural subprogram with differnent words and numbers

  1. Start writing a NatUnit testcase witch check the FizzBuzz implentation.
    2.Write a Natural subprogram. Input is an Array with numbrs and words. Output is Array with numbers and words.

Example:
Input:
Size: 36
3 - Fizz
7 - Buzz

Output:
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, FizzBuzz, 31, 32, Fizz, 34, Buzz, Fizz

Input:
Size: 14
2 - Boo
7 - Foo

Output:
1, Boo, 3, Boo, 5 , Boo, Foo, Boo, 9, Boo, 11, Boo, 13, BooFoo

Solution:
Testcase: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/TCFIZZB2.NSN
Subprogram: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/FIZZB2.NSN

Step 3

Based on solution in Step 2. Implentent FizzBuzz in a Natural subprogram with differnent words and numbers and the number of words.

  1. Start writing a NatUnit testcase witch check the FizzBuzz implentation.
    2.Write a Natural subprogram. Input is an Array with numbrs and words. Output is Array with words an the numbers of the words in the array.

Example:
Input:
Size: 36
3 - Fizz
7 - Buzz

Output:
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, FizzBuzz, 31, 32, Fizz, 34, Buzz, Fizz
Fizz: 10
Buzz: 4
FizzBuzz: 2

Solution:
Testcase: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/TCFIZZB3.NSN
Subprogram: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/FIZZB3.NSN

Step 4

Based on solution in Step 3 implentent FizzBuzz in a Natural subprogram with differnent words and numbers and return the number of words.

  1. Start writing a NatUnit testcase witch check the FizzBuzz implentation.
    2.Write a Natural subprogram. Input is an Array with numbrs and words. Output is the sum of the substitions words.

Example:
Input:
Size: 36
3 - Fizz
7 - Buzz

Output:
Fizz: 10
Buzz: 4
FizzBuzz: 2

Solution:
Testcase: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/TCFIZZB4.NSN
Subprogram: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/FIZZB4.NSN

Step 5

Based on solution in Step 4 Implentent FizzBuzz in a Natural subprogram with differnent words and numbers and return the number of words with a runtime of O(1)

  1. Start writing a NatUnit testcase witch check the FizzBuzz implentation.
    2.Write a Natural subprogram. Input is an Array with numbrs and words. Output is the sum of the substitions words.

Example:
Input:
Size: 36
3 - Fizz
7 - Buzz

Output:
Fizz: 10
Buzz: 4
FizzBuzz: 2

Solution:
Testcase: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/TCFIZZB5.NSN
Subprogram: https://sourceforge.net/p/natunit/code/HEAD/tree/branches/ao/NatUnit-Tutorial/FIZZB5.NSN

Step 6

Find the fault in Solution in Step 5.

Step 7

Do the steps 1-5 with your program written in step 0.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.