Jump to content
  • Advertisement

KenRea

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

114 Neutral

About KenRea

  • Rank
    Newbie
  1. I did for most of them and did notice that 3 & 6 wouldn't compile and that vec3 isn't a c# thing as we have a native vector3 class. I feel this test was written for c++ and misjudged my c# skill set.
  2. As regarding your input it's very helpful. I did get the terminology wrong. I need to know that for interviews even though it's not super relevant to me actually programming in unity. Also yeah the direction was part of a struct. I must have overlooked that and saw it as part of the scope not in a struct. I fail.
  3. I created no structs on my own they were given like that. I knew the ? Return answer would not compile in c# and I also knew that the tree sorting did not work properly due to their struct. But I couldn't hand the test back with 3 blank answers and blame it on them. They told me this was for unity / c# mono so my unity code did work I tested it. I feel like the person who made this test did not ask the right questions for the job and it irritates me.
  4. I like that. I'm going to try it. I'm almost positive the code would work the same since it's basic types.
  5. This is the test with my answers. You guys have any pointers on how I could have done this better or techniques I can learn?   Better Formatted test is attached   Interview Test -    Questions:   1. In C# what is the difference between a class and struct?   Class uses reference types so if you change a variable in the class somewhere it will change for all references to that variable. A struct will only change that iteration of the variable and will not be referenced anywhere else.   Classes are allocated on the stack while structs are allocated in the heap.   For example accessing a struct variable in a list that you have elsewhere will not change in the original struct but a class's variable will.   2. In what is operator overloading? In C# what are some of the operators that can be overloaded? Name some that can not?   Operator Overloading allows you to change the functionality of the standard operators such as +,-,==,++. It allows you to add parameters to the operators and uses a return type.   you cannot change operators such as '=', '?', '.' and others.   3. What does the following function do? bool dosomething(unsigned int x) {   return x && !(x & (x­1))? }   return x makes sure x != 0 !(x & (x-1)) checks if x is a power of two. So it returns true if x is a power of two.   4. Given two arrays A1 and A2. Where A2 has n elements and A1 has m elements plus extra space for n elements. Both arrays are sorted in ascendant order. Write a function to merge the two arrays into A1. The merged array must also be in ascendant order. We want to do this without allocating or using a swap buffer or extra array. void merge(int[] A1, int[] A2) {   // A1 has extra space for A2.   // your code }   { // Which index in array 1 will relate to spots for array 2. int lastSpace = array2.Length; lastSpace = array1.Length - lastSpace;   // Quickly Merge the 2 arrays. for (int i = 0; i < array2.Length; i++) { array1[lastSpace] = array2; lastSpace++; }   // Use QuickSort to quickly sort (this is redundant) the arrays using arrays already given, no buffer no extra arrays used. QuickSort_Recursive(array1, 0, array1.Length - 1); }   int Partition(int[] numbers, int left, int right) { int pivot = numbers; while (true) { while (numbers < pivot) left++;   while (numbers > pivot) right--;   if (left < right) { int temp = numbers; numbers = numbers; numbers = temp; } else { return right; } } }   void QuickSort_Recursive(int[] arr, int left, int right) { // For Recusrion if(left < right) { int pivot = Partition(arr, left, right);   if(pivot > 1) QuickSort_Recursive(arr, left, pivot - 1);   if(pivot + 1 < right) QuickSort_Recursive(arr, pivot + 1, right); } }   5. Write a function that takes a string as an argument and returns a new string that is the reverse of the string passed in.   C#   string ReverseString(string inString) { // This can also be accomplished manually by getting length of string and putting it one by one // into char[] using for loop. char[] reverseString = inString.ToCharArray();   // This is a C# function, useful here but can easily be done in a loop. // To do that I'd just hold the character i'm swapping, swap it and put it at place I swapped from until midpoint. Array.Reverse(reverseString); return reverseString; }   6. Write a function to traverse a binary tree composed of the following structure. Print the contents of "name" at each node.   struct TreeNode { public string name? public TreeNode leftnode? public TreeNode rightnode? }?   // Unity code for printing tree node names in a left first recursive order. void PrintBinaryTree(ref TreeNode treenode ) { Debug.Log(treenode.name); if (treenode.leftnode != null) { PrintBinaryTree(treenode); }   if (treenode.rightnode != null) { PrintBinaryTree(treenode); } }   7. Write a function to sort an array of integers in ascending order. Do not use Array.sort or similar built in functions.   // Just going to use a recursive quicksort again as it is the best way to do this. It's relatively fast. void SortArray( int[] inarray ) { QuickSort_Recursive(inarray, 0, inarray.Length - 1); }   int Partition(int[] numbers, int left, int right) { int pivot = numbers; while (true) { while (numbers < pivot) left++;   while (numbers > pivot) right--;   if (left < right) { int temp = numbers; numbers = numbers; numbers = temp; } else { return right; } } }   void QuickSort_Recursive(int[] arr, int left, int right) { // For Recusrion if(left < right) { int pivot = Partition(arr, left, right);   if(pivot > 1) QuickSort_Recursive(arr, left, pivot - 1);   if(pivot + 1 < right) QuickSort_Recursive(arr, pivot + 1, right); } }   8. Given an up and right vector, reconstruct the forward vector from this data and ensure the result is a vector of unit length. struct Vec3 { public float x? public float y? public float z? }?   public Vec3 CalculateForwardVector( Vec3 up, Vec3 right ) { // reconstruct the forward unit vector // C# Implimentation // Cross products of vectors create the perpendicular. The perpendicular of up and right is forwards / back depending on first parameter (up or right). Vector3 forward = Vector3.Cross(up, right); forward = Vector3.Normalize(forward) return forward;   // This Implementation Vec3 forward = new Vec3;   // Cross the vector forward.x = up.b*right.c - up.c*right.b; forward.y = up.c*right.up - up.a*right.c; forward.z = up.a*right.b - up.b*right.a;   // Normalize the Vector3 to make it unit vector. float length = sqrt((forward.x * forward.x) + (forward.y * forward.y) + (forward.z * forward.z));   forward.x = forward.x / length; forward.y = forward.y / length; forward.z = forward.z / length; return forward; }   9. Given an object with a position and direction, translate the object along the direction vector as defined by "distance". struct Vec3 { public float x? public float y? public float z? }?struct Obj { public Vec3 position? public Vec3 direction? }? public void Translate( ref Obj theobject, float distance ) { // translate theobject by distance along it's direction   Vec3.Normalize(direction); position += direction * distance; theobject.position = position; }   Choose one of the following for the 10th question: // I did both because both intrigued me.   10.?You are a player standing at point P in 3D space. An enemy AI fires a weapon from point E. The bullet follows a straight line and terminates at point H where it hits an object. If the bullet's path comes within distance D of the player, then the game should play a "bullet whiz" sound. Please outline an algorithm to determine wether the game needs to play that sound.   // Using Unity style code (C# / Mono) // Get distance / direction vector of two objects. Vector3 direction = playerObject.transform.position - bulletObject.transform.position; // get distance via magnitude of direction vector float distance = direction.magnitude;   // Play the sound if distance is less than or equal to the distance required to play sound. if (distance <= soundDistance) PlaySound();   // Also in unity you can just use a sphere collider trigger and layers to cause this.   10. ?Your boss comes to you in the 11th hour and says that QA has just discovered that the new shout out feature of the application is allowing people to enter profanity this is then posted to all registered users. He needs you to come up with a solution that will filter only the profane word(s) out of the entered text and replace it with the string "(bleep)". On top of that, he needs to be able to maintain this in some way when new words are to be added to the list of words to filter, and he doesn't want to provide the words in "leet speak" but he does want that filtered as well. So given the word "test" he would like words like the following replaced as well: "t3st", "te5t", "t35t". Please outline a system to determine weather the entered "shout out" string contains profanity, how to replace it, and to be expandable to allow continual inclusion of new words and "leet speak" substitutions to check for.   C# version I also did a simple version of this for my game because people were using obscene user names. I used an XML list that I imported, checked every login (to see if people changed their names). You can then create a dictionary for leetspeak characters and check each letter and convert any leetspeak to regular text then do a simple string.contains(string) to check for obscenities.
  6. me I remember but i don't remember it's mid december 3 hours outside of denver i am the tender the return to sender the up ender of life the misery to your pleasure the visionary with a touch of clever. Tethered to this body but so far disconnected. enveloped in viscerial feelings and mailed to heaven let down by my thoughts i descend again but this time i've come back with a vengence a tenden-cy to remove the seconds and freeze time leave you suspended left behind the recollection then I r...
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!