readme e ristruttura

This commit is contained in:
PesceWanda 2016-12-08 22:05:51 +01:00
parent 3ded8ee9a9
commit 1b4102cd46
10 changed files with 30 additions and 103 deletions

View file

@ -1,3 +1,32 @@
# Buridan_donkey
Written in c++ and python, this program given some choices orders them in casual order.
Written in c++, c and python, this program given some choices orders them in casual order.
More info at: http://francescomecca.eu/index.php/archives/207
# C
The C version is the most complete. It makes a system call to get a random pool of numbers.
Compile including math library.
It supports cli arguments:
```
--urandom, -u: no arguments, uses /dev/urandom instead of /dev/random
--no-numbers, -n: no arguments, disable line numbers
```
# Example
```
$ ls
asino.c asino.cpp asino.py README.md
$ ls | asino
1. asino.c
2. README.md
3. asino.py
4. asino.cpp
```

BIN
bin/asino

Binary file not shown.

Binary file not shown.

View file

@ -1,27 +0,0 @@
ALL = src/asino.c
LOCPATH = ./bin
INSTALLPATH = /usr/local
LFLAGS = -lm
DEBFLAGS = -g -Wall -Wextra -pedantic
all:
mkdir -p $(LOCPATH)
gcc $(ALL) -o $(LOCPATH)/asino $(LFLAGS)
debug:
mkdir -p $(LOCPATH)/debug
gcc $(ALL) -o $(LOCPATH)/debug/asino_debug $(LFLAGS) $(DEBFLAGS)
asan:
gcc $(ALL) -o $(LOCPATH)/debug/asino_debug_asan $(LFLAGS) $(DEBFLAGS) -fsanitize=address
clean:
rm $(LOCPATH)/asino
rm $(LOCPATH)/debug/asino_debug
distclean:
rm -r $(LOCPATH)
install:
cp $(LOCPATH)/asino $(INSTALLPATH)/bin/asino
uninstall:
rm $(INSTALLPATH)/bin/asino

Binary file not shown.

View file

@ -1,48 +0,0 @@
#!/usr/bin/python3
import random
def parse_args ():
import argparse
parser = argparse.ArgumentParser ()
parser.add_argument ('-n', '--no-numbers', action = 'store_true', default = False,
help = 'do not display line numbers')
parser.add_argument ('choices', type = str, nargs= '*', default = [],
help = 'where the various choices belong')
parser.add_argument ('-l', '--limit', type = int, default = False,
help = 'display n lines')
return parser.parse_args ()
_cnt = -1
def enum ():
global _cnt
_cnt += 1
return (''.join ([str (_cnt), '. ']))
def null_string ():
return ''
def main ():
from sys import stdin
args = parse_args ()
if args.limit:
limit = args.limit - 2
if args.no_numbers:
fst = null_string
else:
fst = enum
if not stdin.isatty():
for line in stdin:
if line[-1] is '\n':
line = line[:-1]
args.choices.append(line)
argRange = len(args.choices)
for i in range (argRange):
print (''.join ([fst (), args.choices.pop(random.randrange(0, len(args.choices)))]))
if args.limit and i > limit:
exit ()
if __name__ == '__main__':
main ()

View file

@ -1,27 +0,0 @@
ALL = asino.c
LOCPATH = ./bin
INSTALLPATH = /usr/local
LFLAGS = -lm
DEBFLAGS = -g -Wall -Wextra -pedantic
all:
mkdir -p $(LOCPATH)
gcc $(ALL) -o $(LOCPATH)/asino $(LFLAGS)
debug:
mkdir -p $(LOCPATH)/debug
gcc $(ALL) -o $(LOCPATH)/debug/asino_debug $(LFLAGS) $(DEBFLAGS)
asan:
gcc $(ALL) -o $(LOCPATH)/debug/asino_debug_asan $(LFLAGS) $(DEBFLAGS) -fsanitize=address
clean:
rm $(LOCPATH)/asino
rm $(LOCPATH)/debug/asino_debug
distclean:
rm -r $(LOCPATH)
install:
cp $(LOCPATH)/asino $(INSTALLPATH)/bin/asino
uninstall:
rm $(INSTALLPATH)/bin/asino