Coder Rating
Coder Rating
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)
```
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:
self.type = type
self.literal = literal
def __repr__(self):
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():
def advance():
nonlocal current
current += 1
return input_string[current - 1]
tokens.append(Token(type, literal))
def number():
pass
nonlocal current
current -= 1
value = input_string[start:current]
add_token(NUMBER, value)
def identifier():
pass
current -= 1
value = input_string[start:current]
add_token(IDENTIFIER, value)
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()
current -= 1
identifier()
return tokens
print(tokenize(example_input))
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
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>
int del, i;
scanf("%d", &del);
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
#include <stdlib.h>
return product;
int main() {
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
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
message: textbox
button
When the button is clicked, another div appears such that the values inputted above are shown.
Pick 2
Response 1: 5,5,2,4
Response 2: 5,5,5,5
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{
Pick 2
Response 1: 2 2 2 1
Response 2: 4,5,5,5
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
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
Pick 2
Response 1: 5,4,2,4
Response 2: 5,5,5,5
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
import random
choices = {
"rock": "circle",
"paper": "square",
"scissors": "triangle"
def player_choice(choice):
player_canvas.itemconfig(player_shape, **choices[choice])
computer_choice()
def computer_choice():
computer_choice = random.choice(list(choices.keys()))
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!")
else:
root = tk.Tk()
player_frame.pack(side=tk.LEFT)
player_label.pack(pady=10)
player_buttons = tk.Frame(player_frame)
rock_button.pack(side=tk.LEFT)
paper_button.pack(side=tk.LEFT)
scissors_button.pack(side=tk.LEFT)
player_buttons.pack()
player_canvas.pack()
computer_frame = tk.Frame(root)
computer_frame.pack(side=tk.RIGHT)
computer_label.pack(pady=10)
computer_canvas.pack()
result_label.pack()
root.mainloop()
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
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 && (
×
)}
); } 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;
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
Pick 2
Resp 1 2212
Resp 2 4554
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 = []
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
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>
return product;
int main() {
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.
a Person B sends a request that takes 2 seconds immediately after person A. How will node js handle
it,
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.
Constraints
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
Can you help me understand the hashing method in use here. Pick 2
Question?? Indexing an element from a volatile struct doesn't work in c++. Pick2
If the message doesn't contain any string in a given list then print message. Python code Pick2
Can you explain to me what this code snippets function is? Pick 2
Write a python script where you need to extract all the email address from a given text file. Pick 2
Create a python that takes a list of numeric grades, which might be numbers or strings of numbers.
Rsp 1...5,5,5,5
Rsp 2....5,5,5,2
Import java.util.scanner
I would like an input field to be marked as invalid(red) when the form is submitted regardless of its
content.
Create a main menu in Java using a gridbag layout where I have a little panel in center and 3 button of
the window.
Create a python program that has a typing speed test stimulator on command line
Craft a python code that composes an email with sender and receiver
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
Write a python script that implements simple parallel processing use case.
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.
In Javascript, how can I make an array of 1000 items with 999 items of the same value
Create a unit converter code in C for the units of measure: length, mass, temperature with unit
conversions from imperial to metric
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.