0% found this document useful (0 votes)
8 views

Coder Rating

Uploaded by

David
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Coder Rating

Uploaded by

David
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

1.

Write a JavaScript script for drawing a pair of responsive eyes on the given canvas, enabling
the eyes to track the mouse/cursor movements.\n```html\n<canvas id="canvas" width="300"
height="150"></canvas>\n```

Pick 2

Response 1: 2,4,5,5

Response 2: 5,4,5,5

2. ```python

# reassignment

a = [1, 2, 3, 4]

b=a

a = a + [5, 6, 7, 8]

print(a)

print(b)

# extends

a = [1, 2, 3, 4]

b=a

a += [5, 6, 7, 8]

print(a)

print(b)

```

What is the output in Python? Explain.

Pick 2

Response 1: 2,5,1,3

Response 2: 3,5,5,5
3. UnboundLocalError: cannot access local variable 'current' where it is not associated with a
value

class Token:

def __init__(self, type, literal=None):

self.type = type

self.literal = literal

def __repr__(self):

return f"Token({self.type}, {self.literal})"

LEFT_PAREN = "LEFT_PAREN"

RIGHT_PAREN = "RIGHT_PAREN"

ADD = "ADD"

ASSIGNATION = "ASSIGNATION"

NUMBER = "NUMBER"

IDENTIFIER = "IDENTIFIER"

SEMICOLON = "SEMICOLON"

def tokenize(input_string):

tokens = []

start = 0

current = 0

def is_at_end():

return current >= len(input_string)

def advance():

nonlocal current
current += 1

return input_string[current - 1]

def add_token(type, literal=None):

tokens.append(Token(type, literal))

def number():

while advance().isdigit() and not is_at_end():

pass

nonlocal current

current -= 1

value = input_string[start:current]

add_token(NUMBER, value)

def identifier():

while advance().isalnum() and not is_at_end():

pass

current -= 1

value = input_string[start:current]

add_token(IDENTIFIER, value)

while not is_at_end():

start = current

c = advance()

if c == '(':
add_token(LEFT_PAREN)

elif c == ')':

add_token(RIGHT_PAREN)

elif c == '+':

add_token(ADD)

elif c == '=':

add_token(ASSIGNATION)

elif c == ';':

add_token(SEMICOLON)

elif c.isdigit():

current -= 1

number()

elif c.isalpha() or c == '_':

current -= 1

identifier()

return tokens

example_input = "(a + 5) = 3;"

print(tokenize(example_input))

Please identify the solution to fix this code

Pick 1

Response 1: 5,5,4,5

Response 2: 2, 1,3 1
4. Can you write a code in C++ that removes all the whitespace from a given string? Write the
program using classes and comment on each part of the code.

Pick 1

Response 1: 5,5,5,5

Response 2: 5,5,5,2

5. Write a program in Java to compute the sum of 2 numbers that sum up to the number K

Pick 1

Response 1: 5,5,5,5

Response 2: 5,5,2,5

6. Create a code in C that reads a text file with temperature data and calculates the mean and std
dev. Then it normalizes the data and prints it out.

Pick 2

Response 1: 2,3,2,1

Response 2: 5,5,5,5

7. In Javascript, provide a program that filters and selects cards with the same listId as the target
card being moved, based on whether their order positions specified in cardOrder fall within a
range affected by the move. Adjust the cards order position up or down to make room for the
target card's new order position and ensure no overlapping of order positions

Pick 1

Response 1: 4,5,5,5

Response 2: 1,2,2,1

8. come up with a code that has 50 boxes and each box leads to a different random website

Pick 1

Response 1: 5 5 5 5

Response 2: 2 3 2 3
9. I have a large dataset of sorted product prices. Customers often search for products within a
specific price range. How to use the binary search algorithm to efficiently locate and display the
products falling within a user-defined price range? Provide a Python implementation of how to
apply binary search to address this use case.

Pick 1

Response 1: 5,5,5,5

Response 2: 1,3,1,2

10. Create a Bash script that allows the reading of the content of a .txt file and print each line.

Pick 2

Response 1: 3,2,3,4

Response 2: 5,5,5,5

11. Write a program in Java to compute the sum of two numbers that sum up to a given number K

Pick 1

Response 1: 5,5,5,5

Response 2: 5,5,2,5

Explanation: Response B is inefficcient as its O(n^2) vs A is O(n).

12. What is the syntax for using the replace() method in JavaScript to replace '/ ' to '$$' ?

Pick 2

Response 1: 4,5,2,4

Response 2: 5,5,5,5
13. refactor this c code snippet, don't use bool, and keep cls

```c

#include <stdio.h>

#include <string.h>

#define MAXN 100

void removed(char list[MAXN][21], int *pn) {

search(list, pn); // Assuming search is a function defined elsewhere

printf("Which Name do you want to remove? (input a number): ");

int del, i;

scanf("%d", &del);

if (del >= 0 && del < *pn) {

for (i = del + 1; i < *pn; i++) {

strcpy(list[i - 1], list[i]);

printf("Removed!\n");

(*pn)--;

} else {

printf("Unremoved!\n");

system("cls");

```

Pick 1
Response 1: 5,5,5,5

Response 2: 2,5,4,2

Explanation: Response A properly declares search function def, the code compiles fully and most
importantly it also follows the prompt (system cls) is retained.

14. Person A sends a request to node js that takes 10 seconds, a Person B sends a request that
takes 2 seconds immediately after person A. How will node js handle it, given that node js is
single threaded.

Pick 1

Response 1: 4,5,5,5

Response 2: 2,2,1,2

15. Given an array representing the weights of bananas of each owner, the maximum limit that
the vehicle can hold, find the minimum number vehicles needed to transport all the bananas
to the airport.
Note: There are no loads which are heavier than the given limit.
The weight of the bananas is measured in tons.table in its response time. Can you show me
some JavaScript libraries that handle asynchronous data requests, maybe with caching and/or
retry?

Pick 2

Response 1: 1,2,1,3

Response 2: 4,5,5,5

16. #include <stdio.h>

#include <stdlib.h>

int compare(const void *a, const void *b) {

return (*(int *)a - *(int *)b);

long long maxProduct(int arr[], int n) {


// Sort the array

qsort(arr, n, sizeof(int), compare);

long long product = (long long)arr[n-1] * arr[n-2] * arr[n-3];

return product;

int main() {

int arr[] = {-10, -20, 1, 3, 2};

int n = sizeof(arr) / sizeof(arr[0]);

printf("Largest product of three numbers is: %lld\n", maxProduct(arr, n));

return 0;

My implementation of this code to get the largest 3 number product in an array is wrong. Can you
point out the main issue?

Pick 2

Response 1: 2,2,2,1

Response 2: 4,5,5,5

17. Write a function in Python that prints a matrix in a spiral.

Pick 1

Response 1: 5,5,5,5

Response 2:5,5,2,2

18. I need a program in C++ that converts a binary number into a hexadecimal number. Allow an
input entry for the binary number. Add comments to all the code.
Pick 2

Response 1: 1,2,5,1

Response 2: 5,5,5,5

Response B is better than A because meets the prompt requirements related to the code
comments. Additionally, gives detailed explanations about the different used functions and their
functionality.

19. Implement in python: I have a restaurant that needs a system to assign a bill and table number
to a group of persons that are dining. I need you to provide a code that is easy to use to add
menu items to the bill and separate bills if persons prefer to split. Then calculate gst=12.5% and
print the entire bill plus table number, totals and the server that waited the table.

Pick 2

Response 1: 2,3,2,3

Response 2: 5,5,4,5

20. Let's say a div in HTML has the format of:

first name: input,

last name: input,

message: textbox

button

When the button is clicked, another div appears such that the values inputted above are shown.

first name: value entered by user

last name: value entered by user

message: text written by user

Write some code to accomplish this.

Pick 2
Response 1: 5,5,2,4

Response 2: 5,5,5,5

21. Correct this code:

public class Place {

public static void main(String args[]){

int temp,r,rem=0;

int n=4554;

temp=n;

while(n>0){

r=n%10;

rem=(rem*rem*rem)/r;

n=n/10;

if(temp==rem){

System.out.println("number is palindrome");

else{

System.out.println("number not palindrome");

Pick 2

Response 1: 2 2 2 1

Response 2: 4,5,5,5

What is the time complexity of this code?

int temp =0;


for (int i=0;i<n;i++) {

for (int j=0;j <i*i;j++){

for( int k= 1; ~k ;k-=1){

temp++;

Pick 2

Resp1 2332

Resp2 5555

22. come up with code that has 50 boxes and each box leads to a different random website

Pick 1.

Resp1 5555.

Resp2 2323

23. Please answer the following question.


Question title: indexing an element from a volatile struct doesn't work in C++
I have this code:

Pick 2

Response 1: 2 5 2 2

Response 2: 4,5,4,5

The second response actually gives a working solution (by adding valid copy constructors or
casts). The first response is incorrect. Response B does not give full working code (though its
suggested edits are valid).

24. Create a python function that takes an image and has options for image augmentation such as
flip horizontal, flip vertical and rotations. Cut the image to 255x255 pixels before doing
augments.
Pick 1.

Resp1 4555

Resp2 2312

25. What does the .find() method in Js do?

Pick 2

Response 1: 5,4,2,4

Response 2: 5,5,5,5

26. Here is a samle data from my text file.

Pick 2

Resp1 3323.

Resp2 5555

27. Create a program to read an array A with m x m (m is even number) elements, generate another
array B with m/2 x m/2 elements such that every 2 x 2 sub matrix is replaced with result of
‘bitwise and’ operation of four elements. Implement using user defined function. Code in c
programming

Pick 1.

Resp1 5555.

Resp2 2221

28. Fix the code to remove Value error: Found input variables with inconsistent number of
samples: [3021,2020]

Pick 2

Resp1 2221

Resp2 5555

29. Please complete the 'handleSubmit' function in the code below as well and add the
necessary functions to make it work, be sure to add a validator for each field, and add a
console log when the data is already recorded.
const handleSubmit = (event) => {

Pick 2.

Resp1 2312

Resp2 4555

30. how can i include `en_core_web_lg` in a python script in a way, that makes it possible for
`pyinstaller` to create an `.exe`

Pick 1

Response 1: 5,5,5,5

Response 2: 5,3,5,5

At first sight, both responses are well-oriented and related to the prompt request. A is slightly
better than B because the text formatting uses clear lists to enumerate the steps to install the
`en_core_web_lg` model. Additionally, response A use markdown correctly to wrap the code
between backticks. Finally, both responses close by ending with an appropriate and polite
question that encourages the user to ask more questions.

31. Write the code of a real time working analog clock using swing java. The clock should have the
neumorphic look.

Pick 1

Response 1: 4,5,5,5

Response 2: 2,2,1,3

32. import tkinter as tk

import random

choices = {

"rock": "circle",
"paper": "square",

"scissors": "triangle"

def player_choice(choice):

player_label.config(text=f"You chose: {choice.capitalize()}", fg="blue")

player_canvas.itemconfig(player_shape, **choices[choice])

computer_choice()

def computer_choice():

computer_choice = random.choice(list(choices.keys()))

computer_label.config(text=f"Computer chose: {computer_choice.capitalize()}", fg="green")

computer_canvas.itemconfig(computer_shape, **choices[computer_choice])

determine_winner(computer_choice)

def determine_winner(computer_choice):

player_choice = player_choice_var.get()

if player_choice == computer_choice:

result_label.config(text="It's a tie!")

elif (player_choice == "rock" and computer_choice == "scissors") or \

(player_choice == "paper" and computer_choice == "rock") or \

(player_choice == "scissors" and computer_choice == "paper"):

result_label.config(text="You win!", fg="blue")

else:

result_label.config(text="Computer wins!", fg="green")

root = tk.Tk()

root.title("Rock Paper Scissors")


player_frame = tk.Frame(root)

player_frame.pack(side=tk.LEFT)

player_label = tk.Label(player_frame, text="Choose your move:")

player_label.pack(pady=10)

player_choice_var = tk.StringVar(value="rock") # Set initial choice

player_buttons = tk.Frame(player_frame)

rock_button = tk.Radiobutton(player_buttons, text="Rock", variable=player_choice_var,


value="rock", command=player_choice)

paper_button = tk.Radiobutton(player_buttons, text="Paper", variable=player_choice_var,


value="paper", command=player_choice)

scissors_button = tk.Radiobutton(player_buttons, text="Scissors", variable=player_choice_var,


value="scissors", command=player_choice)

rock_button.pack(side=tk.LEFT)

paper_button.pack(side=tk.LEFT)

scissors_button.pack(side=tk.LEFT)

player_buttons.pack()

player_canvas = tk.Canvas(player_frame, width=100, height=100, bg="white")

player_shape = player_canvas.create_oval(25, 25, 75, 75, fill="gray") # Initial shape as circle

player_canvas.pack()

computer_frame = tk.Frame(root)

computer_frame.pack(side=tk.RIGHT)

computer_label = tk.Label(computer_frame, text="Computer's move:")

computer_label.pack(pady=10)

computer_canvas = tk.Canvas(computer_frame, width=100, height=100, bg="white")


computer_shape = computer_canvas.create_oval(25, 25, 75, 75, fill="gray") # Initial shape as circle

computer_canvas.pack()

result_label = tk.Label(root, text="Click a choice to play!")

result_label.pack()

root.mainloop()

fix this rock paper scissors game

Pick 1

Response 1: 4,5,5,4

Response 2: 2,2,3,1

33. Tell me the errors with my code. It's supposed to be multi threaded java program using execute
service that will read data from data from my text file.

Pick 1

Resp1 5555.

Resp2 2122

34. Explain the following code to me:

import React, { useState } from 'react'; import './App.css'; function App() { const [isPopupOpen,
setIsPopupOpen] = useState(false); const openPopup = () => { setIsPopupOpen(true); }; const
closePopup = () => { setIsPopupOpen(false); }; return (
Open Popup {isPopupOpen && (
×

Hello, How are you?

)}
); } export default App;

Pick 1

Response 1- 5,5,5,5,1,1

Response 2- 5,2,5,5,1,1
35. Given an array representing the weights of bananas of each owner, the maximum limit that
the vehicle can hold, find the minimum number vehicles needed to transport all the bananas
to the airport.
Note: There are no loads which are heavier than the given limit.
The weight of the bananas is measured in tons.

Pick 2

Response 1: 2,3,2,3

Response 2: 5,5,5,5

36. Given a positive integer millis, write an asynchronous function that's sleeps for millis
milliseconds.

Pick1

Resp1 4455

Resp2 4552.

37. Explain this code. Go step by step, explaining each line in detail:

```javascript

const re = /\\\\w+\\\\s/g;

const str = "fee fi fo fum";

const myArray = str.match(re);

console.log(myArray);

```

Pick 2

Response 1: 2,5,5,2

Response 2: 5 5 5 5
38. Define a C++ class called Car with private attributes for the make, model, and year. Implement
public member functions for setting these attributes and displaying the details. Write a program
that creates an instance of the class, sets its details, and displays them.

Pick 1

Response 1: 5454

Response 2: 4224

39. How can I generate hashed passwords in JavaScript using SHA256?...

Pick 2

Resp 1 2212

Resp 2 4554

40. Function to modify a matrix such that if a value in matrix cell.

Pick1.

Resp1 5455.

Resp2 3121

41. Write a c code to write number of digits in an integer without using a function

Pick 2

Response 1: 4525

Response 2:5445

Pick

Response 1:

Response 2:

42. I'm trying to initialize a list of points in python where the y coordinate is double the x
coordinate and the x coordinate is increasing from 0 to 5. Please tell me what I'm doing wrong:

```python

o = {"x": 0, "y": 0}
l = []

for i in xrange(0, 5):

m=o

m["x"] = i

m["y"] = i * 2

l.append(m)

print(l)

```

Pick 1

Response 1: 2 4 1 2

Response 2: 4455

43. Write a generator to yield the Fibonacci numbers in Python.

Pick 2

Response 1: 5 5 5 1

Response 2: 3 5 5 5
Correct Response = "With yield" Incorrect Response = "Without yield" While "Incorrect
Response" appears more detailed and elaborate, it does not properly answer the given prompt.
The prompt asks for writing a generator function to yield the Fibonacci numbers, but "In-correct
Response" provides a normal function that returns a list of Fibonacci numbers. On the other
hand, "Correct Response" exactly follows the prompt, providing a generator function that can
yield Fibonacci numbers indefinitely. This is why "Correct Response" is the better response in
terms of Relevance to the prompt, even though it might seem less flashy than "In-correct
Response". Also, the error in "Incorrect Response" is somewhat subtle because it will still
produce Fibonacci numbers; the key is recognizing that it's not the right type of function for the
given task. Hence, the issue being a medium one to identify.

Pick

Response 1:

Response 2:
Pick

Response 1:

Response 2:

Create a program to read an array A with m x m (m is even number) elements, generate another array B
with m/2 x m/2 elements such that every 2 x 2 submatrix is replaced with result of ‘bitwise and’
operation of four elements. Implement using user defined function. Code in c programming

Write a Python script that says "Hello World," then creates a random repeating string of characters
endlessly.

#include <stdio.h>

#include <stdlib.h>

int compare(const void *a, const void b) {

return ((int *)a - *(int *)b);

long long maxProduct(int arr[], int n) {

// Sort the array

qsort(arr, n, sizeof(int), compare);

long long product = (long long)arr[n-1] * arr[n-2] * arr[n-3];

return product;

int main() {

int arr[] = {-10, -20, 1, 3, 2};

int n = sizeof(arr) / sizeof(arr[0]);

printf("Largest product of three numbers is: %lld\n", maxProduct(arr, n));

return 0;
}

My implementation of this code to get the largest 3 number product in an array is wrong. Can you point
out the main issue?

Tell me the errors with my code. Its supposed to be a multithreaded java program

using executorservice that will read data from my text file. Each line in my file contains an

infix operation of 1 number, an operator and another number all separated by a space.

I need to process this so that the result of that operation is printed to the console along with the thread
that handled its execution....

Create a class named StudentDetails which has a method named getMarks to collect the particulars of
student marks in 5 subjects in an array. Create another class named StudentAverage which computes
the average marks using the computeAverage method. This class also has a method named
computeGPA which will compute the GPA of the student based on the marks secured. Assume that all
the 5 courses are 3 credit courses. If student mark is >=95, give a score of 10. If the mark is >=90 and <
95, give 9. If the mark is >=80 and < 90, give 8. If the mark is >=70 and < 80 give 7. If the mark is >=60
and < 70 give 6. If the mark is >=50 and < 60 give 5. Else give the score as 0. Write a program to compute
the student average mark and GPA and print the same.

1. Person A sends a request to node js that takes 10 seconds,

a Person B sends a request that takes 2 seconds immediately after person A. How will node js handle
it,

given that node js is single threaded.

Generate a program in C++ that uses divide and conquer to do polynomial multiplication

I want you to create a student registration system in java by using OOP CONCEPTs. However, the code
should be able to check that each registration number is unique.

Create a python script that reads 3 CSV files and creates a new csv with output of the first column data
of each file in a column of the new file

Note: There are no loads which are heavier than the given limit.

The weight of the bananas is measured in tons.

Constraints

0 <= len(arr) <= 10^5

0 <= arr[i] <= 10^5

The array may have duplicate numbers.


Input

Variable arr consists of an array of integers denoting the weights of bananas in the godown.

Variable k consists of a single integer k which denotes the maximum weight limit of the vehicle in tons.

Output

Print the minimum number of vehicles needed.

Can you help me understand the hashing method in use here. Pick 2

Resp1 2323 Resp2 4455

Write a python script to solve the following problem. Pick 1

Resp1 3344 Resp2 2221

Write a python script that performs the following tasks. Pick2

Resp1 5355 Resp2 5555

Question?? Indexing an element from a volatile struct doesn't work in c++. Pick2

Resp1 2513 Resp2 3555

If the message doesn't contain any string in a given list then print message. Python code Pick2

Resp1 3524. Resp2 5555

Can you explain to me what this code snippets function is? Pick 2

Resp1 3355 Resp2 5555

Write a python script where you need to extract all the email address from a given text file. Pick 2

Resp1 2221 Resp2 4455

Create a python that takes a list of numeric grades, which might be numbers or strings of numbers.

Pick 2 Resp1 2323 Resp2 4455

What exactly is wrong with my code

Pick1 Resp1 4545 Resp2 2221

Can I have a brief rundown of the python finance library.

Pick 1 Resp1 4444fp Resp2 2433pp

Can y ou write a code in c++ that removes whitespace...1

Rsp 1...5,5,5,5

Rsp 2....5,5,5,2
Import java.util.scanner

Pick 1 Resp1 4444 Resp2 2221

I would like an input field to be marked as invalid(red) when the form is submitted regardless of its
content.

Pick 2 Resp1 3232 Resp2 5555

Create a main menu in Java using a gridbag layout where I have a little panel in center and 3 button of
the window.

Pick 2 Resp1 2221 Resp2 5444

Create a python program that has a typing speed test stimulator on command line

Pick 2 Resp1 2323 Resp2 4545

Craft a python code that composes an email with sender and receiver

Pick 1 Resp1 4555 Resp2 2221

I want a js file that has some data that I need to be stored in session storage but after a while that data
will be deleted

Pick2 Resp1 3121 Resp2 5555

Write a python script that implements simple parallel processing use case.

Pick2 Resp1 2221 Resp2 4545

Write a python script that reads a CSV file, removes any duplicate entries based on the email column
and then saves the cleaned data into a new CSV file.

Pick 1. Resp1 4545. Resp2 3223

In Javascript, how can I make an array of 1000 items with 999 items of the same value

Pick 2 Resp1 3423 Resp2 4454

Correct this code

Pick 2 Resp1 2221. Resp2 4555

Create a unit converter code in C for the units of measure: length, mass, temperature with unit
conversions from imperial to metric

Pick 1. Resp1 4555. Resp2 2321

Write a java programme that includes 2 classes (FirstClass , SecondClass)

Pick 1. Resp1 5555 Resp2 2321


Write a program in Java that concatenates a given string. Give me the code without comments or
docstrings.

Pick 2

Response 1: 3,2,4,4

Response 2: 5,5,5,5

Explanation: Response B is better than A because uses correctly the code wrapped between
backticks, mentioning that the programming language is Java. A has the markdown broken.
Additionally, B closes the response by ending with an appropriate and polite question that
encourages the user to ask more questions.

You might also like