# sed help

Fermat’s Last Theorem is solved! Now I really feel like Rip Van Wrinkle.

I see what you’re saying. You trade speed and simplicity for other options. To everything, there is a purpose.

Have a good day,
kel

Yeah. That is the tool-theory, a tool should do one thing and do it well, and you’d choose the right tool for the job.

This is a good approach, as long as the tool-chain is fast enough, and only then do you rewrite in a higher level language, you can also view tools as functional objects. That using tool is indeed object oriented, sort of.

here is the Wikipedia article about Fermat’s last theorem

I also think you’d like to have a look at the Chinese remainder theorem as well; the calculation is the proof.
If you detested it at school, you may find it intriguing now!

And you have a good day as well kel. -Always a pleasure!

Hello.

Here is a free book for you: Aho/Ullman: Foundations of Computer Science

In 1995, amazing:

Where have you been???

Just kidding, but I remember it as it was today. I was reading it in internet explorer, on Windows 95, I had an annoying friend at the time, who had a Mac, to every problem I had he just said, why don’t you just do it like that, or Ah, I just do that to accompish it. AppleTalk and sharing documents. No such thing on Windows 95!

The book about Fermat’s last theorem, is by the way a very good one, with lots of interesting math in it.

Actually, I got too obsessive with computers in the past. So, I had to go fishing, or hiking, or gardening, or guitars or etc. When I get too obsessive, I go cold turkey. Then, I know that I don’t have to do something all the time. Computers can be addicting. Who would ignore another brain.

Edited: forgot golf.

I would lie if said I didn’t know what you were talking about.

Things got much easier after I started having laptops, less to carry around.

By the way, if there is too much sunshine outside, there is a keyboard shortcut: ctrl-opt-cmd 8, that inverts the screen!

It works most of the time.

I hear you!

We just got wifi and I’m in the garage listening to music and realized that I could go on the internet also. It’s a distraction (or option) that needs to be tamed.

Well, enjoy your wifi, I have been reading something insanely boring today, now I go out, and enjoy the rest of the evening. Have a still good day.

This is good for up to 999 lines:

``````set cmd to "<~/Desktop/WolfandCrane.txt  sed -En '
1 {
# Before editing the first line, create a counter and put it in the hold space. The 30 digits are notionally the three rotating wheels of a three-digit meter, the first, eleventh, and twenty-first digits being the “visible” ones. The initial reading is 001.
h
s/^.*\$/012345678901234567891234567890/
x
}
# Append each line in turn to the meter in the hold space and copy the result into the pattern space.
H
g
# Lose the non-visible digits in the pattern space and substitute a dot and a tab for the linefeed between the meter and the line. (We know the first 30 characters are digits, so we can use “.” rather than “[0-9]” in the regex.)
s/^(.).{9}(.).{9}(.).{9}\\n/\\1\\2\\3.'\$'\\t''/
# Lose any leading zeros and print.
s/^0*//p
# Get the original meter/line combination again from the hold space.
g
# Rotate the “units wheel” by one digit and lose the line text.
s/^(.{20})(.)(.{9}).+/\\1\\3\\2/
/^.{20}0/ {
# If the units have returned to zero, advance the “tens wheel”.
s/^(.{10})(.)(.{9})/\\1\\3\\2/
/^.{10}0/ s/^(.)(.{9})/\\2\\1/
}
# Put the advanced meter back in the hold space.
h'"
do shell script cmd
``````

Text encoding for smart double-quotes corrected 2022-12-01.

Hello.

I must say i am glad I didn’t try to write a proof or something, late last night, when I realized, I might have used the ‘y’ command to shift the numbers one place to the right, but I had trouble with the 100’s and 10’s.

Wery well done Nigel!

Don’t be put off that there aren’t much room in your sed script for doing any other text transforms. it was really instructive to read, and see a clever solution.

Actually, this one will be plastered up on the wall!

Hi Nigel,

Wow! Great idea using the counter also! Who said sed can’t count, huh?

Thanks a lot,
kel

I did

And it doesn’t, but who cares, as the effect is the same anyway!

It is going up on the wall.Nigel’s Fame, my Shame.

I actually got some of the same idea last night, but I couldn’t get longer than to 9 lines.

I don’t remember you saying that. I was just using a bit of irony. Yes, it is a great script!

BTW, does anyone know the maximum number of bytes ‘do shell script’ can handle?

Edited: I should say, from a file for processing.

Hello.

It is really great!

Should give you the maximum length of a command line a shell can handle, as for a do shell script command line, I’d guess that if there is a limit as to the size of the command line, that limit would be 2^14 characters (not bytes).

I guess stream input to a do shell script would be pretty much unlimited.

Thanks, guys.

It turns out that one of the ‘h’ commands can be cut from my script and two of the 's’s combined if the meter reading starts at 001 instead of 000 and is incremented after each line is printed instead of before it. I’ve updated the script accordingly.

Eliminating the anomalies, I get 0.009999990463 secs… I have a feeling that this is good for four ling lines.

Agent Smith?