## Triangle Numbers are a B!*\$@

This is the place for ALL of the user submitted challenges. If you create a little challenge/mission/riddle/whatever, post it here.
Forum rules
Do not post missions that you did NOT create without proper citing.

### Re: Triangle Numbers are a B!*\$@

@Amazingred
Yeah the challenge was designed to appear simplistic, but once you dig in, you actually have to figure out how you will bypass the obstacles of stack recursion and time.

+200 of course, I also appreciate the honesty in your coding algorithm.

For those that know
K: 0x2CD8D4F9

-Ninjex-
Moderator

Posts: 1691
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)

### Re: Triangle Numbers are a B!*\$@

python 2

Code: Select all
`166833500166833500166833500166833500166814981648314981648315`

run like this:
\$ triangle-numbers.py 9 20
( "\$ triangle-numbers.py 9 1" would give 165)
Code: Select all
`#!/usr/bin/python2import sysdef triangle_numbers_sum(n):    triangle_sum = ((n**3)+3*(n**2)+2*n)/6    return triangle_sum    ### Entry Point ###base_number = int(sys.argv[1]) # establish the digit that will repeat.num_digits = int(sys.argv[2]) # establish up to how many digits it shall repeatpower = 1 # power of 10 that will be added to the base_number.iterator_number = base_number # number that will grow with repetitions of base_numbertotal_sum = 0while power <= num_digits:    total_sum = total_sum + triangle_numbers_sum(iterator_number)    iterator_number += base_number*10**power    power += 1    print(total_sum)`

Ayr3s
New User

Posts: 29
Joined: Mon Feb 02, 2015 2:34 pm
Blog: View Blog (0)

### Re: Triangle Numbers are a B!*\$@

Nice and easy problem

Its written in c#,
and the output is:
166833500166833500166833500166833500166814981648314981648315
are the 200 points added to my HTS profile?

Code: Select all
`using System;using System.Collections.Generic;using System.Text;using System.Threading.Tasks;using System.Numerics;using System.Diagnostics;namespace HTS_Triangle_Numbers{    class Program    {        static void Main(string[] args)        {            Stopwatch sw = new Stopwatch();            sw.Start();            BigInteger total = 0;            for (int pow10 = 1; pow10 < 21; pow10++)            {                total += SumofTriangleNo((BigInteger)Math.Pow(10, pow10) - 1)/2;            }            Console.WriteLine(total);            sw.Stop();            Console.WriteLine("{0} ms", sw.ElapsedMilliseconds);            Console.ReadLine();        }        static BigInteger SumofTriangleNo(BigInteger upperlimit)        {//x^3/3 + x^2 + 2x/3             BigInteger toreturn = (BigInteger)((upperlimit * upperlimit * upperlimit) + (3*upperlimit * upperlimit) + (2 * upperlimit))/3;            return toreturn;        }    }}`
Valar_Dragon
New User

Posts: 18
Joined: Sat Oct 17, 2015 10:47 am
Blog: View Blog (0)

### Re: Triangle Numbers are a B!*\$@

Valar_Dragon wrote:are the 200 points added to my HTS profile?

Nope, they're at Ninjex's page. Anyway, you shouldn't worry about points, see what you've learned instead
Free your mind / Think clearly

cyberdrain
Expert

Posts: 2160
Joined: Sun Nov 27, 2011 1:58 pm
Blog: View Blog (0)

### Re: Triangle Numbers are a B!*\$@

Thank you for the reply! Apologies if this isn't the right place to ask,
but is this ninja's page: http://ninjex.webs.com/ ?
If so, I get a message saying the site is frozen
Valar_Dragon
New User

Posts: 18
Joined: Sat Oct 17, 2015 10:47 am
Blog: View Blog (0)

### Re: Triangle Numbers are a B!*\$@

Valar_Dragon wrote:Thank you for the reply! Apologies if this isn't the right place to ask,
but is this ninja's page: http://ninjex.webs.com/ ?
If so, I get a message saying the site is frozen

Yeah, you found the page. I don't remember it being frozen last time or maybe the list is somewhere else now. Try sending a PM to Ninjex.
Free your mind / Think clearly

cyberdrain
Expert

Posts: 2160
Joined: Sun Nov 27, 2011 1:58 pm
Blog: View Blog (0)

### Re: Triangle Numbers are a B!*\$@

I've really stopped keeping up with all this stuff. I left HTS for a while before coming back. I'll probably grab the information and implement a chart on my dedicated sometime, but I'm not going to guarantee anything. I'm slammed with work right now, so I don't have the luxury to do free activities as much, sorry.

For those that know
K: 0x2CD8D4F9

-Ninjex-
Moderator

Posts: 1691
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)

### Re: Triangle Numbers are a B!*\$@

-Ninjex- wrote:I've really stopped keeping up with all this stuff. I left HTS for a while before coming back. I'll probably grab the information and implement a chart on my dedicated sometime, but I'm not going to guarantee anything. I'm slammed with work right now, so I don't have the luxury to do free activities as much, sorry.

Well, at least this challenge is still accessible. Can't we have HTS host some of those user submitted challenges?
Free your mind / Think clearly

cyberdrain
Expert

Posts: 2160
Joined: Sun Nov 27, 2011 1:58 pm
Blog: View Blog (0)

### Re: Triangle Numbers are a B!*\$@

If I recall from previous posts by mShred and discussion, if the challenges are good enough and people like them, they could be implemented. It would have to go through a whole process, and right now I think the staff is more focused on fixes and updating things, rather than bulking up the challenges and adding new content. They may be implemented in the future, but honestly, I don't see it happening until all the other stuff gets done first.

For those that know
K: 0x2CD8D4F9

-Ninjex-
Moderator

Posts: 1691
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)

Previous