1. ## Project Sigma!

Projσct Σ
by Daniel

Notice for those who can't/refuse to read: Do NOT post your solutions, PM Me!

Introduction:
Welcome to Project Sigma! This is along the lines of Project Euler (for those that know of it), but is more oriented to this community of beginner scripters utilising Simba. Don’t be fooled though, as it is designed for every one of all levels! Problems to solve will be released on a weekly basis, with user submissions submitted to me (via the PM system here at SRL/Villavu ONLY). Points are awarded to those whose code executes the fastest on my machine.
Rules:
1. Problems are to be solved using Simba.
i. This includes, but is not limited to, compiled code in the form of external libraries.
ii. Code must be able to compile using the Lape interpreter.
iii. Code cannot be submitted precompiled.
2. Problems must be solved independently.
i. This excludes using the assistance of the Internet to find the pseudo code of a required algorithm.
ii. This applies to You, the coder, directly or indirectly asking for assistance for a given problem (i.e. using IRC, another medium such as StackOverflow or programming-oriented forums).
3. The main, “problem-solving” part of the solution must be your code/creation.
i. e.g., if the problem asks to find the sum of an integer array, you cannot utilise Simba’s included method SumIntegerArray.
4. Solutions must be submitted before or on the due date. Late submissions will forfeit your chance to increment your position on the leader board.
i. If a person submits two or more solutions, then the earliest submitted will only be used – so test and ensure before submitting!
ii. If a person submits two or more solutions to multiple levels, then their highest level submission will only be used for grading.
iii. SRL Members (both past and present) and higher ranked (also, both past and present) are not allowed to compete in the beginner level.
5. Solutions are submitted under a public domain license.
i. This includes the later publication of your solutions for others to learn off of.
ii. By submitting, you agree to allow unrestricted use of your code in other peoples projects, utilising Simba/SRL or otherwise.
6. Use common sense, keep this competition/learning experience clean and fun
Marking Criteria (How you are judged):
If your submission does not meet the required outcomes of the problem, then it will not be graded as per below.

What determines your resultant score is [mainly] based solely on the speed of your submission. Textual outputs (i.e. WriteLn) will not be counted when determining the speed of your submission if they are independent of your problem. A maximum of five (if not otherwise stated) tests will be conducted and run through multiple iterations to determine your speed. The maximum speed attained, will be the speed that is used to determine your score.

If two or more solutions achieve the same result, then all of these solutions will be stress tested for a maximum of 10
× iterations with a much wider variety of parameters used. The winner of this stage will be awarded an additional 5, 3, or 1 point (with respect to their level – Advanced, Intermediate or Beginner).

If two or more solutions once again receive the same speed result, then their solutions performance will be tested using more accurate timing methods using the same test parameters as the previous paragraph. The winner of this stage will be awarded with an additional 7, 5, or 3 points (also, with respect to their level).

If once again, two or more solutions receive the same result, then the amount of raw code that is theirs used to complete the problem will be used to grade the result, with efficiency (CPU usage and memory usage) taken into account. The winner of this stage will be awarded 12, 9 or 6 points with respect to their level. If the solutions examined tie once again, then all entrants will be awarded with 10, 7 or 4 extra points with respect to their level.

Overall:

1. mixster - 20
2. Dgby714 - 10
3. Methrend - 10
4. beginner5 - 5
5. slushpuppy - 5
6. Sex - 2
7. Zyt3x - 2
8. putonajonny - 2
9. masterBB - 2
10. -

1. mixster - 20
2. beginner5 - 5
3. -
4. -
5. -
6. -
7. -
8. -
9. -
10. -

Intermediate:

1. Dgby714 - 10
2. Methrend - 10
3. Sex - 2
4. Zyt3x - 2
5. putonajonny - 2
6. masterBB - 2
7. -
8. -
9. -
10. -

Beginner:

1. slushpuppy - 5
2. -
3. -
4. -
5. -
6. -
7. -
8. -
9. -
10. -
Problem #3:

Beginner:
Binary What?
You are to construct a program which converts X (of type unsigned Integer [that means no negative values will be given]) into its binary equivalent. You are not allowed to use any in-built Simba methods to assist with this conversion. Make sure X is a defined constant that is placed at the beginning of your script and is more suitably named given its purpose.

Example:
 X = 2 Output = 10

Example:

 X = 10 Output = 1010

Example:

 X = 15 Output = 1111
Points Awarded: 5
Intermediate:
Fun With Factorials #2!
Write a program that finds the amount of trailing zeroes of the factorial X. You are not allowed to use the in-built Simba method Factorial to calculate the factorial of a number (you must make your own!). Make sure X is a defined constant that is placed at the beginning of your script and is more suitably named given their purpose.

Example #1:
 X = 5 Factorial = 120 Output = 1

Example #2:
 X = 3 Factorial = 6 Output = 0

Points Awarded: 10
Big-Super-Large Numbers!
You are to write a library for Simba in the form of an include file which enables support for integers larger than length 20 ( Length[IntToStr(2^64)] ). You must support the four basic mathematical operations (addition, subtraction, multiplication and division), as-well as y-√ (i.e. Sqrt[y](x) ) in separate functions with the result type as your big number type, as-well as including a method to convert a big number to and from a standard integer with overflow checking, and to and from a string.

NOTE #1: You are not expected to have support for floating point numbers in your solution.

Example:
 BigNumAdd(100, 100) = 200 // Addition BigNumSub(50, 100) = -50 // Subtraction BigNumMultiply(2, 50) = 100 // Multiplication BigNumDiv(50, 2) = 25 // Division BigNumSqrt(25, 2) [==Sqrt(25)] = 5 // Square root BigNumSqrt(1000, 3) [== y-root(1000, 3)] = 10 // Cube root BigNumToStr(24) = ‘24’ BigNumToInt(1) = 1

Points Awarded: 20
Submission Date:
To be submitted by:
Sunday 25th of March, 2012, 12:00 PM (AEDT / GMT + 11)
OR, Sunday 25th of March, 2012, 01:00 AM (GMT)
OR, Saturday 24th of March, 2012, 5:00 PM (PST / GMT - 8)
Good Luck, and don't rush!
Last edited by Daniel; 03-17-2012 at 11:33 PM. Reason: Added "don't rush" to conclusion of post. Indented submission dates.

2. Past Questions:

Week #2:

Please see this post for user submissions.

Beginner:
Fun With Factorials!
Write a program that programmatically finds the Highest Common Factor of the factorial X and the factorial of Y, otherwise return 0 (zero). Make sure X and Y are defined constants that are placed at the beginning of your script and are more suitably named given their purpose.

Example:
 X = 5, Y = 6 HCF = 120
There were no valid submissions for this entry. Quite disappointing
Intermediate:
Write a program that clones the IntToStr function within Simba. In your solution, you may NOT use Simba’s *ToStr in any way (including Format or any other variant), shape or form, and you must check the validity of the argument given. You must also support integers that are both positive AND negative, and output accordingly.

Example #1:
 Input = 1000 Output = "1000"

Example #2:
 Input = -500 Output = "-500"

Example #3:
 Input = "abc" Output = ""
There were three entries for this. Dgby714's submission, however, was the fastest out of all three. [Nathan]'s I couldn't really accept because it didn't work for most of the values tested (48% success rate).

PolyCom
Write a program that takes a standard array of points of n-length, which constructs a 2-dimensional polygon shape (arr1 connects to arr2 , arr2 -> arr3 , … , arrn-1 -> arrn , arrn -> arr1)note-1. Create separate appropriately-named methods which:

• returns TRUE if the argument point (of type TPoint) is inside the polygon,
• returns TRUE if the polygon is complex,
• returns the amount of closed regions of the polygon,
• returns the maximum angle in DEGREES (minimum precision of 3 floating point numbers) of ALL intersections IF the polygon is complex. You are to sort this array so that it is ordered in a top-down, left-right order.note-2

NOTE #1: You must connect the provided points to each other via straight lines, these will not be given.
NOTE #2: An intersection is defined if TWO lines intersect and continue past that point.

Example #1:
 array = [(0, 0), (5,5), (5, 0)] Result_PointInside(2, 1) = True Result_IsComplex = False Result_RegionCount = 1 Result_Angles = [ [] ]

Example #2:
 array = [(0, 0), (5, 0), (0, 5), (5, 5)] Result_PointInside(6, 1) = False Result_IsComplex = True Result_RegionCount = 2 Result_Angles = [ x.xxx ]
No submissions for this which was quite saddening Dgby714, however, allowed me to show to the public his unfinished submission (which only works for simple polygon's). Quite impressive

No points were awarded.

Week #1:

Please see this post for user submissions.

Beginner:
Find-A-Number! -
Write a program that finds the position of the first occurrence of X in a sorted array of whole numbers. Make sure that X is a defined constant at the beginning of your script and is more appropriately named for its purpose.

Example:
 X = 3, Array = [1, 2, 3, 4, 5] Result = 3

Since there was only one entry (disappointing!), there was only one winner: slushpuppy.

Intermediate:
Write a program that returns all possible combinations of the characters in string, in order of the sequence of characters with no overlaps. Make sure that string is a constant and is placed at the beginning of the script.

Example:
 string = ‘abc’ Result = ‘aaa’, ‘aab’, ‘aac’ … ‘ccc’
[I]There were several entries, which was quite impressive Methrend's was the fastest out of the quad entrants.

Sort n’ Search -
You will be given an n-length array of random integer values with a signed 24-bit range. You are required to sort this array first following a pattern/sequence (i.e. ascending-descending, descending-ascending, odd-even, even-odd, etc - no "intelligent design sort"), not using the internal sorting methods already included Simba, or implementing a Quick Sort or Bubble Sort algorithm. You are then required to return the positions of all occurrences of X and Y in that sorted array. You should return an integer array of these positions in two separate appropriately named arrays. Make sure that X, Y and array are defined constants at the beginning of your script, and are more appropriately named given their purpose.
Example:
 X = 6, Y = 9, Array = [4, 9, 4, 3, 9] ResultX = [], ResultY = [4, 5]

Only two entries: mixster and beginner5 Unfortunately beginner5 used BubbleSort, but I still allowed it anyway because of the limited number of entrants. mixster had won this week in terms of speed.
Last edited by Daniel; 03-17-2012 at 02:34 AM.

3. Reserved in case the first two threads fill up.
Last edited by Daniel; 03-02-2012 at 12:24 PM.

4. lol... Apparently I can't read...
Last edited by Dgby714; 03-02-2012 at 12:27 PM.

5. You might want to specify that submitting is done through PM? At least that is what I believe is the correct way.

6. ii. Code must be able to compile using the Lape interpreter.
Why Lape not PS?

7. Originally Posted by beginner5
Why Lape not PS?
Wider platform support, faster compilation time, pointer support, etc

The code is exactly the same as what you would write in PascalScript, so it shouldn't be a problem at all

Plus, it will also get the community to start adopting Lape in favour of PascalScript, as-well as a great testing ground for Niels

8. Sounds great!

9. Plus, it will also get the community to start adopting Lape in favour of PascalScript, as-well as a great testing ground for Niels
But with Lape in Simba ...hmm I can't even compile this:
Simba Code:
program new;{$i SRL/SRL.simba}beginend. So it's really hard to adopt Lape:P 10. Awesome, been lazy about using Lape, this will get me to finally play with it! 11. Originally Posted by beginner5 But with Lape in Simba ...hmm I can't even compile this: Simba Code: program new;{$i SRL/SRL.simba}beginend.
So it's really hard to adopt Lape:P
You should prob check out the Lape branch for SRL >..>

Anyways yes Lape is missing a few things to make it "Public".
Tho people should still start to learn the extra things it has.

12. Submitted my solution to the advanced problem. +1 internets to anyone that beats me.

13. I've sent in my script and it shall be great wins!

14. I still think my solution is valid under the rewrite, but that is up to herr judge.

15. I only have submissions for the advanced thus far. Nobody wanting to do the other levels?

16. SRL Junior Member
Join Date
Dec 2011
Posts
258
Mentioned
0 Post(s)
Quoted
0 Post(s)
Originally Posted by Daniel
I only have submissions for the advanced thus far. Nobody wanting to do the other levels?
I might have a go at the beginner, what program do you want the answer to appear in?

17. SRL Member
Join Date
Feb 2007
Location
Switzerland
Posts
583
Mentioned
1 Post(s)
Quoted
50 Post(s)
@Daniel
I am trying to do BruteForceMadness at the moment.

18. Originally Posted by Gala
@Daniel
I am trying to do BruteForceMadness at the moment.
Then from now on we are rivals. I submitted my solution.

19. SRL Member
Join Date
Feb 2007
Location
Switzerland
Posts
583
Mentioned
1 Post(s)
Quoted
50 Post(s)
Originally Posted by masterBB
Then from now on we are rivals. I submitted my solution.
I am still struggling with my script, I will try to finish it tomorrow.

20. Originally Posted by sm321
I might have a go at the beginner, what program do you want the answer to appear in?
You are to program in Simba, and display your findings in the debug/output box below.

21. SRL Junior Member
Join Date
Dec 2011
Posts
258
Mentioned
0 Post(s)
Quoted
0 Post(s)
Beginner:
Find-A-Number! -
Write a program that finds the position of the first occurrence of X in a sorted array of whole numbers. Make sure that X is a defined constant at the beginning of your script and is more appropriately named for its purpose.

Example:
Code:
X = 3, Array = [1, 2, 3, 4, 5]
Result = 3
I don't get what you mean by "position of the first occurrence of X". It's written clearly but I'm new to this

22. A few extra examples:

X = 6, Array = [1, 3, 6, 8]
Result = 3

X = 2, Array = [2, 2, 7, 11, 14]
Result = 1

X = 11, Array = [2, 7, 7, 11, 11]
Result = 4

23. SRL Junior Member
Join Date
Dec 2011
Posts
258
Mentioned
0 Post(s)
Quoted
0 Post(s)
Originally Posted by masterBB
A few extra examples:

X = 6, Array = [1, 3, 6, 8]
Result = 3

X = 2, Array = [2, 2, 7, 11, 14]
Result = 1

X = 11, Array = [2, 7, 7, 11, 11]
Result = 4
Sorry, still no idea. Once you have X, then what. I know things like:

Code:
x+4=6
x=2

24. Are you basing the index number from 1 or 0? Technically, your examples should read 1 less, since arrays start with 0.

25. SRL Junior Member
Join Date
Feb 2012
Location
Australia
Posts
87
Mentioned
0 Post(s)
Quoted
0 Post(s)
Originally Posted by sm321
Sorry, still no idea. Once you have X, then what. I know things like:

Code:
x+4=6
x=2
Originally Posted by masterBB
A few extra examples:

X = 6, Array = [1, 3, 6, 8]
Result = 3

X = 2, Array = [2, 2, 7, 11, 14]
Result = 1

X = 11, Array = [2, 7, 7, 11, 11]
Result = 4
What he is trying to tell you is that you must find the first occurrence of "x". A.K.A "At which point you first notice x".

In example 1, x=6. Therefore you look at the numbers and note which point the value for x first occurs.

[1 (first number), 3 (second number), 6(third number), 8(fifth number)]

As you can see, the result is 3. You are not trying to solve what x itself equals, rather what position x has in a list of numbers.

P.S I may be wrong, but that's how I see it.
Last edited by Sytherix; 03-05-2012 at 09:20 AM.