Skip to main content
added 63 characters in body
Source Link
ospahiu
  • 243
  • 1
  • 8

Python 2, 117 111 105 100 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Non-Golfed:

import string

def print_alphatriangle(n):
    offset = 1
    tail_offset = 3
    alpha = string.ascii_uppercase * n
    
    for i in range(len(alpha) - offset):
        if len(alpha) / 2 > i:
            print alpha[:i] + alpha[i::-offset]
            continue
        print alpha[:-i-offset] + alpha[-i-tail_offset::-offset]

This method works simply by string splicing an alphabet string that is concatenated together. Depending on whether i has reached a mid-way point of the string, it then starts to print out decreasing strings.

Python 2, 100 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Non-Golfed:

import string

def print_alphatriangle(n):
    offset = 1
    tail_offset = 3
    alpha = string.ascii_uppercase * n
    
    for i in range(len(alpha) - offset):
        if len(alpha) / 2 > i:
            print alpha[:i] + alpha[i::-offset]
            continue
        print alpha[:-i-offset] + alpha[-i-tail_offset::-offset]

This method works simply by string splicing an alphabet string that is concatenated together. Depending on whether i has reached a mid-way point of the string, it then starts to print out decreasing strings.

Python 2, 117 111 105 100 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Non-Golfed:

import string

def print_alphatriangle(n):
    offset = 1
    tail_offset = 3
    alpha = string.ascii_uppercase * n
    
    for i in range(len(alpha) - offset):
        if len(alpha) / 2 > i:
            print alpha[:i] + alpha[i::-offset]
            continue
        print alpha[:-i-offset] + alpha[-i-tail_offset::-offset]

This method works simply by string splicing an alphabet string that is concatenated together. Depending on whether i has reached a mid-way point of the string, it then starts to print out decreasing strings.

added 124 characters in body
Source Link
ospahiu
  • 243
  • 1
  • 8

Python 2, 100 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Non-Golfed:

import string

def print_alphatriangle(n):
    soffset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"*n1
    tail_offset = 3
    alpha = string.ascii_uppercase * n
    
    for i in range(len(salpha) - 1offset):
        if len(salpha) / 2 > i:
            print s[alpha[:i] + s[ialpha[i::-1]offset]
            continue
        print s[alpha[:-i-1]offset] + s[alpha[-i-3tail_offset::-1]offset]

This method works simply by string splicing an alphabet string that is concatenated together. Depending on whether i has reached a mid-way point of the string, it then starts to print out decreasing strings.

Python 2, 100 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Non-Golfed:

def print_alphatriangle(n):
    s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"*n
    for i in range(len(s) - 1):
        if len(s) / 2 > i:
            print s[:i] + s[i::-1]
            continue
        print s[:-i-1] + s[-i-3::-1]

This method works simply by string splicing an alphabet string that is concatenated together.

Python 2, 100 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Non-Golfed:

import string

def print_alphatriangle(n):
    offset = 1
    tail_offset = 3
    alpha = string.ascii_uppercase * n
    
    for i in range(len(alpha) - offset):
        if len(alpha) / 2 > i:
            print alpha[:i] + alpha[i::-offset]
            continue
        print alpha[:-i-offset] + alpha[-i-tail_offset::-offset]

This method works simply by string splicing an alphabet string that is concatenated together. Depending on whether i has reached a mid-way point of the string, it then starts to print out decreasing strings.

edited body
Source Link
ospahiu
  • 243
  • 1
  • 8

Python 2, 105100 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Non-Golfed:

def print_alphatriangle(n):
    s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"*n
    for i in range(len(s) - 1):
        if len(s) / 2 > i:
            print s[:i] + s[i::-1]
            continue
        print s[:-i-1] + s[-i-3::-1]

This method works simply by string splicing an alphabet string that is concatenated together.

Python 2, 105 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Python 2, 100 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2
for i in range(51):print(s[:-i-1]+s[-i-3::-1],s[:i]+s[i::-1])[26>i]

Run it

Thanks to @LeakyNun and @manatwork for pointing out a few byte saves.

Non-Golfed:

def print_alphatriangle(n):
    s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"*n
    for i in range(len(s) - 1):
        if len(s) / 2 > i:
            print s[:i] + s[i::-1]
            continue
        print s[:-i-1] + s[-i-3::-1]

This method works simply by string splicing an alphabet string that is concatenated together.

deleted 5 characters in body
Source Link
ospahiu
  • 243
  • 1
  • 8
Loading
deleted 6 characters in body
Source Link
ospahiu
  • 243
  • 1
  • 8
Loading
deleted 6 characters in body
Source Link
ospahiu
  • 243
  • 1
  • 8
Loading
Source Link
ospahiu
  • 243
  • 1
  • 8
Loading