Login Register






[Challenge:1] Multiples of 3 and 5 filter_list
Author
Message
RE: Multiples of 3 and 5 #11
(11-27-2016, 12:46 AM)bitm0de Wrote: @Pikami - You could have just used std::map<int, int> and it would have already been sorted on insertions.
Thanks for the tip, I know that using vectors for this is a shity solution Biggrin

Reply

RE: Multiples of 3 and 5 #12
Well done @bitm0de +100 for you.
You should now go for the second challenge https://sinister.li/Thread-Fibonacci-Divisibility .

Reply

RE: Multiples of 3 and 5 #13
Go.

Code:
package main func main() { var total int for i := 0; i < 1000; i++ { if i%3 == 0 || i%5 == 0 { total += i } } println(total) }

Reply

RE: Multiples of 3 and 5 #14
@lux wow first time i hear of this language anyway you've done only the first part +50
For extra 50 points do a function to reverse that sum and a function to sort it in ascending order. (this is the part you forgot to do)

Reply

RE: [Challenge:1] Multiples of 3 and 5 #15
C#

Spoiler:
Code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Multiples {    class Program    {        static void Main(string[] args)        {            //Variables            int intSum = 0;            string strSum = string.Empty;            //Calculate sum            for (int i = 0; i < 1000; i++)            {                if (i % 3 == 0 || i % 5 == 0)                {                    intSum += i;                    strSum = intSum.ToString();                                    }            }            Console.WriteLine("The sum is {0}", strSum); //Write sum result            //Reverse the number (another loop, boring I know)            string strSumReversed = string.Empty;            int intCount = strSum.Length;            for (int x = 0; x < strSum.Length; x++)            {                strSumReversed = strSumReversed + strSum.Substring(intCount -1, 1);                intCount = intCount - 1;            }            Console.WriteLine("The sum reversed is: {0}", strSumReversed); //Write reversed result            Console.ReadLine();                      }        }    }
~~ Might be back? ~~

Reply

RE: [Challenge:1] Multiples of 3 and 5 #16
Good job @Bish0pQ but as mentioned here https://sinister.li/Thread-Competition-R...scoreboard this competition won't continue.

Reply

RE: [Challenge:1] Multiples of 3 and 5 #17
(12-08-2016, 09:36 AM)Bish0pQ Wrote: C#

Spoiler:
Code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Multiples {    class Program    {        static void Main(string[] args)        {            //Variables            int intSum = 0;            string strSum = string.Empty;            //Calculate sum            for (int i = 0; i < 1000; i++)            {                if (i % 3 == 0 || i % 5 == 0)                {                    intSum += i;                    strSum = intSum.ToString();                                    }            }            Console.WriteLine("The sum is {0}", strSum); //Write sum result            //Reverse the number (another loop, boring I know)            string strSumReversed = string.Empty;            int intCount = strSum.Length;            for (int x = 0; x < strSum.Length; x++)            {                strSumReversed = strSumReversed + strSum.Substring(intCount -1, 1);                intCount = intCount - 1;            }            Console.WriteLine("The sum reversed is: {0}", strSumReversed); //Write reversed result            Console.ReadLine();                      }        }    }

String's are immutable in .NET, but why didn't you use the for loop variable here?
Code:
for (int x = 0; x < strSum.Length; x++) { strSumReversed = strSumReversed + strSum.Substring(intCount -1, 1); intCount = intCount - 1; }

Instead of keeping track of your own variable?
(This post was last modified: 12-08-2016, 05:35 PM by bitm0de.)
- mostly braindead monkeys on this forum.

Reply