-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmumbling.cs
More file actions
57 lines (50 loc) · 1.49 KB
/
Copy pathmumbling.cs
File metadata and controls
57 lines (50 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mumbling
{
class Program
{
static void Main(string[] args)
{
//method that repeats given letters based on string position - first is always capitalized
Console.WriteLine("Give me a string: ");
string s = Console.ReadLine();
string something = Accumul.Accum(s);
Console.WriteLine(something);
}
}
public class Accumul
{
public static String Accum(string s)
{
List<char> charList = new List<char>();
charList.AddRange(s);
List<string> stringList = new List<string>();
string word = null;
int counter = 1;
foreach (var item in charList)
{
for (int i = 0; i < counter; i++)
{
stringList.Add(Convert.ToString(item).ToUpper());
}
counter++;
stringList.Add("-");
}
for (int i = 1; i < stringList.Count; i++)
{
if (stringList[i].ToUpper() == stringList[i - 1].ToUpper())
stringList[i] = stringList[i].ToLower();
}
foreach (var item in stringList)
{
word = word + item;
}
word = word.Remove(word.Length - 1);
return word;
}
}
}