Skip to content

Instantly share code, notes, and snippets.

View vmamore's full-sized avatar
🏠
Working from home

Vinícius Mamoré vmamore

🏠
Working from home
View GitHub Profile
namespace FSharpKoans
open FSharpKoans.Core
//---------------------------------------------------------------
// Apply Your Knowledge!
//
// Below is a list containing comma separated data about
// Microsoft's stock prices during March of 2012. Without
// modifying the list, programatically find the day with the
// greatest difference between the opening and closing prices.
static long repeatedString(string s, long n)
{
if(s.Length == 1 && s.Equals("a"))
{
return n;
}
long total = 0;
foreach(var letter in s)
static int jumpingOnClouds(int[] c) {
int totalJumps = 0;
if (c.Length == 2)
{
if (c[0] == 0 && c[1] == 0)
return 1;
else
return 0;
}
public static int countingValleys(int steps, string path)
{
int initialValue = 1;
int valleys = 0;
for(int i = 0; i < steps; i ++){
if(path[i].Equals('U')) {
initialValue++;
if(initialValue == 1)
valleys++;
} else {
static int sockMerchant(int n, int[] ar) {
var hashSet = new HashSet<int>();
int pairs = 0;
for(int i = 0; i < n; i ++){
if(!hashSet.Contains(ar[i])) {
hashSet.Add(ar[i]);
} else {
pairs++;
hashSet.Remove(ar[i]);
}