-
Notifications
You must be signed in to change notification settings - Fork 0
/
OtherFunctions.cs
57 lines (49 loc) · 1.53 KB
/
OtherFunctions.cs
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;
namespace TvShowSubtitleRenamer
{
public class OtherFunctions
{
public static void RearrangeList(ref string[] arr, int[] order)
{
string[] final = new string[arr.Length];
for (int i = 0; i < arr.Length; i++)
{
final[i] = arr[order[i] - 1];
}
arr = final;
}
public static int[] AskOrder()
{
Console.WriteLine("What is the correct order (eg. \"1,3,2,4,5,6,7,8\")");
string input = Console.ReadLine();
string[] splitList = input.Split(',');
int[] intList = new int[splitList.Length];
for (int i = 0; i < splitList.Length; i++)
{
try
{
intList[i] = Int16.Parse(splitList[i]);
}
catch
{
Console.WriteLine("Incorrect format, please try again.");
AskOrder();
}
}
// Verify List
List<int> arrList = intList.ToList();
arrList.Sort();
for (int i = 0; i < arrList.Count - 2; i++)
{
if (arrList[i + 1] - arrList[i] != 1)
{
Console.WriteLine("A number seems to be missing, please try again.");
AskOrder();
}
}
return intList;
}
}
}