Given a string of a constant length, print a triangle out of it. The triangle should start with the given string and keeps shrinking downwards by removing one character from the begining of the string. The spaces on the left side of the triangle should be replaced with dot character.
 
Example 1: 
Input:
S = Geeks
Output:
Geeks
.eeks
..eks
...ks
....s
Example 2: 
Input:
S = @io30 
Output:
 @io30
.io30
..o30
...30
....0 
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function triDownwards() which takes a String S and returns a string formed by joining all the lines together. For the Input "GEEKS" you should return the String "GEEKS.EEKS..EKS...KS....S".
 
Expected Time Complexity: O(|S|^{2})
Expected Auxiliary Space: O(|S|)
 
Constraints:
1 <= |S| <=100

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: #User function Template for python3



class Solution:

    def triDownwards(self, S):

        # code here

Solutions:
class Solution:

	def triDownwards(self, S):
		a = S
		for i in range(1, len(S)):
			a += '.' * i
			a += S[i:]
		return a


class Solution:

	def triDownwards(self, S):
		ans = ''
		n = len(S)
		for i in range(n):
			ans += '.' * i + S[i:]
		return ans


class Solution:

	def triDownwards(self, S):
		new = ''
		for i in range(len(S)):
			new += '.' * i + S[i:]
		return new


class Solution:

	def triDownwards(self, S):
		res = ''
		for i in range(len(S)):
			for j in range(len(S)):
				if i > j:
					res += '.'
				else:
					res += S[j]
		return res


class Solution:

	def triDownwards(self, S):
		dots = 0
		S_str_list = list(str(S))
		T = len(S_str_list)
		result = ''
		for x in S_str_list:
			t = '.' * dots + S[dots:T:1]
			result += t
			dots += 1
		return result


class Solution:

	def triDownwards(self, s):
		x = ''
		for i in range(len(s)):
			x += '.' * i + s[i:]
		return x


class Solution:

	def triDownwards(self, S):
		res = []
		for i in range(len(S) - 1):
			dot = '.' * i
			res.append(dot + S[i:] + '\n')
		dot = '.' * (len(S) - 1)
		res.append(dot + S[-1])
		return res


class Solution:

	def triDownwards(self, S):
		result = ''
		for i in range(len(S)):
			S1 = '.' * i
			S = S1 + S[i:]
			result += S
		return result


class Solution:

	def triDownwards(self, S):
		ans = []
		for i in range(len(S)):
			ans.append('.' * i + S[i:])
		return ''.join(ans)


class Solution:

	def triDownwards(self, S):
		s = ''
		for i in range(len(S)):
			temp = '.' * i
			temp += S[i:]
			s += temp
		return s


class Solution:

	def triDownwards(self, S):
		st = ''
		for i in range(len(S)):
			for j in range(0, i):
				st = st + '.'
			st = st + S[i:]
		return st


class Solution:

	def triDownwards(self, S):
		ans = ''
		count = 1
		for i in range(0, len(S), 1):
			for j in range(0, i, 1):
				ans += '.'
			ans += S[i:]
		return ans


class Solution:

	def triDownwards(self, S):
		a = ''
		n = len(S)
		for column in range(n):
			for row in range(n):
				if column > row:
					a += '.'
				else:
					a += S[row]
		return a


class Solution:

	def triDownwards(self, S):
		l = ''
		for i in range(0, len(S)):
			l += i * '.'
			l += S[i:]
		return l


class Solution:

	def triDownwards(self, S):
		s = ''
		sep = '.'
		l = len(S)
		for i in range(l):
			s = s + i * sep + S[i:]
		return s


class Solution:

	def triDownwards(self, s):
		n = len(s)
		res = ''
		for i in range(n):
			res = res + i * '.'
			res = res + s[i:]
		return res


class Solution:

	def triDownwards(self, S):
		k = ''
		for column in range(len(S)):
			for row in range(len(S)):
				if column > row:
					k += '.'
				else:
					k += S[row]
		return k


class Solution:

	def triDownwards(self, S):
		n = len(S)
		ans = ''
		for i in range(n):
			j = 0
			while j < i:
				ans += '.'
				j = j + 1
			ans += S[i:n]
		return ans


class Solution:

	def triDownwards(self, S):
		out = ''
		for i in range(len(S)):
			curr = '.' * i + S[i:]
			out += curr
		return out


class Solution:

	def triDownwards(self, S):
		output = ''
		for i in range(len(S)):
			pat = i * '.' + S[i:]
			output += pat
		return output


class Solution:

	def triDownwards(self, S):
		a = ''
		p = '.'
		for index in range(len(S)):
			i = p * index + S[index:]
			a += i
		return a


class Solution:

	def triDownwards(self, S):
		n = len(S)
		ans = [S]
		for i in range(n - 1):
			S = S.replace(S[i], '.', 1)
			ans.append(S)
		return ''.join(ans)


class Solution:

	def triDownwards(self, S):
		l1 = []
		k = list(S)
		l1.extend(k)
		for i in range(len(S) - 1):
			k.pop(i)
			k.insert(i, '.')
			l1.extend(k)
		return l1


class Solution:

	def triDownwards(self, S):
		a = ''
		for i in range(0, len(S)):
			b = i * '.'
			c = b + S[i:len(S)]
			a = a + c
		return a


class Solution:

	def triDownwards(self, S):
		l = []
		for i in range(len(S)):
			n = '.' * i + S[i:]
			l.append(n)
		return ''.join(l)


class Solution:

	def triDownwards(self, S):
		l = len(S)
		s = ''
		for i in range(l):
			for j in range(l):
				if i > j:
					s += '.'
				else:
					s += S[j]
		return s


class Solution:

	def triDownwards(self, S):
		newstr = ''
		for i in range(len(S)):
			for j in range(i):
				newstr += '.'
			for k in range(i, len(S)):
				newstr += S[k]
		return newstr


class Solution:

	def triDownwards(self, S):
		st = ''
		for i in range(len(S)):
			x = i * '.' + S[i:]
			st += x
		return st


class Solution:

	def triDownwards(self, S):
		res = ''
		for i in range(len(S)):
			res += S
			S = S.replace(S[i], '.', 1)
		return res


class Solution:

	def triDownwards(self, S):
		lis = []
		out = ''
		for i in S:
			lis.append(i)
		for i in range(len(lis)):
			for j in lis:
				out += j
			lis[i] = '.'
		return out


import re

class Solution:

	def triDownwards(self, S):
		x = ''
		for i in range(len(S)):
			x += '.' * i + S[i:]
		return x


class Solution:

	def triDownwards(self, S):
		n = len(S)
		st = n
		ans = ''
		dt = 0
		for i in range(1, n + 1):
			k = i - 1
			for j in range(1, dt + 1):
				ans = ans + '.'
			for j in range(1, st + 1):
				ans = ans + S[k]
				k = k + 1
			dt = dt + 1
			st = st - 1
		return ans


class Solution:

	def triDownwards(self, S):
		ss = len(S)
		a = []
		x = ''
		for i in range(0, ss):
			for j in range(i):
				x += '.'
			x += S[i:ss]
		return x


class Solution:

	def triDownwards(self, S):
		ans = [S]
		strr = '.'
		final = ''
		for i in range(len(S)):
			ans.append(strr + S[i + 1:])
			strr += '.'
		ans.pop()
		for i in ans:
			final += i
		return final


class Solution:

	def triDownwards(self, S):
		lis = list(S)
		l = []
		l.append(S)
		for i in range(0, len(S) - 1):
			lis[i] = '.'
			st = ''.join(lis)
			l.append(st)
		sti = ''.join(l)
		return sti


class Solution:

	def triDownwards(self, S):
		s = ''
		l = len(S)
		c = 0
		while l > c:
			s = s + '.' * c + S[c:l]
			c = c + 1
		return s


class Solution:

	def triDownwards(self, s):
		new = ''
		for i in range(len(s)):
			for j in range(len(s)):
				if i > j:
					new = new + '.'
				else:
					new = new + s[j]
		return new


class Solution:

	def triDownwards(self, S):
		pattern_list = [S]
		value_holder = list(S)
		return_str = S
		for i in range(1, len(S)):
			value_holder[i - 1] = '.'
			pattern_list.append(''.join(value_holder))
			return_str += pattern_list[i]
		return return_str


class Solution:

	def triDownwards(self, S):
		l = []
		n = len(S)
		a = ''
		for i in range(n):
			x = ''
			for j in range(i):
				x += '.'
			a += x + S[i:]
		return a


class Solution:

	def triDownwards(self, S):
		x = ''
		n = len(S)
		for i in range(n):
			for j in range(n):
				if j >= i:
					x = x + S[j]
				else:
					x = x + '.'
		return x