|
================================================================================================ tc.exe - Windows tiny-C interpreter tc - Linux tiny-C interpreter
a. library.tc - this needs to be in a folder named pps b. mathLib.tc - this needs to be in a folder named pps c. lrblib.tc - 5/25/19 [v 1.14] d. pyGraphicsLib.tc - this needs to be in a folder named pps ================================================================================================ http://primepuzzle.com/lee-bradley/SamplePrograms/The_Book.html Interesting and often challenging problems solved in tiny-C and C with an occasional use of Python and JavaScript and Mouse and Pascal and ... by Lee R. BradleyThe definitive guide to the tiny-C language 0. the_new_classical_tiny-C.doc Two programs that draw stars 1. starc_no_color.c - 5/25/19 2. starc.c - 5/26/19
e. cairopy.py - launched by applications that use Cairo graphics (for example, the next two) When you need to multiply (or add) two Roman numerals (e.g. XIV*XIV=CXCVI) 3. roman.tc
4. spirala.tc, spiralpi.c
5. sieve.c - 5/24/19 D:\Tom Gibson\tiny-c-master\SamplePrograms>sieve sieve.c - 5/24/19 - lrb usage: sieve [-v] Enter a number to factor : 23372 2 2 5843 5a. njtc_sieve_v2.c - 5/27/19 5b. factor.6.2.tc
H:\>tc factor.6.2.tc -r main(0) -l
Sizes: of pr 100000 fun 200 stack 200 var 300
pps\library.tc loaded
(default)
endlibrary
factor.6.2.tc loaded
*** TINY-C VERSION 1.0, COPYRIGHT 1977, T A GIBSON ***
This C version copyright 2017, T A Gibson
2020-02-14 10:52:16
factor.tc - 2/13/20 - lrb - source code has 1647 bytes
Enter number to factor 2123123123
11 23 8391791 = 2123123123
2020-02-14 10:53:14
H:\>
12. star.tc - 5/15/19
13. van.tc - 5/28/19 D:\Tom Gibson\tiny-c-master>tc SamplePrograms\van.tc
*** TINY-C VERSION 1.0, COPYRIGHT 1977, T A GIBSON ***
This C version copyright 2017, T A Gibson
van.tc - lrb - 5/29/18
dollars : 123
number of wrappers to get extra bar : 5
123 147 152 153 wrappers left = 3
done
D:\Tom Gibson\tiny-c-master>
14. colcircles.c
How many socks do you need to pull from a drawer in order to get two pair?
The next one analyses a tiny-C program and shows its structure (the depth of the ifs and whiles).
16. matched_pair.tc
17. page_turners.tc
18a. next_c.tc
19. chas.tc
*** TINY-C VERSION 1.0, COPYRIGHT 1977, T A GIBSON ***
This C version copyright 2017, T A Gibson
chas.tc - 4/14/18
Pace for the first 10 miles (for example 9:39)?
Minutes first, then seconds.
minutes 9
seconds 10
Pace for last 16.2 miles (for example 9:28)?
Minutes first, then seconds.
minutes 12
seconds 13
1 0 : 9 : 10 11 : 24 : 10
2 0 : 18 : 20 11 : 33 : 20
3 0 : 27 : 30 11 : 42 : 30
4 0 : 36 : 40 11 : 51 : 40
5 0 : 45 : 50 12 : 0 : 50
6 0 : 55 : 0 12 : 10 : 0
7 1 : 4 : 10 12 : 19 : 10
8 1 : 13 : 20 12 : 28 : 20
9 1 : 22 : 30 12 : 37 : 30
10 1 : 31 : 40 12 : 46 : 40
11 1 : 43 : 53 12 : 58 : 53
12 1 : 56 : 6 1 : 11 : 6
13 2 : 8 : 19 1 : 23 : 19
14 2 : 20 : 32 1 : 35 : 32
15 2 : 32 : 45 1 : 47 : 45
16 2 : 44 : 58 1 : 59 : 58
17 2 : 57 : 11 2 : 12 : 11
18 3 : 9 : 24 2 : 24 : 24
19 3 : 21 : 37 2 : 36 : 37
20 3 : 33 : 50 2 : 48 : 50
21 3 : 46 : 3 3 : 1 : 3
22 3 : 58 : 16 3 : 13 : 16
23 4 : 10 : 29 3 : 25 : 29
24 4 : 22 : 42 3 : 37 : 42
25 4 : 34 : 55 3 : 49 : 55
26 4 : 47 : 8 4 : 2 : 8
26.2 4 : 49 : 34 4 : 4 : 34
done
D:\Tom Gibson\tiny-c-master>tc SamplePrograms\amort.tc
*** TINY-C VERSION 1.0, COPYRIGHT 1977, T A GIBSON ***
This C version copyright 2017, T A Gibson
amort.tc - lrb - 11/19/18
Today's date and time are 2019-06-08 05:06:38
monthly payment amount (e.g. 100) ? 234
principle (amount borrowed) (e.g. 2000) ? 10000
annual percent interest rate (e.g. 8) ? 6
number of monthly payments is 48.19
22. hasm.tc
23. ver.tc D:\Tom Gibson\tiny-c-master>tc SamplePrograms\ver.tc -r "main\"...\""
*** TINY-C VERSION 1.0, COPYRIGHT 1977, T A GIBSON ***
This C version copyright 2017, T A Gibson
ver.tc - lrb - 6/24/19
The tiny-C build date is 2019-06-23 4:07
The operating system is Windows_NT
The program length is 40000
tiny-C authors ..., ..., ...
The current date and time is 2019-06-24 14:38:40
Enter a number : 31415
Your entry and a message for the day follow.
31415
tiny-C rocks!
Using functions from the libraries
http://primepuzzle.com/lee-bradley/lrblib.tc
http://primepuzzle.com/lee-bradley/pps/library.tc
lrblib version 1.14
http://primepuzzle.com/lee-bradley/ver.tc
Your command tail was ...
3.1415926535897932384
yummm
John Conway's game of Life. This is a very simple implementation of this famous "game." The "board" is small (50x50). It starts by randomly populating the board and then runs for a user-supplied number of generations.
24. slr.tc
24a. Click the link to see the "movie" life.mp4 For when you need to dump a file in hex and character. 25. rdump.tc
99 bottles of beer on the wall (Halloween version) 26. pieces.tc
./tc SamplePrograms\lee-bradley\pieces.tc Enter number of verses : 10 Enter delay in seconds between verses : 2 10 piece(s) of pumpkin pie on the shelf, 10 piece(s) of pumpkin pie. If one of those pieces of pumpkin pie should happen to fall ... 9 piece(s) of pumpkin pie on the shelf. 9 piece(s) of pumpkin pie on the shelf, 9 piece(s) of pumpkin pie. If one of those pieces of pumpkin pie should happen to fall ... 8 piece(s) of pumpkin pie on the shelf. ... 2 piece(s) of pumpkin pie on the shelf, 2 piece(s) of pumpkin pie. If one of those pieces of pumpkin pie should happen to fall ... 1 piece(s) of pumpkin pie on the shelf. 1 piece(s) of pumpkin pie on the shelf, 1 piece(s) of pumpkin pie. If one of those pieces of pumpkin pie should happen to fall ... 0 piece(s) of pumpkin pie on the shelf.This next program computes the value of 3^n-3*n for large n. 27. multseq.tc The 955 digit value of 3^2000-3*2000 is 1747871251722651609659974619164660570529 0624874351885178118880118106862662272754 8929148646986468111107560895069614527658 8771368435875508647514414202093638481872 9123800899771793815296284783205235193191 4268150442405941089021450050064781393581 8925701905402605484098137956979368551025 8252394113186439979165236770447696626286 4640654033562797532961926424507975047086 2462474091105444437355302146151475348090 7553301532690679330916994798890898246508 4179556747860639697566455714373765702708 0403239977757865296846740093712377915770 5360942236880491080232441391830279624844 1107846443951684522796193522126981475341 6782576455507316073751985374046064592546 7960431507378083145016846797580569059487 5924636864441615186313808527660359581641 0945157599742077617618911601185155602080 7717467859593598794901919333899652712754 0312792543224796326967591264610315634395 4375442792688936047041533537523137941310 6908339497677642900813339003803104061547 23157882112449991673819054110434001
Here is a simulation of Karel running around a lake, picking up beepers along the way.
28. mykarel.lw.tc - Windows version
Another sample program which illustrates a few more features
28h. nemo.tc
During Storm Nemo, Karel the Robot was watching Lee solve the problem of where to put the snow. The only way to get rid of it was to shovel a swath and pile it up. Then shovel another swath and pile it in another pile. These piles would then be moved onto Lee's lawn. The piles could only be four feet high. Here's what the piles looked like after one day of shoveling. Here's another Karel program. A maze. http://primepuzzle.com/lee-bradley/SamplePrograms/maze.html
29. xmas.tc
30. amoeba.linux.tc.
Graphic by DeeDee
primepzl@november:~/public_html/lee-bradley$ ./tc SamplePrograms/amoeba.linux.tc
*** TINY-C VERSION 1.0, COPYRIGHT 1977, T A GIBSON ***
This C version copyright 2017, T A Gibson
amoeba.linux.tc - tct - 7/10/19
An amoeba either dies, lives, splits into two or splits into three,
each with probability 1/4. It can be proved that out of 10
simulations, about 10*(sqrt(2)-1), which equals about 4,
populations will die out. It can also be proved that 1.5^n
is the expected number of amoebas after n generations. If n=10,
58 amoebas are expected.
seed? 5
simulation 1: population 0
simulation 2: population 0
simulation 3: population 33
simulation 4: population 0
simulation 5: population 0
simulation 6: population 74
simulation 7: population 0
simulation 8: population 12
simulation 9: population 91
simulation 10: population 137
34 amoebas, on average, were living after 10 generations.
5 population(s) died out.
done
31. bst2.c 31a. tree-128.tc 31b. TREE-16.TC
Here's a sample run.
33. http://primepuzzle.com/lee-bradley/compressor.html 33a. http://primepuzzle.com/lee-bradley/SamplePrograms/compress.tc 33b. http://primepuzzle.com/lee-bradley/SamplePrograms/dompress.tc
38. SOLVE.MSE, COWTRY.MSE 39. CPMDIR.PAS
41. double.tc 42. getproperty.tc 43a. dup.tc 43b. dup.c 44. http://primepuzzle.com/tunxis/integration.c, http://primepuzzle.com/tunxis/integration.amy.try.c 45. http://primepuzzle.com/tc/entropya.c 46. http://primepuzzle.com/tc/easter.tc
48. http://primepuzzle.com/lee-bradley/SamplePrograms/signatur.plus.tc
49. http://primepuzzle.com/lee-bradley/SamplePrograms/totient.tst 50. http://primepuzzle.com/tc/pnut.1.c 50a. !jtc 50b. http://primepuzzle.com/tc/pnut.htm
H:\>pnut.1 -n 1000001 -v 0 largest prime was 999983 n / # primes <= n = 1000001 / 78498 = 12.7391908 ln(1000001) = 13.8155116 51. http://primepuzzle.com/tunxis/delta.epsilon.c 51a. http://primepuzzle.com/tunxis/feb.challenge.html 52. A Programmer's Guide to the Meaning of Life 53. http://primepuzzle.com/tc/tiny-c-programs.html Appendix https://github.com/tgibson37/tiny-c - GitHub repository of the tiny-C interpreter buildPlugIn.bat - script used to build plugins under Windows buildPlugIn.sh - script used to build plugins under Linux
|