Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Pyramids thread

Name: Anonymous 2018-03-29 11:28

Name: Anonymous 2018-03-29 12:37

pyramid 0 = ["*"]
pyramid n = map ((space ++) . (++ space)) down ++
map (unwords . replicate 2) down
where down = pyramid (n - 1)
space = replicate (2 ^ (n - 1)) ' '

main = mapM_ putStrLn $ pyramid 6

Name: Anonymous 2018-03-29 13:44

public static void main(String[] args) {

for(int i=0;i<5;i++) {
for(int j=0;j<5-i;j++) {
System.out.print(" ");
}
for(int k=0;k<=i;k++) {
System.out.print("😱 ");
}
System.out.println();
}
}

Name: Anonymous 2018-03-29 13:51

pyramid my anus

Name: goatfinger.ga 2018-03-29 14:34

(define (pyramid n) (upto (pyramid-row (* 2 n)) n))
(define ((pyramid-row n) g)
(let* ((g (+ 1 (* 2 g)))
(h (quotient (- n g) 2)))
(display (make-string h #\space))
(display (make-string g #\*))
(display (make-string h #\space))
(newline)))
(define (upto f n) (let loop ((i 0)) (when (< i n) (f i) (loop (+ i 1)))))

(pyramid 5)
*
***
*****
*******
*********

Name: Anonymous 2018-03-29 20:12

PROG/ CHALLENGE
#include <stdio.h>
int main()
{
int i, j, rows;

printf("Enter number of rows: ");
scanf("%d",&rows);

for(i=1; i<=rows; ++i)
{
for(j=1; j<=i; ++j)
{
printf("* ");
}
printf("\n");
}
}


Find all problems with above ccode there are four major and you can nitpick moaar

Name: Anonymous 2018-04-02 12:30

ENTERPRISE RECURSIVE SHELL SCRIPTING

#!/bin/sh
layers=$(($1))
[ -n "$1" ] || layers=8
[ $layers -gt 0 ] || exit 1

pyramid() {
if [ $1 -gt $layers ]; then
cat
echo
return
fi
{ sed 's/^/ /'
printf '*%.0s' $(seq $(($1*2-1)))
} | pyramid $(($1+1))
}
printf '' | pyramid 1



Usage:

$ sh pyramid.sh 8
*
***
*****
*******
*********
***********
*************
***************
$

Name: Anonymous 2018-04-02 14:05

use std::env::args;
use std::iter::{once, repeat};

fn main() {
let max_depth = args()
.skip(1)
.next()
.and_then(|arg| arg.parse().ok())
.unwrap_or(8);

let out: String = (1..=max_depth)
.flat_map(|i| {
repeat(' ')
.take(max_depth - i)
.chain(repeat('*').take(i * 2 - 1))
.chain(once('\n'))
})
.collect();

print!("{}", out);
}

Name: Anonymous 2018-04-02 15:15

(INT n)VOID: FOR i TO n DO printf($n(n-i)xn(i*2-1)"*"n(n-i)xl$) OD

Name: Anonymous 2018-04-02 16:27

def pyramid n
puts n.times.map { |m| (' ' * (n - m - 1)) + (?* * (m * 2 + 1)) }
end

Name: Anonymous 2018-04-02 17:16

>>8
Is this Sepples? Fluent notation makes it seem better than then trainwreck it was a couple of years ago. (still rubbish tho)

Name: Anonymous 2018-04-02 17:46

>>11
Its rust.

Don't change these.
Name: Email:
Entire Thread Thread List