Jump to content

oslon

Members
  • Posts

    44
  • Joined

  • Last visited

oslon's Achievements

Member

Member (2/5)

0

Reputation

  1. Here're its table of contents. Can anyone here tell me if there is a better book than this? This book is a huge investment (Costs 50-60$ to me in local currency after taxes, shipping etc.)
  2. U-DLCI,6 C/R,1 EA,1 L-DLCI,4 FECN,1 BECN,1 DE, EA,1 This is a file called table.csv Now, what I what I want is this. The 2nd column values are in bits. bits_per_line=8 Now, I traverse through the file and save the first and second column values into an array. packet_arr=("U-DLCI" "C/R" ....) count_arr=(6 1 1 ...) Now I start a counter that will count if bits_per_line ls over 8, if so, I do a new line. counter=6+1+1 This counter will act upon every line. Then I just print the contents. I can't seem to write a bash shell scripting code for this however, (Even though I have completed tons of udemy courses and made many stuffs).
  3. It's coming to my notice that powerful machine is required for practicing this big data stuffs like elasticsearch(ELK stack) on kubernetes. I've i5.7th gen laptop and I am only able to just start the cluster, the other stuffs justdon't run properly.
  4. cat << EOF > /etc/elasticsearch/elasticsearch.yml cluster.name: MyCluster node.name: mynode path.data: /var/lib/elasticsearch network.host: 0.0.0.0 EOF The thing is that those cluster.name, node.name, path.data, network.host are already uncommented. So, I will be duplicating. Is there a way to find and replace those strings and append my values?
  5. Didn't know the power of ELK stack could actually analyze the logs for you? That's crazy. I will look into it.
  6. Really nothing lol. That's why I am here. My job is to check logs of application and find out the errors. It's tough to automate it. I just deliver logs to developers.
  7. I mean I want project ideas.
  8. I am looking to get into shell scripting writing scripts. And I was really out of ideas. So, I am looking into python and php shell scripting project ideas.
  9. int[][] wh2d = { {0, 34}, {1, 28}, {2, 20}, {3, 31}, {4, 32}, {5, 28}, {6, 37}, {7, 41} }; I need to sort this based on 34.28,20...etc.
  10. https://medium.com/strategio/sudoku-validator-algorithm-dc848cb45093 Found something similar to my approach.
  11. @Barandsir. What do I do with that? I'm getting really puzzled by this puzzle. import java.util.*; public class Example { public static void main(String[] args) { int[][] solution = { {9, 6, 3, 1, 7, 4, 2, 5, 8}, {1, 7, 8, 3, 2, 5, 6, 4, 9}, {2, 5, 4, 6, 8, 9, 7, 3, 1}, {8, 2, 1, 4, 3, 7, 5, 9, 6}, {4, 9, 6, 8, 5, 2, 3, 1, 7}, {7, 3, 5, 9, 6, 1, 8, 2, 4}, {5, 8, 9, 7, 1, 3, 4, 6, 2}, {3, 1, 7, 2, 4, 6, 9, 8, 5}, {6, 4, 2, 5, 9, 8, 1, 7, 3} }; boolean ok = true; int[] count = new int[9]; // row-wise loop for (int i = 0; i < solution.length; i++) { // -1 added for array index starting from 0, means 9 in above means count[8] for (int j = 0; j < solution[0].length; j++) { count[solution[i][j] - 1]++; } ok = checkIfOk(count); System.out.println(ok); reset(count); } // column-wise loop for (int i = 0; i < solution.length; i++) { // -1 added for array index starting from 0, means 9 in above means count[8] for (int j = 0; j < solution[0].length; j++) { count[solution[j][i] - 1]++; } ok = checkIfOk(count); System.out.println(ok); reset(count); } // grid check 3x3 // 1st grid,2nd grid, 3rd grid for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { count[solution[i][j] - 1]++; } ok = checkIfOk(count); System.out.println(ok); reset(count); for (int j = 3; j < 6; j++) { count[solution[i][j] - 1]++; } ok = checkIfOk(count); System.out.println(ok); reset(count); for (int j = 6; j < 9; j++) { count[solution[i][j] - 1]++; } ok = checkIfOk(count); System.out.println(ok); reset(count); } // 4th,5th,6th grid // so on //7th,8th,9th grid // so on System.out.println(ok); } public static void reset(int[] arr) { for (int i = 0; i < arr.length; i++) { arr[i] = 0; } } public static boolean checkIfOk(int[] arr) { for (int i = 0; i < arr.length; i++) { if (arr[i] > 1) { return false; } } return true; } } I've came so far and there is no going back. I need to solve this.
  12. # For grids Now, I attempted to find a pattern. top left subgrid i=1-3 j=1-3 top middle subgrid i=1-3 j=4-6 top right subgrid i=1-3 j=7-9 middle left subgrid i=4-6 j=1-3 middle middle subgrid i=4-6 j=4-6 middle right subgrid i=4-6 j=7-9 bottom left subgrid i=7-9 j=1-3 bottom middle subgrid i=7-9 j=4-6 bottom right subgrid i=7-9 j=7-9 This is the pattern that I've caught. However, I am unable to exactly translate these stuffs to code. Checking row/col wise was easy, just interchanged j and i. import java.util.*; public class Example { public static void main(String[] args) { int[][] solution = { {9, 6, 3, 1, 7, 4, 2, 5, 8}, {1, 7, 8, 3, 2, 5, 6, 4, 9}, {2, 5, 4, 6, 8, 9, 7, 3, 1}, {8, 2, 1, 4, 3, 7, 5, 9, 6}, {4, 9, 6, 8, 5, 2, 3, 1, 7}, {7, 3, 5, 9, 6, 1, 8, 2, 4}, {5, 8, 9, 7, 1, 3, 4, 6, 2}, {3, 1, 7, 2, 4, 6, 9, 8, 5}, {6, 4, 2, 5, 9, 8, 1, 7, 3} }; boolean ok = true; int[] count = new int[9]; // row-wise loop for (int i = 0; i < solution.length; i++) { // -1 added for array index starting from 0, means 9 in above means count[8] for (int j = 0; j < solution[0].length; j++) { count[solution[i][j] - 1]++; } ok = checkIfOk(count); reset(count); } // column-wise loop for (int i = 0; i < solution.length; i++) { // -1 added for array index starting from 0, means 9 in above means count[8] for (int j = 0; j < solution[0].length; j++) { count[solution[j][i] - 1]++; } ok = checkIfOk(count); reset(count); } System.out.println(ok); } public static void reset(int[] arr) { for (int i = 0; i < arr.length; i++) { arr[i] = 0; } } public static boolean checkIfOk(int[] arr) { for (int i = 0; i < arr.length; i++) { if (arr[i] > 1) { return false; } } return true; } }
  13. import java.util.*; public class Example { public static void main(String[] args) { int[][] solution = { {9, 6, 3, 1, 7, 4, 2, 5, 8}, {1, 7, 8, 3, 2, 5, 6, 4, 9}, {2, 5, 4, 6, 8, 9, 7, 3, 1}, {8, 2, 1, 4, 3, 7, 5, 9, 6}, {4, 9, 6, 8, 5, 2, 3, 1, 7}, {7, 3, 5, 9, 6, 1, 8, 2, 4}, {5, 8, 9, 7, 1, 3, 4, 6, 2}, {3, 1, 7, 2, 4, 6, 9, 8, 5}, {6, 4, 2, 5, 9, 8, 1, 7, 3} }; boolean ok = true; int[] count = new int[9]; for (int i = 0; i < solution.length; i++) { // -1 added for array index starting from 0, means 9 in above means count[8] for (int j = 0; j < solution[0].length; j++) { count[solution[i][j] - 1]++; } ok = checkIfOk(count); reset(count); } System.out.println(ok); } public static void reset(int[] arr) { for (int i = 0; i < arr.length; i++) { arr[i] = 0; } } public static boolean checkIfOk(int[] arr) { for (int i = 0; i < arr.length; i++) { if (arr[i] > 1) { return false; } } return true; } } Better modularized code
  14. import java.util.*; public class Example { public static void main(String[] args) { int[][] solution = { {9, 6, 3, 1, 7, 4, 2, 5, 8}, {1, 7, 8, 3, 2, 5, 6, 4, 9}, {2, 5, 4, 6, 8, 9, 7, 3, 1}, {8, 2, 1, 4, 3, 7, 5, 9, 6}, {4, 9, 6, 8, 5, 2, 3, 1, 7}, {7, 3, 5, 9, 6, 1, 8, 2, 4}, {5, 8, 9, 7, 1, 3, 4, 6, 2}, {3, 1, 7, 2, 4, 6, 9, 8, 5}, {6, 4, 2, 5, 9, 8, 1, 7, 3} }; boolean ok = true; int[] count = new int[9]; for (int i = 0; i < solution.length; i++) { // -1 added for array index starting from 0, means 9 in above means count[8] for (int j = 0; j < solution[0].length; j++) { count[solution[i][j] - 1]++; } // ok or not checker for (int x = 0; x < count.length; x++) { System.out.println(count[x]); if (count[x] > 1) { ok = false; } } // reset the array count for next loop for (int k = 0; k < count.length; k++) { count[k] = 0; } } } }
  15. I mean those 3x3 boxes. I want to check there (I can check for rows, columns) however I am lil bit confused on 3x3 boxes contains all digits or not.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.