Skip to content

Commit

Permalink
Merge branch 'main' into project2
Browse files Browse the repository at this point in the history
  • Loading branch information
alstondsouza1 authored Nov 10, 2024
2 parents 027aca4 + aaa7206 commit a71c899
Show file tree
Hide file tree
Showing 13 changed files with 231 additions and 13 deletions.
4 changes: 2 additions & 2 deletions archive/a/ada/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Welcome to Sample Programs in Ada! To find documentation related to the Ada code in this repo, look [here.](https://sampleprograms.io/languages/ada)

## Sample Programs List - 2/37 :disappointed:
## Sample Programs List - 3/37 :disappointed:

In this section, we feature a list of completed and missing programs in Ada. See above for the current amount of completed programs in Ada. If you see a program that is missing and would like to add it, please submit an issue, so we can assign it to you.

Expand All @@ -11,6 +11,7 @@ In this section, we feature a list of completed and missing programs in Ada. See
Below, you'll find a list of completed code snippets in Ada. Code snippets preceded by :warning: link to a GitHub issue query featuring a possible article request issue. If an article request issue doesn't exist, we encourage you to create one. Meanwhile, code snippets preceded by :white_check_mark: link to an existing article which provides further documentation. To see the list of approved projects, check out the official Sample Programs projects list.

- :warning: [Baklava in Ada](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+baklava+ada) [[Requirements](https://sampleprograms.io/projects/baklava)]
- :warning: [Fizz Buzz in Ada](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+fizz+buzz+ada) [[Requirements](https://sampleprograms.io/projects/fizz-buzz)]
- :warning: [Hello World in Ada](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+hello+world+ada) [[Requirements](https://sampleprograms.io/projects/hello-world)]

### Missing Programs
Expand All @@ -28,7 +29,6 @@ The following list contains all of the approved programs that are not currently
- :x: [Factorial](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,factorial&template=code-snippet-request.md&title=Add+Factorial+in+Ada) [[Requirements](https://sampleprograms.io/projects/factorial)]
- :x: [Fibonacci](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,fibonacci&template=code-snippet-request.md&title=Add+Fibonacci+in+Ada) [[Requirements](https://sampleprograms.io/projects/fibonacci)]
- :x: [File Input Output](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,file+input+output&template=code-snippet-request.md&title=Add+File+Input+Output+in+Ada) [[Requirements](https://sampleprograms.io/projects/file-input-output)]
- :x: [Fizz Buzz](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,fizz+buzz&template=code-snippet-request.md&title=Add+Fizz+Buzz+in+Ada) [[Requirements](https://sampleprograms.io/projects/fizz-buzz)]
- :x: [Fraction Math](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,fraction+math&template=code-snippet-request.md&title=Add+Fraction+Math+in+Ada) [[Requirements](https://sampleprograms.io/projects/fraction-math)]
- :x: [Insertion Sort](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,insertion+sort&template=code-snippet-request.md&title=Add+Insertion+Sort+in+Ada) [[Requirements](https://sampleprograms.io/projects/insertion-sort)]
- :x: [Job Sequencing](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,job+sequencing&template=code-snippet-request.md&title=Add+Job+Sequencing+in+Ada) [[Requirements](https://sampleprograms.io/projects/job-sequencing)]
Expand Down
19 changes: 19 additions & 0 deletions archive/a/ada/fizz-buzz.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
with Text_IO; use Text_IO;

procedure Fizz_Buzz is
Counter : Integer := 1;
begin
while Counter < 101
loop
if Counter mod 3 = 0 and Counter mod 5 = 0 then
Put_Line("FizzBuzz");
elsif Counter mod 3 = 0 then
Put_Line("Fizz");
elsif Counter mod 5 = 0 then
Put_Line("Buzz");
else
Put_Line(Integer'Image(Counter));
end if;
Counter := Counter + 1;
end loop;
end Fizz_Buzz;
4 changes: 2 additions & 2 deletions archive/c/c-plus-plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Welcome to Sample Programs in C++! To find documentation related to the C++ code in this repo, look [here.](https://sampleprograms.io/languages/c-plus-plus)

## Sample Programs List - 26/37 :relaxed:
## Sample Programs List - 27/37 :relaxed:

In this section, we feature a list of completed and missing programs in C++. See above for the current amount of completed programs in C++. If you see a program that is missing and would like to add it, please submit an issue, so we can assign it to you.

Expand Down Expand Up @@ -32,6 +32,7 @@ Below, you'll find a list of completed code snippets in C++. Code snippets prece
- :warning: [Palindromic Number in C++](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+palindromic+number+c++) [[Requirements](https://sampleprograms.io/projects/palindromic-number)]
- :warning: [Prime Number in C++](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+prime+number+c++) [[Requirements](https://sampleprograms.io/projects/prime-number)]
- :warning: [Quick Sort in C++](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+quick+sort+c++) [[Requirements](https://sampleprograms.io/projects/quick-sort)]
- :warning: [Remove All Whitespace in C++](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+remove+all+whitespace+c++) [[Requirements](https://sampleprograms.io/projects/remove-all-whitespace)]
- :warning: [Reverse String in C++](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+reverse+string+c++) [[Requirements](https://sampleprograms.io/projects/reverse-string)]
- :warning: [Roman Numeral in C++](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+roman+numeral+c++) [[Requirements](https://sampleprograms.io/projects/roman-numeral)]
- :warning: [Rot13 in C++](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+rot13+c++) [[Requirements](https://sampleprograms.io/projects/rot13)]
Expand All @@ -49,7 +50,6 @@ The following list contains all of the approved programs that are not currently
- :x: [Maximum Subarray](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,maximum+subarray&template=code-snippet-request.md&title=Add+Maximum+Subarray+in+C%2B%2B) [[Requirements](https://sampleprograms.io/projects/maximum-subarray)]
- :x: [Minimum Spanning Tree](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,minimum+spanning+tree&template=code-snippet-request.md&title=Add+Minimum+Spanning+Tree+in+C%2B%2B) [[Requirements](https://sampleprograms.io/projects/minimum-spanning-tree)]
- :x: [Quine](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,quine&template=code-snippet-request.md&title=Add+Quine+in+C%2B%2B) [[Requirements](https://sampleprograms.io/projects/quine)]
- :x: [Remove All Whitespace](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,remove+all+whitespace&template=code-snippet-request.md&title=Add+Remove+All+Whitespace+in+C%2B%2B) [[Requirements](https://sampleprograms.io/projects/remove-all-whitespace)]
- :x: [Sleep Sort](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,sleep+sort&template=code-snippet-request.md&title=Add+Sleep+Sort+in+C%2B%2B) [[Requirements](https://sampleprograms.io/projects/sleep-sort)]
- :x: [Transpose Matrix](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,transpose+matrix&template=code-snippet-request.md&title=Add+Transpose+Matrix+in+C%2B%2B) [[Requirements](https://sampleprograms.io/projects/transpose-matrix)]

Expand Down
34 changes: 34 additions & 0 deletions archive/c/c-plus-plus/remove-all-whitespace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <iostream>
#include <string>
#include <cctype> // for std::isspace


int main(int argc, char* argv[]) {

// Check if given string passed
if (argc < 2) {
std::cout << "Usage: please provide a string" << std::endl;
return 1; // Return error code if no string is given
}

// Get the string passed
std::string input = argv[1];
std::string result;

// Check if input string is empty
if (input.empty()) {
std::cout << "Usage: please provide a string" << std::endl;
return 1; // Exit error code if the string is empty
}

for(char c : input) {
// If the character is not a whitespace character, add it to result
if (!std::isspace(static_cast<unsigned char>(c))) {
result += c;
}
}
//print out the result (string should have no spaces)
std::cout << result << std::endl;

return 0;
}
71 changes: 71 additions & 0 deletions archive/c/c-sharp/LongestPalindromicSubstring.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Text.RegularExpressions;

namespace SamplePrograms
{
public class LongestPalindromicSubstring
{
public static void Main(string[] args)
{
string input = string.Join(" ", args);
Console.WriteLine(LongestPalindrome(input));
}

public static string LongestPalindrome(string input)
{
if (string.IsNullOrEmpty(input) || !ContainsPalindrome(input))
{
return "Usage: please provide a string that contains at least one palindrome";
}

int start = 0;
int end = 0;

for (int i = 0; i < input.Length; i++)
{
int lengthOne = ExpandAroundCenter(input, i, i);
int lengthTwo = ExpandAroundCenter(input, i, i + 1);
int length = Math.Max(lengthOne, lengthTwo);

if (length > end - start)
{
start = i - (length - 1) / 2;
end = i + length / 2;
}
}
return input.Substring(start, end - start + 1);
}

private static int ExpandAroundCenter(string input, int left, int right)
{
while (left >= 0 && right < input.Length && input[left] == input[right])
{
left--;
right++;
}
return right - left - 1;
}

private static bool ContainsPalindrome(string input)
{
string[] words = input.Split(' ');
foreach (string word in words)
{
if (word.Length > 1 && word == Reverse(word))
{
return true;
}
}

string cleanedInput = input.Replace(" ", "");
return cleanedInput.Length > 1 && cleanedInput == Reverse(cleanedInput);
}

private static string Reverse(string input)
{
char[] charArray = input.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
}
}
27 changes: 27 additions & 0 deletions archive/c/c-sharp/LongestWord.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Linq;

public class LongestWord
{
public static void Main(string[] args)
{
// check for empty string or empty input
if (args.Length == 0 || args[0] == "") {
Console.WriteLine("Usage: please provide a string");
} else {
// stores string from args
string sentence = args[0];

// split string by whitespace (these four special characters), removes empty entries
string[] words = sentence.Split(new[] {' ', '\t', '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries);

// sort array by length in descending order so longest string is first and returns is to array
words = words.OrderByDescending(word => word.Length).ToArray();

// log the length of longest word
Console.WriteLine(words[0].Length);
}
}


}
6 changes: 3 additions & 3 deletions archive/c/c-sharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Welcome to Sample Programs in C#! To find documentation related to the C# code in this repo, look [here.](https://sampleprograms.io/languages/c-sharp)

## Sample Programs List - 24/37 :relaxed:
## Sample Programs List - 26/37 :relaxed:

In this section, we feature a list of completed and missing programs in C#. See above for the current amount of completed programs in C#. If you see a program that is missing and would like to add it, please submit an issue, so we can assign it to you.

Expand All @@ -24,6 +24,8 @@ Below, you'll find a list of completed code snippets in C#. Code snippets preced
- :warning: [Josephus Problem in C#](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+josephus+problem+c#) [[Requirements](https://sampleprograms.io/projects/josephus-problem)]
- :warning: [Linear Search in C#](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+linear+search+c#) [[Requirements](https://sampleprograms.io/projects/linear-search)]
- :warning: [Longest Common Subsequence in C#](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+longest+common+subsequence+c#) [[Requirements](https://sampleprograms.io/projects/longest-common-subsequence)]
- :warning: [Longest Palindromic Substring in C#](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+longest+palindromic+substring+c#) [[Requirements](https://sampleprograms.io/projects/longest-palindromic-substring)]
- :warning: [Longest Word in C#](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+longest+word+c#) [[Requirements](https://sampleprograms.io/projects/longest-word)]
- :warning: [Merge Sort in C#](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+merge+sort+c#) [[Requirements](https://sampleprograms.io/projects/merge-sort)]
- :warning: [Prime Number in C#](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+prime+number+c#) [[Requirements](https://sampleprograms.io/projects/prime-number)]
- :warning: [Quick Sort in C#](https://github.com//TheRenegadeCoder/sample-programs-website/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+quick+sort+c#) [[Requirements](https://sampleprograms.io/projects/quick-sort)]
Expand All @@ -45,8 +47,6 @@ The following list contains all of the approved programs that are not currently
- :x: [Duplicate Character Counter](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,duplicate+character+counter&template=code-snippet-request.md&title=Add+Duplicate+Character+Counter+in+C%23) [[Requirements](https://sampleprograms.io/projects/duplicate-character-counter)]
- :x: [Fraction Math](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,fraction+math&template=code-snippet-request.md&title=Add+Fraction+Math+in+C%23) [[Requirements](https://sampleprograms.io/projects/fraction-math)]
- :x: [Job Sequencing](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,job+sequencing&template=code-snippet-request.md&title=Add+Job+Sequencing+in+C%23) [[Requirements](https://sampleprograms.io/projects/job-sequencing)]
- :x: [Longest Palindromic Substring](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,longest+palindromic+substring&template=code-snippet-request.md&title=Add+Longest+Palindromic+Substring+in+C%23) [[Requirements](https://sampleprograms.io/projects/longest-palindromic-substring)]
- :x: [Longest Word](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,longest+word&template=code-snippet-request.md&title=Add+Longest+Word+in+C%23) [[Requirements](https://sampleprograms.io/projects/longest-word)]
- :x: [Maximum Array Rotation](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,maximum+array+rotation&template=code-snippet-request.md&title=Add+Maximum+Array+Rotation+in+C%23) [[Requirements](https://sampleprograms.io/projects/maximum-array-rotation)]
- :x: [Maximum Subarray](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,maximum+subarray&template=code-snippet-request.md&title=Add+Maximum+Subarray+in+C%23) [[Requirements](https://sampleprograms.io/projects/maximum-subarray)]
- :x: [Minimum Spanning Tree](https://github.com/TheRenegadeCoder/sample-programs/issues/new?assignees=&labels=enhancement,minimum+spanning+tree&template=code-snippet-request.md&title=Add+Minimum+Spanning+Tree+in+C%23) [[Requirements](https://sampleprograms.io/projects/minimum-spanning-tree)]
Expand Down
Loading

0 comments on commit a71c899

Please sign in to comment.