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!*$@

Post by -Ninjex- on Sat Sep 21, 2013 3:44 am
([msg=77447]see Re: Triangle Numbers are a B!*$@[/msg])

@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.
image
For those that know
K: 0x2CD8D4F9
User avatar
-Ninjex-
Moderator
Moderator
 
Posts: 1691
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)


Re: Triangle Numbers are a B!*$@

Post by Ayr3s on Mon Jul 13, 2015 3:10 pm
([msg=89001]see Re: Triangle Numbers are a B!*$@[/msg])

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/python2

import sys

def 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 repeat

power = 1 # power of 10 that will be added to the base_number.
iterator_number = base_number # number that will grow with repetitions of base_number
total_sum = 0

while power <= num_digits:
    total_sum = total_sum + triangle_numbers_sum(iterator_number)
    iterator_number += base_number*10**power
    power += 1
   
print(total_sum)
User avatar
Ayr3s
New User
New User
 
Posts: 29
Joined: Mon Feb 02, 2015 2:34 pm
Blog: View Blog (0)


Re: Triangle Numbers are a B!*$@

Post by Valar_Dragon on Mon Oct 19, 2015 2:54 pm
([msg=90218]see Re: Triangle Numbers are a B!*$@[/msg])

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
New User
 
Posts: 18
Joined: Sat Oct 17, 2015 10:47 am
Blog: View Blog (0)


Re: Triangle Numbers are a B!*$@

Post by cyberdrain on Mon Oct 19, 2015 4:55 pm
([msg=90225]see Re: Triangle Numbers are a B!*$@[/msg])

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
User avatar
cyberdrain
Expert
Expert
 
Posts: 2160
Joined: Sun Nov 27, 2011 1:58 pm
Blog: View Blog (0)


Re: Triangle Numbers are a B!*$@

Post by Valar_Dragon on Mon Oct 19, 2015 6:50 pm
([msg=90231]see Re: Triangle Numbers are a B!*$@[/msg])

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
New User
 
Posts: 18
Joined: Sat Oct 17, 2015 10:47 am
Blog: View Blog (0)


Re: Triangle Numbers are a B!*$@

Post by cyberdrain on Tue Oct 20, 2015 5:51 am
([msg=90248]see Re: Triangle Numbers are a B!*$@[/msg])

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
User avatar
cyberdrain
Expert
Expert
 
Posts: 2160
Joined: Sun Nov 27, 2011 1:58 pm
Blog: View Blog (0)


Re: Triangle Numbers are a B!*$@

Post by -Ninjex- on Tue Oct 20, 2015 6:03 am
([msg=90249]see Re: Triangle Numbers are a B!*$@[/msg])

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.
image
For those that know
K: 0x2CD8D4F9
User avatar
-Ninjex-
Moderator
Moderator
 
Posts: 1691
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)


Re: Triangle Numbers are a B!*$@

Post by cyberdrain on Wed Oct 21, 2015 8:55 am
([msg=90260]see Re: Triangle Numbers are a B!*$@[/msg])

-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
User avatar
cyberdrain
Expert
Expert
 
Posts: 2160
Joined: Sun Nov 27, 2011 1:58 pm
Blog: View Blog (0)


Re: Triangle Numbers are a B!*$@

Post by -Ninjex- on Wed Oct 21, 2015 10:47 am
([msg=90266]see Re: Triangle Numbers are a B!*$@[/msg])

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.
image
For those that know
K: 0x2CD8D4F9
User avatar
-Ninjex-
Moderator
Moderator
 
Posts: 1691
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)


Previous

Return to User Submitted

Who is online

Users browsing this forum: No registered users and 0 guests