row_id
int64 0
48.4k
| init_message
stringlengths 1
342k
| conversation_hash
stringlengths 32
32
| scores
dict |
|---|---|---|---|
30,618
|
hello
|
d454ef0672297c0ed481ca0179d1ae33
|
{
"intermediate": 0.32064199447631836,
"beginner": 0.28176039457321167,
"expert": 0.39759764075279236
}
|
30,619
|
I need a query to list all the tables that are getting joined in a view. I need it like one column should be view name, and another column with all the table names that are getting joined in that view
|
8690acf4233cf39cb02caf31beb850d7
|
{
"intermediate": 0.446528822183609,
"beginner": 0.21085655689239502,
"expert": 0.34261465072631836
}
|
30,620
|
If I have an Input component in React, this input has a name property and in this Input I have an Icon by clicking on which I need to pass the name of the input to the function then how do I do that?
|
e90c4158b59803e2dbcd113b8769292e
|
{
"intermediate": 0.6473307609558105,
"beginner": 0.22358040511608124,
"expert": 0.1290888488292694
}
|
30,621
|
hello
|
39f5bbc9bbef6394b74de1ae1dd45a90
|
{
"intermediate": 0.32064199447631836,
"beginner": 0.28176039457321167,
"expert": 0.39759764075279236
}
|
30,622
|
Make in silico translation. Convert an input RNA string to a peptide string. Each three letter RNA combination (see table) codes for a one peptide letter. Assume peptide starts from the beginning of the RNA input string.
Example input: CAUUUUGAUGACUCUUUUGUUAGGAAAUGA
Example output: HFDDSFVSK
|
4d59739b8ac8e1c518aeda28c112ecff
|
{
"intermediate": 0.2196417599916458,
"beginner": 0.1767394244670868,
"expert": 0.603618860244751
}
|
30,623
|
How do I get all the characters from a python string and store it in a list
|
6b4d57eb7d1b39ef71fea2ab00fb3bba
|
{
"intermediate": 0.4090626537799835,
"beginner": 0.14358001947402954,
"expert": 0.44735729694366455
}
|
30,624
|
Print all codons that code for a given amino acid. Use the previous table for genetic code with no def functions
Example input: L
Example output: UUA UUG CUU CUC CUA CUG
|
7218993d0c08e7b5a60bed27e004e449
|
{
"intermediate": 0.3858160078525543,
"beginner": 0.2755715548992157,
"expert": 0.33861246705055237
}
|
30,625
|
Give 4 numbers, 1,2 ,3 and 4. They can be freely combined like 1 and 2, or 1, 3 and 4. I want to find all the combinations that contains all 4 numbers, like 1, 2, 3, 4 as one of the result. 1, 2, 3 and 3, 4 can also be an result because 1 2 3 4 are inside the 2 combinations. But I want the combinations as less as possibile. Say if we have 1000 numbers, can you find all the combinations. Writing it in Python.
|
42d1344e2b18e1f0c831c47d0b66548f
|
{
"intermediate": 0.3893677890300751,
"beginner": 0.2276635318994522,
"expert": 0.38296863436698914
}
|
30,626
|
Hi, for example I have a array [ [1,1,1,1,1,1,1,1], [2,2,3,4], [1,2] , [3,4] ]. Can you find the combinations of the array item that can find 1,2,3,4 all 4 numbers in the comnibanation?
|
d06e74e10ce1c54486a220685653e9f2
|
{
"intermediate": 0.449640154838562,
"beginner": 0.1401159167289734,
"expert": 0.4102439880371094
}
|
30,627
|
Implement a character level language model in C using Vanilla RNN architecture.
The model you will implement should be able to train on batches of a file (input.txt).
Print the predictions, epochs and loss while training.
|
a34edba84c2cd78f3fe2cca483bf660e
|
{
"intermediate": 0.21780875325202942,
"beginner": 0.12311693280935287,
"expert": 0.6590743660926819
}
|
30,628
|
Let's say I have a arry [[1], [2,3], [3], [2,4], [4], [1,4]]. Can you find the array item combinations that can build 1,2,3,4? like [1], [2,3] and [4] can be seen as an result cause 1, 2, 3, 4 can befound in the combination. [1,4], [2,4],[3] can also be seen as an result. Even though that 4 comes twice but we can still find 1,2,3,4 in the combinations.
|
8833984b360081bcd25da27839ef5189
|
{
"intermediate": 0.40144485235214233,
"beginner": 0.15805596113204956,
"expert": 0.4404992163181305
}
|
30,629
|
public class CardDeck
{
public List<Card> Cards { get; set; } = new();
public CardDeck()
{
foreach (var power in Enum.GetValues<PowerOfCard>())
{
foreach (var suit in Enum.GetValues<Suits>())
{
Cards.Add(new Card(power, suit));
}
}
}
public Card GetCard()
{
if (CountOfCardsInDeck() < 1)
{
throw new OutOfCardsExceptions("This deck is empty");
}
var card = Cards[0];
Cards.Remove(card);
return card;
}
public List<Card> GetCards(int count)
{
if (count < 1)
{
throw new ArgumentException($"{nameof(count)} must be positive and non zero");
}
if (CountOfCardsInDeck() < count)
{
throw new OutOfCardsExceptions("There are not enough cards in the deck");
}
var result = new List<Card>();
for (int i = 0; i < count; i++)
{
result.Add(Cards[i]);
}
Cards.RemoveRange(0, count);
return result;
}
public int CountOfCardsInDeck() => Cards.Count;
}
Напиши тесты язык c#
|
3eba0404e84d4138b80fb4c04118a064
|
{
"intermediate": 0.38040873408317566,
"beginner": 0.3209116756916046,
"expert": 0.29867953062057495
}
|
30,630
|
using UnityEngine;
using UnityEngine.AI;
public class EnemyAI : MonoBehaviour
{
public Camera camera;
public float wanderRadius = 10f;
public float detectionRadius = 5f;
public float chaseDuration = 15f;
public float stopChaseDelay = 5f;
public float speed = 2f;
private GameObject player;
private NavMeshAgent agent;
private Animator animator;
private float originalSpeed;
private bool isChasing = false;
private bool canChase = true;
private float chaseTimer = 0f;
private float stopChaseTimer = 0f;
void Start()
{
player = GameObject.FindGameObjectWithTag("Player");
agent = GetComponent<NavMeshAgent>();
animator = GetComponent<Animator>();
originalSpeed = agent.speed;
agent.speed = 5;
InvokeRepeating("Wander", 5f, 15f);
}
void Update()
{
float distanceToPlayer = Vector3.Distance(transform.position, player.transform.position);
if (distanceToPlayer <= detectionRadius)
{
if (!isChasing && canChase)
{
isChasing = true;
agent.speed = speed;
animator.SetInteger("State", 2);
chaseTimer = 0f;
}
if (isChasing)
{
chaseTimer += Time.deltaTime;
if (chaseTimer >= chaseDuration)
{
isChasing = false;
agent.speed = 5;
animator.SetInteger("State", 0);
stopChaseTimer = 0f;
canChase = false;
Invoke("ResetChaseState", stopChaseDelay);
}
else
{
agent.SetDestination(player.transform.position);
}
}
}
else if (!isChasing)
{
stopChaseTimer += Time.deltaTime;
if (stopChaseTimer >= 5f)
{
agent.speed = 5;
animator.SetInteger("State", 0);
canChase = true;
}
}
}
void Wander()
{
if (isChasing) return;
Vector3 randomPoint = transform.position + Random.insideUnitSphere * wanderRadius;
NavMeshHit hit;
NavMesh.SamplePosition(randomPoint, out hit, wanderRadius, 1);
Vector3 finalPosition = hit.position;
agent.SetDestination(finalPosition);
agent.speed = speed;
animator.SetInteger("State", 1);
}
void ResetChaseState()
{
canChase = true;
}
}
добавь чтобы при начале преследования проигрывался выбранный звук
|
66a07170e92c3ed8a66ccb0a55b32cf1
|
{
"intermediate": 0.34866029024124146,
"beginner": 0.5003113150596619,
"expert": 0.15102839469909668
}
|
30,631
|
you are a llm expert and coding genuis. i want to custom code a python script, can you help me?
|
9ed40c2e5237c017b27c43c90474be37
|
{
"intermediate": 0.34982120990753174,
"beginner": 0.26904335618019104,
"expert": 0.381135493516922
}
|
30,632
|
create heroes 3 example in javascript
|
2b022c5d8d86cfd39591b2e2e822460b
|
{
"intermediate": 0.3470418453216553,
"beginner": 0.30662021040916443,
"expert": 0.3463379442691803
}
|
30,633
|
fix this micosoft sql management code : create database shopland1
go
USE shopland1
GO
CREATE TABLE Employee (
FirstName NVARCHAR(50) NOT NULL,
LastName NVARCHAR(50) NOT NULL,
Birthday DATE NOT NULL,
Address NVARCHAR(150) NOT NULL,
Sex NVARCHAR(50) NOT NULL,
SSN INT IDENTITY(1,1) PRIMARY KEY,
super_ssn int not null,
Salary BIGINT NOT NULL,
Dno INT,
CONSTRAINT FK_Employee_super_ssn FOREIGN KEY (ssn) REFERENCES Employee(ssn),
);
CREATE TABLE Department (
Dname NVARCHAR(100) NOT NULL,
Dnumber INT IDENTITY(1,1) PRIMARY KEY,
Mgr_ssn INT NOT NULL,
Mgr_start_date DATE NOT NULL,
CONSTRAINT FK_Employee_mgr_ssn FOREIGN KEY (Mgr_ssn) REFERENCES Employee(ssn)
);
CREATE TABLE Dept_location (
Dnumber INT NOT NULL,
Dlocation NVARCHAR(150) NOT NULL,
CONSTRAINT FK_Department_Dnumber FOREIGN KEY (Dnumber) REFERENCES Department(Dnumber)
);
CREATE TABLE Project (
Pname NVARCHAR(100),
Pnumber INT IDENTITY(1,1) PRIMARY KEY,
Plocation NVARCHAR(150) NOT NULL,
Dnum INT,
CONSTRAINT FK_Department_Dnum FOREIGN KEY (Dnum) REFERENCES Department(Dnumber)
);
CREATE TABLE Works_on (
Essn INT NOT NULL,
Pno INT NOT NULL,
Whours NVARCHAR(50),
CONSTRAINT FK_Project_Pno FOREIGN KEY (Pno) REFERENCES Project(Pnumber),
CONSTRAINT FK_Employee_essn FOREIGN KEY (Essn) REFERENCES Employee(ssn)
);
CREATE TABLE WDependent (
EmployeeId INT NOT NULL,
Dependent_name NVARCHAR(100) PRIMARY KEY,
Sex NVARCHAR(100),
Bdate DATE,
Relationship NVARCHAR(100),
CONSTRAINT FK_Employee_employeeId FOREIGN KEY (EmployeeId) REFERENCES Employee(ssn)
);
alter table Employee (
add CONSTRAINT FK_Department_Dno FOREIGN KEY (Dno) REFERENCES Department(Dnumber)
);
|
e58312c7ce5f450b086b7ce72cbaa49f
|
{
"intermediate": 0.4365784525871277,
"beginner": 0.23845867812633514,
"expert": 0.32496288418769836
}
|
30,634
|
help me do a rect test file for
/* eslint-disable react/function-component-definition */
import React from 'react';
interface ArrowLineProps {
startX: number,
startY: number,
endX: number,
endY: number,
color?: string
}
const ArrowLine: React.FC<ArrowLineProps> = ({
startX,
startY,
endX,
endY,
color = 'blue',
}) => {
const deltaX = endX - startX;
const deltaY = endY - startY;
const length = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
const turnPointX = startX + length / 2;
return (
<svg style={{
height: '100%', overflow: 'visible', position: 'absolute', width: '100%',
}}
>
<line
stroke={color}
strokeWidth={2}
x1={startX}
x2={turnPointX}
y1={startY}
y2={startY}
/>
<line
markerEnd="url(#arrowhead)"
stroke={color}
strokeWidth={1}
x1={turnPointX}
x2={turnPointX}
y1={startY}
y2={endY}
/>
<defs>
<marker
id="arrowhead"
markerHeight="7"
markerUnits="strokeWidth"
markerWidth="10"
orient="auto"
refX="0"
refY="3.5"
>
<path d="M0,0 L0,7 L10,3.5 z" fill={color} />
</marker>
</defs>
</svg>
);
};
export default ArrowLine;
|
2dd056e8a7eaa55c2da502286c06fedf
|
{
"intermediate": 0.33072739839553833,
"beginner": 0.4507168233394623,
"expert": 0.21855580806732178
}
|
30,635
|
Please Write python code for the Library System:
Catalog: -catalog_num:int, -title: str, -published_date:str, -init():None,-eq():bool, -str():str
Book: -cover_type:CoverType, -subject:str,-author:str,-init():None,-_str():str
Periodical:-periodical_type:PeriodicalType,-article:list[Article],-init():None,-str():str,-add_article(article):None
Article:-title:str,-author:str,-issue_date:str,-periodical_title:str,-init():None,-str():str
PeriodicalType(Enum):+JOURNUAL,+MAGAZINE,+NEWSPAPER
Library:-library_name:str,-items:list[Catalog],+init():None,+eq():bool,+str():str,+add_item(self,item:Catalog):None,+remove_item(self,catalog_num:int):None,+update_item(self,item:Catalog):None,+search_by_catalog_num(self,catalog_num:int):Catalog,+search_by_title(self,title:str):list[Catalog],+search_by_article_title(self,title:str):list,+get_books_by_cover_type(self,cover_type:str):list[Book],+get_movies_by_movie_format(self,format_type:str):list[Movie],+save_to_db():None,+read-from_db():None
LibraryApp:-library:Library,+init():None,+show_program_title():None,+show_menu():None,+process_command():None
CatalogRepository:-filename:str,+init():None,+save_items(items:list[Catalog]):None,+get_items():list[Catalog]
Movie:-subject:str,format_type:FormatType,-director:str,actors:int,-year:int,-length:int,-init():None,-str():str
FormatType(Enum):+DVD,+BLU_RAY,+VCD
|
53f2b72717459a83d189ba4bcb3edc19
|
{
"intermediate": 0.5907518267631531,
"beginner": 0.312213659286499,
"expert": 0.09703453630208969
}
|
30,636
|
Problem Description
Given a square grid (a 2-D array called puzzleMap) of size 2N x 2N (N = 1, 2, 3), you need to fill the grid with L-shaped blocks with the given one empty cell.
Please note that the algorithm works in all positive integers N. We restrict N to 3 because we use 21 letters to represent at most 21 L-shapes in an 8x8 square. It is hard to have meaningful characters if N is larger than 3.
The program accepts the following inputs:
The width / height of the grid (either 2, 4, or 8).
The x and y coordinates of the empty cell (which should lie within the grid).
The output mode:
0: Exit directly for testing checkInput function;
1: Output Quadrant of the empty cell;
2 for console output without normalization;
3 for console output with normalization.
The normalization process will be explained later.
The number of L-shaped blocks:
2 x 2 square = 1 L-shapes and 1 empty cell (3 filled cells + 1 empty cell).
4 x 4 square = 5 L-shapes and 1 empty cell (15 filled cells + 1 empty cell).
8 x 8 square = 21 L-shapes and 1 empty cell (63 filled cells + 1 empty cell).
Coordinate
A coordinate, (x, y), can be used to represent an element in the 2-D array (e.g., puzzleMap in this assignment). The coordinate system is zero-indexed, meaning it starts from 0. It's worth noting that coordinate (x, y) corresponds to array_2d[x][y]. Please compare carefully the grid and the actual data stored in puzzleMap.
finish TODO parts in the code (C++):
/*
The following program solves the L-shape blocks problem
Given
A 2^N x 2^N array (In this assignment, we restrict the value N as 1, 2 and 3 )
The location of the empty cell (x,y)
The legal (x,y) coordinates of the empty cell:
For a 2 x 2 block, the legal range is 0-1
For a 4 x 4 block, the legal range is 0-3
For a 8 x 8 block, the legal range is 0-7
You can assume all the input values are correct
Output:
The empty cell (x,y) remains empty
All other cells are filled by non-overlapping L-shape blocks
Output mode:
(0) Console output without normalization
(1) Console output with normalization
Author: Peter, Brian, Tommy
*/
#include <iostream>
using namespace std;
// Constants in global scope
const int MAX_WIDTH = 8;
const int LOCATEQUADRANT_NOT_IMPLEMENTED = 0;
// TODO:
// function locateQuadrant:
// @param x: x coordinate of the empty cell
// @param y: y coordinate of the empty cell
//
// If x < half width, y < half width, then return 1
// If x >= half width, y < half width, then return 2
// If x >= half width, y >= half width, then return 3
// If x < half width, y >= half width, then return 4
//
// @return: int
// The function returns after getting valid values for width, emptyXPos and emptyYPos
int locateQuadrant(int width, int x, int y)
{
if (x < width / 2 && y < width / 2)
return 1;
else if (x >= width / 2 && y < width / 2)
return 2;
else if (x >= width / 2 && y >= width / 2)
return 3;
else if (x < width / 2 && y >= width / 2)
return 4;
//return LOCATEQUADRANT_NOT_IMPLEMENTED;
}
/**
Given the puzzleMap (2D array from the recursive function),
Generate the console output
*/
void visualizePuzzleByText(int width, char puzzleMap[][MAX_WIDTH])
{
cout << " ";
for (int x = 0; x < width; x++)
cout << x << " ";
cout << endl;
for (int y = 0; y < width; y++)
{
cout << y << ":";
for (int x = 0; x < width; x++)
cout << puzzleMap[x][y] << " ";
cout << endl;
}
}
/**
* Initialize the whole puzzleMap using by a space character: ' '
*/
void initializePuzzleMap(int width, char puzzleMap[][MAX_WIDTH])
{
for (int x = 0; x < width; x++)
for (int y = 0; y < width; y++)
puzzleMap[x][y] = ' ';
}
// TODO:
// Normalize the whole puzzleMap. The space character ' ' will not be changed.
//
void normalizePuzzleMap(int width, char puzzleMap[][MAX_WIDTH])
{
char nextChar = 'A';
for (int y = 0; y < width; y++)
{
for (int x = 0; x < width; x++)
{
if (puzzleMap[x][y] != ' ' )
puzzleMap[x][y] = nextChar;
}
}
return;
}
// TODO:
// [The most important function in this program]
// The recursive function to fill up the character array: puzzleMap
// You need to figure out the parameters of the fillPuzzleRecursive function by yourself
//
void fillPuzzleRecursive(int width, char puzzleMap[][MAX_WIDTH], int tx,
int ty, int x, int y, char &nextChar)
{
// tx: top Left X coordinate
// ty: top Left Y coordinate
// x: x coordinate of the empty cell
// y: y coordinate of the empty cell
int quad = locateQuadrant(width, x, y);
if (width == 2)
{
for (int i = tx; i < 2; i++)
for (int j = ty; j < 2; j++)
if (i == x && j == y)
puzzleMap[i][j] = ' ';
else
puzzleMap[i][j] = nextChar++;
return;
}
switch (quad){
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
return;
}
// TODO:
// function checkInput:
//
// @param width: the width of the square. Valid values: 2, 4, 8
// You can assume inputs are always integers.
// @param emptyXPos: the x-axis of the empty position.
// Valid range: [0, width-1].
// You can assume inputs are always integers.
// @param emptyYPos: the y-axis of the empty position.
// Valid range: [0, width-1].
// You can assume inputs are always integers.
//
// Note: The pass-by-reference variables will be used in the main function.
// @return: void
// The function returns after getting valid values for width, emptyXPos and emptyYPos
void checkInput(int &width, int &emptyXPos, int &emptyYPos)
{
// Some helper lines for you to use:
width = 0;
emptyXPos = -1;
emptyYPos = -1;
while (true)
{
cout << "Enter the width/height of the puzzle (2, 4, 8): ";
cin >> width;
cout << endl;
if (width == 2 || width == 4 || width == 8)
break;
}
while (true)
{
cout << "Enter the x-coordinate of the empty cell (0-" << width - 1 << "): ";
cin >> emptyXPos;
cout << endl;
if (emptyXPos < width && emptyXPos >= 0)
break;
}
while (true)
{
cout << "Enter the y-coordinate of the empty cell (0-" << width - 1 << "): ";
cin >> emptyYPos;
cout << endl;
if (emptyYPos < width && emptyYPos >= 0)
break;
}
return;
}
// You are NOT ALLOWED to modify the main function
int main()
{
int width = 0;
int emptyXPos = 0;
int emptyYPos = 0;
checkInput(width, emptyXPos, emptyYPos);
// initialized with empty spaces..
char puzzleMap[MAX_WIDTH][MAX_WIDTH];
// initialize
initializePuzzleMap(width, puzzleMap);
int modeOfOperation = 0;
do
{
cout
<< "0: Exit directly (for testing checkInput function), 1: Output Quadrant of the empty cell,"
<< endl
<< "2: Output without normalization (for student's debug only), 3: Output with normalization"
<< endl;
cout << "Enter the output mode: ";
cin >> modeOfOperation;
} while (modeOfOperation < 0 || modeOfOperation > 3);
if (modeOfOperation == 0)
{
return 0;
}
if (modeOfOperation == 1)
{
int quad = locateQuadrant(width, emptyXPos, emptyYPos);
cout << "Quadrant for the empty cell: " << quad << endl;
return 0;
}
char nextChar = 'A';
// invoke the recursive call here...
// Result: puzzleMap will be filled by characters
fillPuzzleRecursive(width, puzzleMap, 0, 0, emptyXPos, emptyYPos, nextChar);
int quad = locateQuadrant(width, emptyXPos, emptyYPos);
cout << "Quadrant for the empty cell: " << quad << endl;
if (modeOfOperation == 2)
{
visualizePuzzleByText(width, puzzleMap);
}
else
{
normalizePuzzleMap(width, puzzleMap);
visualizePuzzleByText(width, puzzleMap);
}
return 0;
}
|
5636eae1b3b8ab43d95ae2f8cbc42a8e
|
{
"intermediate": 0.30462363362312317,
"beginner": 0.4422231614589691,
"expert": 0.2531531751155853
}
|
30,637
|
error: qualified-id in declaration before ‘temp’
std::set::iterator temp = st.find(num);
код
#include <iostream>
#include <set>
#include <string>
// int compare(std::vector<int, std::string> a, std::vector<int, std::string> b){
// return a[1] < b[1];
// }
int main()
{
int k, n;
// std::vector<std::pair<int, std::string>> arr;
std::set<std::string> st;
for(int i = 0; i<n; ++i){
std::string num;
std::cin >> num;
st.insert(num);
//find
std::string last = "";
std::string next = "";
std::set::iterator temp = st.find(num);
if(temp != st.start()){
last = *(temp - 1);
std::cout << last << " ";
} else
std::cout << -1 << " ";
if (temp != st.end()){
next = *(temp + 1);
std::cout << next << std::endl;
} else
std::cout << -1 << std::endl;
}
}
return 0;
}
|
ecc548b1a54d8b14a1eb40d6642fa865
|
{
"intermediate": 0.3602024018764496,
"beginner": 0.3901154100894928,
"expert": 0.24968217313289642
}
|
30,638
|
menu.setOnMenuItemClickListener {
}
Type mismatch: inferred type is Unit but Boolean was expected
|
28a793aceb28687e92867a98fad4fd64
|
{
"intermediate": 0.42229539155960083,
"beginner": 0.22869114577770233,
"expert": 0.34901344776153564
}
|
30,639
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MarioController : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 5f;
public float ladderClimbSpeed = 2f;
public int maxHealth = 3;
private int currentHealth;
private bool grounded;
private bool onLadder;
private bool climbingLadder;
private Vector2 direction;
private Rigidbody2D rb2d;
private new Collider2D collider;
private Collider2D[] results;
private void Awake()
{
rb2d = GetComponent<Rigidbody2D>();
collider = GetComponent<Collider2D>();
results = new Collider2D[4];
}
private void Start()
{
currentHealth = maxHealth;
}
private void CheckCollision()
{
grounded = false;
onLadder = false;
Vector2 size = collider.bounds.size;
size.y += 0.1f;
size.x /= 2f;
int amount = Physics2D.OverlapBoxNonAlloc(transform.position, size, 0f, results);
for (int i = 0; i < amount; i++)
{
GameObject hit = results[i].gameObject;
if (hit.layer == LayerMask.NameToLayer("Platform"))
{
grounded = hit.transform.position.y < (transform.position.y - 0.5f);
}
else if (hit.layer == LayerMask.NameToLayer("Ladder"))
{
onLadder = true;
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.layer == LayerMask.NameToLayer("Barrel"))
{
// If Mario collides with a barrel, decrease health and reset the scene
currentHealth = 0;
ResetScene();
}
else if (collision.gameObject.layer == LayerMask.NameToLayer("Win"))
{
// If Mario collides with the win object, reset the scene
ResetScene();
}
}
private void ResetScene()
{
// Reload the current scene
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
private void Update()
{
CheckCollision();
if (grounded && Input.GetButtonDown("Jump"))
{
rb2d.velocity = new Vector2(rb2d.velocity.x, jumpForce);
}
float movement = Input.GetAxis("Horizontal");
if (grounded)
{
direction.y = Mathf.Max(direction.y, -1f);
climbingLadder = false;
}
if (onLadder && Input.GetButton("Vertical"))
{
// Climb the ladder vertically
climbingLadder = true;
float climbDirection = Input.GetAxis("Vertical");
rb2d.velocity = new Vector2(0, climbDirection * ladderClimbSpeed);
rb2d.gravityScale = 0f;
}
else if (climbingLadder)
{
rb2d.gravityScale = 1f;
rb2d.velocity = new Vector2(rb2d.velocity.x, 0f);
rb2d.constraints = RigidbodyConstraints2D.FreezePositionX;
}
else
{
rb2d.gravityScale = 1f;
rb2d.constraints = RigidbodyConstraints2D.FreezeRotation;
}
rb2d.velocity = new Vector2(movement * moveSpeed, rb2d.velocity.y);
if (movement > 0)
{
transform.localScale = new Vector3(1f, 1f, 1f);
}
else if (movement < 0)
{
transform.localScale = new Vector3(-1f, 1f, 1f);
}
}
}
add to this script that when mario dies it destroys the Life1 game object, then the second time he dies it destroys the Life2 game object and finally after the third time he dies it destroyes the Life3 game object and when the scene resets it instantiates the Life1, Life2, and Life3 game objects again
|
23ef896af6f06d86d62b36f3dad1acc2
|
{
"intermediate": 0.32335320115089417,
"beginner": 0.4799302816390991,
"expert": 0.19671650230884552
}
|
30,640
|
Use image
(‘eight.tif’)
-Apply Gnoise on the given image
-Apply different smoothing filters with different window size)
(Average ,median filter, mean filter )
|
153b9c3a921042250ecf06cbda7ef135
|
{
"intermediate": 0.3688904643058777,
"beginner": 0.25524789094924927,
"expert": 0.37586167454719543
}
|
30,641
|
Write a C++ program. Initialize and print an array of n elements. Find the index of the 1st even element (remember the returned number). Then transform the last (returned number) elements by multiplying it by the value of the first odd element.
|
513eba1729df0c902110699f9877b01c
|
{
"intermediate": 0.3035239279270172,
"beginner": 0.32018667459487915,
"expert": 0.376289427280426
}
|
30,642
|
make a C# script where it relates back to the MarioController script where if mario's health is 0 the Life1 game object is destroyed and the scene is reset (except for the Life1 game object); then do the same thing with Life2 and Life3 game objects; once Life1, Life2, and Life3 are destroyed, re-instantiate them
|
82797754537e01440d5ffc831ed14667
|
{
"intermediate": 0.6403826475143433,
"beginner": 0.1735190451145172,
"expert": 0.18609827756881714
}
|
30,643
|
Fix my C++ program. It's supposed to initialize and print an array of n elements, Find the index of the 1st even element (val), Then transform the last (val) elements by multiplying it by the value of the first odd element. My code fails at the very end as it doesn't multiply the correct number of last elements
Write a C++ program. Initialize and print an array of n elements. Find the index of the 1st even element (remember the returned number). Then transform the last (returned number) elements by multiplying it by the value of the first odd element.
|
90f4c721d604a19a0ccbba6291255aed
|
{
"intermediate": 0.4159250259399414,
"beginner": 0.30272775888442993,
"expert": 0.2813471555709839
}
|
30,644
|
Fix my C++ program. It's supposed to initialize and print an array of n elements, find the index of the 1st even element (val). Then transform the last (val) elements by multiplying it by the value of the first odd element. My code doesn't work correctly as it multiplies the wrong quantity of last elements at the very end.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void print(int* a, int n) {
for (int i = 0; i < n; ++i)
cout << a[i] << " ";
cout << "\n";
}
int firstEvenIndex(int* a, int n) {
for (int i = 0; i < n; ++i) {
if (a[i] % 2 == 0) {
return i;
}
}
cout << "No even elements found";
return -1;
}
int firstOddElem(int* a, int n, int ind) {
for (int i = 0; i < n; ++i) {
if (a[i] % 2 != 0) {
return a[i];
}
}
return -1;
}
int main() {
srand(time(0));
int n;
cout << "Enter array's length: ";
cin >> n;
if (n < 0) n = -n;
else if (n == 0) n = 1;
int* arr = new int[n];
if (arr == nullptr) {
cout << "\nMemory error";
return 1;
}
for (int i = 0; i < n; ++i)
arr[i] = rand() % 21 - 10;
cout << "\nArr before:" << endl;
print(arr, n);
int ind = firstEvenIndex(arr, n);
if (ind != -1) {
int elem = firstOddElem(arr, n, ind);
cout << "\nIndex of the first even element: " << ind << endl;
cout << "First odd element: " << elem << endl;
for (int i = ind + 1; i < n; ++i) arr[i] *= elem;
cout << "\nArr after:" << endl;
print(arr, n);
}
delete[] arr;
arr = nullptr;
return 0;
}
|
a0697257168ca232c829ee3d054b76f6
|
{
"intermediate": 0.3712943196296692,
"beginner": 0.4815841019153595,
"expert": 0.14712154865264893
}
|
30,645
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MarioController : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 5f;
public float ladderClimbSpeed = 2f;
public int maxHealth = 3;
private int currentHealth;
private bool grounded;
private bool onLadder;
private bool climbingLadder;
private Vector2 direction;
private Rigidbody2D rb2d;
private new Collider2D collider;
private Collider2D[] results;
private void Awake()
{
rb2d = GetComponent<Rigidbody2D>();
collider = GetComponent<Collider2D>();
results = new Collider2D[4];
}
private void Start()
{
currentHealth = maxHealth;
}
private void CheckCollision()
{
grounded = false;
onLadder = false;
Vector2 size = collider.bounds.size;
size.y += 0.1f;
size.x /= 2f;
int amount = Physics2D.OverlapBoxNonAlloc(transform.position, size, 0f, results);
for (int i = 0; i < amount; i++)
{
GameObject hit = results[i].gameObject;
if (hit.layer == LayerMask.NameToLayer("Platform"))
{
grounded = hit.transform.position.y < (transform.position.y - 0.5f);
}
else if (hit.layer == LayerMask.NameToLayer("Ladder"))
{
onLadder = true;
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.layer == LayerMask.NameToLayer("Barrel"))
{
// If Mario collides with a barrel, decrease health and reset the scene
currentHealth = 0;
ResetScene();
}
else if (collision.gameObject.layer == LayerMask.NameToLayer("Win"))
{
// If Mario collides with the win object, reset the scene
ResetScene();
}
}
private void ResetScene()
{
// Reload the current scene
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
private void Update()
{
CheckCollision();
if (grounded && Input.GetButtonDown("Jump"))
{
rb2d.velocity = new Vector2(rb2d.velocity.x, jumpForce);
}
float movement = Input.GetAxis("Horizontal");
if (grounded)
{
direction.y = Mathf.Max(direction.y, -1f);
climbingLadder = false;
}
if (onLadder && Input.GetButton("Vertical"))
{
// Climb the ladder vertically
climbingLadder = true;
float climbDirection = Input.GetAxis("Vertical");
rb2d.velocity = new Vector2(0, climbDirection * ladderClimbSpeed);
rb2d.gravityScale = 0f;
}
else if (climbingLadder)
{
rb2d.gravityScale = 1f;
rb2d.velocity = new Vector2(rb2d.velocity.x, 0f);
rb2d.constraints = RigidbodyConstraints2D.FreezePositionX;
}
else
{
rb2d.gravityScale = 1f;
rb2d.constraints = RigidbodyConstraints2D.FreezeRotation;
}
rb2d.velocity = new Vector2(movement * moveSpeed, rb2d.velocity.y);
if (movement > 0)
{
transform.localScale = new Vector3(1f, 1f, 1f);
}
else if (movement < 0)
{
transform.localScale = new Vector3(-1f, 1f, 1f);
}
}
}
add to this script where when marios heath is 0 the scene is reset and Life1 game object is removed. Then if marios health reaches 0 again reset the scene and Life2 game object is removed (Life1 game objected should still be removed). Then if marios health reaches 0 and the scene is reset for a third time reset Life1 and Life2 game object
|
87550d26791e88642ec1fa96453fb6f7
|
{
"intermediate": 0.32335320115089417,
"beginner": 0.4799302816390991,
"expert": 0.19671650230884552
}
|
30,646
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MarioController : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 5f;
public float ladderClimbSpeed = 2f;
public int maxHealth = 3;
private int currentHealth;
private bool grounded;
private bool onLadder;
private bool climbingLadder;
private Vector2 direction;
private Rigidbody2D rb2d;
private new Collider2D collider;
private Collider2D[] results;
private void Awake()
{
rb2d = GetComponent<Rigidbody2D>();
collider = GetComponent<Collider2D>();
results = new Collider2D[4];
}
private void Start()
{
currentHealth = maxHealth;
}
private void CheckCollision()
{
grounded = false;
onLadder = false;
Vector2 size = collider.bounds.size;
size.y += 0.1f;
size.x /= 2f;
int amount = Physics2D.OverlapBoxNonAlloc(transform.position, size, 0f, results);
for (int i = 0; i < amount; i++)
{
GameObject hit = results[i].gameObject;
if (hit.layer == LayerMask.NameToLayer("Platform"))
{
grounded = hit.transform.position.y < (transform.position.y - 0.5f);
}
else if (hit.layer == LayerMask.NameToLayer("Ladder"))
{
onLadder = true;
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.layer == LayerMask.NameToLayer("Barrel"))
{
// If Mario collides with a barrel, decrease health and reset the scene
currentHealth = 0;
ResetScene();
}
else if (collision.gameObject.layer == LayerMask.NameToLayer("Win"))
{
// If Mario collides with the win object, reset the scene
ResetScene();
}
}
private void ResetScene()
{
// Reload the current scene
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
private void Update()
{
CheckCollision();
if (grounded && Input.GetButtonDown("Jump"))
{
rb2d.velocity = new Vector2(rb2d.velocity.x, jumpForce);
}
float movement = Input.GetAxis("Horizontal");
if (grounded)
{
direction.y = Mathf.Max(direction.y, -1f);
climbingLadder = false;
}
if (onLadder && Input.GetButton("Vertical"))
{
// Climb the ladder vertically
climbingLadder = true;
float climbDirection = Input.GetAxis("Vertical");
rb2d.velocity = new Vector2(0, climbDirection * ladderClimbSpeed);
rb2d.gravityScale = 0f;
}
else if (climbingLadder)
{
rb2d.gravityScale = 1f;
rb2d.velocity = new Vector2(rb2d.velocity.x, 0f);
rb2d.constraints = RigidbodyConstraints2D.FreezePositionX;
}
else
{
rb2d.gravityScale = 1f;
rb2d.constraints = RigidbodyConstraints2D.FreezeRotation;
}
rb2d.velocity = new Vector2(movement * moveSpeed, rb2d.velocity.y);
if (movement > 0)
{
transform.localScale = new Vector3(1f, 1f, 1f);
}
else if (movement < 0)
{
transform.localScale = new Vector3(-1f, 1f, 1f);
}
}
}
modify this script so when marios currentHealth = 0, the scene changes to _Scene_DonkeyKong25M2. then if marios currentHealth = 0 in _Scene_DonkeyKong25M2, the scene changes to _Scene_DonkeyKong25M3. then if marios currentHealth = 0 in _Scene_DonkeyKong25M3, the scene changes to _Scene_DonkeyKong25M
|
3819c2887ce35261ee14e8f9b90abc24
|
{
"intermediate": 0.32335320115089417,
"beginner": 0.4799302816390991,
"expert": 0.19671650230884552
}
|
30,647
|
write a C# PointCollider script for when it collides with a barrel game object +100. Here is the ScoreCounter script for reference: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; //This line enables use of uGUI classes like Text.
public class ScoreCounter : MonoBehaviour
{
[Header("Dynamic")]
public int score = 0;
private Text uiText;
// Start is called before the first frame update
void Start()
{
uiText = GetComponent<Text>();
}
// Update is called once per frame
void Update()
{
uiText.text = score.ToString("Score:#,0"); //This 0 is a zero!
}
}
|
aa2e40e3e53e95a28fdc956ecb857088
|
{
"intermediate": 0.41139674186706543,
"beginner": 0.38176319003105164,
"expert": 0.20684003829956055
}
|
30,648
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MarioController : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 5f;
public float ladderClimbSpeed = 2f;
public int maxHealth = 3;
private int currentHealth;
private bool grounded;
private bool onLadder;
private bool climbingLadder;
private Vector2 direction;
private Rigidbody2D rb2d;
private new Collider2D collider;
private Collider2D[] results;
private int currentSceneIndex;
private void Awake()
{
rb2d = GetComponent<Rigidbody2D>();
collider = GetComponent<Collider2D>();
results = new Collider2D[4];
}
private void Start()
{
currentHealth = maxHealth;
currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
}
private void CheckCollision()
{
grounded = false;
onLadder = false;
Vector2 size = collider.bounds.size;
size.y += 0.1f;
size.x /= 2f;
int amount = Physics2D.OverlapBoxNonAlloc(transform.position, size, 0f, results);
for (int i = 0; i < amount; i++)
{
GameObject hit = results[i].gameObject;
if (hit.layer == LayerMask.NameToLayer("Platform"))
{
grounded = hit.transform.position.y < (transform.position.y - 0.5f);
}
else if (hit.layer == LayerMask.NameToLayer("Ladder"))
{
onLadder = true;
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.layer == LayerMask.NameToLayer("Barrel"))
{
currentHealth--;
ResetScene();
}
else if (collision.gameObject.layer == LayerMask.NameToLayer("Win"))
{
SceneManager.LoadScene("_Scene_DonkeyKong25M");
}
}
private void ResetScene()
{
if (currentSceneIndex == 0)
{
SceneManager.LoadScene("_Scene_DonkeyKong25M2");
}
else if (currentSceneIndex == 1)
{
SceneManager.LoadScene("_Scene_DonkeyKong25M3");
}
else if (currentSceneIndex == 2)
{
SceneManager.LoadScene("_Scene_DonkeyKong25M");
}
}
private void Update()
{
CheckCollision();
if (grounded && Input.GetButtonDown("Jump"))
{
rb2d.velocity = new Vector2(rb2d.velocity.x, jumpForce);
}
float movement = Input.GetAxis("Horizontal");
if (grounded)
{
direction.y = Mathf.Max(direction.y, -1f);
climbingLadder = false;
}
if (onLadder && Input.GetButton("Vertical"))
{
climbingLadder = true;
float climbDirection = Input.GetAxis("Vertical");
rb2d.velocity = new Vector2(0, climbDirection * ladderClimbSpeed);
rb2d.gravityScale = 0f;
}
else if (climbingLadder)
{
rb2d.gravityScale = 1f;
rb2d.velocity = new Vector2(rb2d.velocity.x, 0f);
rb2d.constraints = RigidbodyConstraints2D.FreezePositionX;
}
else
{
rb2d.gravityScale = 1f;
rb2d.constraints = RigidbodyConstraints2D.FreezeRotation;
}
rb2d.velocity = new Vector2(movement * moveSpeed, rb2d.velocity.y);
if (movement > 0)
{
transform.localScale = new Vector3(1f, 1f, 1f);
}
else if (movement < 0)
{
transform.localScale = new Vector3(-1f, 1f, 1f);
}
}
}
make it so if mario collides with the "Win" layer, he gains +500 score
|
73b25e42e03c31690d72260a983942e5
|
{
"intermediate": 0.3211897313594818,
"beginner": 0.5172820091247559,
"expert": 0.16152825951576233
}
|
30,649
|
const { market_list } = require("./server");
const GarageItem = require("./GarageItem"),
Area = require("./Area"),
{ turrets, hulls, paints, getType } = require("./server"),
InventoryItem = require("./InventoryItem");
class Garage extends Area {
static fromJSON(data) {
if (typeof (data.tank) !== "undefiend") {
var garage = new Garage(data.tank);
garage.items = Garage.fromItemsObject(data.items);
garage.updateMarket();
garage.mounted_turret = data.mounted_turret;
garage.mounted_hull = data.mounted_hull;
garage.mounted_paint = data.mounted_paint;
garage.inventory = null;
return garage;
}
return null;
}
static fromItemsObject(obj) {
var items = [];
for (var i in obj.items) {
items.push(GarageItem.fromJSON(obj.items[i]));
}
return items;
}
constructor(tank) {
super();
this.tank = tank;
this.items = [GarageItem.get("smoky", 0), GarageItem.get("green", 0), GarageItem.get("holiday", 0), GarageItem.get("wasp", 0), GarageItem.get("health", 0)];
this.updateMarket();
this.mounted_turret = "smoky_m0";
this.mounted_hull = "wasp_m0";
this.mounted_paint = "green_m0";
this.inventory = [];
}
getPrefix() {
return "garage";
}
getInventory() {
// if (this.inventory !== null)
// return this.inventory;
var inventory = [];
for (var i in this.items) {
var item = this.items[i];
if (getType(item.id) === 4) {
inventory.push(InventoryItem.fromGarageItem(item));
}
}
this.inventory = inventory;
return inventory;
}
addGarageItem(id, amount) {
var tank = this.tank;
var new_item = GarageItem.get(id, 0);
if (new_item !== null) {
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
}
}
return true;
}
useItem(id) {
for (var i in this.items) {
if (this.items[i].isInventory && this.items[i].id === id) {
if (this.items[i].count <= 0)
return false;
if (this.items[i].count = 1)
{
this.deleteItem(this.items[i])
}
--this.items[i].count;
}
}
return true;
}
hasItem(id, m = null) {
for (var i in this.items) {
if (this.items[i].id === id) {
if (this.items[i].type !== 4) {
if (m === null)
return true;
return this.items[i].modificationID >= m;
}
else if (this.items[i].count > 0)
return true;
else {
this.items.splice(i, 1);
}
}
}
return false;
}
initiate(socket) {
this.send(socket, "init_garage_items;" + JSON.stringify({ items: this.items }));
this.addPlayer(this.tank);
}
initMarket(socket) {
this.send(socket, "init_market;" + JSON.stringify(this.market));
}
initMountedItems(socket) {
this.send(socket, "init_mounted_item;" + this.mounted_hull);
this.send(socket, "init_mounted_item;" + this.mounted_turret);
this.send(socket, "init_mounted_item;" + this.mounted_paint);
}
getItem(id) {
for (var i in this.items) {
if (this.items[i].id === id)
return this.items[i];
}
return null;
}
getTurret() {
return this.getItem(this.mounted_turret.split("_")[0]);
}
getHull() {
return this.getItem(this.mounted_hull.split("_")[0]);
}
getPaint() {
return this.getItem(this.mounted_paint.split("_")[0]);
}
updateMarket() {
this.market = { items: [] };
for (var i in market_list) {
if (!this.hasItem(market_list[i]["id"]) && market_list[i]["index"] >= 0) {
this.market.items.push(market_list[i]);
}
}
}
onData(socket, args) {
if (this.tank === null || !this.hasPlayer(this.tank.name))
return;
var tank = this.tank;
if (args.length === 1) {
if (args[0] === "get_garage_data") {
this.updateMarket();
setTimeout(() => {
this.initMarket(socket);
this.initMountedItems(socket);
}, 1500);
}
} else if (args.length === 3) {
if (args[0] === "try_buy_item") {
var itemStr = args[1];
var arr = itemStr.split("_");
var id = itemStr.replace("_m0", "");
var amount = parseInt(args[2]);
var new_item = GarageItem.get(id, 0);
if (new_item !== null) {
if (tank.crystals >= new_item.price * amount && tank.rank >= new_item.rank) {
var obj = {};
obj.itemId = id;
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
obj.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
obj.count = item.count;
}
tank.crystals -= new_item.price * amount;
if (id === "1000_scores")
tank.addScore(500 * amount);
if (id === "1000_scores")
tank.addScore(1000 * amount);
if (id === "supplies")
{
this.addKitItem("health",0,100,tank);
this.addKitItem("armor",0,100,tank);
this.addKitItem("damage",0,100,tank);
this.addKitItem("nitro",0,100,tank);
this.addKitItem("mine",0,100,tank);
this.send(socket,"reload")
}
else
{
this.send(socket, "buy_item;" + itemStr + ";" + JSON.stringify(obj));
}
tank.sendCrystals();
}
}
}
} else if (args.length === 2) {
if (args[0] === "try_mount_item") {
var itemStr = args[1];
var itemStrArr = itemStr.split("_");
if (itemStrArr.length === 2) {
var modificationStr = itemStrArr[1];
var item_id = itemStrArr[0];
if (modificationStr.length === 2) {
var m = parseInt(modificationStr.charAt(1));
if (!isNaN(m)) {
this.mountItem(item_id, m);
this.sendMountedItem(socket, itemStr);
tank.save();
}
}
}
} else if (args[0] === "try_update_item") {
var itemStr = args[1],
arr = itemStr.split("_"),
modStr = arr.pop(),
id = arr.join("_");
if (modStr.length === 2) {
var m = parseInt(modStr.charAt(1));
if (!isNaN(m) && m < 3) {
if (this.hasItem(id, m) && this.getItem(id).attempt_upgrade(tank)) {
this.send(socket, "update_item;" + itemStr);
tank.sendCrystals();
}
}
}
}
}
}
addKitItem(item, m, count, tank) {
// this.items.push(item);
var itemStr = item + "_m"
var arr = itemStr.split("_");
var id = itemStr.replace("_m", "");
var amount = parseInt(count);
var new_item = GarageItem.get(id, 0);
console.log(new_item)
if (new_item !== null) {
var obj = {};
obj.itemId = id;
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
new_item.modificationID = m;
obj.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
item.modificationID = m;
obj.count = item.count;
}
}
}
addItem(item) {
this.items.push(item);
}
deleteItem(item) {
delete this.items[item];
}
mountItem(item_id, m) {
if (this.hasItem(item_id, m)) {
var itemStr = item_id + "_m" + m;
if (hulls.includes(item_id))
this.mounted_hull = itemStr;
else if (turrets.includes(item_id))
this.mounted_turret = itemStr;
else if (paints.includes(item_id))
this.mounted_paint = itemStr;
}
}
sendMountedItem(socket, itemStr) {
this.send(socket, "mount_item;" + itemStr);
}
getItemsObject() {
var items = [];
for (var i in this.items) {
items.push(this.items[i].toObject());
}
return { items: items };
}
toSaveObject() {
return { items: this.getItemsObject(), mounted_turret: this.mounted_turret, mounted_hull: this.mounted_hull, mounted_paint: this.mounted_paint };
}
}
module.exports = Garage;
как сделать чтобы if (id === "1000_scores") не добавлялся после покупку в гараж игрока
|
e82f6e4203735d354b320b166bf53037
|
{
"intermediate": 0.2909576892852783,
"beginner": 0.5029168725013733,
"expert": 0.20612549781799316
}
|
30,650
|
import sys
if len(sys.argv) < 3:
print("""Usage
python3 main.py -t 8 -api / -scrape""")
# add t to threads var and api/scrape vars to a bool if it has been chosen, error if both have been added.
implement the lpogic for args
|
414a0f823d9a63a099d03c7dfe18fe43
|
{
"intermediate": 0.27298516035079956,
"beginner": 0.568279504776001,
"expert": 0.15873534977436066
}
|
30,651
|
const { market_list } = require("./server");
const GarageItem = require("./GarageItem"),
Area = require("./Area"),
{ turrets, hulls, paints, getType } = require("./server"),
InventoryItem = require("./InventoryItem");
class Garage extends Area {
static fromJSON(data) {
if (typeof (data.tank) !== "undefiend") {
var garage = new Garage(data.tank);
garage.items = Garage.fromItemsObject(data.items);
garage.updateMarket();
garage.mounted_turret = data.mounted_turret;
garage.mounted_hull = data.mounted_hull;
garage.mounted_paint = data.mounted_paint;
garage.inventory = null;
return garage;
}
return null;
}
static fromItemsObject(obj) {
var items = [];
for (var i in obj.items) {
items.push(GarageItem.fromJSON(obj.items[i]));
}
return items;
}
constructor(tank) {
super();
this.tank = tank;
this.items = [GarageItem.get("smoky", 0), GarageItem.get("green", 0), GarageItem.get("holiday", 0), GarageItem.get("wasp", 0), GarageItem.get("health", 0)];
this.updateMarket();
this.mounted_turret = "smoky_m0";
this.mounted_hull = "wasp_m0";
this.mounted_paint = "green_m0";
this.inventory = [];
}
getPrefix() {
return "garage";
}
getInventory() {
// if (this.inventory !== null)
// return this.inventory;
var inventory = [];
for (var i in this.items) {
var item = this.items[i];
if (getType(item.id) === 4) {
inventory.push(InventoryItem.fromGarageItem(item));
}
}
this.inventory = inventory;
return inventory;
}
addGarageItem(id, amount) {
var tank = this.tank;
var new_item = GarageItem.get(id, 0);
if (new_item !== null) {
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
}
}
return true;
}
useItem(id) {
for (var i in this.items) {
if (this.items[i].isInventory && this.items[i].id === id) {
if (this.items[i].count <= 0)
return false;
if (this.items[i].count = 1)
{
this.deleteItem(this.items[i])
}
--this.items[i].count;
}
}
return true;
}
hasItem(id, m = null) {
for (var i in this.items) {
if (this.items[i].id === id) {
if (this.items[i].type !== 4) {
if (m === null)
return true;
return this.items[i].modificationID >= m;
}
else if (this.items[i].count > 0)
return true;
else {
this.items.splice(i, 1);
}
}
}
return false;
}
initiate(socket) {
this.send(socket, "init_garage_items;" + JSON.stringify({ items: this.items }));
this.addPlayer(this.tank);
}
initMarket(socket) {
this.send(socket, "init_market;" + JSON.stringify(this.market));
}
initMountedItems(socket) {
this.send(socket, "init_mounted_item;" + this.mounted_hull);
this.send(socket, "init_mounted_item;" + this.mounted_turret);
this.send(socket, "init_mounted_item;" + this.mounted_paint);
}
getItem(id) {
for (var i in this.items) {
if (this.items[i].id === id)
return this.items[i];
}
return null;
}
getTurret() {
return this.getItem(this.mounted_turret.split("_")[0]);
}
getHull() {
return this.getItem(this.mounted_hull.split("_")[0]);
}
getPaint() {
return this.getItem(this.mounted_paint.split("_")[0]);
}
updateMarket() {
this.market = { items: [] };
for (var i in market_list) {
if (!this.hasItem(market_list[i]["id"]) && market_list[i]["index"] >= 0) {
this.market.items.push(market_list[i]);
}
}
}
onData(socket, args) {
if (this.tank === null || !this.hasPlayer(this.tank.name))
return;
var tank = this.tank;
if (args.length === 1) {
if (args[0] === "get_garage_data") {
this.updateMarket();
setTimeout(() => {
this.initMarket(socket);
this.initMountedItems(socket);
}, 1500);
}
} else if (args.length === 3) {
if (args[0] === "try_buy_item") {
var itemStr = args[1];
var arr = itemStr.split("_");
var id = itemStr.replace("_m0", "");
var amount = parseInt(args[2]);
var new_item = GarageItem.get(id, 0);
if (new_item !== null) {
if (tank.crystals >= new_item.price * amount && tank.rank >= new_item.rank) {
var obj = {};
obj.itemId = id;
if (new_item !== null && id !== "1000_scores") {
var item = tank.garage.getItem(id);
if (item === null)
{
new_item.count = amount;
this.addItem(new_item);
}
else
{
item.count += amount;
}
}
tank.crystals -= new_item.price * amount;
if (id === "1000_scores")
tank.addScore(500 * amount);
if (id === "1000_scores")
tank.addScore(1000 * amount);
if (id === "supplies")
{
this.addKitItem("health",0,100,tank);
this.addKitItem("armor",0,100,tank);
this.addKitItem("damage",0,100,tank);
this.addKitItem("nitro",0,100,tank);
this.addKitItem("mine",0,100,tank);
this.send(socket,"reload")
}
else
{
this.send(socket, "buy_item;" + itemStr + ";" + JSON.stringify(obj));
}
tank.sendCrystals();
}
}
}
} else if (args.length === 2) {
if (args[0] === "try_mount_item") {
var itemStr = args[1];
var itemStrArr = itemStr.split("_");
if (itemStrArr.length === 2) {
var modificationStr = itemStrArr[1];
var item_id = itemStrArr[0];
if (modificationStr.length === 2) {
var m = parseInt(modificationStr.charAt(1));
if (!isNaN(m)) {
this.mountItem(item_id, m);
this.sendMountedItem(socket, itemStr);
tank.save();
}
}
}
} else if (args[0] === "try_update_item") {
var itemStr = args[1],
arr = itemStr.split("_"),
modStr = arr.pop(),
id = arr.join("_");
if (modStr.length === 2) {
var m = parseInt(modStr.charAt(1));
if (!isNaN(m) && m < 3) {
if (this.hasItem(id, m) && this.getItem(id).attempt_upgrade(tank)) {
this.send(socket, "update_item;" + itemStr);
tank.sendCrystals();
}
}
}
}
}
}
addKitItem(item, m, count, tank) {
// this.items.push(item);
var itemStr = item + "_m"
var arr = itemStr.split("_");
var id = itemStr.replace("_m", "");
var amount = parseInt(count);
var new_item = GarageItem.get(id, 0);
console.log(new_item)
if (new_item !== null) {
var obj = {};
obj.itemId = id;
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
new_item.modificationID = m;
obj.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
item.modificationID = m;
obj.count = item.count;
}
}
}
addItem(item) {
this.items.push(item);
}
deleteItem(item) {
delete this.items[item];
}
mountItem(item_id, m) {
if (this.hasItem(item_id, m)) {
var itemStr = item_id + "_m" + m;
if (hulls.includes(item_id))
this.mounted_hull = itemStr;
else if (turrets.includes(item_id))
this.mounted_turret = itemStr;
else if (paints.includes(item_id))
this.mounted_paint = itemStr;
}
}
sendMountedItem(socket, itemStr) {
this.send(socket, "mount_item;" + itemStr);
}
getItemsObject() {
var items = [];
for (var i in this.items) {
items.push(this.items[i].toObject());
}
return { items: items };
}
toSaveObject() {
return { items: this.getItemsObject(), mounted_turret: this.mounted_turret, mounted_hull: this.mounted_hull, mounted_paint: this.mounted_paint };
}
}
module.exports = Garage;
как сюда добавить multicounted если что значение должно выбираться false или true в отдельном файле где прописывается товар продающийся в магазине
|
691c75f54a03b7817a43430227eab454
|
{
"intermediate": 0.2909576892852783,
"beginner": 0.5029168725013733,
"expert": 0.20612549781799316
}
|
30,652
|
an api responds with this json object, please write python code to get all the challange imgs.
{"session_token":"86817966165352965.1276073005","challengeID":"825654ea5fda71c37.3598523505","challengeURL":"https:\/\/github-api.arkoselabs.com\/fc\/assets\/match-game-ui\/0.33.0\/standard\/index.html","audio_challenge_urls":null,"audio_game_rate_limited":null,"sec":30,"end_url":null,"game_data":{"display_fc_welldone":true,"final_challenge_text":"","customGUI":{"example_images":{"key":"https:\/\/github-api.arkoselabs.com\/cdn\/fc\/assets\/game4failureexamples\/3d_rollball\/3D_Rollball_animated_key_01.png","answer":"https:\/\/github-api.arkoselabs.com\/cdn\/fc\/assets\/game4failureexamples\/3d_rollball\/3D_Rollball_animated_answer_01.png"},"_challenge_imgs":["https:\/\/github-api.arkoselabs.com\/rtig\/image?challenge=0&sessionToken=86817966165352965.1276073005&gameToken=825654ea5fda71c37.3598523505","https:\/\/github-api.arkoselabs.com\/rtig\/image?challenge=1&sessionToken=86817966165352965.1276073005&gameToken=825654ea5fda71c37.3598523505","https:\/\/github-api.arkoselabs.com\/rtig\/image?challenge=2&sessionToken=86817966165352965.1276073005&gameToken=825654ea5fda71c37.3598523505"],"_final_chal_lang_key":"touch_done_info_colour","_disableFinalChalAfterSecChal":1,"watermark_not_for_public":0,"_final_ball":null,"_app_bg":"https:\/\/github-api.arkoselabs.com\/cdn\/fc\/assets\/graphics\/funcaptcha\/004\/white.png","_end_banner":"https:\/\/github-api.arkoselabs.com\/cdn\/fc\/assets\/graphics\/funcaptcha\/general\/fc_meta_solve_bg.jpg","audio_disabled":false},"waves":3,"instruction_string":"3d_rollball_animals","game_difficulty":6,"answer_width":200,"answer_height":200,"key_width":125,"key_height":200,"puzzle_name":"3d Rollball","feature_game4_at_availability":true,"gameType":4},"game_sid":"eu-west-1","sid":"eu-west-1","lang":"en","string_table_prefixes":["github_custom_instructions"],"string_table":{"meta.help":"Get answers to your questions","4.game_progress":"{{currentChallenge}} of {{numChallenges}}","4.key_image_annotation":"Match This!","meta.audio_info_play-3":"Press Play, type the number of the song that is the most sad, then press enter:","meta.text_info":"Enter the text you see:","meta.footer_general_info":"Play like humans do.","4.fail_info_timed_top":"That was not quite fast enough.","meta.audio_info_ctrl":"Press CTRL to play again.","4.key_image_annotation-3d_rollball_animals_multi":"icon and hand direction","meta.star_info":"Stars you have earned","meta.visual_version":"Change to a visual challenge","aria.tick_icon_alt":"Example for correct answer.","meta.audio_sending_answer":"Committing your answer. Please wait...","4.instructions-3d_rollball_animals_alt":"<strong>Use the arrows<\/strong> to <strong>rotate the animal<\/strong> to face <strong>where the hand is pointing.<\/strong>","4.hint-3d_rollball_animals_alt":"Make sure the animal is facing in the same direction that the hand is pointing towards.","game_meta.seconds":"seconds","meta.audio_play_again":"Play sound again","meta.audio_please_download_info":"Please download and listen to the sound, then type what you heard:","meta.audio_info":"Enter the numbers you hear:","meta.session_timeout":"The connection to a verification server was interrupted. Please <strong>refresh this page<\/strong> to try again.","meta.audio_info_play":"Press Play and type what you hear:","meta.footer_finished_info-1":"<p><strong>Verification complete!<\/strong><\/p><p>You've proven you're a human.<\/p><p>Continue your action.<\/p>","meta.footer_finished_info-3":"<b>Verification complete!<\/b><br>You've proven you're a human.<br>Continue your action.","github_custom_instructions-1.touch_button_info":"Touch the arrows,to roll the image","4.fail_button":"Try again","4.instructions-3d_rollball_animals":"<strong>Use the arrows<\/strong> to <strong>rotate the animal<\/strong> to face in the <strong>direction of the hand.<\/strong>","meta.audio_play_button":"Play","4.interstitial_progress_2":"{{currentChallenge}} of {{numChallenges}}","4.interstitial_progress_1":"{{currentChallenge}} done","aria.correct_image_alt":"Example for correct answer.","meta.audio_new_puzzle":"Start over with a different challenge","meta.html_verify_info":"Please prove you're not a spammer by doing this quick activity!","game_meta.game_great":"Great","meta.funcaptcha_website":"Open Arkose Labs website","aria.challenge_image_alt":"Image {{count}}.","github_custom_instructions_v2-3.intro_title":"Please solve this puzzle to verify that you are human","github_custom_instructions_v2-game_meta.landing_button":"Start puzzle","game_meta.verification":"Verification","aria.input_placeholder":"Type here...","meta.audio_sent_info":"Verification complete! You've proven you're a human. Continue your action.","meta.funcaptcha":"Arkose Labs","meta.reload_challenge":"Reload Challenge","aria.left_arrow":"Navigate to previous image","4.hint-3d_rollball_animals_arrow_2":"Make sure the animal is facing in the same direction that the arrow is pointing towards.","meta.generic_error":"Something went wrong. Please reload the challenge to try again.","aria.audio_challenge":"Audio challenge","meta.audio_disabled":"The audio challenge has been disabled. Please use the visual challenge, or contact the customer support team for assistance.","4.challenge_progress":"{{currentChallenge}} of {{numChallenges}}","meta.stars_link":"Stars","meta.api_timeout_error":"The connection to a verification server was interrupted. Please reload the challenge to try again. ","aria.right_arrow":"Navigate to next image","meta.audio_challenge_frame_title":"Audio challenge","aria.visual_challenge_describe":"Audio challenge is available below. Compatible with screen reader software.","meta.audio_version":"Change to an audio challenge","meta.audio_answer_input":"Challenge Answer","meta.audio_challenge":"Change to an audio challenge","meta.footer_patent":"Patent pending","4.submit_button":"Submit","game_meta.checking":"Checking","game_meta.game_good":"Good","aria.answer_field":"Answer field","4.hint":"Make sure to select an image that matches what you see in the example image.","meta.audio_verify_button":"Verify","meta.audio_play":"Play Sound","meta.audio_please_download_info-3":"Please download and listen to the sound, type the number of the song that is the most sad:","4.intro_title":"Verification","github_custom_instructions_v2-game_meta.landing_info":"Click \"Start puzzle\" to continue","4.hint-3d_rollball_animals_arrow":"Make sure the animal is facing in the same direction that the hand is pointing towards.","meta.audio_alert":"Please enter your answer into the input box.","meta.loading_info":"Working, please wait...","aria.audio_answer_input":"Challenge answer","meta.html_verify_button":"Verify","meta.meta_start_cta":"Start visual challenge","4.instructions-3d_rollball_animals_multi":"<strong>Use the arrows<\/strong> to <strong>rotate the animal with the same icon<\/strong> to face where the <strong>hand is pointing<\/strong>","meta.footer_general_info-1":"Please solve the puzzle.","game_meta.challenge":"Challenge {{count}}","4.instructions":"<strong>Press the arrows<\/strong> to see different images. When the image <strong>matches the example<\/strong> on the left, press Submit!","4.fail_info_timed_middle_hidden":"Try to answer before too much time runs out!","4.instructions-3d_rollball_animals_arrow_2":"Pick the image where the animal is facing in the same direction the arrow is pointing to","github_custom_instructions_v2-meta.html_verify_button":"Start puzzle","game_meta.not_for_public_watermark":"NOT FOR PRODUCTION USE","game_meta.interstitial_progress_1":"{{currentChallenge}} done","meta.funcaptcha_solved_phrase":"Verification challenge has been solved","4.instructions-3d_rollball_animals_arrow":"Pick the image where the animal is facing in the same direction the arrow is pointing to","github_custom_instructions_v2-game_meta.landing_heading":"Please solve this puzzle to verify that you are human","4.key_image_annotation-3d_rollball_animals":"Match this angle","game_meta.wait_text":"Please wait while we check your score.","aria.visual_challenge_label":"Visual challenge.","game_meta.landing_heading":"Protecting your account","meta.verification_complete":"Verification complete!","aria.cross_icon_alt":"Example for incorrect answer.","aria.wrong_image_alt":"Example for incorrect answer.","4.hint-3d_rollball_animals_multi":"Make sure the animal with the same icon above it as the left image, is facing in the same direction that the hand is pointing towards.","aria.restart_challenge":"Restarting challenge","meta.audio_rate_limit":"Use of the audio challenge for this user has been too high. Please try again.","meta.restart_label":"Restart","meta.audio_incorrect":"Incorrect, try again","4.hint-3d_rollball_animals":"Make sure the animal is facing in the same direction that the hand is pointing towards.","game_meta.landing_info":"Please solve this puzzle so we know you are a real person","4.fail_top":"That was not quite right.","game_meta.game_perfect":"Perfect","4.key_image_annotation-3d_rollball_animals_alt":"Match this angle","4.finish_message":"<b>Verification Complete<\/b> <br>You've proven you're a human. <br>Continue your action.","meta.audio_challenge_label":"Audio","github_custom_instructions-game_meta.landing_start":"Verify","meta.finished_info":"You've proven you're a human. Continue your action.","meta.footer_phone_mode_on":"This isn't working for me","game_meta.game_check":"Check!","meta.session_reset":"Your session was reset. Please try again.","game_meta.landing_button":"Verify","github_custom_instructions_v2-game_meta.landing_start":"Start puzzle","aria.visual_challenge":"Visual challenge. Audio challenge is available below, compatible with screen reader software.","meta.visual_challenge_label":"Visual","meta.visual_challenge_frame_title":"Visual challenge","game_meta.landing_start":"Start Puzzle","meta.audio_download":"Download Sound"},"earlyVictoryMessage":null,"font_size_adjustments":null,"style_theme":"default","dapib_url":"https:\/\/github-api.arkoselabs.com\/dapib\/eu-west-1\/ecc50ba2-07bb-4e09-adb4-8dfd2ce4eeae\/979.js?mac=v55w2KCF5XSIzVB3v28LB6F7gZlzt4A6Jm9kNQcco3o%3D&expiry=1699654918030"}
|
16de79ee97aee5d9a2d374106205062d
|
{
"intermediate": 0.4140183925628662,
"beginner": 0.31147125363349915,
"expert": 0.27451038360595703
}
|
30,653
|
an api responds with this json object, please write python code to get all the challange imgs, do not write our the json object, i can replace it myself you are just gonna waste time.
{"session_token":"86817966165352965.1276073005","challengeID":"825654ea5fda71c37.3598523505","challengeURL":"https:\/\/github-api.arkoselabs.com\/fc\/assets\/match-game-ui\/0.33.0\/standard\/index.html","audio_challenge_urls":null,"audio_game_rate_limited":null,"sec":30,"end_url":null,"game_data":{"display_fc_welldone":true,"final_challenge_text":"","customGUI":{"example_images":{"key":"https:\/\/github-api.arkoselabs.com\/cdn\/fc\/assets\/game4failureexamples\/3d_rollball\/3D_Rollball_animated_key_01.png","answer":"https:\/\/github-api.arkoselabs.com\/cdn\/fc\/assets\/game4failureexamples\/3d_rollball\/3D_Rollball_animated_answer_01.png"},"_challenge_imgs":["https:\/\/github-api.arkoselabs.com\/rtig\/image?challenge=0&sessionToken=86817966165352965.1276073005&gameToken=825654ea5fda71c37.3598523505","https:\/\/github-api.arkoselabs.com\/rtig\/image?challenge=1&sessionToken=86817966165352965.1276073005&gameToken=825654ea5fda71c37.3598523505","https:\/\/github-api.arkoselabs.com\/rtig\/image?challenge=2&sessionToken=86817966165352965.1276073005&gameToken=825654ea5fda71c37.3598523505"],"_final_chal_lang_key":"touch_done_info_colour","_disableFinalChalAfterSecChal":1,"watermark_not_for_public":0,"_final_ball":null,"_app_bg":"https:\/\/github-api.arkoselabs.com\/cdn\/fc\/assets\/graphics\/funcaptcha\/004\/white.png","_end_banner":"https:\/\/github-api.arkoselabs.com\/cdn\/fc\/assets\/graphics\/funcaptcha\/general\/fc_meta_solve_bg.jpg","audio_disabled":false},"waves":3,"instruction_string":"3d_rollball_animals","game_difficulty":6,"answer_width":200,"answer_height":200,"key_width":125,"key_height":200,"puzzle_name":"3d Rollball","feature_game4_at_availability":true,"gameType":4},"game_sid":"eu-west-1","sid":"eu-west-1","lang":"en","string_table_prefixes":["github_custom_instructions"],"string_table":{"meta.help":"Get answers to your questions","4.game_progress":"{{currentChallenge}} of {{numChallenges}}","4.key_image_annotation":"Match This!","meta.audio_info_play-3":"Press Play, type the number of the song that is the most sad, then press enter:","meta.text_info":"Enter the text you see:","meta.footer_general_info":"Play like humans do.","4.fail_info_timed_top":"That was not quite fast enough.","meta.audio_info_ctrl":"Press CTRL to play again.","4.key_image_annotation-3d_rollball_animals_multi":"icon and hand direction","meta.star_info":"Stars you have earned","meta.visual_version":"Change to a visual challenge","aria.tick_icon_alt":"Example for correct answer.","meta.audio_sending_answer":"Committing your answer. Please wait...","4.instructions-3d_rollball_animals_alt":"<strong>Use the arrows<\/strong> to <strong>rotate the animal<\/strong> to face <strong>where the hand is pointing.<\/strong>","4.hint-3d_rollball_animals_alt":"Make sure the animal is facing in the same direction that the hand is pointing towards.","game_meta.seconds":"seconds","meta.audio_play_again":"Play sound again","meta.audio_please_download_info":"Please download and listen to the sound, then type what you heard:","meta.audio_info":"Enter the numbers you hear:","meta.session_timeout":"The connection to a verification server was interrupted. Please <strong>refresh this page<\/strong> to try again.","meta.audio_info_play":"Press Play and type what you hear:","meta.footer_finished_info-1":"<p><strong>Verification complete!<\/strong><\/p><p>You've proven you're a human.<\/p><p>Continue your action.<\/p>","meta.footer_finished_info-3":"<b>Verification complete!<\/b><br>You've proven you're a human.<br>Continue your action.","github_custom_instructions-1.touch_button_info":"Touch the arrows,to roll the image","4.fail_button":"Try again","4.instructions-3d_rollball_animals":"<strong>Use the arrows<\/strong> to <strong>rotate the animal<\/strong> to face in the <strong>direction of the hand.<\/strong>","meta.audio_play_button":"Play","4.interstitial_progress_2":"{{currentChallenge}} of {{numChallenges}}","4.interstitial_progress_1":"{{currentChallenge}} done","aria.correct_image_alt":"Example for correct answer.","meta.audio_new_puzzle":"Start over with a different challenge","meta.html_verify_info":"Please prove you're not a spammer by doing this quick activity!","game_meta.game_great":"Great","meta.funcaptcha_website":"Open Arkose Labs website","aria.challenge_image_alt":"Image {{count}}.","github_custom_instructions_v2-3.intro_title":"Please solve this puzzle to verify that you are human","github_custom_instructions_v2-game_meta.landing_button":"Start puzzle","game_meta.verification":"Verification","aria.input_placeholder":"Type here...","meta.audio_sent_info":"Verification complete! You've proven you're a human. Continue your action.","meta.funcaptcha":"Arkose Labs","meta.reload_challenge":"Reload Challenge","aria.left_arrow":"Navigate to previous image","4.hint-3d_rollball_animals_arrow_2":"Make sure the animal is facing in the same direction that the arrow is pointing towards.","meta.generic_error":"Something went wrong. Please reload the challenge to try again.","aria.audio_challenge":"Audio challenge","meta.audio_disabled":"The audio challenge has been disabled. Please use the visual challenge, or contact the customer support team for assistance.","4.challenge_progress":"{{currentChallenge}} of {{numChallenges}}","meta.stars_link":"Stars","meta.api_timeout_error":"The connection to a verification server was interrupted. Please reload the challenge to try again. ","aria.right_arrow":"Navigate to next image","meta.audio_challenge_frame_title":"Audio challenge","aria.visual_challenge_describe":"Audio challenge is available below. Compatible with screen reader software.","meta.audio_version":"Change to an audio challenge","meta.audio_answer_input":"Challenge Answer","meta.audio_challenge":"Change to an audio challenge","meta.footer_patent":"Patent pending","4.submit_button":"Submit","game_meta.checking":"Checking","game_meta.game_good":"Good","aria.answer_field":"Answer field","4.hint":"Make sure to select an image that matches what you see in the example image.","meta.audio_verify_button":"Verify","meta.audio_play":"Play Sound","meta.audio_please_download_info-3":"Please download and listen to the sound, type the number of the song that is the most sad:","4.intro_title":"Verification","github_custom_instructions_v2-game_meta.landing_info":"Click \"Start puzzle\" to continue","4.hint-3d_rollball_animals_arrow":"Make sure the animal is facing in the same direction that the hand is pointing towards.","meta.audio_alert":"Please enter your answer into the input box.","meta.loading_info":"Working, please wait...","aria.audio_answer_input":"Challenge answer","meta.html_verify_button":"Verify","meta.meta_start_cta":"Start visual challenge","4.instructions-3d_rollball_animals_multi":"<strong>Use the arrows<\/strong> to <strong>rotate the animal with the same icon<\/strong> to face where the <strong>hand is pointing<\/strong>","meta.footer_general_info-1":"Please solve the puzzle.","game_meta.challenge":"Challenge {{count}}","4.instructions":"<strong>Press the arrows<\/strong> to see different images. When the image <strong>matches the example<\/strong> on the left, press Submit!","4.fail_info_timed_middle_hidden":"Try to answer before too much time runs out!","4.instructions-3d_rollball_animals_arrow_2":"Pick the image where the animal is facing in the same direction the arrow is pointing to","github_custom_instructions_v2-meta.html_verify_button":"Start puzzle","game_meta.not_for_public_watermark":"NOT FOR PRODUCTION USE","game_meta.interstitial_progress_1":"{{currentChallenge}} done","meta.funcaptcha_solved_phrase":"Verification challenge has been solved","4.instructions-3d_rollball_animals_arrow":"Pick the image where the animal is facing in the same direction the arrow is pointing to","github_custom_instructions_v2-game_meta.landing_heading":"Please solve this puzzle to verify that you are human","4.key_image_annotation-3d_rollball_animals":"Match this angle","game_meta.wait_text":"Please wait while we check your score.","aria.visual_challenge_label":"Visual challenge.","game_meta.landing_heading":"Protecting your account","meta.verification_complete":"Verification complete!","aria.cross_icon_alt":"Example for incorrect answer.","aria.wrong_image_alt":"Example for incorrect answer.","4.hint-3d_rollball_animals_multi":"Make sure the animal with the same icon above it as the left image, is facing in the same direction that the hand is pointing towards.","aria.restart_challenge":"Restarting challenge","meta.audio_rate_limit":"Use of the audio challenge for this user has been too high. Please try again.","meta.restart_label":"Restart","meta.audio_incorrect":"Incorrect, try again","4.hint-3d_rollball_animals":"Make sure the animal is facing in the same direction that the hand is pointing towards.","game_meta.landing_info":"Please solve this puzzle so we know you are a real person","4.fail_top":"That was not quite right.","game_meta.game_perfect":"Perfect","4.key_image_annotation-3d_rollball_animals_alt":"Match this angle","4.finish_message":"<b>Verification Complete<\/b> <br>You've proven you're a human. <br>Continue your action.","meta.audio_challenge_label":"Audio","github_custom_instructions-game_meta.landing_start":"Verify","meta.finished_info":"You've proven you're a human. Continue your action.","meta.footer_phone_mode_on":"This isn't working for me","game_meta.game_check":"Check!","meta.session_reset":"Your session was reset. Please try again.","game_meta.landing_button":"Verify","github_custom_instructions_v2-game_meta.landing_start":"Start puzzle","aria.visual_challenge":"Visual challenge. Audio challenge is available below, compatible with screen reader software.","meta.visual_challenge_label":"Visual","meta.visual_challenge_frame_title":"Visual challenge","game_meta.landing_start":"Start Puzzle","meta.audio_download":"Download Sound"},"earlyVictoryMessage":null,"font_size_adjustments":null,"style_theme":"default","dapib_url":"https:\/\/github-api.arkoselabs.com\/dapib\/eu-west-1\/ecc50ba2-07bb-4e09-adb4-8dfd2ce4eeae\/979.js?mac=v55w2KCF5XSIzVB3v28LB6F7gZlzt4A6Jm9kNQcco3o%3D&expiry=1699654918030"}
|
7e098a96733e17ce430d0470ddd21aeb
|
{
"intermediate": 0.40055036544799805,
"beginner": 0.2848620116710663,
"expert": 0.31458762288093567
}
|
30,654
|
const { market_list } = require("./server");
const GarageItem = require("./GarageItem"),
Area = require("./Area"),
{ turrets, hulls, paints, getType } = require("./server"),
InventoryItem = require("./InventoryItem");
class Garage extends Area {
static fromJSON(data) {
if (typeof (data.tank) !== "undefiend") {
var garage = new Garage(data.tank);
garage.items = Garage.fromItemsObject(data.items);
garage.updateMarket();
garage.mounted_turret = data.mounted_turret;
garage.mounted_hull = data.mounted_hull;
garage.mounted_paint = data.mounted_paint;
garage.inventory = null;
return garage;
}
return null;
}
static fromItemsObject(obj) {
var items = [];
for (var i in obj.items) {
items.push(GarageItem.fromJSON(obj.items[i]));
}
return items;
}
constructor(tank) {
super();
this.tank = tank;
this.items = [GarageItem.get("smoky", 0), GarageItem.get("green", 0), GarageItem.get("holiday", 0), GarageItem.get("wasp", 0), GarageItem.get("health", 0)];
this.updateMarket();
this.mounted_turret = "smoky_m0";
this.mounted_hull = "wasp_m0";
this.mounted_paint = "green_m0";
this.inventory = [];
}
getPrefix() {
return "garage";
}
getInventory() {
// if (this.inventory !== null)
// return this.inventory;
var inventory = [];
for (var i in this.items) {
var item = this.items[i];
if (getType(item.id) === 4) {
inventory.push(InventoryItem.fromGarageItem(item));
}
}
this.inventory = inventory;
return inventory;
}
addGarageItem(id, amount) {
var tank = this.tank;
var new_item = GarageItem.get(id, 0);
if (new_item !== null) {
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
}
}
return true;
}
useItem(id) {
for (var i in this.items) {
if (this.items[i].isInventory && this.items[i].id === id) {
if (this.items[i].count <= 0)
return false;
if (this.items[i].count = 1)
{
this.deleteItem(this.items[i])
}
--this.items[i].count;
}
}
return true;
}
hasItem(id, m = null) {
for (var i in this.items) {
if (this.items[i].id === id) {
if (this.items[i].type !== 4) {
if (m === null)
return true;
return this.items[i].modificationID >= m;
}
else if (this.items[i].count > 0)
return true;
else {
this.items.splice(i, 1);
}
}
}
return false;
}
initiate(socket) {
this.send(socket, "init_garage_items;" + JSON.stringify({ items: this.items }));
this.addPlayer(this.tank);
}
initMarket(socket) {
this.send(socket, "init_market;" + JSON.stringify(this.market));
}
initMountedItems(socket) {
this.send(socket, "init_mounted_item;" + this.mounted_hull);
this.send(socket, "init_mounted_item;" + this.mounted_turret);
this.send(socket, "init_mounted_item;" + this.mounted_paint);
}
getItem(id) {
for (var i in this.items) {
if (this.items[i].id === id)
return this.items[i];
}
return null;
}
getTurret() {
return this.getItem(this.mounted_turret.split("_")[0]);
}
getHull() {
return this.getItem(this.mounted_hull.split("_")[0]);
}
getPaint() {
return this.getItem(this.mounted_paint.split("_")[0]);
}
updateMarket() {
this.market = { items: [] };
for (var i in market_list) {
if (!this.hasItem(market_list[i]["id"]) && market_list[i]["index"] >= 0 && !market_list[i]["multicounted"]) {
this.market.items.push(market_list[i]);
}
}
}
onData(socket, args) {
if (this.tank === null || !this.hasPlayer(this.tank.name))
return;
var tank = this.tank;
if (args.length === 1) {
if (args[0] === "get_garage_data") {
this.updateMarket();
setTimeout(() => {
this.initMarket(socket);
this.initMountedItems(socket);
}, 1500);
}
} else if (args.length === 3) {
if (args[0] === "try_buy_item") {
var itemStr = args[1];
var arr = itemStr.split("_");
var id = itemStr.replace("_m0", "");
var amount = parseInt(args[2]);
var new_item = GarageItem.get(id, 0);
if (new_item !== null) {
if (tank.crystals >= new_item.price * amount && tank.rank >= new_item.rank) {
var obj = {};
obj.itemId = id;
if (new_item !== null && id !== "1000_scores") {
var item = tank.garage.getItem(id);
if (item === null)
{
new_item.count = amount;
this.addItem(new_item);
}
else
{
item.count += amount;
}
}
tank.crystals -= new_item.price * amount;
if (id === "1000_scores")
tank.addScore(500 * amount);
if (id === "1000_scores")
tank.addScore(1000 * amount);
if (id === "supplies")
{
this.addKitItem("health",0,100,tank);
this.addKitItem("armor",0,100,tank);
this.addKitItem("damage",0,100,tank);
this.addKitItem("nitro",0,100,tank);
this.addKitItem("mine",0,100,tank);
this.send(socket,"reload")
}
else
{
this.send(socket, "buy_item;" + itemStr + ";" + JSON.stringify(obj));
}
tank.sendCrystals();
}
}
}
} else if (args.length === 2) {
if (args[0] === "try_mount_item") {
var itemStr = args[1];
var itemStrArr = itemStr.split("_");
if (itemStrArr.length === 2) {
var modificationStr = itemStrArr[1];
var item_id = itemStrArr[0];
if (modificationStr.length === 2) {
var m = parseInt(modificationStr.charAt(1));
if (!isNaN(m)) {
this.mountItem(item_id, m);
this.sendMountedItem(socket, itemStr);
tank.save();
}
}
}
} else if (args[0] === "try_update_item") {
var itemStr = args[1],
arr = itemStr.split("_"),
modStr = arr.pop(),
id = arr.join("_");
if (modStr.length === 2) {
var m = parseInt(modStr.charAt(1));
if (!isNaN(m) && m < 3) {
if (this.hasItem(id, m) && this.getItem(id).attempt_upgrade(tank)) {
this.send(socket, "update_item;" + itemStr);
tank.sendCrystals();
}
}
}
}
}
}
addKitItem(item, m, count, tank) {
// this.items.push(item);
var itemStr = item + "_m"
var arr = itemStr.split("_");
var id = itemStr.replace("_m", "");
var amount = parseInt(count);
var new_item = GarageItem.get(id, 0);
console.log(new_item)
if (new_item !== null) {
var obj = {};
obj.itemId = id;
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
new_item.modificationID = m;
obj.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
item.modificationID = m;
obj.count = item.count;
}
}
}
addItem(item) {
this.items.push(item);
}
deleteItem(item) {
delete this.items[item];
}
mountItem(item_id, m) {
if (this.hasItem(item_id, m)) {
var itemStr = item_id + "_m" + m;
if (hulls.includes(item_id))
this.mounted_hull = itemStr;
else if (turrets.includes(item_id))
this.mounted_turret = itemStr;
else if (paints.includes(item_id))
this.mounted_paint = itemStr;
}
}
sendMountedItem(socket, itemStr) {
this.send(socket, "mount_item;" + itemStr);
}
getItemsObject() {
var items = [];
for (var i in this.items) {
items.push(this.items[i].toObject());
}
return { items: items };
}
toSaveObject() {
return { items: this.getItemsObject(), mounted_turret: this.mounted_turret, mounted_hull: this.mounted_hull, mounted_paint: this.mounted_paint };
}
}
module.exports = Garage;
товар с multicounted со значением true пропадают из магазина, без возможности купить их
|
1ecfd6334348b224fbd3136ebe9b3f09
|
{
"intermediate": 0.2909576892852783,
"beginner": 0.5029168725013733,
"expert": 0.20612549781799316
}
|
30,655
|
const { market_list } = require("./server");
const GarageItem = require("./GarageItem"),
Area = require("./Area"),
{ turrets, hulls, paints, getType } = require("./server"),
InventoryItem = require("./InventoryItem");
class Garage extends Area {
static fromJSON(data) {
if (typeof (data.tank) !== "undefiend") {
var garage = new Garage(data.tank);
garage.items = Garage.fromItemsObject(data.items);
garage.updateMarket();
garage.mounted_turret = data.mounted_turret;
garage.mounted_hull = data.mounted_hull;
garage.mounted_paint = data.mounted_paint;
garage.inventory = null;
return garage;
}
return null;
}
static fromItemsObject(obj) {
var items = [];
for (var i in obj.items) {
items.push(GarageItem.fromJSON(obj.items[i]));
}
return items;
}
constructor(tank) {
super();
this.tank = tank;
this.items = [GarageItem.get("smoky", 0), GarageItem.get("green", 0), GarageItem.get("holiday", 0), GarageItem.get("wasp", 0), GarageItem.get("health", 0)];
this.updateMarket();
this.mounted_turret = "smoky_m0";
this.mounted_hull = "wasp_m0";
this.mounted_paint = "green_m0";
this.inventory = [];
}
getPrefix() {
return "garage";
}
getInventory() {
// if (this.inventory !== null)
// return this.inventory;
var inventory = [];
for (var i in this.items) {
var item = this.items[i];
if (getType(item.id) === 4) {
inventory.push(InventoryItem.fromGarageItem(item));
}
}
this.inventory = inventory;
return inventory;
}
addGarageItem(id, amount) {
var tank = this.tank;
var new_item = GarageItem.get(id, 0);
if (new_item !== null) {
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
}
}
return true;
}
useItem(id) {
for (var i in this.items) {
if (this.items[i].isInventory && this.items[i].id === id) {
if (this.items[i].count <= 0)
return false;
if (this.items[i].count = 1)
{
this.deleteItem(this.items[i])
}
--this.items[i].count;
}
}
return true;
}
hasItem(id, m = null) {
for (var i in this.items) {
if (this.items[i].id === id) {
if (this.items[i].type !== 4) {
if (m === null)
return true;
return this.items[i].modificationID >= m;
}
else if (this.items[i].count > 0)
return true;
else {
this.items.splice(i, 1);
}
}
}
return false;
}
initiate(socket) {
this.send(socket, "init_garage_items;" + JSON.stringify({ items: this.items }));
this.addPlayer(this.tank);
}
initMarket(socket) {
this.send(socket, "init_market;" + JSON.stringify(this.market));
}
initMountedItems(socket) {
this.send(socket, "init_mounted_item;" + this.mounted_hull);
this.send(socket, "init_mounted_item;" + this.mounted_turret);
this.send(socket, "init_mounted_item;" + this.mounted_paint);
}
getItem(id) {
for (var i in this.items) {
if (this.items[i].id === id)
return this.items[i];
}
return null;
}
getTurret() {
return this.getItem(this.mounted_turret.split("_")[0]);
}
getHull() {
return this.getItem(this.mounted_hull.split("_")[0]);
}
getPaint() {
return this.getItem(this.mounted_paint.split("_")[0]);
}
updateMarket() {
this.market = { items: [] };
for (var i in market_list) {
if (!this.hasItem(market_list[i]["id"]) && market_list[i]["index"] >= 0)
{
this.market.items.push(market_list[i]);
}
this.hasItem(market_list[i]["multicounted"])
}
}
onData(socket, args) {
if (this.tank === null || !this.hasPlayer(this.tank.name))
return;
var tank = this.tank;
if (args.length === 1) {
if (args[0] === "get_garage_data") {
this.updateMarket();
setTimeout(() => {
this.initMarket(socket);
this.initMountedItems(socket);
}, 1500);
}
} else if (args.length === 3) {
if (args[0] === "try_buy_item") {
var itemStr = args[1];
var arr = itemStr.split("_");
var id = itemStr.replace("_m0", "");
var amount = parseInt(args[2]);
var new_item = GarageItem.get(id, 0);
if (new_item !== null) {
if (tank.crystals >= new_item.price * amount && tank.rank >= new_item.rank) {
var obj = {};
obj.itemId = id;
if (new_item !== null && id !== "1000_scores") {
var item = tank.garage.getItem(id);
if (item === null)
{
new_item.count = amount;
this.addItem(new_item);
}
else
{
item.count += amount;
}
}
tank.crystals -= new_item.price * amount;
if (id === "1000_scores")
tank.addScore(1000 * amount);
if (id === "supplies")
{
this.addKitItem("health",0,100,tank);
this.addKitItem("armor",0,100,tank);
this.addKitItem("damage",0,100,tank);
this.addKitItem("nitro",0,100,tank);
this.addKitItem("mine",0,100,tank);
this.send(socket,"reload")
}
else
{
this.send(socket, "buy_item;" + itemStr + ";" + JSON.stringify(obj));
}
tank.sendCrystals();
}
}
}
} else if (args.length === 2) {
if (args[0] === "try_mount_item") {
var itemStr = args[1];
var itemStrArr = itemStr.split("_");
if (itemStrArr.length === 2) {
var modificationStr = itemStrArr[1];
var item_id = itemStrArr[0];
if (modificationStr.length === 2) {
var m = parseInt(modificationStr.charAt(1));
if (!isNaN(m)) {
this.mountItem(item_id, m);
this.sendMountedItem(socket, itemStr);
tank.save();
}
}
}
} else if (args[0] === "try_update_item") {
var itemStr = args[1],
arr = itemStr.split("_"),
modStr = arr.pop(),
id = arr.join("_");
if (modStr.length === 2) {
var m = parseInt(modStr.charAt(1));
if (!isNaN(m) && m < 3) {
if (this.hasItem(id, m) && this.getItem(id).attempt_upgrade(tank)) {
this.send(socket, "update_item;" + itemStr);
tank.sendCrystals();
}
}
}
}
}
}
addKitItem(item, m, count, tank) {
// this.items.push(item);
var itemStr = item + "_m"
var arr = itemStr.split("_");
var id = itemStr.replace("_m", "");
var amount = parseInt(count);
var new_item = GarageItem.get(id, 0);
console.log(new_item)
if (new_item !== null) {
var obj = {};
obj.itemId = id;
var item = tank.garage.getItem(id);
if (item === null) {
new_item.count = amount;
new_item.modificationID = m;
obj.count = amount;
this.addItem(new_item);
} else {
item.count += amount;
item.modificationID = m;
obj.count = item.count;
}
}
}
addItem(item) {
this.items.push(item);
}
deleteItem(item) {
delete this.items[item];
}
mountItem(item_id, m) {
if (this.hasItem(item_id, m)) {
var itemStr = item_id + "_m" + m;
if (hulls.includes(item_id))
this.mounted_hull = itemStr;
else if (turrets.includes(item_id))
this.mounted_turret = itemStr;
else if (paints.includes(item_id))
this.mounted_paint = itemStr;
}
}
sendMountedItem(socket, itemStr) {
this.send(socket, "mount_item;" + itemStr);
}
getItemsObject() {
var items = [];
for (var i in this.items) {
items.push(this.items[i].toObject());
}
return { items: items };
}
toSaveObject() {
return { items: this.getItemsObject(), mounted_turret: this.mounted_turret, mounted_hull: this.mounted_hull, mounted_paint: this.mounted_paint };
}
}
module.exports = Garage;
как 1000_scores добавить выбор количества для покупки
|
117fe39ae612a272f60c776fa585d378
|
{
"intermediate": 0.2909576892852783,
"beginner": 0.5029168725013733,
"expert": 0.20612549781799316
}
|
30,656
|
how would i program in a way to tell the computer to open a specific website (www.test.com) in a c++ sdl 2 application?
|
53dc28371be6128b57353fcbb59f3cbb
|
{
"intermediate": 0.3793335258960724,
"beginner": 0.2534739375114441,
"expert": 0.36719250679016113
}
|
30,657
|
const { c, market_list, getType } = require("./server");
class GarageItem {
static get(id, m = 1) {
return new GarageItem(id, 0, m);
}
static fromJSON(data) {
var item = new GarageItem(c(data.id), c(data.modificationID, 0), c(data.count, 0));
return item;
}
static getInfo(id) {
for (var i in market_list) {
if (market_list[i]["id"] === id)
return market_list[i];
}
return null;
}
constructor(id, modificationID = 0, count = 0) {
this.id = id;
var info = GarageItem.getInfo(id);
if (info !== null) {
this.name = info.name;
this.description = info.description;
this.index = info.index;
this.modification = info.modification;
}
else {
this.name = "null";
this.description = "";
this.index = 3;
this.modification = [];
}
this.modificationID = modificationID;
this.type = getType(this.id);
this.price = 0;
this.rank = 0;
this.properts = [];
if (this.type > 3)
this.count = count;
var modifications = this.modification;
if (typeof (modifications[modificationID]) !== "undefined") {
this.price = modifications[modificationID].price;
this.rank = modifications[modificationID].rank;
this.properts = modifications[modificationID].properts;
}
if (modificationID >= modifications.length - 1) {
this.next_price = this.price;
this.next_rank = this.rank;
}
else {
this.next_price = modifications[modificationID + 1].price;
this.next_rank = modifications[modificationID + 1].rank;
}
this.isInventory = this.type === 4;
}
attempt_upgrade(tank) {
if (this.type < 3 && this.modificationID < 3 && tank.crystals >= this.price && tank.rank >= this.rank) {
tank.crystals -= this.next_price;
this.modificationID++;
var modificationID = this.modificationID,
modifications = this.modification;
if (typeof (modifications[modificationID]) !== "undefined") {
this.price = modifications[modificationID].price;
this.rank = modifications[modificationID].rank;
this.properts = modifications[modificationID].properts;
}
if (modificationID >= modifications.length - 1) {
this.next_price = this.price;
this.next_rank = this.rank;
}
else {
this.next_price = modifications[modificationID + 1].price;
this.next_rank = modifications[modificationID + 1].rank;
}
return true;
}
return false;
}
toObject() {
return { id: this.id, count: this.count, modificationID: this.modificationID };
}
}
module.exports = GarageItem;
как сюда добавит второй description только для ru языка, и чтобы в market.json в характеристиках товара было две строки description_EN и description _RU а язые какой определал по этому значению receive: system;init_location;EN
|
25099772c60ae67db6e6354fe6c83c76
|
{
"intermediate": 0.31071266531944275,
"beginner": 0.4544334411621094,
"expert": 0.23485387861728668
}
|
30,658
|
rms = np.zeros((m, int(timepoints/10)))
normalized_rms= np.zeros((m, int(timepoints/2277)))#1
#compute
for i in range(timepoints/2277):
current_bin_data = MVC[10*i:10*i+9,:]#i=0,i=1
#(1-9,10-19...)
rms[i,:]=np.sqrt(np.mean(current_bin_data**2, axis=1))#开平方;xyz轴,2
#normalize
for p in range(mucsles):#除了时间点
max_values = np.amax(rms[:,m])#
normalized_rms= rms[i,:] / max_values
修改正确
|
2a360f6f49fbdfd017e971a4de70d85a
|
{
"intermediate": 0.36743807792663574,
"beginner": 0.2848958373069763,
"expert": 0.34766608476638794
}
|
30,659
|
this.previewId = this.mapId + "_preview";
if (this.bonuses)
{
this.tickingRegions = [];
var regions = this.map.getBonusRegions(["medkit", "nitro", "damageup", "armorup"]);
for (var i in regions)
this.tickingRegions.push(new BonusRegion(regions[i]));
setInterval(() =>
{
this.update(1);
}, 900);
} как сделать чтобы ящики падали не завимисо от фонд, а каждые 5 секунд
|
0d831a41f43e0ae92132308f742945b4
|
{
"intermediate": 0.3497760593891144,
"beginner": 0.2629725933074951,
"expert": 0.3872513175010681
}
|
30,660
|
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[14], line 1
----> 1 G1= pd.read_excel(r"C:\Users\10039\Desktop\G1 WK2.xlsx", sheet_name=['G1T1','G1T7','G1T15','G1R1','G1R5'])
File D:\python\Lib\site-packages\pandas\io\excel\_base.py:486, in read_excel(io, sheet_name, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, date_format, thousands, decimal, comment, skipfooter, storage_options, dtype_backend)
480 raise ValueError(
481 "Engine should not be specified when passing "
482 "an ExcelFile - ExcelFile already has the engine set"
483 )
485 try:
--> 486 data = io.parse(
487 sheet_name=sheet_name,
488 header=header,
489 names=names,
490 index_col=index_col,
491 usecols=usecols,
492 dtype=dtype,
493 converters=converters,
494 true_values=true_values,
495 false_values=false_values,
496 skiprows=skiprows,
497 nrows=nrows,
498 na_values=na_values,
499 keep_default_na=keep_default_na,
500 na_filter=na_filter,
501 verbose=verbose,
502 parse_dates=parse_dates,
503 date_parser=date_parser,
504 date_format=date_format,
505 thousands=thousands,
506 decimal=decimal,
507 comment=comment,
508 skipfooter=skipfooter,
509 dtype_backend=dtype_backend,
510 )
511 finally:
512 # make sure to close opened file handles
513 if should_close:
File D:\python\Lib\site-packages\pandas\io\excel\_base.py:1551, in ExcelFile.parse(self, sheet_name, header, names, index_col, usecols, converters, true_values, false_values, skiprows, nrows, na_values, parse_dates, date_parser, date_format, thousands, comment, skipfooter, dtype_backend, **kwds)
1518 def parse(
1519 self,
1520 sheet_name: str | int | list[int] | list[str] | None = 0,
(...)
1538 **kwds,
1539 ) -> DataFrame | dict[str, DataFrame] | dict[int, DataFrame]:
1540 """
1541 Parse specified sheet(s) into a DataFrame.
1542
(...)
1549 DataFrame from the passed in Excel file.
1550 """
-> 1551 return self._reader.parse(
1552 sheet_name=sheet_name,
1553 header=header,
1554 names=names,
1555 index_col=index_col,
1556 usecols=usecols,
1557 converters=converters,
1558 true_values=true_values,
1559 false_values=false_values,
1560 skiprows=skiprows,
1561 nrows=nrows,
1562 na_values=na_values,
1563 parse_dates=parse_dates,
1564 date_parser=date_parser,
1565 date_format=date_format,
1566 thousands=thousands,
1567 comment=comment,
1568 skipfooter=skipfooter,
1569 dtype_backend=dtype_backend,
1570 **kwds,
1571 )
File D:\python\Lib\site-packages\pandas\io\excel\_base.py:746, in BaseExcelReader.parse(self, sheet_name, header, names, index_col, usecols, dtype, true_values, false_values, skiprows, nrows, na_values, verbose, parse_dates, date_parser, date_format, thousands, decimal, comment, skipfooter, dtype_backend, **kwds)
743 print(f"Reading sheet {asheetname}")
745 if isinstance(asheetname, str):
--> 746 sheet = self.get_sheet_by_name(asheetname)
747 else: # assume an integer if not a string
748 sheet = self.get_sheet_by_index(asheetname)
File D:\python\Lib\site-packages\pandas\io\excel\_openpyxl.py:569, in OpenpyxlReader.get_sheet_by_name(self, name)
568 def get_sheet_by_name(self, name: str):
--> 569 self.raise_if_bad_sheet_by_name(name)
570 return self.book[name]
File D:\python\Lib\site-packages\pandas\io\excel\_base.py:597, in BaseExcelReader.raise_if_bad_sheet_by_name(self, name)
595 def raise_if_bad_sheet_by_name(self, name: str) -> None:
596 if name not in self.sheet_names:
--> 597 raise ValueError(f"Worksheet named '{name}' not found")
ValueError: Worksheet named 'G1T1' not found怎么解决
|
44e7f03c99509dd0dfda932ef68b5d5a
|
{
"intermediate": 0.44905492663383484,
"beginner": 0.4461248219013214,
"expert": 0.10482022911310196
}
|
30,661
|
in lua construction for i, v in <table> do I need to declare i, v local?
|
70a5b75d28a48d670e42ced1111029f8
|
{
"intermediate": 0.4209896922111511,
"beginner": 0.2983699142932892,
"expert": 0.28064045310020447
}
|
30,662
|
I am a fashion researcher collecting a list of details that are often found in clothing and names of clothing items. I need you to provide me with a list of such elements in the form of a list of python strings.
For example: ["sleeves", "shirt", "t-shirt", "trousers", "pockets", "denim"]
Take a deep breath, provide exactly 1000 examples. Do not repeat examples. Keep the examples at 3 words or less. Do not write anything other than what I asked for.
|
538ddf8f110fa6ad0289968bafc5c68f
|
{
"intermediate": 0.26822808384895325,
"beginner": 0.44375643134117126,
"expert": 0.2880154550075531
}
|
30,663
|
crea un database seeder para esta db
Tabla 1: "technicians"
- id (pk)
- name
- last_name
- address
- phone
- email
Tabla 2: “services”
- id (pk)
- description
- price
- category_id(fk)
Tabla 3: categories
- id (pk)
- name
- description
Tabla 4: “services_technicians”
- id (pk)
- technical_id(fk)
- service_id (fk)
Tabla 5: "users
- id (pk)
- name
- last_name
- address
- phone
- email
Tabla 6: "demands"
- id (pk)
- user_id (Clave foránea)
- service_technical_id
- date
- status (acepted, pending, rejected)
table 7 "scores"
- id
- user_id
- service_technical_id
- date
- score (1-5)
- comment
Tabla 8: ubications
- id
- name
- ubicable_id
- ubicable_type
|
938262899bbba8ba709228e0a149737d
|
{
"intermediate": 0.3443434238433838,
"beginner": 0.36920467019081116,
"expert": 0.28645193576812744
}
|
30,664
|
hdb3_data = zeros(1, length(binary_data));
pulse = 1;
count = 0;
for i = 1:length(binary_data)
if binary_data(i) == 0
count = count + 1;
if count == 4
hdb3_data(i - 3:i) = ones(1, 4) * pulse;
pulse = -pulse;
count = 0;
end
else
count = 0;
end
end
这段代码不能正确显示HDB3码,可以修改成正确的吗
|
e919c5a4448fa954df8b47476637ff3d
|
{
"intermediate": 0.3169279992580414,
"beginner": 0.362738698720932,
"expert": 0.3203333616256714
}
|
30,665
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BarrelController : MonoBehaviour
{
private bool canPhase = true;
private Rigidbody2D rb;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
// Check if the barrel’s Y position falls below -10
if (transform.position.y < -10)
{
Destroy(gameObject); // Destroy the barrel GameObject
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("BarrelChute") && canPhase)
{
// Move down -1 unit
transform.position = new Vector2(transform.position.x, transform.position.y - 1f);
}
if (collision.gameObject.layer == LayerMask.NameToLayer("MidBarrelChute") && canPhase)
{
float randomChance = Random.Range(0f, 1f); // Get a random value between 0 and 1
if (randomChance <= 0.5f) // 50% chance of not colliding
{
Physics2D.IgnoreCollision(collision.collider, GetComponent<Collider2D>(), true); // Ignore collision
}
else
{
// Move down -1 unit
transform.position = new Vector2(transform.position.x, transform.position.y - 1f);
}
}
if (collision.gameObject.CompareTag("Platform") && canPhase)
{
float platformXPos = collision.gameObject.transform.position.x;
if (platformXPos == negativeX)
{
// Increase velocity by 5 units in the negative x direction
rb.velocity += new Vector2(-3f, 0f);
}
else (platformXPos == positiveX)
{
// Increase velocity by 5 units in the positive x direction
rb.velocity += new Vector2(3f, 0f);
}
}
}
}
fix the if and else statements under the OnCollisionEnter2D method
|
8a35dceee14a007eb757b7c56e21faad
|
{
"intermediate": 0.3758101463317871,
"beginner": 0.35011395812034607,
"expert": 0.2740758955478668
}
|
30,666
|
if (collision.gameObject.CompareTag("Platform") && canPhase)
{
float platformXPos = collision.gameObject.transform.position.x;
if (platformXPos == position.-x)
{
// Increase velocity by 5 units in the negative x direction
rb.velocity += new Vector2(-3f, 0f);
}
else (platformXPos == position.x)
{
// Increase velocity by 5 units in the positive x direction
rb.velocity += new Vector2(3f, 0f);
}
} how do i fix the if (platformXPos == position.-x) and (platformXPos == position.x)?
|
862f2259d2e8e282becbbed7bf0ffbe1
|
{
"intermediate": 0.40912869572639465,
"beginner": 0.3664156496524811,
"expert": 0.22445566952228546
}
|
30,667
|
How to remove a same object in an array for JS?
|
d1c349ff200913d323bd73a828417803
|
{
"intermediate": 0.5370522141456604,
"beginner": 0.218959242105484,
"expert": 0.24398858845233917
}
|
30,668
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BarrelController : MonoBehaviour
{
private bool canPhase = true;
private Rigidbody2D rb;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
// Check if the barrel’s Y position falls below -10
if (transform.position.y < -10)
{
Destroy(gameObject); // Destroy the barrel GameObject
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("BarrelChute") && canPhase)
{
// Move down -1 unit
transform.position = new Vector2(transform.position.x, transform.position.y - 1f);
}
if (collision.gameObject.layer == LayerMask.NameToLayer("MidBarrelChute") && canPhase)
{
float randomChance = Random.Range(0f, 1f); // Get a random value between 0 and 1
if (randomChance <= 0.5f) // 50% chance of not colliding
{
Physics2D.IgnoreCollision(collision.collider, GetComponent<Collider2D>(), true); // Ignore collision
}
else
{
// Move down -1 unit
transform.position = new Vector2(transform.position.x, transform.position.y - 1f);
}
}
if (collision.gameObject.CompareTag("Platform") && canPhase)
{
float platformXPos = collision.gameObject.transform.position.x;
if (platformXPos < transform.position.x)
{
// Increase velocity by 5 units in the negative x direction
rb.velocity += new Vector2(-3f, 0f);
}
else
{
// Increase velocity by 5 units in the positive x direction
rb.velocity += new Vector2(3f, 0f);
}
}
}
}
edit the if/else (platformXPos < transform.position.x) to make it so if the Platform has a negative X position the barrel will increase the velocity in the negative x direction and if the Platform has a positive X position the barrel will increase the velocity in the positive x direction
|
c5939981ebe31653dc51000e09d435fc
|
{
"intermediate": 0.34403547644615173,
"beginner": 0.4368344843387604,
"expert": 0.21913005411624908
}
|
30,669
|
как удалить всем повторяющиеся данные в sqlite
c.execute("INSERT INTO eda VALUES (NULL, ?, ?, ?, ?, ?, ?)", (name, phone, adr, other, gps, header))
|
d8ff29dc55bafbcd6c9156a734705142
|
{
"intermediate": 0.386188268661499,
"beginner": 0.34391555190086365,
"expert": 0.26989614963531494
}
|
30,670
|
There are 3 tasks to be accomplished
Write Java program and classes according to the requirement
Let all the classes to be public and each class into a .java file
Write your main program as a main class name them:
"TestTask1", "TestTask2" and "TestTask3"
Task 1
(1) Define all the classes in the table
(2)Write your main program to create an instance and print the price per each class
Hard Drive $75.0
Compact Hard Drive $64.0
Large Capacity Hard Drive $130.0
SSD $80.0
Large Capacity SSD $120.0
16GB Memory Module (Ram16GB) $40.0
32GB Memory Module (Ram32GB) $69.0
Efficient Processor $306.0
Powerful Processor $589.0
Task 2
(1)Follow Find the common parts between the classes, define superclass of them and add the property of platters, change all the classes of the hard drives to be subclasses of the HardDrive superclass
(2) Handle the issue of totalNumOfPlatter to get the correct amount
(3) Write your main program, create multiple instances of each of the classes, print and check the totalNumOfPlatter
Task 3
(1) Create a new class ProductPackage which contains a storage, a memory
and a porcessor
The price = 50% of the price of the storage + 45% of the price of the memory + 90% of the price of the processor
(2)Create instances of the following packages in your main program and output
the price
packageA: a SDD, 16G Memory and an Efficient Processor
packageB: a Large Capacity Hard Drive, 32G Memory and a Powerful Processor
ProductPackage
storage : Storage
memory : Memory
processor : Processor
+ProductPackage (storage : Storage, memory : Memory, processor : Processor) +getPrice() : double
|
de02c29f1c2fc653a16f5b73fc9e9b33
|
{
"intermediate": 0.4205601215362549,
"beginner": 0.3579806983470917,
"expert": 0.22145918011665344
}
|
30,671
|
private void OnTriggerEnter2D(Collision2D other)
{
if (other.gameObject.layer == LayerMask.NameToLayer("MidBarrelChute") && canPhase)
{
float randomChance = Random.Range(0f, 1f); // Get a random value between 0 and 1
if (randomChance <= 0.5f) // 50% chance of not colliding
{
Physics2D.IgnoreCollision(collision.collider, GetComponent<Collider2D>(), true); // Ignore collision
}
else
{
// Move down -1 unit
transform.position = new Vector2(transform.position.x, transform.position.y - 1f);
}
}
} fix this so that there are no errors
|
e20d81ecabdb7d511a9c111b05302d6d
|
{
"intermediate": 0.34671106934547424,
"beginner": 0.3584491014480591,
"expert": 0.29483988881111145
}
|
30,672
|
using (up_11_02Entities1 db = new up_11_02Entities1())
{
var CountId = Instances.db.Database.SqlQuery<string>("SELECT TOP (1) pk_product_with_user_id FROM dbo.products_users_table ORDER BY pk_product_with_user_id DESC");
string productIdd = Convert.ToString(CountId);
string selectedProductName = Convert.ToString(productList.SelectedItem);
long productId = (from p in db.products
where p.product_name == selectedProductName
select p.pf_product_id).FirstOrDefault();
double price = Convert.ToDouble(PriceBox.Text);
int count = Convert.ToInt32(CountBox.Text);
products_users_table products = new products_users_table
{
pk_product_with_user_id = Convert.ToInt32(CountId) + 1,
fk_product_id = productId,
fk_user_id = UserId,
price = price,
count = count,
sum = count * price
};
Измени код, чтобы я мог использовать переменную CountId из запроса и прибавлять 1 в строке: pk_product_with_user_id = Convert.ToInt32(CountId) + 1, Сейчас ошибка.
|
7fa4da1d8965f3c9f9d794b153f2509a
|
{
"intermediate": 0.34498417377471924,
"beginner": 0.3742329180240631,
"expert": 0.28078290820121765
}
|
30,673
|
There are 3 tasks to be accomplished
Write Java program and classes according to the requirement
Let all the classes to be public and each class into a .java file
Write your main program as a main class name them:
"TestTask1", "TestTask2" and "TestTask3"
public class Ram16GB {
private double price;
public Ram16GB() {
price = 40.0;
}
public double getPrice() {
return price;
}
}
Task 1
(1) Define all the classes in the table
(2)Write your main program to create an instance and print the price per each class
Hard Drive $75.0
Compact Hard Drive $64.0
Large Capacity Hard Drive $130.0
SSD $80.0
Large Capacity SSD $120.0
16GB Memory Module (Ram16GB) $40.0
32GB Memory Module (Ram32GB) $69.0
Efficient Processor $306.0
Powerful Processor $589.0
|
05cb171a56858d5ba51e0e581195ff48
|
{
"intermediate": 0.2782352566719055,
"beginner": 0.4703652560710907,
"expert": 0.2513994872570038
}
|
30,674
|
Hi, If I have a dictionary in Python [1: [1,2,3,4,5,6], 2:[1,2,3,3,4,4,5,5,6]], how can I remove duplicated values and make the values into a set?
|
94b5373761ce115cdb0bead44787d723
|
{
"intermediate": 0.5743860602378845,
"beginner": 0.12716491520404816,
"expert": 0.2984490394592285
}
|
30,675
|
import itertools
dictionary = {
1: [1,2,3,4,5,6],
2: [1,2,3,3,4,4,5,5,6]
}
combined_set = set(itertools.chain.from_iterable(dictionary.values()))
print(combined_set) Can you write the result into a file that each set item is in one line?
|
2a10f878da004543c003c7a835623c8a
|
{
"intermediate": 0.43791428208351135,
"beginner": 0.3667541444301605,
"expert": 0.19533158838748932
}
|
30,676
|
package task1;
public class HardDrive {
private double price;
public HardDrive() {
price = 75.0;
}
public double getPrice() {
return price;
}
}
public class CompactHardDrive {
private double price;
public CompactHardDrive() {
price = 64.0;
}
public double getPrice() {
return price;
}
}
public class LargeCapacityHardDrive {
private double price;
public LargeCapacityHardDrive() {
price = 130.0;
}
public double getPrice() {
return price;
}
}
public class SSD {
private double price;
public SSD() {
price = 80.0;
}
public double getPrice() {
return price;
}
}
public class LargeCapacitySSD {
private double price;
public LargeCapacitySSD() {
price = 120.0;
}
public double getPrice() {
return price;
}
}
public class Ram16GB {
private double price;
public Ram16GB() {
price = 40.0;
}
public double getPrice() {
return price;
}
}
public class Ram32GB {
private double price;
public Ram32GB() {
price = 69.0;
}
public double getPrice() {
return price;
}
}
public class EfficientProcessor {
private double price;
public EfficientProcessor() {
price = 306.0;
}
public double getPrice() {
return price;
}
}
public class PowerfulProcessor {
private double price;
public PowerfulProcessor() {
price = 589.0;
}
public double getPrice() {
return price;
}
java name is task 1 why it is wrong , how to correct it
|
60d0c43479a59306d57d8509ccd2c73c
|
{
"intermediate": 0.31757211685180664,
"beginner": 0.4121190309524536,
"expert": 0.27030885219573975
}
|
30,677
|
Hard Drive $75.0
Compact Hard Drive $64.0
Large Capacity Hard Drive $130.0
SSD $80.0
Large Capacity SSD $120.0
16GB Memory Module (Ram16GB) $40.0
32GB Memory Module (Ram32GB) $69.0
Efficient Processor $306.0
Powerful Processor $589.0
Task 2
(1)Follow Find the common parts between the classes, define superclass of them and add the property of platters, change all the classes of the hard drives to be subclasses of the HardDrive superclass
(2) Handle the issue of totalNumOfPlatter to get the correct amount
(3) Write your main program, create multiple instances of each of the classes, print and check the totalNumOfPlatter
|
af59959f993887aa96e5620b49c0cce9
|
{
"intermediate": 0.3062087595462799,
"beginner": 0.4446893632411957,
"expert": 0.24910187721252441
}
|
30,678
|
Write a client server chatroom program in C using sockets and pthreads, in which we can run server code with:
server [server-port-number]
and client code:
client ][server-host-name ][[server-port-numberclient-name]
|
1fd5827c432672fdda747a6dcdddc34b
|
{
"intermediate": 0.38716545701026917,
"beginner": 0.3641865849494934,
"expert": 0.248648002743721
}
|
30,679
|
suggest code to append value to lua array, with base index 1
|
2d9596c20b189c850b005dc6be3f3749
|
{
"intermediate": 0.36584728956222534,
"beginner": 0.13260211050510406,
"expert": 0.5015506148338318
}
|
30,680
|
#include <iostream>
using namespace std;
void display_arr(int a[],&size)
{
for (int i = 0; i<size;i++ )
{
cout << a[i] << " ";
}
cout<<endl;
}
int lesson_1(int a[],&size)
{
int total_sum=0;
for (int i = 0; i<size;i++ )
{
total_sum += a[i];
}
return total_sum;
}
int main()
{
srand(time(NULL));
int size = 10;
int a[size] = {1,2,3,4,5};
display_arr(a,size);
cout << lesson_1(a,size)<<endl;
return 0;
}
исправь код на С++ чтобы он работал исправно
|
3797976e135552f61d40a8792913a7dc
|
{
"intermediate": 0.36844030022621155,
"beginner": 0.4021168649196625,
"expert": 0.22944283485412598
}
|
30,681
|
#include
using namespace std;
void display_arr(int a[],&size)
{
for (int i = 0; i<size;i++ )
{
cout << a[i] << " ";
}
cout<<endl;
}
int lesson_1(int a[],&size)
{
int total_sum=0;
for (int i = 0; i<size;i++ )
{
total_sum += a[i];
}
return total_sum;
}
int main()
{
srand(time(NULL));
int size = 10;
int a[size] = {1,2,3,4,5};
display_arr(a,size);
cout << lesson_1(a,size)<<endl;
return 0;
}
исправь код на С++ чтобы он работал исправно. Затем напиши функцию, которая получает массив и его размер, а
возвращает сумму и произведение его элементов в двух параметрах-ссылках
|
bd1f7a04f01e14f46890ad1bee6d1497
|
{
"intermediate": 0.2716308534145355,
"beginner": 0.5453287959098816,
"expert": 0.18304024636745453
}
|
30,682
|
Tell me about the book Pro ASP.NET Core 6, 9th Edition (2022).
|
7c5685f48d37085cf4e3a62301db148f
|
{
"intermediate": 0.4846843481063843,
"beginner": 0.2693561017513275,
"expert": 0.2459595799446106
}
|
30,683
|
the command-line tools provided by the .NET SDK has comprehensive commands that can create projects and solutions, add packages and references, build and run and publish projects.
From SDK developer's perspecive, if you are to design such SDK command line tools, how would you design the tool architecture, so that the SDK has many commands while maintain a elegant and succint structure?
|
5af3dbb1668bd2ada4cab1514b41c21f
|
{
"intermediate": 0.43414586782455444,
"beginner": 0.31226348876953125,
"expert": 0.2535906136035919
}
|
30,684
|
Make an html resume page as a behinner
|
4127ed7f39b74fc2472cfcef25b39898
|
{
"intermediate": 0.388731986284256,
"beginner": 0.32840773463249207,
"expert": 0.28286030888557434
}
|
30,685
|
lua code x = {objId, coord[1], coord[2], coord[4]}. does it initialise an array? can I adrress it by index?
|
968dd0ed66fd4a5da3d930c72c7a6bb5
|
{
"intermediate": 0.5071656703948975,
"beginner": 0.27780747413635254,
"expert": 0.2150268703699112
}
|
30,686
|
"""
#导入库
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.metrics import roc_curve
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn import svm
from sklearn import metrics
from sklearn.metrics import roc_auc_score
from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
from sklearn.feature_selection import SelectKBest, f_classif
from imblearn.over_sampling import SMOTE
from sklearn.model_selection import cross_val_score
### 数据导入 /data/bigfiles/20230905_Cervical.csv
data = pd.read_csv("/data/bigfiles/20230905_Cervical.csv")
### 建立标签
y = data["Target"]
X = data.loc[:, "Age": "SampEn_MSE5"]
### 数据划分
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 62)
### 数据归一化
MinMaxScaler = MinMaxScaler(feature_range=[0,1])
X_train_scaled = MinMaxScaler.fit_transform(X_train)
X_test_scaled = MinMaxScaler.fit_transform(X_test)
### 数据标准化
standardScaler = StandardScaler()
X_train = standardScaler.fit_transform(X_train)
X_test = standardScaler.fit_transform(X_test)
### 建立svm模型
svm_model = svm.SVC(kernel='rbf', C=100, gamma=0.5, class_weight='balanced')
svm_model.fit(X_train,y_train)
selector = SelectKBest(f_classif, k=5)
X_train_new = selector.fit_transform(X_train, y_train)
X_test_new = selector.transform(X_test)
svm_model.fit(X_train_new, y_train)
smote = SMOTE(random_state=52)
X_train_new_resampled, y_train_resampled = smote.fit_resample(X_train_new, y_train)
svm_model.fit(X_train_new_resampled, y_train_resampled)
### 评价模型
y_test_pred = svm_model.predict(X_test_new)
confusion = metrics.confusion_matrix(y_test,y_test_pred)
TN = confusion[0,0]
FP = confusion[0,1]
FN = confusion[1,0]
TP = confusion[1,1]
accuracy = (TP+TN)/(TN+FP+FN+TP)
precision = TP/(TP+FP)
recall = TP/(TP+FN)
F1_score = 2*precision*recall/(precision+recall)
auc_score = roc_auc_score(y_test, y_test_pred)
# 输出ROC曲线
fpr, tpr, thresholds = roc_curve(y_test, y_test_pred)
plt.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % auc_score)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic')
plt.legend(loc="lower right")
plt.show()
# 执行交叉验证
cv_scores = cross_val_score(svm_model, X_train_new_resampled, y_train_resampled, cv=10, scoring='roc_auc')
mean_auc_score = np.mean(cv_scores)
print("Mean AUC score from cross-validation: {:.2f}".format(mean_auc_score))
print("accuracy:{:.2f}, precision:{:.2f}, recall:{:.2f}, F1_score:{:.2f}".format(accuracy,precision,recall,F1_score))修改以上代码使输出auc超过0.8
|
0e561551fcba6506e0ae2d67ac4b95d9
|
{
"intermediate": 0.3305051922798157,
"beginner": 0.3838988244533539,
"expert": 0.2855960726737976
}
|
30,687
|
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
Ошибка при запуске, сам код:
//ошибки по итераторам:
//нет операций +/-/*, сравнение(</>) для итераторов класса map, set, list. Только инткремент, декримент.
//или доп.функция: advance(<итератор>, <значение>);
//Операции +=, -=, +, -, <, <=, >, >= и <=> поддерживаются только итераторами произвольного доступа (итераторы контейнеров std::vector, array и deque)
#include <iostream>
#include <set>
#include <string>
// int compare(std::vector<int, std::string> a, std::vector<int, std::string> b){
// return a[1] < b[1];
// }
int main()
{
int k, n;
// std::vector<std::pair<int, std::string>> arr;
std::set<std::string> st;
std::cin >> n;
for(int i = 0; i<n; ++i){
std::string num;
std::cin >> num;
st.insert(num);
//find
std::string last = "";
std::string next = "";
std::set<std::string>::iterator temp = st.find(num);
if(temp != st.begin()){
last = *(--temp);
std::cout << last << " ";
} else
std::cout << -1 << " ";
if (temp != st.end()){
next = *(++temp);
std::cout << next << std::endl;
} else
std::cout << -1 << std::endl;
}
return 0;
}
|
778b5c7849381b05d572e59b934585c5
|
{
"intermediate": 0.23867858946323395,
"beginner": 0.6304317712783813,
"expert": 0.1308896690607071
}
|
30,688
|
Quicksort in python
|
569f4ed943518a1ce7a7688c54f2248a
|
{
"intermediate": 0.30776259303092957,
"beginner": 0.14897920191287994,
"expert": 0.5432581901550293
}
|
30,689
|
Write a program in C++ that inputs distance travelled in miles and speed of vehicle in mph.It then calculates time required to reach the destination and prints it
|
82f2ebb78f810501e8b68cb7466d0561
|
{
"intermediate": 0.32357242703437805,
"beginner": 0.24784281849861145,
"expert": 0.4285848140716553
}
|
30,690
|
#include <iostream>
using namespace std;
int main()
{
char S1[] = "water";
char S2[] = "fire";
char S3[] = "";
cout << S1<<endl;
cout << S3<<endl;
return 0;
} какой метод для c-строк считает размер строки?
|
cdae088b93410058dde1cf5c39864841
|
{
"intermediate": 0.2951818108558655,
"beginner": 0.4805341362953186,
"expert": 0.2242840677499771
}
|
30,691
|
I need to compare whether the values shifted two month back is blank using DAX if and DATEADD function. Help with that
|
b61910e7a34d0cf1bd97d505085dd157
|
{
"intermediate": 0.5175886750221252,
"beginner": 0.22159051895141602,
"expert": 0.2608208656311035
}
|
30,692
|
#include
using namespace std;
int main()
{
char S1[] = “water”;
char S2[] = “fire”;
char S3[] = “”;
cout << S1<<endl;
cout << S3<<endl;
return 0;
} какой пополнить S3 содержимым строки S1 с помощью for statenebt
|
707f96567305354ab1e89b7da3cb2376
|
{
"intermediate": 0.32301759719848633,
"beginner": 0.48960649967193604,
"expert": 0.18737590312957764
}
|
30,693
|
Write a C++ program. Initialize and print a two-dimensional array using functions. Pass the array using reference
|
a7e5de7e156f4567e1c39b57eff1676c
|
{
"intermediate": 0.24030235409736633,
"beginner": 0.5668061971664429,
"expert": 0.1928914338350296
}
|
30,694
|
Write a C++ program. Initialize and print a two-dimensional array using functions. Pass the array using pointer. Both dimensions are const values
|
255d7288fbb69f7a0c13c2562116728e
|
{
"intermediate": 0.2915411591529846,
"beginner": 0.4846530258655548,
"expert": 0.22380581498146057
}
|
30,695
|
I have a table
Client | Date | Amount
------ | ---------- | ------
A | 2022-12-01 | 120
A | 2022-11-01 | 250
A | 2022-10-01 | 200
A | 2022-09-01 | 180
B | 2022-11-01 | 150
B | 2022-10-01 | 130
B | 2022-09-01 | 110
I need a DAX measure to first check whether for each client exists the row shifted two month back. If so, the New amount is equal to Amount shifted two months back. Othewise, it is equal to current Amount. So the new measure should be
Client | Date | Amount | New measure
------ | ---------- | ------ | ------
A | 2022-12-01 | 120 | 200
A | 2022-11-01 | 250| 180
A | 2022-10-01 | 200| 200
A | 2022-09-01 | 180| 180
B | 2022-11-01 | 150| 110
B | 2022-10-01 | 130| 130
B | 2022-09-01 | 110| 110
Write the measure
|
6c8cc967f986f15d32527fdb29da7a55
|
{
"intermediate": 0.4318868815898895,
"beginner": 0.3429088890552521,
"expert": 0.2252042293548584
}
|
30,696
|
could you speed up my code?
# создадим список датафреймов
pets_vs_nests = []
# для каждого, кто заходил в петов 3 раза и более и покупал гнездо
for i in tqdm(pets_basic[pets_basic.nest_buyer].appsflyer_id.unique()):
# создадим свой датафрейм
df = pets_n_nests[pets_n_nests.appsflyer_id == i].reset_index(drop=True)
# сохраним кол-во открытий петов до первой покупки гнезда
opens_before_buy = df[df.event_value.str.contains('UnlockNest')].index.min()
# сохраним кол-во дней до первой покупки гнезда
days_before_buy = (df[df.event_value.str.contains('UnlockNest')].event_time.dt.date.min()
- df.event_time.dt.date.min()).days
# соберем датафрейм с данными по игроку
player = pd.DataFrame({'appslfyer_id': i,
'opens_before_buy': opens_before_buy,
'days_before_buy': days_before_buy},
index=[0])
# добавим его в общий список
pets_vs_nests.append(player)
# объединим всех игроков в один датафрейм
pets_vs_nests = pd.concat(pets_vs_nests)
|
9a3928f96df8bc060653f2bb736de987
|
{
"intermediate": 0.5552085041999817,
"beginner": 0.19735288619995117,
"expert": 0.24743860960006714
}
|
30,697
|
function hcyl(bottom, height, radius, id) {
let radsq = radius * radius
let innerRadsq = (radius - 1.2) * (radius - 1.2)
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x * x + z * z
if (d < radsq && d >= innerRadsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function cyl(bottom, height, radius, id) {
let radsq = radius * radius
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x * x + z * z
if (d < radsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function cube(bottom, height, radius, id) {
let radsq = radius * radius
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x + z
if (d < radsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function sphereoid(w, h, d, id) {
let w2 = w * w
let h2 = h * h
let d2 = d * d
let w3 = (w - 1.5) * (w - 1.5)
let h3 = (h - 1.5) * (h - 1.5)
let d3 = (d - 1.5) * (d - 1.5)
for (let y = -h; y < h; y++) {
for (let x = -w; x <= w; x++) {
for (let z = -d; z <= d; z++) {
let n = x * x / w2 + y * y / h2 + z * z / d2
let n2 = x * x / w3 + y * y / h3 + z * z / d3
if (n < 1 && n2 >= 1) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function sleep(ms) {
return new Promise(resolve => setTimeout(() => resolve(), ms))
}
async function asphereoid(w, h, d, id) {
let px = p2.x
let py = p2.y
let pz = p2.z
let w2 = w * w
let h2 = h * h
let d2 = d * d
let w3 = (w - 1.5) * (w - 1.5)
let h3 = (h - 1.5) * (h - 1.5)
let d3 = (d - 1.5) * (d - 1.5)
for (let y = -h; y < h; y++) {
for (let x = -w; x <= w; x++) {
for (let z = -d; z <= d; z++) {
let n = x * x / w2 + y * y / h2 + z * z / d2
let n2 = x * x / w3 + y * y / h3 + z * z / d3
if (n < 1 && n2 >= 1) {
world.setBlock(px + x, py + y, pz + z, id)
await sleep(10)
}
}
}
}
}
function line(x1, y1, z1, x2, y2, z2, id) {
let dx = Math.abs(x2 - x1);
let dy = Math.abs(y2 - y1);
let dz = Math.abs(z2 - z1);
let sx = (x1 < x2) ? 1 : -1;
let sy = (y1 < y2) ? 1 : -1;
let sz = (z1 < z2) ? 1 : -1;
let err1 = dx - dy;
let err2 = dx - dz;
let err3 = dy - dz;
while (true) {
world.setBlock(x1, y1, z1, id);
if (x1 === x2 && y1 === y2 && z1 === z2) break;
let e2 = 2 * err1;
let e3 = 2 * err2;
let e4 = 2 * err3;
if (e2 > -dy) {
err1 -= dy;
err2 -= dz;
x1 += sx;
}
if (e2 < dx) {
err1 += dx;
err3 -= dz;
y1 += sy;
}
if (e3 > -dz) {
err2 += dy;
err3 += dx;
z1 += sz;
}
}
}
function cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l) {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + y, dz + z, block);
}
}
}
}
function duplicateBlock(sx, sy, sz, dx, dy, dz, w, h, l, offsetX, offsetY, offsetZ, num) {
for (let i = 0; i < num; i++) {
cloneBlock(sx, sy, sz, dx + offsetX * i, dy + offsetY * i, dz + offsetZ * i, w, h, l);
}
}
function rotateBlock(sx, sy, sz, dx, dy, dz, w, h, l, angle) {
let rad = angle * (Math.PI / 180);
let sin = Math.sin(rad);
let cos = Math.cos(rad);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let nx = Math.round(x * cos - z * sin);
let nz = Math.round(x * sin + z * cos);
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + nx, dy + y, dz + nz, block);
}
}
}
}
function fillBlock(sx, sy, sz, dx, dy, dz, id) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(startX + x, startY + y, startZ + z, id);
}
}
}
}
function moveBlock(sx, sy, sz, dx, dy, dz, w, h, l) {
cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l);
fillBlock(sx, sy, sz, sx + w - 1, sy + h - 1, sz + l - 1, 0);
}
function paintBlock(sx, sy, sz, dx, dy, dz, w, h, l, colorId) {
cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(dx + x, dy + y, dz + z, colorId);
}
}
}
}
function replaceBlock(sx, sy, sz, dx, dy, dz, id, newId) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
if (world.getBlock(startX + x, startY + y, startZ + z) === id) {
world.setBlock(startX + x, startY + y, startZ + z, newId);
}
}
}
}
}
function mirrorBlock(sx, sy, sz, dx, dy, dz, w, h, l, axis) {
if (axis === "x") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + w - x - 1, dy + y, dz + z, block);
}
}
}
} else if (axis === "y") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + h - y - 1, dz + z, block);
}
}
}
} else if (axis === "z") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + y, dz + l - z - 1, block);
}
}
}
}
}
function clearBlock(sx, sy, sz, dx, dy, dz) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(startX + x, startY + y, startZ + z, 0);
}
}
}
}
let colorBlock
|
a3d7a48d801a4338a487807b1cfd0d70
|
{
"intermediate": 0.2089826762676239,
"beginner": 0.5734841227531433,
"expert": 0.2175331860780716
}
|
30,698
|
function hcyl(bottom, height, radius, id) {
let radsq = radius * radius
let innerRadsq = (radius - 1.2) * (radius - 1.2)
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x * x + z * z
if (d < radsq && d >= innerRadsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function cyl(bottom, height, radius, id) {
let radsq = radius * radius
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x * x + z * z
if (d < radsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function cube(bottom, height, radius, id) {
let radsq = radius * radius
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x + z
if (d < radsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function sphereoid(w, h, d, id) {
let w2 = w * w
let h2 = h * h
let d2 = d * d
let w3 = (w - 1.5) * (w - 1.5)
let h3 = (h - 1.5) * (h - 1.5)
let d3 = (d - 1.5) * (d - 1.5)
for (let y = -h; y < h; y++) {
for (let x = -w; x <= w; x++) {
for (let z = -d; z <= d; z++) {
let n = x * x / w2 + y * y / h2 + z * z / d2
let n2 = x * x / w3 + y * y / h3 + z * z / d3
if (n < 1 && n2 >= 1) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function sleep(ms) {
return new Promise(resolve => setTimeout(() => resolve(), ms))
}
async function asphereoid(w, h, d, id) {
let px = p2.x
let py = p2.y
let pz = p2.z
let w2 = w * w
let h2 = h * h
let d2 = d * d
let w3 = (w - 1.5) * (w - 1.5)
let h3 = (h - 1.5) * (h - 1.5)
let d3 = (d - 1.5) * (d - 1.5)
for (let y = -h; y < h; y++) {
for (let x = -w; x <= w; x++) {
for (let z = -d; z <= d; z++) {
let n = x * x / w2 + y * y / h2 + z * z / d2
let n2 = x * x / w3 + y * y / h3 + z * z / d3
if (n < 1 && n2 >= 1) {
world.setBlock(px + x, py + y, pz + z, id)
await sleep(10)
}
}
}
}
}
function line(x1, y1, z1, x2, y2, z2, id) {
let dx = Math.abs(x2 - x1);
let dy = Math.abs(y2 - y1);
let dz = Math.abs(z2 - z1);
let sx = (x1 < x2) ? 1 : -1;
let sy = (y1 < y2) ? 1 : -1;
let sz = (z1 < z2) ? 1 : -1;
let err1 = dx - dy;
let err2 = dx - dz;
let err3 = dy - dz;
while (true) {
world.setBlock(x1, y1, z1, id);
if (x1 === x2 && y1 === y2 && z1 === z2) break;
let e2 = 2 * err1;
let e3 = 2 * err2;
let e4 = 2 * err3;
if (e2 > -dy) {
err1 -= dy;
err2 -= dz;
x1 += sx;
}
if (e2 < dx) {
err1 += dx;
err3 -= dz;
y1 += sy;
}
if (e3 > -dz) {
err2 += dy;
err3 += dx;
z1 += sz;
}
}
}
function cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l) {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + y, dz + z, block);
}
}
}
}
function duplicateBlock(sx, sy, sz, dx, dy, dz, w, h, l, offsetX, offsetY, offsetZ, num) {
for (let i = 0; i < num; i++) {
cloneBlock(sx, sy, sz, dx + offsetX * i, dy + offsetY * i, dz + offsetZ * i, w, h, l);
}
}
function rotateBlock(sx, sy, sz, dx, dy, dz, w, h, l, angle) {
let rad = angle * (Math.PI / 180);
let sin = Math.sin(rad);
let cos = Math.cos(rad);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let nx = Math.round(x * cos - z * sin);
let nz = Math.round(x * sin + z * cos);
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + nx, dy + y, dz + nz, block);
}
}
}
}
function fillBlock(sx, sy, sz, dx, dy, dz, id) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(startX + x, startY + y, startZ + z, id);
}
}
}
}
function moveBlock(sx, sy, sz, dx, dy, dz, w, h, l) {
cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l);
fillBlock(sx, sy, sz, sx + w - 1, sy + h - 1, sz + l - 1, 0);
}
function paintBlock(sx, sy, sz, dx, dy, dz, w, h, l, colorId) {
cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(dx + x, dy + y, dz + z, colorId);
}
}
}
}
function replaceBlock(sx, sy, sz, dx, dy, dz, id, newId) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
if (world.getBlock(startX + x, startY + y, startZ + z) === id) {
world.setBlock(startX + x, startY + y, startZ + z, newId);
}
}
}
}
}
function mirrorBlock(sx, sy, sz, dx, dy, dz, w, h, l, axis) {
if (axis === "x") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + w - x - 1, dy + y, dz + z, block);
}
}
}
} else if (axis === "y") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + h - y - 1, dz + z, block);
}
}
}
} else if (axis === "z") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + y, dz + l - z - 1, block);
}
}
}
}
}
function clearBlock(sx, sy, sz, dx, dy, dz) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(startX + x, startY + y, startZ + z, 0);
}
}
}
}
const color(x, y, z, c)
|
5e3c9fd3e06190f68e3920429d028e02
|
{
"intermediate": 0.2089826762676239,
"beginner": 0.5734841227531433,
"expert": 0.2175331860780716
}
|
30,699
|
function hcyl(bottom, height, radius, id) {
let radsq = radius * radius
let innerRadsq = (radius - 1.2) * (radius - 1.2)
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x * x + z * z
if (d < radsq && d >= innerRadsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function cyl(bottom, height, radius, id) {
let radsq = radius * radius
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x * x + z * z
if (d < radsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function cube(bottom, height, radius, id) {
let radsq = radius * radius
height += bottom
for (let x = -radius; x <= radius; x++) {
for (let y = bottom; y < height; y++) {
for (let z = -radius; z <= radius; z++) {
let d = x + z
if (d < radsq) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function sphereoid(w, h, d, id) {
let w2 = w * w
let h2 = h * h
let d2 = d * d
let w3 = (w - 1.5) * (w - 1.5)
let h3 = (h - 1.5) * (h - 1.5)
let d3 = (d - 1.5) * (d - 1.5)
for (let y = -h; y < h; y++) {
for (let x = -w; x <= w; x++) {
for (let z = -d; z <= d; z++) {
let n = x * x / w2 + y * y / h2 + z * z / d2
let n2 = x * x / w3 + y * y / h3 + z * z / d3
if (n < 1 && n2 >= 1) {
world.setBlock(p2.x + x, p2.y + y, p2.z + z, id)
}
}
}
}
}
function sleep(ms) {
return new Promise(resolve => setTimeout(() => resolve(), ms))
}
async function asphereoid(w, h, d, id) {
let px = p2.x
let py = p2.y
let pz = p2.z
let w2 = w * w
let h2 = h * h
let d2 = d * d
let w3 = (w - 1.5) * (w - 1.5)
let h3 = (h - 1.5) * (h - 1.5)
let d3 = (d - 1.5) * (d - 1.5)
for (let y = -h; y < h; y++) {
for (let x = -w; x <= w; x++) {
for (let z = -d; z <= d; z++) {
let n = x * x / w2 + y * y / h2 + z * z / d2
let n2 = x * x / w3 + y * y / h3 + z * z / d3
if (n < 1 && n2 >= 1) {
world.setBlock(px + x, py + y, pz + z, id)
await sleep(10)
}
}
}
}
}
function line(x1, y1, z1, x2, y2, z2, id) {
let dx = Math.abs(x2 - x1);
let dy = Math.abs(y2 - y1);
let dz = Math.abs(z2 - z1);
let sx = (x1 < x2) ? 1 : -1;
let sy = (y1 < y2) ? 1 : -1;
let sz = (z1 < z2) ? 1 : -1;
let err1 = dx - dy;
let err2 = dx - dz;
let err3 = dy - dz;
while (true) {
world.setBlock(x1, y1, z1, id);
if (x1 === x2 && y1 === y2 && z1 === z2) break;
let e2 = 2 * err1;
let e3 = 2 * err2;
let e4 = 2 * err3;
if (e2 > -dy) {
err1 -= dy;
err2 -= dz;
x1 += sx;
}
if (e2 < dx) {
err1 += dx;
err3 -= dz;
y1 += sy;
}
if (e3 > -dz) {
err2 += dy;
err3 += dx;
z1 += sz;
}
}
}
function cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l) {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + y, dz + z, block);
}
}
}
}
function duplicateBlock(sx, sy, sz, dx, dy, dz, w, h, l, offsetX, offsetY, offsetZ, num) {
for (let i = 0; i < num; i++) {
cloneBlock(sx, sy, sz, dx + offsetX * i, dy + offsetY * i, dz + offsetZ * i, w, h, l);
}
}
function rotateBlock(sx, sy, sz, dx, dy, dz, w, h, l, angle) {
let rad = angle * (Math.PI / 180);
let sin = Math.sin(rad);
let cos = Math.cos(rad);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let nx = Math.round(x * cos - z * sin);
let nz = Math.round(x * sin + z * cos);
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + nx, dy + y, dz + nz, block);
}
}
}
}
function fillBlock(sx, sy, sz, dx, dy, dz, id) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(startX + x, startY + y, startZ + z, id);
}
}
}
}
function moveBlock(sx, sy, sz, dx, dy, dz, w, h, l) {
cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l);
fillBlock(sx, sy, sz, sx + w - 1, sy + h - 1, sz + l - 1, 0);
}
function paintBlock(sx, sy, sz, dx, dy, dz, w, h, l, colorId) {
cloneBlock(sx, sy, sz, dx, dy, dz, w, h, l);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(dx + x, dy + y, dz + z, colorId);
}
}
}
}
function replaceBlock(sx, sy, sz, dx, dy, dz, id, newId) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
if (world.getBlock(startX + x, startY + y, startZ + z) === id) {
world.setBlock(startX + x, startY + y, startZ + z, newId);
}
}
}
}
}
function mirrorBlock(sx, sy, sz, dx, dy, dz, w, h, l, axis) {
if (axis === "x") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + w - x - 1, dy + y, dz + z, block);
}
}
}
} else if (axis === "y") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + h - y - 1, dz + z, block);
}
}
}
} else if (axis === "z") {
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
let block = world.getBlock(sx + x, sy + y, sz + z);
world.setBlock(dx + x, dy + y, dz + l - z - 1, block);
}
}
}
}
}
function clearBlock(sx, sy, sz, dx, dy, dz) {
let w = Math.abs(dx - sx) + 1;
let h = Math.abs(dy - sy) + 1;
let l = Math.abs(dz - sz) + 1;
let startX = Math.min(sx, dx);
let startY = Math.min(sy, dy);
let startZ = Math.min(sz, dz);
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
for (let z = 0; z < l; z++) {
world.setBlock(startX + x, startY + y, startZ + z, 0);
}
}
}
}
const colorBlock(
|
f7f59c8428041f308ef6300af5fdde3d
|
{
"intermediate": 0.2089826762676239,
"beginner": 0.5734841227531433,
"expert": 0.2175331860780716
}
|
30,700
|
I have a table
Client | Date | Type| Amount
------ | ---------- | ------| ------
A | 2022-12-01 |X| 120
A | 2022-11-01 |X| 250
A | 2022-10-01 |X|200
A | 2022-09-01 |Y| 180
B | 2022-11-01 |X| 150
B | 2022-10-01 |X| 130
B | 2022-09-01 |X| 110
I need a DAX measure to first check whether for each client and Type =X exists the row shifted two month back. If so, the New amount is equal to Amount shifted two months back. Othewise, it is equal to current Amount. If Type is not X, set blank to New measure. So the new measure should be
Client | Date | Type|Amount | New measure
------ | ---------- | ------ | ------
A | 2022-12-01 |X| 120 | 200
A | 2022-11-01 |X| 250| 250
A | 2022-10-01 |X| 200| 200
A | 2022-09-01 |Y|180|
B | 2022-11-01 |X|150| 110
B | 2022-10-01 |X|130| 130
B | 2022-09-01 |X|110| 110
Write the measure
|
1a3b10d9a62783b2f5176f2fc6dad8c8
|
{
"intermediate": 0.37213778495788574,
"beginner": 0.2692500054836273,
"expert": 0.35861220955848694
}
|
30,701
|
I would like to learn react redux I'm importing import {createStore} from 'redux' and try to use const store = createStore(movies);
window.store = store;. But store is not available in window object. How I could solve this problem?
|
63603cb0b0a503dd5aece4efedad5a14
|
{
"intermediate": 0.7286375761032104,
"beginner": 0.20285487174987793,
"expert": 0.0685075893998146
}
|
30,702
|
observations = {}
while True:
line = input()
if line == "":
break
bird, count = line.split(": ")
count = int(count)
if bird in observations:
observations[bird] += count
else:
observations[bird] = count
for bird, count in observations.items():
print(f"{bird}: {count}")
|
ff8282e26afd6fb4e1d915fce14448be
|
{
"intermediate": 0.372332364320755,
"beginner": 0.4505011737346649,
"expert": 0.17716649174690247
}
|
30,703
|
python code to build auto customer service of product chatbot
|
0aac70d36e98852c169eba0ac43904df
|
{
"intermediate": 0.4205651581287384,
"beginner": 0.24086754024028778,
"expert": 0.3385672867298126
}
|
30,704
|
explain how this html code works <input id="lazy" name="personality" type="checkbox"> <label for="lazy">Lazy</label>
|
964e6b90363b8b8ba6e27ae44980d0f9
|
{
"intermediate": 0.37602174282073975,
"beginner": 0.43393474817276,
"expert": 0.19004349410533905
}
|
30,705
|
Do not use any Context from before! Create at least 5 coding excercises that build upon each other. You create exercises with multiple turns. Meaning there is a first excercises the user has to solve. After that the created solution should be incorporated in the next excercise, so the user has to adjust the code of the first solution. Use the information of the following to create at least 5 turns of excercises and the corresponding solutions. Mainly create Coding excercises. Never mention anything like Exercise or Solution etc.. Include the library Python 3.11 in every instruction/USER. Use just the functions directly without creating functions with def if the code is short. NEVER create placeholders in the Code! Create it in the template:
USER: *Add instruction for the excercises, include Python 3.11 in the instruction*
SYSTEM: *Explanation for the Code*
*solution in code form*
USER: *Add instruction for the excercises that is based on solution*
SYSTEM:
*Detailled solution in Code form with detailled explanations*
Here is an additional example:
USER: Extend the code to include XSRF protection by adding an "X-XSRF-TOKEN" header with a generated token.
SYSTEM: You can extend the code to include XSRF protection by adding an "X-XSRF-TOKEN" header with a generated token. Here's the updated code:
// Code
This code extends the interceptor to include XSRF protection by adding the "X-XSRF-TOKEN" header with a generated token. You should implement the logic for generating the XSRF token as needed.
Use the following Context for the excercises. Use all of the information to include in the excercises:
BEGINOFCONTEXT
DO NOT REFERENCE EXCERCISES, USE ADJUST OR FROM PREVIOUS ETC.
Example:
- Use something like "Adjust the last Code to ..." or "Use the previous Code and ..."
NEVER use something like "use the Code from Excercise 1", "adjust Excercise 2 ..."
Fairly portable uname interface. Returns a namedtuple() containing six attributes: system, node, release, version, machine, and processor. Note that this adds a sixth attribute (processor) not present in the os.uname() result. Also, the attribute names are different for the first two attributes; os.uname() names them sysname and nodename. Entries which cannot be determined are set to ''. Changed in version 3.3: Result changed from a tuple to a namedtuple().
Java Platform
Version interface for Jython. Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being a tuple (vm_name, vm_release, vm_vendor) and osinfo being a tuple (os_name, os_version, os_arch). Values which cannot be determined are set to the defaults given as parameters (which all default to '').
Windows Platform
Get additional version information from the Windows Registry and return a tuple (release, version, csd, ptype) referring to OS release, version number, CSD level (service pack) and OS type (multi/single processor). Values which cannot be determined are set to the defaults given as parameters (which all default to an empty string). As a hint: ptype is 'Uniprocessor Free' on single processor NT machines and 'Multiprocessor Free' on multi processor machines. The ‘Free’ refers to the OS version being free of debugging code. It could also state ‘Checked’ which means the OS version uses debugging code, i.e. code that checks arguments, ranges, etc.
Returns a string representing the current Windows edition, or None if the value cannot be determined. Possible values include but are not limited to 'Enterprise', 'IoTUAP', 'ServerStandard', and 'nanoserver'. New in version 3.8.
Return True if the Windows edition returned by win32_edition() is recognized as an IoT edition. New in version 3.8.
macOS Platform
Get macOS version information and return it as tuple (release, versioninfo,
machine) with versioninfo being a tuple (version, dev_stage,
non_release_version). Entries which cannot be determined are set to ''. All tuple entries are strings.
Unix Platforms
Tries to determine the libc version against which the file executable (defaults to the Python interpreter) is linked. Returns a tuple of strings (lib,
version) which default to the given parameters in case the lookup fails. Note that this function has intimate knowledge of how different libc versions add symbols to the executable is probably only usable for executables compiled using gcc. The file is read and scanned in chunks of chunksize bytes.
Linux Platforms
Get operating system identification from os-release file and return it as a dict. The os-release file is a freedesktop.org standard and is available in most Linux distributions. A noticeable exception is Android and Android-based distributions. Raises OSError or subclass when neither /etc/os-release nor /usr/lib/os-release can be read. On success, the function returns a dictionary where keys and values are strings. Values have their special characters like " and $ unquoted. The fields NAME, ID, and PRETTY_NAME are always defined according to the standard. All other fields are optional. Vendors may include additional fields. Note that fields like NAME, VERSION, and VARIANT are strings suitable for presentation to users. Programs should use fields like ID, ID_LIKE, VERSION_ID, or VARIANT_ID to identify Linux distributions. Example: def get_like_distro():
info = platform.freedesktop_os_release()
ids = [info["ID"]]
if "ID_LIKE" in info:
# ids are space separated and ordered by precedence
ids.extend(info["ID_LIKE"].split())
return ids
New in version 3.10.
© 2001–2023 Python Software Foundation
Licensed under the PSF License.
https://docs.python.org/3.11/library/platform.html
ENDOFCONTEXT
|
9c1928d9379f013037cacb677e25482c
|
{
"intermediate": 0.43010973930358887,
"beginner": 0.3461252748966217,
"expert": 0.22376491129398346
}
|
30,706
|
I used this code:
df = client.depth(symbol=symbol)
def signal_generator(df):
if df is None or len(df) < 2:
return ''
signal = []
final_signal = []
# Retrieve depth data
th = 0.35
depth_data = client.depth(symbol=symbol)
bid_depth = depth_data['bids']
ask_depth = depth_data['asks']
buy_price = float(bid_depth[0][0]) if bid_depth else 0.0
sell_price = float(ask_depth[0][0]) if ask_depth else 0.0
mark_price_data = client.ticker_price(symbol=symbol)
mark_price = float(mark_price_data['price']) if 'price' in mark_price_data else 0.0
mark_price_data_change = client.ticker_24hr_price_change(symbol=symbol)
mark_price_percent = float(mark_price_data_change['priceChangePercent']) if 'priceChangePercent' in mark_price_data_change else 0.0
buy_qty = float(bid_depth[0][1]) if bid_depth else 0.0
sell_qty = float(ask_depth[0][1]) if ask_depth else 0.0
# Calculate the threshold for order price deviation
if mark_price_percent > 2:
pth = 7 / 100
elif mark_price_percent < -2:
pth = 7 / 100
else:
pth = 7 / 100
executed_orders_buy = 0.0
for order in bid_depth:
if float(order[0]) == mark_price:
executed_orders_buy += float(order[1])
else:
break
buy_qty = float(bid_depth[0][1]) if bid_depth else 0.0
buy_result = buy_qty - executed_orders_buy
executed_orders_sell = 0.0
for order in ask_depth:
if float(order[0]) == mark_price:
executed_orders_sell += float(order[1])
else:
break
sell_qty = float(ask_depth[0][1]) if ask_depth else 0.0
sell_result = sell_qty - executed_orders_sell
if (sell_result > (1 + th) > float(buy_qty)) and (sell_price < mark_price - (pth + 0.08)):
signal.append('sell')
elif (buy_result > (1 + th) > float(sell_qty)) and (buy_price > mark_price + (pth + 0.08)):
signal.append('buy')
else:
signal.append('')
if signal == ['buy'] and not ((buy_result < sell_qty) and (buy_price < mark_price)):
final_signal.append('buy')
elif signal == ['sell'] and not ((sell_result < buy_qty) and (sell_price > mark_price)):
final_signal.append('sell')
else:
final_signal.append('')
return final_signal
Can you remove return final_signal and plce here code based on my algorithm: if final_signal == ['buy'] andbuy_result > 10000 return final_signal elif _final_signal == ['sell'] and sell_result > 10000 return final_signal else: return None
|
c0cfe1b5aaca62a8e1a2def0e8b7fda8
|
{
"intermediate": 0.25650617480278015,
"beginner": 0.5119444131851196,
"expert": 0.2315494269132614
}
|
30,707
|
char S1[] = "water";
char S2[] = "fire";
int len_s1_s2 = strlen(S1)+ strlen(S2);
char S3_2[len_s1_s2];
int j1 = 0;
for (int i = 0; i < strlen(S1); i++)
{
for (int k = 0; k < strlen(S2); k++)
{
if (S1[i] == S2[k])
{
S3_2[j1++] = S1[i];
break;
}
}
}
cout << "S3.2: "<< S3_2 <<endl;
char S3_3[len_s1_s2];
int j3 = 0;
for (int i = 0; i < strlen(S1); i++)
{
bool found = false;
for (int k = 0; k < strlen(S2); k++)
{
if (S1[i] == S2[k])
{
found = true;
break;
}
}
if (!found)
{
S3_3[j3++] = S1[i];
}
}
cout << "S3.3: " << S3_3 << endl;
как изменить код так чтобы длины строки в обоих случаях была не больше чем их содержимое если мы заранее не знаем длину их содержимого
|
ffde1d17052e328dec27166a337378ba
|
{
"intermediate": 0.2670329511165619,
"beginner": 0.3876579999923706,
"expert": 0.3453091084957123
}
|
30,708
|
# Define the input array
array = [[1], [2,3], [3], [2,4], [4], [1,4]]
# Define the target set
target = {1, 2, 3, 4}
# Initialize an empty list to store the results
results = []
# Loop through all possible combinations of array items
from itertools import combinations
for i in range(1, len(array) + 1):
for combo in combinations(array, i):
# Check if the union of the combo items is equal to the target set
if set().union(*combo) == target:
# Add the combo to the results list
results.append(combo)
# Sort the results list by the length of the combos
results.sort(key=len)
# Print the results
print("The array item combinations that can build 1, 2, 3, 4 are:")
for result in results:
print(result); Please optimize the code. When array and target length is longer, it tooks too much time.
|
be75a1ed1f489fe21b20f1c3200cc097
|
{
"intermediate": 0.36542725563049316,
"beginner": 0.36202242970466614,
"expert": 0.2725503444671631
}
|
30,709
|
Write a C++ program. Initialize a 2d array (3x10) as follows: {{1,2,3,4,5,1,2,3,4,5},{1,0,1,0,1,0,1,0,1,0},{5,4,3,2,1,5,4,3,2,1}}. Use a function for that
|
05c09083d5029bc1377f22dbcfe650f4
|
{
"intermediate": 0.29060301184654236,
"beginner": 0.41940996050834656,
"expert": 0.28998705744743347
}
|
30,710
|
Помоги мне добавить в мою игру класс, который бы занимался анимацией. #include <SFML/Graphics.hpp>
class Character
{
private:
sf::Texture texture;
sf::Sprite sprite;
sf::Clock clock;
public:
Character(const std::string& _filename, sf::RenderWindow& _window)
{
texture.loadFromFile(_filename);
sprite.setTexture(texture);
sprite.setPosition(sf::Vector2f(0.0f, _window.getSize().y - sprite.getLocalBounds().height));
}
void draw(sf::RenderWindow& _window) const
{
_window.draw(sprite);
}
void moveUp(float _distance)
{
sprite.move(0, -_distance);
}
void moveDown(float _distance)
{
sprite.move(0, _distance);
}
void moveLeft(float _distance)
{
sprite.move(-_distance, 0);
}
void moveRight(float _distance)
{
sprite.move(_distance, 0);
}
};
class GameMap
{
private:
sf::Texture texture;
sf::Sprite sprite;
public:
GameMap(const std::string& _filename, const sf::Vector2u& _windowSize)
{
texture.loadFromFile(_filename);
sprite.setTexture(texture);
sprite.setScale((float)_windowSize.x / texture.getSize().x, (float)_windowSize.y / texture.getSize().y);
}
void draw(sf::RenderWindow& _window) const
{
_window.draw(sprite);
}
};
int main()
{
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML Game");
Character character("Images/mario-without-back.png", window);
GameMap gameMap("Images/mario-world.jpg", window.getSize());
sf::Clock clock;
float deltaTime = 0.0f;
const float movementSpeed = 200.0f;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
deltaTime = clock.restart().asSeconds();
float distance = movementSpeed * deltaTime;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
character.moveUp(distance);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
character.moveDown(distance);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
character.moveLeft(distance);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
character.moveRight(distance);
}
window.clear();
gameMap.draw(window);
character.draw(window);
window.display();
}
return 0;
}
|
7b632d4bc4ef6c4fdd5b4eeba629f05f
|
{
"intermediate": 0.27097681164741516,
"beginner": 0.5007468461990356,
"expert": 0.228276327252388
}
|
30,711
|
The depth data printing me: ‘bids’: [[‘236.72’, ‘6.312’], [‘236.71’, ‘1.513’], [‘236.70’, ‘5.585’]] and more I need code which will gett qty , qty in this returnment is 6.312 , 1.513 and 5.585 ,buy every returnment like this is in [] and it looks like this [][][][][] and they are in [] , all order book looks like : ‘bids’: [[][][][][][]], ‘asks’ : [[][][][][][][][][]] you need to give me system which will gett all this bids and asks price and qty
|
92e6866119fb0fe03ae2b55f638f37e1
|
{
"intermediate": 0.37080809473991394,
"beginner": 0.14041922986507416,
"expert": 0.4887726902961731
}
|
30,712
|
# Define the input array
array = [[1], [2,3], [3], [2,4], [4], [1,4]]
# Define the target set
target = {1, 2, 3, 4}
# Initialize an empty list to store the results
results = []
# Create a dictionary to store the count of each element in the array
count = {}
for item in array:
for num in item:
count[num] = count.get(num, 0) + 1
# Define the DFS function
def dfs(curr_set, remaining_count):
# Check if the current set is equal to the target set
if curr_set == target:
results.append(list(curr_set))
return
# Iterate over the remaining elements
for num in remaining_count:
# Check if the current element exists in the remaining count and its count is greater than zero
if remaining_count[num] > 0:
curr_set.add(num) # Add the current element to the current set
remaining_count[num] -= 1 # Decrement the count of the current element
dfs(curr_set, remaining_count) # Recursively call the DFS function
curr_set.remove(num) # Remove the current element from the current set
remaining_count[num] += 1 # Increment the count of the current element
return
# Call the DFS function
dfs(set(), count)
# Sort the results list by the length of the combos
results.sort(key=len)
# Print the results
print(“The array item combinations that can build 1, 2, 3, 4 are:”)
for result in results:
print(result); When I run the code I got below error: Traceback (most recent call last):
File "./2.py", line 38, in <module>
dfs(set(), count)
File "./2.py", line 31, in dfs
dfs(curr_set, remaining_count) # Recursively call the DFS function
File "./2.py", line 31, in dfs
dfs(curr_set, remaining_count) # Recursively call the DFS function
File "./2.py", line 31, in dfsdfs(curr_set, remaining_count) # Recursively call the DFS function
File "./2.py", line 31, in dfs
dfs(curr_set, remaining_count) # Recursively call the DFS function
File "./2.py", line 31, in dfs
dfs(curr_set, remaining_count) # Recursively call the DFS function
File "./2.py", line 31, in dfs
dfs(curr_set, remaining_count) # Recursively call the DFS function
File "./2.py", line 32, in dfs
curr_set.remove(num) # Remove the current element from the current set
KeyError: 4; Please fix the code and send me the workable code.
|
d3bb601ec78d0e3145a139ac251e06cb
|
{
"intermediate": 0.599327564239502,
"beginner": 0.2916223406791687,
"expert": 0.1090501993894577
}
|
30,713
|
python code for bot to trade in binance with out api use strategy if close rise from dawn to up vwap 180 and if close rise from dawn to up ema 60 now bot can buy and if price rise to 100% sell
|
6f3b7051d1494b88446c796b0935e1cc
|
{
"intermediate": 0.3885593116283417,
"beginner": 0.20799529552459717,
"expert": 0.40344536304473877
}
|
30,714
|
сделай плагин на базар, чтобы когда ты вводил команду /bz открывалось меню, сделай так чтобы в меню можно было настроить предметы, сделай так чтобы в 5 слоту меню был камень, сделай так чтобы его можно было продать. Сделай так чтобы цена камня была всегда рандомной, первоначальная цена - 10, сделай так чтобы цена камня менялась в каждые 30 секунд на 1-4% в плюс или минус, сделай так что если бы цена камня падала ниже 40% от первоначальной цены или выше, то камень гарантированно возвращался к базовой цене. Скинь итоговый код
|
8d4d402123f1391b6259b60dc07b1177
|
{
"intermediate": 0.28768372535705566,
"beginner": 0.3909303545951843,
"expert": 0.32138586044311523
}
|
30,715
|
# Define the input array
array = [[1], [2,3], [3], [2,4], [4], [1,4]]
# Define the target set
target = {1, 2, 3, 4}
# Initialize an empty list to store the results
results = []
# Loop through all possible combinations of array items
from itertools import combinations
for i in range(1, len(array) + 1):
for combo in combinations(array, i):
# Check if the union of the combo items is equal to the target set
if set().union(*combo) == target:
# Add the combo to the results list
results.append(combo)
# Sort the results list by the length of the combos
results.sort(key=len)
# Print the results
print("The array item combinations that can build 1, 2, 3, 4 are:")
for result in results:
print(result)
THe code tooks too much time. Can you optimize the code? Make the code workable and make the result same as the above code.)
|
158269b953102876e8b649a5207f9601
|
{
"intermediate": 0.2993236184120178,
"beginner": 0.22223782539367676,
"expert": 0.4784385859966278
}
|
30,716
|
Что можно изменить в моей программе, чтобы она была в стиле ООП? #include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
using namespace sf;
float offsetX = 0, offsetY = 0;
const int H = 17;
const int W = 150;
String TileMap[H] = {/*MAP IS HERE*/};
class PLAYER {
public:
float dx, dy;
FloatRect rect;
bool onGround;
Sprite sprite;
float currentFrame;
PLAYER(Texture& image)
{
sprite.setTexture(image);
rect = FloatRect(100, 180, 16, 16);
dx = dy = 0.1;
currentFrame = 0;
}
void update(float time)
{
rect.left += dx * time;
Collision(0);
if (!onGround) dy = dy + 0.0005 * time;
rect.top += dy * time;
onGround = false;
Collision(1);
currentFrame += time * 0.005;
if (currentFrame > 3) currentFrame -= 3;
if (dx > 0) sprite.setTextureRect(IntRect(112 + 31 * int(currentFrame), 144, 16, 16));
if (dx < 0) sprite.setTextureRect(IntRect(112 + 31 * int(currentFrame) + 16, 144, -16, 16));
sprite.setPosition(rect.left - offsetX, rect.top - offsetY);
dx = 0;
}
void Collision(int num)
{
for (int i = rect.top / 16; i < (rect.top + rect.height) / 16; i++)
for (int j = rect.left / 16; j < (rect.left + rect.width) / 16; j++)
{
if ((TileMap[i][j] == 'P') || (TileMap[i][j] == 'k') || (TileMap[i][j] == '0') || (TileMap[i][j] == 'r') || (TileMap[i][j] == 't'))
{
if (dy > 0 && num == 1)
{
rect.top = i * 16 - rect.height; dy = 0; onGround = true;
}
if (dy < 0 && num == 1)
{
rect.top = i * 16 + 16; dy = 0;
}
if (dx > 0 && num == 0)
{
rect.left = j * 16 - rect.width;
}
if (dx < 0 && num == 0)
{
rect.left = j * 16 + 16;
}
}
if (TileMap[i][j] == 'c') {
// TileMap[i][j]=' ';
}
}
}
};
class ENEMY
{
public:
float dx, dy;
FloatRect rect;
Sprite sprite;
float currentFrame;
bool life;
void set(Texture& image, int x, int y)
{
sprite.setTexture(image);
rect = FloatRect(x, y, 16, 16);
dx = 0.05;
currentFrame = 0;
life = true;
}
void update(float time)
{
rect.left += dx * time;
Collision();
currentFrame += time * 0.005;
if (currentFrame > 2) currentFrame -= 2;
sprite.setTextureRect(IntRect(18 * int(currentFrame), 0, 16, 16));
if (!life) sprite.setTextureRect(IntRect(58, 0, 16, 16));
sprite.setPosition(rect.left - offsetX, rect.top - offsetY);
}
void Collision()
{
for (int i = rect.top / 16; i < (rect.top + rect.height) / 16; i++)
for (int j = rect.left / 16; j < (rect.left + rect.width) / 16; j++)
if ((TileMap[i][j] == 'P') || (TileMap[i][j] == '0'))
{
if (dx > 0)
{
rect.left = j * 16 - rect.width; dx *= -1;
}
else if (dx < 0)
{
rect.left = j * 16 + 16; dx *= -1;
}
}
}
};
int main()
{
RenderWindow window(VideoMode(400, 250), "SFML works!");
Texture tileSet;
tileSet.loadFromFile("Images/Mario_Tileset.png");
PLAYER Mario(tileSet);
ENEMY enemy;
enemy.set(tileSet, 48 * 16, 13 * 16);
Sprite tile(tileSet);
SoundBuffer buffer;
buffer.loadFromFile("Sounds/Jump.ogg");
Sound sound(buffer);
Music music;
music.openFromFile("Sounds/Mario_Theme.ogg");
music.play();
Clock clock;
while (window.isOpen())
{
float time = clock.getElapsedTime().asMicroseconds();
clock.restart();
time = time / 500; // здесь регулируем скорость игры
if (time > 20) time = 20;
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
if (Keyboard::isKeyPressed(Keyboard::Left)) Mario.dx = -0.1;
if (Keyboard::isKeyPressed(Keyboard::Right)) Mario.dx = 0.1;
if (Keyboard::isKeyPressed(Keyboard::Up)) if (Mario.onGround) { Mario.dy = -0.27; Mario.onGround = false; sound.play(); }
Mario.update(time);
enemy.update(time);
if (Mario.rect.intersects(enemy.rect))
{
if (enemy.life) {
if (Mario.dy > 0) { enemy.dx = 0; Mario.dy = -0.2; enemy.life = false; }
else Mario.sprite.setColor(Color::Red);
}
}
if (Mario.rect.left > 200) offsetX = Mario.rect.left - 200; //смещение
window.clear(Color(107, 140, 255));
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
{
if (TileMap[i][j] == 'P') tile.setTextureRect(IntRect(143 - 16 * 3, 112, 16, 16));
if (TileMap[i][j] == 'k') tile.setTextureRect(IntRect(143, 112, 16, 16));
if (TileMap[i][j] == 'c') tile.setTextureRect(IntRect(143 - 16, 112, 16, 16));
if (TileMap[i][j] == 't') tile.setTextureRect(IntRect(0, 47, 32, 95 - 47));
if (TileMap[i][j] == 'g') tile.setTextureRect(IntRect(0, 16 * 9 - 5, 3 * 16, 16 * 2 + 5));
if (TileMap[i][j] == 'G') tile.setTextureRect(IntRect(145, 222, 222 - 145, 255 - 222));
if (TileMap[i][j] == 'd') tile.setTextureRect(IntRect(0, 106, 74, 127 - 106));
if (TileMap[i][j] == 'w') tile.setTextureRect(IntRect(99, 224, 140 - 99, 255 - 224));
if (TileMap[i][j] == 'r') tile.setTextureRect(IntRect(143 - 32, 112, 16, 16));
if ((TileMap[i][j] == ' ') || (TileMap[i][j] == '0')) continue;
tile.setPosition(j * 16 - offsetX, i * 16 - offsetY);
window.draw(tile);
}
window.draw(Mario.sprite);
window.draw(enemy.sprite);
window.display();
}
return 0;
}
|
5582a9d5b84c9ed3b94dcd6046cd2219
|
{
"intermediate": 0.26459360122680664,
"beginner": 0.47092974185943604,
"expert": 0.26447659730911255
}
|
30,717
|
constructor(system, name, map_id, type, time, max_people, min_rank, max_rank, limit, bonuses, autoBalance, friendlyFire, pro)
{
super();
////////////////////////////////////////////
this.name = name;
this.mapId = map_id;
this.battleId = mt_rand(9000, 90000) + "@" + name + "@#" + lobby.battle_count++;
this.map = new Map(map_id);
this.countPeople = 0;
this.maxPeople = max_people;
this.min_rank = min_rank;
this.max_rank = max_rank;
this.limit = limit;
this.bonuses = bonuses;
this.isPaid = pro;
this.system = system;
////////////////////////////////////////////#battle16791@Island CTF@#2
this.previewId = this.mapId + "_preview";
if (this.bonuses)
{
this.tickingRegions = [];
var regions = this.map.getBonusRegions(["medkit", "nitro", "damageup", "armorup"]);
for (var i in regions)
this.tickingRegions.push(new BonusRegion(regions[i]));
setInterval(() =>
{
this.update(5);
if ((this.fund % 5) === 0)
{
this.dropBonus("damageup", 1);
}
if ((this.fund % 5) === 0)
{
this.dropBonus("armorup", 1);
}
if ((this.fund % 5) === 0)
{
this.dropBonus("nitro", 1);
}
if ((this.fund % 5) === 0)
{
this.dropBonus("medkit", 1);
}
if ((this.fund % 5) === 0)
{
this.dropBonus("crystal", 1);
}
}, 5000);
}
////////////////////////////////////////////
this.users = {};
this.spectators = {};
this.team = false;
this.empty = true;
this.emptyTime = 0;
this.fund = 0;
// init_effects;{"effects":[{"durationTime":60000,"itemIndex":4,"userID":"noder"},{"durationTime":60000,"itemIndex":3,"userID":"noder"},{"durationTime":60000,"itemIndex":2,"userID":"noder"},{"durationTime":60000,"itemIndex":2,"userID":"DenPLay"},{"durationTime":60000,"itemIndex":4,"userID":"DenPLay"},{"durationTime":60000,"itemIndex":2,"userID":"maks24"},{"durationTime":60000,"itemIndex":2,"userID":"canya"}]}end~
this.effects = [];
this.temp_leaves = [];
this.type = type;
try
{
time = parseInt(time);
}
catch (e)
{
time = 900;
}
this.timeLimit = time;
this.time = time + Math.floor(Date.now() / 1000);
this.mines = [];
this.crystalCounter = 0;
this.goldCounter = 0;
this.moneyCounter = 0;
this.medCounter = 0;
this.armorCounter = 0;
this.damageCounter = 0;
this.nitroCounter = 0;
this.prizeCounter = 0;
this.healthCounter = 0;
this.bonus_dropped = [];
this.bonuses_dropped = 0;
this.incration_id = 0;
} как сделать чтобы (["medkit", "nitro", "damageup", "armorup"]); падали рандомно по одному и тому же времени
|
7654d2e1f6afc9dbea748ace6fcafd25
|
{
"intermediate": 0.3283708095550537,
"beginner": 0.23092889785766602,
"expert": 0.44070035219192505
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.