Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

HackerRank Triangle Quest 2 solution in python

YASH PAL, 31 July 2024

In this Triangle Quest 2 problem, we need to develop a python program that can read an integer input and then print a triangle equal to the size of that input on the output screen.

HackerRank Triangle Quest 2 solution in python

Problem solution in Python 2 programming.

for i in range(1,int(raw_input())+1): #More than 2 lines will result in 0 score. Do not leave a blank line also
    print sum(map(sum, map(lambda y: map(lambda x: 10 ** x, xrange(y)), xrange(1, i + 1)))) * (10 ** (i-1))+sum(map(sum, map(lambda y: map(lambda x: 10 ** (i - x - 2), xrange(y)), xrange(1, i))))

Problem solution in Python 3 programming.

for i in range(1,int(input())+1): #More than 2 lines will result in 0 score. Do not leave a blank line also
    print (((10**i - 1)//9)**2)

Problem solution in pypy programming.

for x in range(1,int(input())+1):
    print(((10**x - 1)//9)**2)

Problem solution in pypy3 programming.

for x in range(1,int(input())+1):# Enter your code here. Read input from STDIN. Print output to STDOUT
    print(((111111111)%(10**x))**2)

coding problems solutions Python Solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes