static void Cookie_Clicker_Alpha() { int T = File_Manager.ReadInts()[0]; for (int t = 0; t < T; t++) { List <double> CFX = File_Manager.ReadDoubles(); double C = CFX[0]; double F = CFX[1]; double X = CFX[2]; double rate = 2; double time = 0; while (true) { if ((X / (rate + F)) >= ((X - C) / rate)) { time += X / rate; break; } else { time += C / rate; rate += F; } } File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + time.ToString("0.0000000")); } }
private void fileManagerToolStripMenuItem_Click(object sender, EventArgs e) { selected2 = dataGridView1.CurrentRow.Cells[0].Value.ToString(); File_Manager f = new File_Manager(); f.Show(); }
private void btn_Import_Click(object sender, EventArgs e) { List <DLB_Data> lstImport = new List <DLB_Data>(); //Get Import File string txt_FileName = Globals.GetFile(); FileInfo fi = new FileInfo(txt_FileName); //Check if File is locked if (Globals.IsFileLocked(fi) == true) { MessageBox.Show("Source file is currently in a read-only state." + Environment.NewLine + "Please verify file is not being accessed by an additional program and try again."); return; } else if (fi.Exists == false) { MessageBox.Show("Incorrect File Name Entered Into Text Field" + Environment.NewLine + "Please verify file name and try again"); return; } //Read IMport File lstImport = File_Manager.ReadSource(fi); //Upload data to the registration table. SQL_Commands.Registration.Import.Registration(lstImport, dgv_Registration); SQL_Commands.Registration.Get.Registration(dgv_Registration); MessageBox.Show("Import Completed Succesfully"); }
private void StoreOrder(Order Order) { string json = System.Text.Json.JsonSerializer.Serialize(Order); File_Manager.CreateFolder(App_Constands.FolderPath); File_Manager.CreateFile(App_Constands.FilePathOrder); File_Manager.WriteDataToFile(json, App_Constands.FilePathOrder); }
private void StorePizza(object pizza) { string json = System.Text.Json.JsonSerializer.Serialize(pizza); File_Manager.CreateFolder(App_Constands.FolderPath); File_Manager.CreateFile(App_Constands.FilePathPizza); File_Manager.WriteDataToFile(json, App_Constands.FilePathPizza); }
private void StoreIngredient(object ingredient) { string json = System.Text.Json.JsonSerializer.Serialize(ingredient); File_Manager.CreateFolder(App_Constands.FolderPath); File_Manager.CreateFile(App_Constands.FilePathIngredient); File_Manager.WriteDataToFile(json, App_Constands.FilePathIngredient); }
static void Magic_Trick() { int T = File_Manager.ReadInts()[0]; for (int t = 0; t < T; t++) { int ans1 = File_Manager.ReadInts()[0]; List <int> row1 = new List <int>(); for (int r = 1; r < 5; r++) { if (r == ans1) { row1 = File_Manager.ReadInts(); } else { File_Manager.ReadLine(); } } int ans2 = File_Manager.ReadInts()[0]; List <int> row2 = new List <int>(); for (int r = 1; r < 5; r++) { if (r == ans2) { row2 = File_Manager.ReadInts(); } else { File_Manager.ReadLine(); } } List <int> values = new List <int>(); foreach (int a in row1) { if (row2.Contains(a)) { values.Add(a); } } if (values.Count == 0) { File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + "Volunteer cheated!"); } else if (values.Count == 1) { File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + values[0]); } else { File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + "Bad magician!"); } } }
private static void LoadJsonData(Battle_Manager a_Battle_Manager) { if (File_Manager.LoadFromFile("SaveData.dat", out var json)) { Save_Data sd = new Save_Data(); sd.LoadFromJson(json); a_Battle_Manager.LoadFromSaveData(sd); } }
public void UpdateIngredients() { // A computer has no feelings, let it work :-) File_Manager.DeleteFile(App_Constands.FilePathIngredient); for (int i = 0; i < GlobalIngredients.Count; i++) { StoreIngredient(GlobalIngredients[i]); } }
static void Main(string[] args) { File_Manager.Open(@"C:\Users\Plumley\Downloads\A-large (2).in"); //Problem call goes here Part_Elf(); File_Manager.Close(); File_Manager.Write(@"C:\Users\Plumley\Downloads\A-large (2).out"); System.Console.WriteLine("Done"); System.Console.ReadLine(); //Pause }
static void Main(string[] args) { File_Manager.Open(@"C:\Users\Plumley\Downloads\C-small-attempt0 (1).in"); //Problem call goes here Enclosure(); File_Manager.Close(); File_Manager.Write(@"C:\Users\Plumley\Downloads\C-small-attempt0 (1).out"); System.Console.WriteLine("Done"); System.Console.ReadLine(); //Pause }
public int Start(byte[,] pokemon, string path, int row, int column) { File_Manager fm = new File_Manager(); byte[] inputFile; int found = 0; inputFile = fm.OpenFile(path); found = SearchPokemon(pokemon, inputFile, row, column); return(found); }
private static void SaveJsonData(Battle_Manager a_Battle_Manager) { Save_Data sd = gridSaveData; //a_Battle_Manager.PopulateSaveData(sd); if (File_Manager.WriteToFile("SaveData.dat", sd.ToJson())) { Debug.Log("Save successful!"); Debug.Log(Application.persistentDataPath); } }
IEnumerator Post(SubmitInfo Info) { SubmitCallBack Call_Back; // Set server url and data to send string Submit_Url = Url + "/YourWebPage"; // Post request to server var Request = new UnityWebRequest(Submit_Url, "POST"); byte[] Body_Raw = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(Info)); Request.uploadHandler = (UploadHandler) new UploadHandlerRaw(Body_Raw); Request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); Request.SetRequestHeader("Content-Type", "application/json"); yield return(Request.Send()); if (Request.responseCode == 200) { string Content = Request.downloadHandler.text; Call_Back = JsonConvert.DeserializeObject <SubmitCallBack>(Content); if (Call_Back.Your_CallBack == "Insert or Update your information") { // Save informations File_Manager.Save_Info(); // Deactive submit score menu and active ten highscore Button_OnClick.Set_SubmitScoreMenu(false); Button_OnClick.Set_TopTenMenu(true); StartCoroutine(TopTen_Records(Info)); } else if (Call_Back.Your_CallBack == "Name is taken") { // Server error Button_OnClick.Set_InteractableSubmitScore(true); Button_OnClick.Set_Error(true, "this name is taken"); } else { // Server error Button_OnClick.Set_InteractableSubmitScore(true); Button_OnClick.Set_Error(true, "server error"); } } else { // Server error Button_OnClick.Set_InteractableSubmitScore(true); Button_OnClick.Set_Error(true, "server error"); } }
static void Deceitful_War() { int T = File_Manager.ReadInts()[0]; for (int t = 0; t < T; t++) { int N = File_Manager.ReadInts()[0]; List <double> Naomi = File_Manager.ReadDoubles(); List <double> Ken = File_Manager.ReadDoubles(); Naomi.Sort(); Ken.Sort(); List <double> NW = new List <double>(Naomi); List <double> KW = new List <double>(Ken); int NWScore = 0; for (int n = N - 1; n >= 0; n--) { if (NW[n] > KW[n]) { NWScore++; NW.RemoveAt(n); KW.RemoveAt(0); } else { NW.RemoveAt(n); KW.RemoveAt(n); } } int NDWScore = 0; for (int n = N - 1; n >= 0; n--) { if (Naomi[0] > Ken[0]) { NDWScore++; Naomi.RemoveAt(0); Ken.RemoveAt(0); } else { Naomi.RemoveAt(0); Ken.RemoveAt(n); } } File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + NDWScore + " " + NWScore); } }
private void SetOrder(Order newOrder) { double itemPrice = 0; int pizzaId = newOrder.Items[ItemIndex][0]; int size = newOrder.Items[ItemIndex][1]; int crust = newOrder.Items[ItemIndex][2]; int quantity = newOrder.Items[ItemIndex][3]; if (size == Convert.ToInt32(PizzaSize.small)) { itemPrice = Pizza_Manager.GlobalPizzas[pizzaId].PriceSmall; } else if (size == Convert.ToInt32(PizzaSize.medium)) { itemPrice = Pizza_Manager.GlobalPizzas[pizzaId].PriceMedium; } else if (size == Convert.ToInt32(PizzaSize.large)) { itemPrice = Pizza_Manager.GlobalPizzas[pizzaId].PriceLarge; } else { UserIO.PrintRed("Error"); } if (crust == Convert.ToInt32(PizzaCrust.CheeseCrust)) { itemPrice += 2; } itemPrice *= quantity; newOrder.ItemPrice.Add(itemPrice); newOrder.ItemPriceArray = newOrder.ItemPrice.ToArray(); newOrder.TotalPrice += itemPrice; newOrder.ItemCount += quantity; //newOrder.Date = Convert.ToString(DateTime.Now); newOrder.Date = DateTime.Now; int id = File_Manager.CountLinesFile(App_Constands.FilePathOrder); newOrder.Id = id; }
void Set_GameOver() { if (Data_Manager.Get_HighScore() < Score) { Data_Manager.Set_HighScore(Score); } Txt_GameOverScore.text = Score.ToString(); Txt_GameOverHighsocre.text = Data_Manager.Get_HighScore().ToString(); GameObject Background_Canvas = GameObject.Find("Background_Canvas"); // Active game over menu Button_OnClick.Set_GameOverMenu(true); // Enable animation Background_Canvas.GetComponent <Animator>().enabled = true; // Save file File_Manager.Save_Info(); }
static void Part_Elf() { int T = File_Manager.ReadInts()[0]; for (int t = 0; t < T; t++) { BigInteger[] AB = File_Manager.ReadBigInts().ToArray(); double frac = (double)((double)AB[0] / (double)AB[1]); string bin = DoubleToBinary(frac, 41); Simplify(AB); if (AB[1].IsPowerOfTwo && bin.Contains('1')) { int n = bin.IndexOf('1') - 1; File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + n); } else { File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + "impossible"); } } }
static void The_Bored_Traveling_Salesman() { //start at lowest // consider children of all chosen // pick lowest unless not picking a current child // then pick lowest who can reach current children int T = File_Manager.ReadInts()[0]; for (int t = 0; t < T; t++) { List <int> NM = File_Manager.ReadInts(); int N = NM[0]; int M = NM[1]; int[] zips = new int[N]; int[][] cons = new int[N][]; for (int n = 0; n < N; n++) { zips[n] = File_Manager.ReadInts()[0]; cons[n] = new int[N]; } for (int m = 0; m < M; m++) { List <int> ab = File_Manager.ReadInts(); cons[ab[0]][ab[1]] = 1; cons[ab[1]][ab[0]] = 1; } List <int> order = new List <int>(); order.Add(Array.IndexOf(zips, zips.Min())); int curZip = zips.Min(); List <int> front = new List <int>(); for (int i = 0; i < N; i++) { } File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": "); } }
private void LoadAllPizzas() { File_Manager.CreateFolder(App_Constands.FolderPath); File_Manager.CreateFile(App_Constands.FilePathPizza); AllPizzasJson = File_Manager.LoadAllFiles(App_Constands.FilePathPizza); }
// Start is called before the first frame update void Start() { m_FileManager = this; ImagesName = new List <string>(); LoadImages(); }
void Awake() { instance = (File_Manager)this; }
static void Enclosure() { int T = File_Manager.ReadInts()[0]; for (int t = 0; t < T; t++) { List <int> NMK = File_Manager.ReadInts(); int N = NMK[0]; int M = NMK[1]; int K = NMK[2]; int min = Math.Min(N, M); int S = 0; if (min == 1 || min == 2) { S = K; } else if (min == 3) { if (K < 5) { S = K; } else if (K < M * N - 3) { S = 2 * (int)((double)K / 3.0); if (K % 3 == 0) { S += 1; } else { S += 2; } } else { S = 2 * M + 2 * N - 4 - (M * N - K); } } else { if (K < 5) { S = K; } else if (K < 6) { S = 4; } else if (K < M * N - 3) { S = (int)Math.Ceiling((double)K / 2.0) + 2; } else { S = 2 * M + 2 * N - 4 - (M * N - K); } } File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + S); } }
void Start() { m_FileManager = File_Manager.m_FileManager; }
private void LoadAllOrders() { File_Manager.CreateFolder(App_Constands.FolderPath); File_Manager.CreateFile(App_Constands.FilePathOrder); AllOrdersJson = File_Manager.LoadAllFiles(App_Constands.FilePathOrder); }
private void LoadAllIngredients() { File_Manager.CreateFolder(App_Constands.FolderPath); File_Manager.CreateFile(App_Constands.FilePathIngredient); AllIngredientsJson = File_Manager.LoadAllFiles(App_Constands.FilePathIngredient); }
static void The_Repeater() { int T = File_Manager.ReadInts()[0]; for (int t = 0; t < T; t++) { bool fail = false; int N = File_Manager.ReadInts()[0]; string[] strings = new string[N]; List <char> order = new List <char>(); List <int[]> counts = new List <int[]>(); for (int n = 0; n < N; n++) { strings[n] = File_Manager.ReadLine(); char[] letters = strings[n].ToCharArray(); if (n == 0) { order.Add(letters[0]); counts.Add(new int[N]); } int orderNo = 0; for (int i = 0; i < letters.Length; i++) { if (letters[i] == order[orderNo]) { counts[orderNo][n]++; } else { if (order.Count > orderNo + 1) { if (order[orderNo + 1] == letters[i]) { orderNo++; counts[orderNo][n] = 1; } else { fail = true; } } else { orderNo++; order.Add(letters[i]); counts.Add(new int[N]); counts[orderNo][n] = 1; } } } } int noChars = order.Count; int moves = 0; for (int i = 0; i < noChars; i++) { if (counts[i].Contains(0)) { fail = true; } else { Array.Sort(counts[i]); for (int a = 0; a < N; a++) { moves += Math.Abs(counts[i][a] - counts[i][(int)(N / 2)]); } } } if (fail) { File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + "Fegla Won"); } else { File_Manager.QueueLine("Case #" + (t + 1).ToString() + ": " + moves); } } }