Basicprogramming(.org) > Code and examples

Floyd's Triangle

<< < (3/3)

jj2007:

--- Quote from: Tomaaz on October 17, 2018, 11:59:43 PM ---It wasn't about speed, readability was the last thing I was concerned about and I didn't really care about the beauty of the output. ... but it was fun.
--- End quote ---

You should add it to the Rosetta code Ruby example. Your coding style is certainly different from mine, but when I saw your one-liner, my first thought was WOW!  ;)

@Mike: No, that was no waste of time. Tomaaz impressed you and me, and he had fun.

Aurel:
well tommat (  ;D ) like to to do such a stuff ,,,yee haaa

here is one in REXX

This REXX version uses a simple formula to calculate the maximum value (triangle element) displayed.

/*REXX program constructs & displays  Floyd's triangle for any number of specified rows.*/
parse arg N .;    if N=='' | N==","  then N= 5   /*Not specified?  Then use the default.*/
mx= N * (N+1) % 2  - N                           /*calculate the maximum of any value.  */
say 'displaying a '  N  " row Floyd's triangle:" /*show the header for Floyd's triangle.*/
say                                              /*display a blank line below the title.*/
#=1;    do    r=1  for N;           i= 0;     _= /*construct Floyd's triangle row by row*/
           do #=#  for r;           i= i + 1     /*start to construct a row of triangle.*/
           _= _ right(#, length( mx+i ) )        /*build a row of the Floyd's triangle. */
           end   /*#*/                           /*calculate the max length on the fly. */
        say substr(_, 2)                         /*remove 1st leading blank in the line.*/
        end      /*r*/                           /*stick a fork in it,  we're all done. */

Tomaaz:
Mike, you wasted much more than 30 min. for talking about me wasting 30 min. That's rather funny. ;D What is not funny is your patronising style and constan attempts to convert every single topic to BASIC vs other languages competition. I want to show and see differences between languages. I'm not interested in finding overall winner, because it's simply impossible.

B+:
I have to say, what Tomaaz contributes to this forum has usually been challenging, interesting, stimulating, at least to this BASIC fan.

I also appreciate Mike's (no L needed) experienced tech point of view that can see through smoke and mirrors eg the illusion of one-liners.

What is boring is hostility or hysterics ;) which I think Mike himself has noted when I screwed up and Tomaaz has mentioned a time or two too.

And I have to agree with JJ on two points:
1. It is NOT a waste of time when someone is having fun at no other's expense.
2. The fixed spacing, right alignment of columns in Floyd's Triangle just plain looks better with a nice crisp line down the slope.

Navigation

[0] Message Index

[*] Previous page

Go to full version