Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #412901
| From | owl <owl@rooftop.invalid> |
|---|---|
| Newsgroups | comp.os.linux.advocacy |
| Subject | Re: Snit hitting the glue bag early today |
| Date | 2017-05-04 20:06 +0000 |
| Organization | O.W.L. |
| Message-ID | <zcv83tga9.lao00@rooftop.invalid> (permalink) |
| References | (7 earlier) <acv03.abhuu4@rooftop.invalid> <oeclcq$tll$3@dont-email.me> <uzv003.aui@rooftop.invalid> <oefa57$1lg$2@dont-email.me> <sandman-ffd99ec5113f5e5586dc5538f29c16f1@individual.net> |
Sandman <mr@sandman.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> In article <oefa57$1lg$2@dont-email.me>, DFS wrote:
>
>> data.txt
>> 01 5
>> 02 10
>> 03 15
>> 04 30
>> 05 60
>> 06 301
>> 07 21
>> 08 0
>> 09 7
>> 10 20
>>
>> $ python repeat.py data.txt * 70
>> 01 5 *****
>> 02 10 **********
>> 03 15 ***************
>> 04 30 ******************************
>> 05 60 ************************************************************
>> 06 301 ************************************************************
>> ************************************************************
>> ************************************************************
>> ************************************************************
>> ************************************************************
>> *
>> 07 21 *********************
>> 08 0
>> 09 7 *******
>> 10 20 ********************
>
> Why the indentation? Also, I think percentages looks a lot neater:
>
> dfs> ./marks.php data.txt
> 000: ****
> 001: ********
> 002: *************
> 003: *************************
> 004: **************************************************
> 005: *
> 006: ******************
> 007:
> 008: ******
> 009: *****************
>
> dfs> ./marks.php data.txt - 20
> 000: --
> 001: ---
> 002: -----
> 003: ----------
> 004: --------------------
> 005:
> 006: -------
> 007:
> 008: --
> 009: -------
>
> dfs> cat marks.php
> #!/usr/bin/php
> <?
> foreach (file($argv[1]) as $nr) $data[] = intval($nr);
> foreach ($data as $nr) printf("%03d: %s\n", $line++,
> str_repeat(($argv[2]?:'*'), round($nr * ($argv[3]?:50) / max($data))));
>
> Yeah, four line script, two lines of code. :-D
>
> If you *really* want to print all marks, it's even easier:
>
> dfs> ./marks2.php data.txt
> 000: *****
> 001: **********
> 002: ***************
> 003: ******************************
> 004: ************************************************************
> 005: **********************************************************************
> **********************************************************************
> **********************************************************************
> **********************************************************************
> *********************
> 006: *********************
> 007:
> 008: *******
> 009: ********************
>
> dfs> ./marks2.php data.txt - 40
> 000: -----
> 001: ----------
> 002: ---------------
> 003: ------------------------------
> 004: ----------------------------------------
> --------------------
> 005: ----------------------------------------
> ----------------------------------------
> ----------------------------------------
> ----------------------------------------
> ----------------------------------------
> ----------------------------------------
> ----------------------------------------
> ---------------------
> 006: ---------------------
> 007:
> 008: -------
> 009: --------------------
>
> dfs> cat marks2.php
> #!/usr/bin/php
> <?
> foreach (file($argv[1]) as $nr) printf("%03d: %s\n", $line++,
> wordwrap(str_repeat(($argv[2]?:'*'), intval($nr)), ($argv[3]?:70), "\n
> ", true));
>
> Yup, one line of code :-D
>
>> bash == severely pwned
>> C == severely pwned
>
> DFS, severely owned by Sandman. :-D
>
Why are you dropping the file data from the output?
Also, I had to exchange "<?" for "<?php" to get it
to run at all, and it still errors out whit "line"
not defined. It's also slower even than the python.
Back to comp.os.linux.advocacy | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-01 18:35 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-02 02:23 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-02 11:26 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-02 22:12 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-03 09:22 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-03 14:07 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-04 09:29 -0400
Re: Snit hitting the glue bag early today Sandman <mr@sandman.net> - 2017-05-04 16:42 +0000
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-04 20:06 +0000
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-04 20:12 +0000
Re: Snit hitting the glue bag early today chrisv <chrisv@nospam.invalid> - 2017-05-05 06:52 -0500
Re: Snit hitting the glue bag early today Marek Novotny <marek.novotny@marspolar.com> - 2017-05-05 10:32 -0500
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-05 13:22 -0400
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-05 13:01 -0400
Re: Snit hitting the glue bag early today Steve Carroll <fretwizzer@gmail.com> - 2017-05-04 13:16 -0700
Re: Snit hitting the glue bag early today Sandman <mr@sandman.net> - 2017-05-04 21:36 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-06 09:44 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-04 19:49 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-04 19:28 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-05 02:56 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-04 23:40 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-05 06:18 +0000
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-05 06:34 +0000
Re: Snit hitting the glue bag early today Sandman <mr@sandman.net> - 2017-05-05 07:07 +0000
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-05 07:29 +0000
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-05 16:48 +0000
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-05 20:49 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-05 13:02 -0400
Re: Snit hitting the glue bag early today Sandman <mr@sandman.net> - 2017-05-05 19:12 +0000
Re: Snit hitting the glue bag early today Snit <usenet@gallopinginsanity.com> - 2017-05-05 13:45 -0700
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-05 17:09 -0400
Re: Snit hitting the glue bag early today Sandman <mr@sandman.net> - 2017-05-05 21:41 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-05 13:00 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-05 20:14 +0000
Re: Snit hitting the glue bag early today Snit <usenet@gallopinginsanity.com> - 2017-05-05 13:44 -0700
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-05 23:51 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-06 04:48 +0000
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-06 10:06 -0400
Re: Snit hitting the glue bag early today owl <owl@rooftop.invalid> - 2017-05-06 15:50 +0000
Re: Snit hitting the glue bag early today Chris Ahlstrom <OFeem1987@teleworm.us> - 2017-05-05 05:28 -0400
Re: Snit hitting the glue bag early today DFS <nospam@dfs.com> - 2017-05-05 13:02 -0400
csiph-web