Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mouse-reeve/placevalue_ascii
Create integer grids of binary place values for a function
https://github.com/mouse-reeve/placevalue_ascii
binary mathematics numbering-system place-values visualization
Last synced: 1 day ago
JSON representation
Create integer grids of binary place values for a function
- Host: GitHub
- URL: https://github.com/mouse-reeve/placevalue_ascii
- Owner: mouse-reeve
- License: mit
- Created: 2017-06-18T01:34:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-18T18:45:46.000Z (over 6 years ago)
- Last Synced: 2024-11-05T04:34:04.980Z (7 days ago)
- Topics: binary, mathematics, numbering-system, place-values, visualization
- Language: Python
- Homepage: https://www.mousereeve.com/
- Size: 4.88 KB
- Stars: 32
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Placevalue Ascii
Creates an ascii representation of the binary ouput of two variable function at a certian place value, arrayed on a grid.
## What?
Consider the function `f(x, y) = x + y`.
Now, make a grid of the outputs of this function for incrementing integer values of `x` and `y`, like so:
```
_|_0___1___2___3__
0| 0 1 2 3
1| 1 2 3 4
2| 2 3 4 5
3| 3 4 5 6
```Convert each number to binary:
```
_|_0___1___2___3__
0| 000 001 010 011
1| 001 010 011 100
2| 010 011 100 101
3| 011 100 101 110
```Reduce the grid to only the digits at a certain place value, let's say 3:
```
_|_0___1___2___3__
0| 0 0 0 0
1| 0 0 0 1
2| 0 0 1 1
3| 0 1 1 1
```Now, replace the `1`s with an asterisk, `*` and the `0` with a space, ` `:
```
*
**
***
```## Script example
This command produces a 16 by 16 ascii pattern for the function `f(x, y) = x + y` at place value.
``` bash
$ python placevalue_ascii.py "x + y" 3 16 16
****
****
****
****
****
**** *
**** **
**** ***
**** ****
**** ****
**** ****
**** ****
**** ****
*** **** *
** **** **
* **** ***
```