row_id
int64 0
48.4k
| init_message
stringlengths 1
342k
| conversation_hash
stringlengths 32
32
| scores
dict |
|---|---|---|---|
30,313
|
in emscripten i have a variable fileSize=123 that i would like to include externally from the generated .js file by emcc. how do I do that
|
129ebd8787e8eb899a9eccfa2f3b16a2
|
{
"intermediate": 0.3822886049747467,
"beginner": 0.45544013381004333,
"expert": 0.16227126121520996
}
|
30,314
|
how to write excel by each row (not each cell) in VB.NET
|
5cccc723ed89f9d8d9bab05d6cadb736
|
{
"intermediate": 0.3906252980232239,
"beginner": 0.30522122979164124,
"expert": 0.30415353178977966
}
|
30,315
|
alignment in excel vb.net
|
e311ff9ead5bfdc57b88898cf25748a7
|
{
"intermediate": 0.3191602826118469,
"beginner": 0.23194997012615204,
"expert": 0.4488897919654846
}
|
30,316
|
keep alignment of template excel in vb.net
|
d6d2a767439ff891e9bcbdc362f06502
|
{
"intermediate": 0.3127651810646057,
"beginner": 0.23850540816783905,
"expert": 0.44872933626174927
}
|
30,317
|
hello
|
37f4ba32a48a2ea84240cc6cb41d91aa
|
{
"intermediate": 0.32064199447631836,
"beginner": 0.28176039457321167,
"expert": 0.39759764075279236
}
|
30,318
|
how to read ident_file location and the file itself? give commands for psql
|
2b4c6f8b7615c346f6f4dcb08ad20ab4
|
{
"intermediate": 0.5453656911849976,
"beginner": 0.15593081712722778,
"expert": 0.29870346188545227
}
|
30,319
|
which types of transactions exists in postgresql? describe each one and give example
|
2f3c772e02d4ab71e6a47507afd7a5a4
|
{
"intermediate": 0.4476308524608612,
"beginner": 0.2875586450099945,
"expert": 0.2648104429244995
}
|
30,320
|
remove password from role psql command
|
6266ada0cafa6fd450d76f881887a329
|
{
"intermediate": 0.3749483823776245,
"beginner": 0.26594892144203186,
"expert": 0.35910269618034363
}
|
30,321
|
What is the latex syntax in Obsidian for: 10^9 events / 10^5 seconds in a day = 10,000
|
ccd95c2e9c205bc9025dd52d221ed4d9
|
{
"intermediate": 0.19487135112285614,
"beginner": 0.7113162279129028,
"expert": 0.09381238371133804
}
|
30,322
|
driver.get(URL);
JavascriptExecutor js = (JavascriptExecutor) driver;
for (int i = 0; i <= 8; i++) {
Actions actions1 = new Actions(driver);
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
actions1.pause(1000).perform();
}
List<WebElement> images = driver.findElements(By.xpath("//img"));
int count = 0;
for (int i = 0; i < images.size(); i++) {
if (count >= 200) {
break;
}
WebElement image = images.get(i);
String imageUrl = image.getAttribute("src");
if (imageUrl == null || imageUrl.isEmpty()) {
continue;
}
try {
URL url = new URL(imageUrl);
BufferedImage bufferedImage = ImageIO.read(url);
File output = new File("Piligrim/" + count + ".png");
ImageIO.write(bufferedImage, "PNG", output);
count++;
} catch (IOException e) {
e.printStackTrace();
}
}
driver.quit(); как изменить код чтобы картинка скачалась в оригинальном размере?
|
ff50bec2a35032a39d23582d9c667f68
|
{
"intermediate": 0.4578239321708679,
"beginner": 0.2943715751171112,
"expert": 0.24780453741550446
}
|
30,323
|
write code in python for lfsr ecryption and decryption
|
7932aebf3c203d19469ee1840a71919f
|
{
"intermediate": 0.3690398335456848,
"beginner": 0.15851610898971558,
"expert": 0.472444087266922
}
|
30,324
|
I'm using Amazon OpenSearch, now I would like to check if one index is existing, how to write PPL code
|
48ea555438407386cdba51db16c07e55
|
{
"intermediate": 0.6582728624343872,
"beginner": 0.19205407798290253,
"expert": 0.1496729999780655
}
|
30,325
|
NoSQL 예제
|
4a6ee3809092162385b9fd085e05f3b5
|
{
"intermediate": 0.23467236757278442,
"beginner": 0.22387459874153137,
"expert": 0.5414530634880066
}
|
30,326
|
make this object rotate to the right using this GDSCRIPT if Input.is_action_just_pressed("ui_right") and is_on_floor():
|
0f600aa3a5c5dd39f146a4a24ec5ddc6
|
{
"intermediate": 0.4453357458114624,
"beginner": 0.2098923772573471,
"expert": 0.34477195143699646
}
|
30,327
|
hi
|
d31add3bf3bf00d590649dd9fc93e534
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
30,328
|
Write code c++ for delete node
|
4924f5a4432487fd72a4315f2bf29753
|
{
"intermediate": 0.29759976267814636,
"beginner": 0.3313084542751312,
"expert": 0.3710918128490448
}
|
30,329
|
typedef struct BevCameraFrame {
CameraFrame* camera_frame=nullptr;
CameraFrame* yuv_camera_frame=nullptr;
std::shared_ptr<cv::Mat> camera_result_image = nullptr;
std::string camera_name;
std::string origin_file_path;
Eigen::Matrix4f prev_pose_transfor;
Eigen::Matrix4f intri_transfer;
Eigen::Matrix<double, 1, 4> quat_ego2global_rotation;
Eigen::Matrix<double, 1, 3> ego2global_translation;
Eigen::Matrix<double, 1, 4> sensor2ego_rotation;
Eigen::Matrix<double, 1, 3> sensor2ego_translation;
std::array<float, 4> quat_lidar2ego_rotation_arr = {0};
std::array<float, 3> lidar2ego_translation_arr = {0};
std::array<float, 4> ego2global_rotation_arr = {0};
std::array<float, 3> ego2global_translation_arr = {0};
BevCameraFrame(){
camera_frame = nullptr;
prev_pose_transfor = Eigen::Matrix4f::Identity();
}
} BevCameraFrame;
typedef std::map<uint64_t, BevCameraFrame> CameraFrameSet;
struct BevFrame{
CameraFrameSet camera_frame_set;
BevMapFrame map_frame;
std::string frame_dir_path;
std::vector<char> out_message_array;
};
BevFrame bev_frame;
camera_frame_set_queue_.push(bev_frame);
receiver_->OnReceiveData(camera_frame_set_queue_.front());
bool BevObstacleDetectionComponent::OnReceiveData(
BevFrame &bev_frame){
CameraFrameSet &camera_frame_set = bev_frame.camera_frame_set;
WriteResultImageMessage(camera_frame_set);
return true;
}
如何把上面的WriteResultImageMessage函数融入车道线组件里,目的是想将已经检测出的车道线图片写入camera_image_output_writer_。int LaneDetectionComponent::WriteResultImageMessage(camera::CameraFrame &camera_frame)可以这样吗,struct CameraFrame {
// timestamp
double timestamp = 0.0;
// frame sequence id
int frame_id = 0;
// data provider
DataProvider *data_provider = nullptr;
// calibration service
BaseCalibrationService *calibration_service = nullptr;
// hdmap struct
base::HdmapStructPtr hdmap_struct = nullptr;
// tracker proposed objects
std::vector<base::ObjectPtr> proposed_objects;
// segmented objects
std::vector<base::ObjectPtr> detected_objects;
// tracked objects
std::vector<base::ObjectPtr> tracked_objects;
// feature of all detected object ( num x dim)
// detect lane mark info
std::vector<base::LaneLine> lane_objects;
std::vector<float> pred_vpt;
std::shared_ptr<base::Blob<float>> track_feature_blob = nullptr;
std::shared_ptr<base::Blob<float>> lane_detected_blob = nullptr;
// detected traffic lights
std::vector<base::TrafficLightPtr> traffic_lights;
// camera intrinsics
Eigen::Matrix3f camera_k_matrix = Eigen::Matrix3f::Identity();
// camera extrinsic
Eigen::Matrix<float, 5, 1> camera_d_matrix;
// narrow to obstacle projected_matrix
Eigen::Matrix3d project_matrix = Eigen::Matrix3d::Identity();
// camera to world pose
Eigen::Affine3d camera2world_pose = Eigen::Affine3d::Identity();
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
} EIGEN_ALIGN16; // struct CameraFrame
|
db93bbb0b4412e1a6ba4364006a072d0
|
{
"intermediate": 0.4685837924480438,
"beginner": 0.32965898513793945,
"expert": 0.20175720751285553
}
|
30,330
|
dma_pool_zalloc
|
fb436a77f966db0e5c1fb226f36db24d
|
{
"intermediate": 0.2724260687828064,
"beginner": 0.2731947600841522,
"expert": 0.4543791115283966
}
|
30,331
|
как мне добавить на фон текстуру в шейдере opengl kotlin при условии, что в шейдере и коде что то есть
|
9b7be84797f38a08fee51838c4536457
|
{
"intermediate": 0.3994825780391693,
"beginner": 0.20009909570217133,
"expert": 0.40041840076446533
}
|
30,332
|
how to ignore corrupt jpeg data
|
8b02090f7c0c645a43d4bbd74bbdfbda
|
{
"intermediate": 0.31897297501564026,
"beginner": 0.3429892659187317,
"expert": 0.33803775906562805
}
|
30,333
|
есть вот такой запрос import { Box } from "@mts/box";
import { Divider } from "@mts/divider";
import { Icon } from "@mts/icon";
import { IconButton } from "@mts/icon-button";
import { Link } from "@mts/link";
import { Text } from "@mts/text";
import React, { useCallback, useContext, useEffect, useState } from "react";
import style from "./MyDataMain.module.scss";
import { Context } from "../../Context";
import { fetchApi } from "../../fetchApi";
// схема
type CardLinkScheme = {
data: CardLinkTypes[];
return_code: number;
};
//типы данных которые достает функция getLinkCard() из linkCard и которые потом .map в в <Link> </Link>
type CardLinkTypes = {
id: number;
title: string;
link: string;
};
// типы карточек в блоке SidebarRight БЛОК <МОИ ДАННЫЕ> с двумя иконками справа и текстом внизу
// эти типы данных мы передаем в workCard
type CardItem = {
title: string;
description: string;
id: number;
};
// workCard это массив данных CardItem
type PropsDataMainList = {
workCard: CardItem;
};
//Экспортируем компонент-карточку в Main
export const MyDataMain = (props: PropsDataMainList) => {
//в linkCard лежат данные в дженерике <CardLinkTypes[]> которые мы достаем из функции getLinkCard() в которой делаем запрос
// на получение ссылки/ссылок в карточке , после .map и отображаются в дальнейшем в <Link> </Link>
const [linkCard, setLinkCard] = useState<CardLinkTypes[]>([]);
const { setError } = useContext(Context);
const { workCard } = props;
const getLinkCard = useCallback(
async (id: number) => {
let params = {
url: https://allplusbebetterfe.bebetterdev.mts-corp.ru/api/0.1/users?action=user_workcard_link_list&workcard_id=${id},
req_params: {
method: "GET",
},
};
try {
//Эта строка выполняет асинхронный вызов функции fetchApi с передачей параметра params.
//Результат этого вызова присваивается переменной result.
//Ожидание (await) используется, чтобы дождаться завершения запроса к API.
//Тип переменной result явно указан как Response | void, что означает, что она может содержать объект Response или быть пустой (void).
//Это полезно для явного определения типов данных, что помогает в статическом анализе кода и предотвращает потенциальные ошибки типов.
const result: Response | void = await fetchApi(params);
if (!result) {
setError("No response");
return;
}
if (result.status !== 200) {
setError(result.status);
return;
}
// Эта строка выполняет асинхронный вызов метода .json() на объекте result, чтобы получить данные из ответа в формате JSON.
//Данные присваиваются переменной response, и тип данных ожидается быть CardLinkScheme,
const response: CardLinkScheme = await result.json();
//Этот блок if проверяет, если поле return_code в объекте response равно 0,
//то выполняются следующие действия: устанавливается состояние linkCard с данными из response.data,
// и выводится сообщение в консоль с данными о linkCard.
if (response.return_code === 0) {
setLinkCard(response.data);
console.log("Данные о linkCard после обновления", response.data);
}
} catch (error) {
setError(error);
}
},
[setLinkCard, setError]
);
useEffect(() => {
getLinkCard(workCard.id); // id карточки
}, [getLinkCard, workCard.id]); мне нужно по аналогии его сделать запрос вот тут import React, { useEffect, useState } from 'react';
import { Box } from '@mts/box';
import { Text } from '@mts/text';
import { Icon } from '@mts/icon';
import { IconButton } from '@mts/icon-button';
import style from './TableBody.module.scss';
import {userAuthentication} from "../../Api/Api"
export type TableBodyItem = {
id: number;
title: string;
dataOpen: string;
closingDate: string;
// ranges:[{id:number,saleLimit:number,saleRate:number,saleOutLimit:number,saleOutRate:number}]//диапозоны
};
//Пропсы tableBody берем из AdminSales.tsx
type PropsInterfaceTableBody = {
tableBody: TableBodyItem[];
};
//Тело таблицы "TableBody" экспортируется в компонент Sales в AdminSales.tsx
export const TableBody = (props: PropsInterfaceTableBody) => {
const { tableBody } = props;
const [loading, setLoading] = useState(false);
const [logUser, setLogUser] = useState(null);
const [email, setEmail] = useState("");
const [firstName, setFirstName] = useState("");
const [error, setError] = useState<number | null>(null);
// Функция получения инфы с сервера для шапки таблицы <TableHeader/>
const getInfoTableBody = async (id: number) => {
setLoading(true);
console.log("Запрос о пользователе начат 1 ");
try {
const response = await userAuthentication();
const result = response as Response;
console.log(result, "result");
if (result.status === 200) {
const data = await result.json();
console.log(data, "!!!!!!!!!!!!");
setEmail(data.user.email);
setFirstName(data.user.first_name);
setError(result.status);
tableBody([
{
id: 1,
title: data.user.email,
dataOpen: "01.06.2023",
closingDate: "01.09.2023",
},
{
id: 2,
title: data.user.first_name,
dataOpen: "01.06.2023",
closingDate: "01.09.2023",
},
{ id: 3, title: "дальше" },
{ id: 4, title: "дальше" },
]);
}
} catch (error) {
console.error("Ошибка при получении информации о пользователе", error);
}
console.log("Запрос о пользователе завершен 3");
};
useEffect(() => {
if (logUser === null && !loading) {
getInfoTableBody(tableBody[0].id);
}
}, [loading, logUser]); сделай так же отвечай на русском
|
1b1952d3219577edf6caa3ec6127766c
|
{
"intermediate": 0.2423800379037857,
"beginner": 0.5335626602172852,
"expert": 0.22405725717544556
}
|
30,334
|
def quick_sort(arr, low, high, k):
if low < high:
pivot_index = partition(arr, low, high, k)
quick_sort(arr, low, pivot_index - 1, k)
quick_sort(arr, pivot_index + 1, high, k)
def partition(arr, low, high, k):
pivot = arr[high][k]
i = low - 1
for j in range(low, high):
if arr[j][k] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == ‘U’:
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
quick_sort(playersU, 0, len(playersU) - 1, 0)
quick_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
quick_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])改进这个程序使它在面对百万级的数据量时处理更快
|
958eb1722e2a15b459ed2425857d0932
|
{
"intermediate": 0.22568409144878387,
"beginner": 0.470575213432312,
"expert": 0.3037407100200653
}
|
30,335
|
from operator import xor
def txt_to_ascii(txt):
ascii_list = []
for char in txt:
ascii_list.append(ord(char))
return ascii_list
def ascii_to_txt(ascii_list):
txt = " "
for value in ascii_list:
txt += chr(value)
return txt
def shifting(initial_vector):
shifted_reg = initial_vector.copy()
shifted_reg.insert(0, 0)
shifted_reg.pop()
return shifted_reg
def xoring(poly, vec):
feedback_bit = vec[poly[0]]
for x in range(1, len(poly)):
feedback_bit = xor(feedback_bit, vec[poly[x]])
return feedback_bit
def getKey(initial_vector):
shifted_reg = initial_vector.copy()
shifted_reg.insert(0, 0)
pop_bit = shifted_reg.pop()
return pop_bit
def lfsr(initial_vector, poly, m):
num_clk = (2 ** m)
key = []
for i in range(num_clk):
if i == 0:
shifted_vector = shifting(initial_vector)
feedback = xoring(poly, initial_vector)
shifted_vector[0] = feedback
k = getKey(initial_vector)
key.append(k)
else:
shifted_vector = shifting(shifted_vector)
feedback = xoring(poly, shifted_vector)
shifted_vector[0] = feedback
k = getKey(shifted_vector)
key.append(k)
return key
def encryption(plain_txt_):
plain_txt_ = txt_to_ascii(plain_txt_)
key = lfsr([1, 0, 0], [1, 2], 3)
for _ in range(len(plain_txt_)):
if len(key) <= len(plain_txt_):
key = key + key
cipher_txt = []
for bit in range(len(plain_txt_)):
cipher_txt.append(xor(plain_txt_[bit], key[bit]))
return cipher_txt
def decryption(cipher_txt, poly, m):
init_vector = cipher_txt[:(2 ** m)]
print(init_vector)
key2 = lfsr(init_vector, poly, m)
# key2 = key2[:len(cipher_txt)]
for _ in range(len(cipher_txt)):
if len(key2) <= len(cipher_txt):
key2 = key2 + key2
plain_txt_ = []
for bit in range(len(cipher_txt)):
plain_txt_.append(xor(cipher_txt[bit], key2[bit]))
return plain_txt_
plain_txt = input()
encrypted_txt = encryption(plain_txt)
print(encrypted_txt)
print(ascii_to_txt(encrypted_txt))
clear_txt = decryption(encrypted_txt, [1, 2], 3)
print(clear_txt)
# ---------------------------------------
# encrypt (plain_txt)
# converter = convert(plain_txt) form letter to ascii
# key1 = lfsr(initial_vector, poly, m)
# key2 = repeat key1 along to converter
# cipher_txt = converter xor key2
# encrypted_txt = convert(cipher_txt) form ascii to letter
# return encrypted_txt
#
# decrypt(encrypted_txt, m, poly)
# converter = convert(encrypted_txt) form letter to ascii
# key_len = 2^m
# converter[0: key_len] = key1
# key2 = lfsr(key1, poly, m)
# plain_txt = converter xor key2
# decrypted_txt = convert(plain_txt) form ascii to letter
# return decrypted_txt
what is wrong
|
673e2ece61551cd2ca152e3d4b504faa
|
{
"intermediate": 0.27347248792648315,
"beginner": 0.5188559293746948,
"expert": 0.2076716423034668
}
|
30,336
|
rewrite the stata code into python code:
replace linkenddt = mofd(linkenddt)
|
adb69bc08c719a96802bca824178bc60
|
{
"intermediate": 0.33695924282073975,
"beginner": 0.34130859375,
"expert": 0.3217322528362274
}
|
30,337
|
Привет, добавь в следующем коде в шейдер квадрат, который будет под отрисовывающейся фигурой и текстура ему будет задана u_texture1:
internal class MyRenderer(var c: Context) : GLSurfaceView.Renderer {
private val texture = IntArray(2)
private val x_camera: Float
private val y_camera: Float
private val z_camera: Float
private val x_light_position = 5f
private val y_light_position = 30f
private val z_light_position = 5f
private val model_matrix: FloatArray
private val view_matrix: FloatArray
private val model_view_matrix: FloatArray
private val projection_matrix: FloatArray
private val model_view_projection_matrix: FloatArray
private val max_size_x = 70
private val max_size_z = 60
private val size_index: Int
private val x0 = -1.3f
private val z0 = -1.5f
private val dx = 0.05f
private val dz = 0.05f
private val x: FloatArray
private val y: Array<FloatArray>
private val z: FloatArray
private val vertexes: FloatArray
private val normales_x: Array<FloatArray>
private val normales_y: Array<FloatArray>
private val normales_z: Array<FloatArray>
private val normales: FloatArray
private val vertexes_buffer: FloatBuffer
private val normales_buffer: FloatBuffer
private val index_buffer: ShortBuffer
private var m_shader: Shader? = null
init {
model_matrix = FloatArray(16)
view_matrix = FloatArray(16)
model_view_matrix = FloatArray(16)
projection_matrix = FloatArray(16)
model_view_projection_matrix = FloatArray(16)
Matrix.setIdentityM(model_matrix, 0)
x_camera = -1.0f
y_camera = 6.0f
z_camera = 0.0f
Matrix.setLookAtM(view_matrix, 0, x_camera, y_camera, z_camera, 0f, 0.0f, 0f, 0f, 1f, 0f)
Matrix.multiplyMM(model_view_matrix, 0, view_matrix, 0, model_matrix, 0)
x = FloatArray(max_size_x + 1)
z = FloatArray(max_size_z + 1)
y = Array(max_size_z + 1) { FloatArray(max_size_x + 1) }
vertexes = FloatArray((max_size_z + 1) * (max_size_x + 1) * 3)
normales_x = Array(max_size_z + 1) { FloatArray(max_size_x + 1) }
normales_y = Array(max_size_z + 1) { FloatArray(max_size_x + 1) }
normales_z = Array(max_size_z + 1) { FloatArray(max_size_x + 1) }
normales = FloatArray((max_size_z + 1) * (max_size_x + 1) * 3)
for (i in 0..max_size_x) {
x[i] = x0 + i * dx
}
for (j in 0..max_size_z) {
z[j] = z0 + j * dz
}
val vb = ByteBuffer.allocateDirect((max_size_z + 1) * (max_size_x + 1) * 3 * 4)
vb.order(ByteOrder.nativeOrder())
vertexes_buffer = vb.asFloatBuffer()
vertexes_buffer.position(0)
val nb = ByteBuffer.allocateDirect((max_size_z + 1) * (max_size_x + 1) * 3 * 4)
nb.order(ByteOrder.nativeOrder())
normales_buffer = nb.asFloatBuffer()
normales_buffer.position(0)
val index: ShortArray
size_index = 2 * (max_size_x + 1) * max_size_z + (max_size_z - 1)
index = ShortArray(size_index)
var k = 0
var j = 0
while (j < max_size_z) {
for (i in 0..max_size_x) {
index[k] = chain(j, i)
k++
index[k] = chain(j + 1, i)
k++
}
if (j < max_size_z - 1) {
index[k] = chain(j + 1, max_size_x)
k++
}
j++
if (j < max_size_z) {
for (i in max_size_x downTo 0) {
index[k] = chain(j, i)
k++
index[k] = chain(j + 1, i)
k++
}
if (j < max_size_z - 1) {
index[k] = chain(j + 1, 0)
k++
}
j++
}
}
val bi = ByteBuffer.allocateDirect(size_index * 2)
bi.order(ByteOrder.nativeOrder())
index_buffer = bi.asShortBuffer()
index_buffer.put(index)
index_buffer.position(0)
get_vertexes()
get_normales()
}
private fun chain(j: Int, i: Int): Short {
return (i + j * (max_size_x + 1)).toShort()
}
private fun get_vertexes() {
val time = System.currentTimeMillis().toDouble()
for (j in 0..max_size_z) {
for (i in 0..max_size_x) {
y[j][i] = 0.02f * Math.cos(0.005 * time + 5 * (z[j] + x[i])).toFloat()
}
}
var k = 0
for (j in 0..max_size_z) {
for (i in 0..max_size_x) {
vertexes[k] = x[i]
k++
vertexes[k] = y[j][i]
k++
vertexes[k] = z[j]
k++
}
}
vertexes_buffer.put(vertexes)
vertexes_buffer.position(0)
}
private fun get_normales() {
for (j in 0 until max_size_z) {
for (i in 0 until max_size_x) {
normales_x[j][i] = -(y[j][i + 1] - y[j][i]) * dz
normales_y[j][i] = dx * dz
normales_z[j][i] = -dx * (y[j + 1][i] - y[j][i])
}
}
for (j in 0 until max_size_z) {
normales_x[j][max_size_x] = (y[j][max_size_x - 1] - y[j][max_size_x]) * dz
normales_y[j][max_size_x] = dx * dz
normales_z[j][max_size_x] = -dx * (y[j + 1][max_size_x] - y[j][max_size_x])
}
for (i in 0 until max_size_x) {
normales_x[max_size_z][i] = -(y[max_size_z][i + 1] - y[max_size_z][i]) * dz
normales_y[max_size_z][i] = dx * dz
normales_z[max_size_z][i] = dx * (y[max_size_z - 1][i] - y[max_size_z][i])
}
normales_x[max_size_z][max_size_x] =
(y[max_size_z][max_size_x - 1] - y[max_size_z][max_size_x]) * dz
normales_y[max_size_z][max_size_x] = dx * dz
normales_z[max_size_z][max_size_x] =
dx * (y[max_size_z - 1][max_size_x] - y[max_size_z][max_size_x])
var k = 0
for (j in 0..max_size_z) {
for (i in 0..max_size_x) {
normales[k] = normales_x[j][i]
k++
normales[k] = normales_y[j][i]
k++
normales[k] = normales_z[j][i]
k++
}
}
normales_buffer.put(normales)
normales_buffer.position(0)
}
@SuppressLint("ResourceType")
override fun onSurfaceCreated(gl: GL10?, config: javax.microedition.khronos.egl.EGLConfig?) {
gl?.glGenTextures(2, texture, 0)
val stream: InputStream
val bitmap: Bitmap
stream = c.resources.openRawResource(R.drawable.water1)
bitmap = BitmapFactory.decodeStream(stream)
gl?.glBindTexture(GL10.GL_TEXTURE_2D, texture[0])
gl?.glTexParameterf(
GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
GL10.GL_LINEAR.toFloat()
)
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0)
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR)
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR)
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0)
bitmap.recycle()
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0)
GLES20.glEnable(GLES20.GL_DEPTH_TEST)
GLES20.glEnable(GLES20.GL_BLEND)
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA)
val vertex_shader = "uniform mat4 u_modelViewProjectionMatrix;" +
"attribute vec3 a_vertex;" +
"attribute vec3 a_normal;" +
"varying vec3 v_vertex;" +
"varying vec3 v_normal;" +
"void main() {" +
"v_vertex = a_vertex;" +
"vec3 n_normal = normalize(a_normal);" +
"v_normal = n_normal;" +
"gl_Position = u_modelViewProjectionMatrix * vec4(a_vertex, 1.0);" +
"}"
val fragment_shader = "precision mediump float;" +
"uniform vec3 u_camera;" +
"uniform vec3 u_lightPosition;" +
"uniform sampler2D u_texture0;" +
"uniform sampler2D u_texture1;" +
"varying vec3 v_vertex;" +
"varying vec3 v_normal;" +
"vec3 myrefract(vec3 IN, vec3 NORMAL, float k) {" +
" float nv = dot(NORMAL,IN);" +
" float v2 = dot(IN,IN);" +
" float knormal = (sqrt(((k * k - 1.0) * v2) / (nv * nv) + 1.0) - 1.0) * nv;" +
" vec3 OUT = IN + (knormal * NORMAL);" +
" return OUT;" +
"}" +
"void main() {" +
" vec3 n_normal = normalize(v_normal);" +
" vec3 lightvector = normalize(u_lightPosition - v_vertex);" +
" vec3 lookvector = normalize(u_camera - v_vertex);" +
" float ambient = 0.1;" +
" float k_diffuse = 0.7;" +
" float k_specular = 0.3;" +
" float diffuse = k_diffuse * max(dot(n_normal, lightvector), 0.0);" +
" vec3 reflectvector = reflect(-lightvector, n_normal);" +
" float specular = k_specular * pow( max(dot(lookvector,reflectvector),0.0), 40.0);" +
" vec4 one = vec4(1.0,1.0,1.0,1.0);" +
" vec4 lightColor = (ambient + diffuse + specular) * one;" +
" vec3 OUT = myrefract(-lookvector, n_normal, 1.2);" +
" float ybottom = -1.0;" +
" float xbottom = v_vertex.x + OUT.x * (ybottom - v_vertex.y) / OUT.y;" +
" float zbottom = v_vertex.z + OUT.z * (ybottom - v_vertex.y) / OUT.y;" +
" vec2 texCoord = vec2(xbottom, zbottom);" +
" vec4 textureColor = texture2D(u_texture0, texCoord);" +
" textureColor.a *= 0.5;" +
" gl_FragColor = lightColor * textureColor;" +
"vec4 textureColor1 = texture2D(u_texture1, gl_FragCoord.xy);" +
//"gl_FragColor = mix(textureColor0, textureColor1, textureColor1.a) * lightColor;" +
"}"
val textureId = texture[1]
val options = BitmapFactory.Options()
options.inScaled = false
val bitmap1 = BitmapFactory.decodeResource(Resources.getSystem(), R.drawable.water, options)
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId)
m_shader = Shader(vertex_shader, fragment_shader)
m_shader!!.link_vertex_buffer(vertexes_buffer)
m_shader!!.link_normal_buffer(normales_buffer)
m_shader!!.link_texture(texture)
}
override fun onSurfaceChanged(gl: GL10, width: Int, height: Int) {
gl.glViewport(0, 0, width, height)
val ratio = width.toFloat() / height
val k = 0.0555f
val left = -k * ratio
val right = k * ratio
val bottom = -k
val near = 0.1f
val far = 10.0f
Matrix.frustumM(projection_matrix, 0, left, right, bottom, k, near, far)
Matrix.multiplyMM(
model_view_projection_matrix,
0,
projection_matrix,
0,
model_view_matrix,
0
)
}
override fun onDrawFrame(gl: GL10) {
m_shader!!.link_model_view_projection_matrix(model_view_projection_matrix)
m_shader!!.link_camera(x_camera, y_camera, z_camera)
m_shader!!.link_light_source(x_light_position, y_light_position, z_light_position)
get_vertexes()
get_normales()
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT or GLES20.GL_DEPTH_BUFFER_BIT)
GLES20.glDrawElements(
GLES20.GL_TRIANGLE_STRIP, size_index, GLES20.GL_UNSIGNED_SHORT,
index_buffer
)
}
}
|
bab8efb1262a2a64002fff4fc5d8e49f
|
{
"intermediate": 0.24224406480789185,
"beginner": 0.4923844337463379,
"expert": 0.2653714418411255
}
|
30,338
|
what does this stata code "#delimit ;" mean?
|
e9f5ba008f6a75c7b7df681c08a20b75
|
{
"intermediate": 0.23934030532836914,
"beginner": 0.2833731174468994,
"expert": 0.47728651762008667
}
|
30,339
|
def quick_sort(arr, low, high, k):
stack = []
stack.append((low, high))
while stack:
low, high = stack.pop()
if low < high:
pivot_index = partition(arr, low, high, k)
stack.append((low, pivot_index - 1))
stack.append((pivot_index + 1, high))
def partition(arr, low, high, k):
pivot = arr[high][k]
i = low - 1
for j in range(low, high):
if arr[j][k] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == ‘U’:
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
quick_sort(playersU, 0, len(playersU) - 1, 0)
quick_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
quick_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])减少这个程序在百万级输入时的运算速度
|
c03ad74f7a184c3ec43a26116fa14c90
|
{
"intermediate": 0.2075776308774948,
"beginner": 0.491933137178421,
"expert": 0.300489217042923
}
|
30,340
|
def quick_sort(arr, low, high, k):
stack = []
stack.append((low, high))
while stack:
low, high = stack.pop()
if low < high:
pivot_index = partition(arr, low, high, k)
stack.append((low, pivot_index - 1))
stack.append((pivot_index + 1, high))
def partition(arr, low, high, k):
pivot = arr[high][k]
i = low - 1
for j in range(low, high):
if arr[j][k] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
quick_sort(playersU, 0, len(playersU) - 1, 0)
quick_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
quick_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])减少这个程序在百万级输入时的运算速度
|
2ec23f592d77cfba2499172dee7dc473
|
{
"intermediate": 0.21786276996135712,
"beginner": 0.5340721011161804,
"expert": 0.24806515872478485
}
|
30,341
|
как залогиниться с помощью aiohttp, asyncio URL Запроса:
https://xms.miatel.ru/oauth/token
Метод Запроса:
POST
Код Статуса:
201 Created
Удаленный Адрес:
91.206.88.70:443
Правило Для URL Перехода:
no-referrer
Access-Control-Allow-Origin:
*
Access-Control-Expose-Headers:
Request-Id
Content-Length:
295
Content-Type:
application/cbor
Date:
Wed, 08 Nov 2023 08:01:21 GMT
Request-Id:
651100ae3113e087cd17fca263dc0e1f
Request-Time:
0.030
Server:
nginx
Vary:
Origin
:authority:
xms.miatel.ru
:method:
POST
:path:
/oauth/token
:scheme:
https
Accept:
application/cbor
Accept-Encoding:
gzip, deflate, br
Accept-Language:
ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Content-Length:
53
Content-Type:
application/cbor
Origin:
https://xms.miatel.ru
Sec-Ch-Ua:
"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"
Sec-Ch-Ua-Mobile:
?0
Sec-Ch-Ua-Platform:
"Windows"
Sec-Fetch-Dest:
empty
Sec-Fetch-Mode:
cors
Sec-Fetch-Site:
same-origin
User-Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
запрос сведений о полезной нагрузке £!#<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>$tzThiRDvQ6KOQa8QhzJsy
|
c6c5b959319272bc10a51e829d65a1fb
|
{
"intermediate": 0.4149497151374817,
"beginner": 0.30468741059303284,
"expert": 0.28036290407180786
}
|
30,342
|
def quick_sort(arr, low, high, k):
stack = []
stack.append((low, high))
while stack:
low, high = stack.pop()
if low < high:
pivot_index = partition(arr, low, high, k)
stack.append((low, pivot_index - 1))
stack.append((pivot_index + 1, high))
def partition(arr, low, high, k):
pivot = arr[high][k]
i = low - 1
for j in range(low, high):
if arr[j][k] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
quick_sort(playersU, 0, len(playersU) - 1, 0)
quick_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
quick_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])
优化该程序,使它面对百万级输入时能有更好地运算速度
|
fc15cebae89d8a6917d3942c4cb11817
|
{
"intermediate": 0.23229515552520752,
"beginner": 0.5058294534683228,
"expert": 0.26187536120414734
}
|
30,343
|
fix this code the multiplication is not working.
#include<stdio.h>
int main()
{
int m,n,p,q;
int matrix1[10][10], matrix2[10][10], sum[10][10], prd[10][10];
printf("Enter no of columns and rows for 1st matrix: \n");
scanf("%d%d", &m, &n);
printf("Enter no of columns and rows for 2nd matrix: \n");
scanf("%d%d", &p, &q);
if(m!=p || n!=q)
{
printf("Addition of the matrix is not possible");
}
else if(n!=p)
{
printf("Multiplication of the matrix is not possible");
}
else
{
printf("Enter the elements of 1st matrix: \t");
for (int i=0; i<m; i++)
{
for (int j=0; j<n; j++)
{
scanf("%d",&matrix1[i][j]);
}
}
printf("Enter the elements of 2nd matrix: \t");
for (int i=0; i<m; i++)
{
for (int j=0; j<n; j++)
{
scanf("%d",&matrix2[i][j]);
}
}
printf("\nFirst Matrix is: \n");
for (int i=0; i<m; i++)
{
for (int j=0; j<n; j++)
{
printf(" %d", matrix1[i][j]);
}
printf("\n");
}
printf("second Matrix is: \n");
for (int i=0; i<m; i++)
{
for (int j=0; j<n; j++)
{
printf(" %d", matrix2[i][j]);
}
printf("\n");
}
printf("Added Matrix is: \n");
for (int i=0; i<m; i++)
{
for (int j=0; j<n; j++)
{
sum[i][j] = matrix1[i][j] + matrix2[i][j];
printf(" %d", sum[i][j]);
}
printf("\n");
}
for (int i=0; i<m; i++)
{
for (int j=0; j<n; j++)
{
for (int k=0; k<n; k++)
{
prd[i][j] = prd[i][j] + matrix1[i][k] * matrix2[k][j];
}
printf("\n");
}
}
printf("multiplied Matrix is: \n");
for (int i=0; i<m; i++)
{
for (int j=0; j<n; j++)
{
printf(" %d", prd[i][j]);
}
printf("\n");
}
}
return 0;
}
|
3b59ec4074929c995aa4dc8cdb4fd8f7
|
{
"intermediate": 0.2968113124370575,
"beginner": 0.3983882665634155,
"expert": 0.304800420999527
}
|
30,344
|
In pandas, how to read only a few columns in the dta file?
|
7b5ce1d068af64a5c09918829521dd6a
|
{
"intermediate": 0.4445394277572632,
"beginner": 0.23261331021785736,
"expert": 0.3228472173213959
}
|
30,345
|
in R. Consider the example of calculating the probability of having "at least" two people having
the same birthday in a class size of 40. Write an R function
p(n,x) that will calculate this probability as a function of class size, n, and the number of
people, x, having the same birthday (at least x people). Draw, in R, a 3D graph showing this probability as a function
of n and x.
|
c51eb3ef02c9ba992f98f22007817a2e
|
{
"intermediate": 0.20893265306949615,
"beginner": 0.40758681297302246,
"expert": 0.3834805488586426
}
|
30,346
|
def merge(li, left, mid, right, k):
i = left
j = mid + 1
t = []
while i <= mid and j <= right:
m = li[i]
n = li[j]
if m[k] <= n[k]:
t.append(m)
i += 1
else:
t.append(n)
j += 1
while i <= mid:
t.append(li[i])
i += 1
while j <= right:
t.append(li[j])
j += 1
li[left: right+1] = t
def merge_sort(li, left, right, i):
if left < right:
mid = (left + right) // 2
merge_sort(li, left, mid, i)
merge_sort(li, mid + 1, right, i)
merge(li, left, mid, right, i)
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
merge_sort(playersU, 0, len(playersU) - 1, 0)
merge_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
merge_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])
增加多线程处理能力,加快其在百万级数据下的运算速度
|
c163daaf81d930bdb88cd0fcc60c697a
|
{
"intermediate": 0.2432171255350113,
"beginner": 0.496299147605896,
"expert": 0.2604837417602539
}
|
30,347
|
def merge(li, left, mid, right, k):
i = left
j = mid + 1
t = []
while i <= mid and j <= right:
m = li[i]
n = li[j]
if m[k] <= n[k]:
t.append(m)
i += 1
else:
t.append(n)
j += 1
while i <= mid:
t.append(li[i])
i += 1
while j <= right:
t.append(li[j])
j += 1
li[left: right+1] = t
def merge_sort(li, left, right, i):
if left < right:
mid = (left + right) // 2
merge_sort(li, left, mid, i)
merge_sort(li, mid + 1, right, i)
merge(li, left, mid, right, i)
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
merge_sort(playersU, 0, len(playersU) - 1, 0)
merge_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
merge_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])
优化该程序,使它在面对百万级输入时能有更快的输出(不考虑内存)
|
ffff7ca7343a8be7593bf52e920672a3
|
{
"intermediate": 0.2432171255350113,
"beginner": 0.496299147605896,
"expert": 0.2604837417602539
}
|
30,348
|
Write a python code for intel neural compressor for object detection
|
cd1531a99ac7b8dad599df351cc1bd12
|
{
"intermediate": 0.18337038159370422,
"beginner": 0.05745700001716614,
"expert": 0.7591726183891296
}
|
30,349
|
def merge(li, left, mid, right, k):
i = left
j = mid + 1
t = []
while i <= mid and j <= right:
m = li[i]
n = li[j]
if m[k] <= n[k]:
t.append(m)
i += 1
else:
t.append(n)
j += 1
while i <= mid:
t.append(li[i])
i += 1
while j <= right:
t.append(li[j])
j += 1
li[left: right+1] = t
def merge_sort(li, left, right, i):
if left < right:
mid = (left + right) // 2
merge_sort(li, left, mid, i)
merge_sort(li, mid + 1, right, i)
merge(li, left, mid, right, i)
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
merge_sort(playersU, 0, len(playersU) - 1, 0)
merge_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
merge_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])
优化该程序,使它面对百万级的n能有更好的输出速度
|
15b26f5b1b9a9de57d9d8f6ab2bf4736
|
{
"intermediate": 0.2432171255350113,
"beginner": 0.496299147605896,
"expert": 0.2604837417602539
}
|
30,350
|
correct code snipet
|
abba761e0b1ad111de28c9b70d49a694
|
{
"intermediate": 0.24363049864768982,
"beginner": 0.4337642788887024,
"expert": 0.3226052224636078
}
|
30,351
|
class Person:
data_base={
id:0,
"name":"NULL",
"age":0,
"car_name":"NULL",
"number_of_the_car":"NULL",
}
"Создание пользователя в базе данных"
def get_user_data(self,user_id,name,age,car_name,number_of_the_car):
data_base[user_id]["name"]=self.name
data_base[user_id]["age"]=self.age
data_base[user_id]["car_name"]=self.car_name
data_base[user_id]["number_of_the_car"]=self.number_of_the_car
def show(self):
print(f"""
Имя: {self.name}
Возраст: {self.age}
Марка автомобиля: {self.car_name}
Номер автомобиля: {self.number_of_the_car}
""")
A=Person()
user_id=1
name=input("Enter your name:")
age=input("Enter your age:")
car_name=input("Enter your car name:")
number_of_the_car=input("Enter your number of the car:")
A.get_user_data(user_id,name,age,car_name,number_of_the_car)
A.show()
|
4b64af4ee6f053c757cf2f71182836e0
|
{
"intermediate": 0.26173993945121765,
"beginner": 0.5322791337966919,
"expert": 0.20598089694976807
}
|
30,352
|
a docker container based on ubuntu image is already running, how to enter to bash of the container in windows
|
725bb80dcc1f9c0cb4dc235590c47868
|
{
"intermediate": 0.3423752188682556,
"beginner": 0.31481844186782837,
"expert": 0.34280624985694885
}
|
30,353
|
this code is ok but i want to know beforehand if the addition or multiplication is possible.
#include<stdio.h>
int main()
{
int m, n, p, q;
int matrix1[10][10], matrix2[10][10], sum[10][10], prd[10][10];
printf("Enter the number of columns and rows for the 1st matrix: \n");
scanf("%d %d", &m, &n);
printf("Enter the number of columns and rows for the 2nd matrix: \n");
scanf("%d %d", &p, &q);
printf("Enter the elements of the 1st matrix: \n");
for(int i=0; i<m; i++)
{
for(int j=0; j<n; j++)
{
scanf("%d", &matrix1[i][j]);
}
}
printf("Enter the elements of the 2nd matrix: \n");
for(int i=0; i<p; i++)
{
for(int j=0; j<q; j++)
{
scanf("%d", &matrix2[i][j]);
}
}
printf("\nFirst Matrix is: \n");
for(int i=0; i<m; i++)
{
for(int j=0; j<n; j++)
{
printf("%d\t", matrix1[i][j]);
}
printf("\n");
}
printf("Second Matrix is: \n");
for(int i=0; i<p; i++)
{
for(int j=0; j<q; j++)
{
printf("%d\t", matrix2[i][j]);
}
printf("\n");
}
if(m != p)
{
printf("Addition of the matrices is not possible\n");
}
else
{
printf("Added Matrix is: \n");
for(int i=0; i<m; i++)
{
for(int j=0; j<q; j++)
{
if(i < p && j < n)
{
sum[i][j] = matrix1[i][j] + matrix2[i][j];
printf("%d\t", sum[i][j]);
}
else if(i >= p && j >= n)
{
sum[i][j] = matrix2[i][j];
printf("%d\t", sum[i][j]);
}
else if(i >= p)
{
sum[i][j] = matrix1[i][j];
printf("%d\t", sum[i][j]);
}
else if(j >= n)
{
sum[i][j] = matrix1[i][j];
printf("%d\t", sum[i][j]);
}
}
printf("\n");
}
}
if(n != p)
{
printf("Multiplication of the matrices is not possible\n");
}
else
{
printf("\nMultiplied Matrix is: \n");
for(int i=0; i<m; i++)
{
for(int j=0; j<q; j++)
{
prd[i][j] = 0;
for(int k=0; k<n; k++)
{
prd[i][j] += matrix1[i][k] * matrix2[k][j];
}
printf("%d\t", prd[i][j]);
}
printf("\n");
}
}
return 0;
}
|
2b80bcc6ea1ba03079b6ef16fb07ad2b
|
{
"intermediate": 0.2475554645061493,
"beginner": 0.48481428623199463,
"expert": 0.26763030886650085
}
|
30,354
|
def merge(li, left, mid, right, k):
i = left
j = mid + 1
t = []
while i <= mid and j <= right:
m = li[i]
n = li[j]
if m[k] <= n[k]:
t.append(m)
i += 1
else:
t.append(n)
j += 1
while i <= mid:
t.append(li[i])
i += 1
while j <= right:
t.append(li[j])
j += 1
li[left: right+1] = t
def merge_sort(li, left, right, i):
if left < right:
mid = (left + right) // 2
merge_sort(li, left, mid, i)
merge_sort(li, mid + 1, right, i)
merge(li, left, mid, right, i)
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
merge_sort(playersU, 0, len(playersU) - 1, 0)
merge_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
merge_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])优化程序使这个程序能多线程处理
|
f196aaf18528e77e3a9107c2f860964b
|
{
"intermediate": 0.2432171255350113,
"beginner": 0.496299147605896,
"expert": 0.2604837417602539
}
|
30,355
|
create an app for the best italian restaurant in london
|
6e4e92fc8ada175247f339ccbda1599e
|
{
"intermediate": 0.32721513509750366,
"beginner": 0.18983928859233856,
"expert": 0.4829455614089966
}
|
30,356
|
import sys
def partition(arr, low, high, k):
pivot = arr[high][k]
i = low - 1
for j in range(low, high):
if arr[j][k] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def quick_sort(arr, low, high, k):
stack = []
stack.append((low, high))
while stack:
low, high = stack.pop()
if low < high:
pivot_index = partition(arr, low, high, k)
stack.append((low, pivot_index - 1))
stack.append((pivot_index + 1, high))
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(sys.stdin.readline().strip())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = sys.stdin.readline().strip().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
playersU.sort(key=lambda x: x[0])
playersD.sort(key=lambda x: x[0])
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
players.sort(key=lambda x: x[2])
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])优化程序,使它能在8秒内完成百万级输入的运算
|
f9a8c049c36c42c476663f7a31693039
|
{
"intermediate": 0.2754287123680115,
"beginner": 0.42510244250297546,
"expert": 0.2994688153266907
}
|
30,357
|
1.1 Description
Imagine a group of n players that are located in different floors. The i-th player (for each i such that
1 ≤ i ≤ n, where i is an integer) is characterized by the following:
• pi
, a unique starting floor level
• hi
, a starting HP (Health Points) value
• di
, a direction of movement, either U indicating that the i-th player is going upward or D indicating
that the i-th player is going downward
All players move simultaneously at the same speed in their respective directions. When two players
meet, they engage in a battle. The player with the lower health is eliminated instantaneously, while
the other continue to move in the same direction at the same speed but with a reduced HP by 1. In a
case where two players have identical HP, they are both eliminated simultaneously after the battle.
Your task is to determine the final HP of the surviving players.
1.2 Input
The first line of input contains an integer n, representing the number of players.
The next n lines follow.
The i-th line contains three values: pi
, hi
, di - an integer representing the starting floor level for the
i-th player, an integer representing the HP value for the i-th player, and a character representing the
direction of movement for the i-th player.
write A python program to solve it
|
5bf8b07ca6efaf7a617e83b54abb32b3
|
{
"intermediate": 0.3420460522174835,
"beginner": 0.30199819803237915,
"expert": 0.35595569014549255
}
|
30,358
|
func AddOrUpdateVirtualHost(vh *route.VirtualHost, routeName string) error {
lock.Lock()
defer lock.Unlock()
routes := snapshot.Resources[types.Route].Items
rs, ok := routes[routeName]
if !ok {
return fmt.Errorf("unknown route config name: %s", routeName)
}
routeConfig, ok := rs.Resource.(*route.RouteConfiguration)
if !ok {
return fmt.Errorf("resource cannot cast to RouteConfiguration")
}
for i := range routeConfig.VirtualHosts {
if routeConfig.VirtualHosts[i].Name == vh.Name {
routeConfig.VirtualHosts = append(routeConfig.VirtualHosts[:i], routeConfig.VirtualHosts[i+1:]...)
break
}
}
routeConfig.VirtualHosts = append([]*route.VirtualHost{vh}, routeConfig.VirtualHosts...)
oldVersion, _ := strconv.Atoi(snapshot.Resources[types.Route].Version)
snapshot.Resources[types.Route].Version = fmt.Sprintf("%d", oldVersion+1)
return snapshotCache.SetSnapshot(ctx, nodeID, snapshot)
} 单元测试
|
8d033c38d0d27df8adc5c6af325f21a6
|
{
"intermediate": 0.2991585433483124,
"beginner": 0.44490399956703186,
"expert": 0.25593751668930054
}
|
30,359
|
如果不使用numpy,可以使用普通的Python列表来存储玩家数据,并对代码进行一些其他优化,如减少循环次数和避免不必要的操作。以下是修改后的代码示例:
import sys
import multiprocessing as mp
def partition(arr, low, high, k):
pivot = arr[high][k]
i = low - 1
for j in range(low, high):
if arr[j][k] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def quick_sort(arr, low, high, k):
if low < high:
pivot_index = partition(arr, low, high, k)
quick_sort(arr, low, pivot_index - 1, k)
quick_sort(arr, pivot_index + 1, high, k)
def determine_final_hp(data):
playerU = data[0]
playerD = data[1]
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return data
def process_data(floor_hp_direction):
floor, hp, direction = floor_hp_direction[0], floor_hp_direction[1], floor_hp_direction[2]
if direction == ‘U’:
return [int(floor), int(hp), 0] # 0表示上半场
else:
return [int(floor), int(hp), 1] # 1表示下半场
n = int(sys.stdin.readline().strip())
players = []
for _ in range(n):
floor_hp_direction = sys.stdin.readline().strip().split()
players.append(process_data(floor_hp_direction))
playersU = [player for player in players if player[2] == 0]
playersD = [player for player in players if player[2] == 1]
processes = []
pool = mp.Pool(processes=mp.cpu_count())
playersU, playersD = pool.map(determine_final_hp, [(playersU, playersD)])[0]
pool.close()
quick_sort(playersU, 0, len(playersU) - 1, 0)
quick_sort(playersD, 0, len(playersD) - 1, 0)
players = playersU + playersD
quick_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])
这种修改方式避免了使用numpy,使用普通的Python列表来存储玩家数据,同时进行了一些优化来减少循环次数和避免不必要的操作。请注意,对于百万级数据来说,使用纯Python的列表可能会导致一些性能问题。如果需要处理更大规模的数据,可以考虑使用其他的高性能数据结构或者将数据存储到磁盘上并使用分布式计算框架来处理。
Traceback (most recent call last):
File “<string>”, line 1, in <module>
File “C:\Users\HKY\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py”, line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File “C:\Users\HKY\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py”, line 125, in _main
prepare(preparation_data)
File “C:\Users\HKY\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py”, line 236, in prepare
_fixup_main_from_path(data[‘init_main_from_path’])
File “C:\Users\HKY\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py”, line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File “C:\Users\HKY\AppData\Local\Programs\Python\Python39\lib\runpy.py”, line 288, in run_path
return _run_module_code(code, init_globals, run_name,
File “C:\Users\HKY\AppData\Local\Programs\Python\Python39\lib\runpy.py”, line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File “C:\Users\HKY\AppData\Local\Programs\Python\Python39\lib\runpy.py”, line 87, in _run_code
exec(code, run_globals)
File “C:\Users\HKY\AppData\Roaming\JetBrains\PyCharmCE2022.2\scratches\scratch_5.py”, line 47, in <module>
n = int(sys.stdin.readline().strip())
ValueError: invalid literal for int() with base 10: ‘’
|
5c692028fb4cc9f9f21abc9b9912f7a2
|
{
"intermediate": 0.33953964710235596,
"beginner": 0.42050638794898987,
"expert": 0.2399539351463318
}
|
30,360
|
Write a c# function that calculates the best fit for a bunch of points
|
4965a68728a4b167b71854928332794a
|
{
"intermediate": 0.21550436317920685,
"beginner": 0.29532158374786377,
"expert": 0.4891740381717682
}
|
30,361
|
Write a c# function that calculates the best fit of a bunch of points but minimizes the overall path of he polynomial
|
7426c32fa353ec04745aa960bf3c1752
|
{
"intermediate": 0.26249492168426514,
"beginner": 0.1630079746246338,
"expert": 0.5744970440864563
}
|
30,362
|
import sys
def partition(arr, low, high, k):
pivot = arr[high][k]
i = low - 1
for j in range(low, high):
if arr[j][k] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def quick_sort(arr, low, high, k):
if low < high:
pivot_index = partition(arr, low, high, k)
quick_sort(arr, low, pivot_index - 1, k)
quick_sort(arr, pivot_index + 1, high, k)
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(sys.stdin.readline().strip())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = sys.stdin.readline().strip().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
quick_sort(playersU, 0, len(playersU) - 1, 0)
quick_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
quick_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])优化该程序,使它在面对百万级输入时能有更好表现
|
ee89a1f811355c4d079a4a8baef3afef
|
{
"intermediate": 0.28226181864738464,
"beginner": 0.48638883233070374,
"expert": 0.23134930431842804
}
|
30,363
|
import sys
def partition(arr, low, high, k):
pivot = arr[high][k]
i = low - 1
for j in range(low, high):
if arr[j][k] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def quick_sort(arr, low, high, k):
if low < high:
pivot_index = partition(arr, low, high, k)
quick_sort(arr, low, pivot_index - 1, k)
quick_sort(arr, pivot_index + 1, high, k)
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(sys.stdin.readline().strip())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = sys.stdin.readline().strip().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
quick_sort(playersU, 0, len(playersU) - 1, 0)
quick_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
quick_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])优化该程序
|
396c0b0ab070fb2d9006c830b1200d5f
|
{
"intermediate": 0.2793278098106384,
"beginner": 0.4601101875305176,
"expert": 0.260562002658844
}
|
30,364
|
what different between primitive or reducible or irreducible
|
944bc7e4654519cd1e7bfcd783599f24
|
{
"intermediate": 0.29817360639572144,
"beginner": 0.3160255551338196,
"expert": 0.38580089807510376
}
|
30,365
|
def merge(li, left, mid, right, k):
i = left
j = mid + 1
t = []
while i <= mid and j <= right:
m = li[i]
n = li[j]
if m[k] <= n[k]:
t.append(m)
i += 1
else:
t.append(n)
j += 1
while i <= mid:
t.append(li[i])
i += 1
while j <= right:
t.append(li[j])
j += 1
li[left: right+1] = t
def merge_sort(li, left, right, i):
if left < right:
mid = (left + right) // 2
merge_sort(li, left, mid, i)
merge_sort(li, mid + 1, right, i)
merge(li, left, mid, right, i)
def determine_final_hp(playerU, playerD):
for i in range(len(playerD)):
for j in range(len(playerU)):
k = len(playerU) - j - 1
playeri = playerD[i]
playerj = playerU[k]
if playeri[0] >= playerj[0] and playeri[1] > 0 and playerj[1] > 0:
if playeri[1] < playerj[1]:
playeri[1] = 0
playerj[1] -= 1
elif playeri[1] > playerj[1]:
playerj[1] = 0
playeri[1] -= 1
else:
playeri[1] = 0
playerj[1] = 0
return playerU, playerD
n = int(input())
playersU = []
playersD = []
players = []
for i in range(n):
floor, hp, direction = input().split()
if direction == 'U':
playersU.append([int(floor), int(hp), i])
else:
playersD.append([int(floor), int(hp), i])
merge_sort(playersU, 0, len(playersU) - 1, 0)
merge_sort(playersD, 0, len(playersD) - 1, 0)
playersU, playersD = determine_final_hp(playersU, playersD)
for u in range(len(playersU)):
players.append(playersU[u])
for d in range(len(playersD)):
players.append(playersD[d])
merge_sort(players, 0, len(players) - 1, 2)
for i in range(len(players)):
player = players[i]
if player[1] != 0:
print(player[1])优化该程序,使它能更好地面对大数字
|
4946e97208c90937d5781ef68968ec31
|
{
"intermediate": 0.2432171255350113,
"beginner": 0.496299147605896,
"expert": 0.2604837417602539
}
|
30,366
|
give me apython code for the game super mario bros
|
9770d1a88901fd087bf4f05eb152685f
|
{
"intermediate": 0.5422220230102539,
"beginner": 0.2247956544160843,
"expert": 0.23298227787017822
}
|
30,367
|
привет! как в nodejs проверить что существует таблица в MS SQL
|
c5f8994cddbee73dd84b5f869036fbb2
|
{
"intermediate": 0.5399169325828552,
"beginner": 0.2476360946893692,
"expert": 0.21244697272777557
}
|
30,368
|
incompatible types when assigning to type ‘struct file’ from type ‘struct file *’
|
7eed34c4a9f64dfe12595ac7bdd9a8c0
|
{
"intermediate": 0.40529847145080566,
"beginner": 0.26659390330314636,
"expert": 0.328107625246048
}
|
30,369
|
write command prompt code for taking incremental file backup
|
1220ef2a92185734977799e60c4c4b6d
|
{
"intermediate": 0.41362231969833374,
"beginner": 0.2524994909763336,
"expert": 0.3338782489299774
}
|
30,370
|
how to use func in sqlalchemy
|
2ae652f1d2b80e446bdce46c3814a8f4
|
{
"intermediate": 0.5426334738731384,
"beginner": 0.2896491289138794,
"expert": 0.16771741211414337
}
|
30,371
|
func generateTransportSocket(conf *anypb.Any) *core.TransportSocket {
return &core.TransportSocket{
Name: "envoy.transport_sockets.tls",
ConfigType: &core.TransportSocket_TypedConfig{
TypedConfig: conf,
},
}
}编写单元测试
|
86c51b9ac96e905fbf71a4ec9a3744ce
|
{
"intermediate": 0.35636529326438904,
"beginner": 0.29019370675086975,
"expert": 0.35344094038009644
}
|
30,372
|
how to delete the story in the widget are my Stream in iSymphony
|
ec4ac68e965f789c75dd9d5bf0cc95ef
|
{
"intermediate": 0.3970396816730499,
"beginner": 0.27866601943969727,
"expert": 0.3242943286895752
}
|
30,373
|
I need to use Draft.js createEmpty method to reset the EditorState, however the problem is that the button I need to assign the reset function to is placed a few components above from the the component in which EditorState that determines the state of the component is defined. What can I do?
|
57ef874dec72abe9cae374a2e4a7beb8
|
{
"intermediate": 0.6557871103286743,
"beginner": 0.18567493557929993,
"expert": 0.15853798389434814
}
|
30,374
|
hello world application with c++
|
8ede36f3cf7f768f9f54c1f8f4c1a179
|
{
"intermediate": 0.41146236658096313,
"beginner": 0.3249204158782959,
"expert": 0.2636171877384186
}
|
30,375
|
package com.example.dht11;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class MainActivity extends AppCompatActivity {
private MqttClient client;
private MqttConnectOptions options;
private Handler handler;
private ScheduledExecutorService scheduler;
private String mode;
private int led_state;
private String productKey = "k0bct3pO6p0";
private String deviceName = "STM32APP";
private String deviceSecret = "ad951232c8feb2419a84a58d805dad2b";
private final String pub_topic = "/sys/k0bct3pO6p0/STM32APP/thing/event/property/post";
private final String sub_topic = "/sys/k0bct3pO6p0/STM32APP/thing/service/property/set";
private int temperature =0;
private int humidity =0;
private int humi_thre =0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv_temp = findViewById(R.id.tv_temp);
TextView tv_humi = findViewById(R.id.tv_humi);
TextView tv_mode = findViewById(R.id.tv_mode);
TextView tv_humi_thre = findViewById(R.id.tv_humi_thre);
TextView tv_led_state = findViewById(R.id.tv_led_state);
Button btn_open = findViewById(R.id.btn_open);
Button btn_close = findViewById(R.id.btn_close);
btn_open.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//开
publish_message("{\"params\":{\"LED_STATE\":0},\"version\":\"1.0.0\"}");
}
});
btn_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//关
publish_message("{\"params\":{\"LED_STATE\":1},\"version\":\"1.0.0\"}");
}
});
mqtt_init();
start_reconnect();
handler = new Handler() {
@SuppressLint("SetTextI18n")
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 1: //开机校验更新回传
break;
case 2: // 反馈回传
break;
case 3: //MQTT 收到消息回传 UTF8Buffer msg=new UTF8Buffer(object.toString());
String message = msg.obj.toString();
Log.d("nicecode", "handleMessage: "+ message);
try {
JSONObject jsonObjectALL = null;
jsonObjectALL = new JSONObject(message);
JSONObject items = jsonObjectALL.getJSONObject("items");
JSONObject obj_temp = items.getJSONObject("TEMP");
JSONObject obj_humi = items.getJSONObject("HUMI");
JSONObject obj_mode = items.getJSONObject("MODE");
JSONObject obj_led_state = items.getJSONObject("LED_STATE");
JSONObject obj_humi_thre = items.getJSONObject("HUMI_LIMIT");
temperature = obj_temp.getInt("value");
humidity = obj_humi.getInt("value");
mode = obj_mode.getString("value");
humi_thre = obj_humi_thre.getInt("value");
led_state = obj_led_state.getInt("value");
tv_temp.setText(temperature + "");
tv_humi.setText(humidity + "");
if(mode.equals("Gateway Mode")==true)
{
tv_mode.setText("网关工作模式" + "");
}else{
tv_mode.setText("普通控制模式" + "");
}
tv_humi_thre.setText(humi_thre + "");
if(led_state==1)
{
tv_led_state.setText("关" + "");
}else{
tv_led_state.setText("开" + "");
}
Log.d("nicecode", "TEMP: "+ temperature);
Log.d("nicecode", "HUMI: "+ humidity);
Log.d("nicecode", "MODE: "+ mode);
Log.d("nicecode", "HUMI_LIMIT: "+ humi_thre);
Log.d("nicecode", "LED_STATE: "+ led_state);
} catch (JSONException e) {
e.printStackTrace();
break;
}
break;
case 30: //连接失败
Toast.makeText(MainActivity.this, "连接失败", Toast.LENGTH_SHORT).show();
break;
case 31: //连接成功
Toast.makeText(MainActivity.this, "连接成功", Toast.LENGTH_SHORT).show();
try {
client.subscribe(sub_topic, 1);
} catch (MqttException e) {
e.printStackTrace();
}
break;
default:
break;
}
}
};
}
private void mqtt_init() {
try {
String clientId = "a1MoTKOqkVK.test_device1";
Map<String, String> params = new HashMap<String, String>(16);
params.put("productKey", productKey);
params.put("deviceName", deviceName);
params.put("clientId", clientId);
String timestamp = String.valueOf(System.currentTimeMillis());
params.put("timestamp", timestamp);
// cn-shanghai
String host_url ="tcp://"+ productKey + ".iot-as-mqtt.cn-shanghai.aliyuncs.com:1883";
String client_id = clientId + "|securemode=2,signmethod=hmacsha1,timestamp=" + timestamp + "|";
String user_name = deviceName + "&" + productKey;
String password = com.example.dht11.AliyunIoTSignUtil.sign(params, deviceSecret, "hmacsha1");
//host为主机名,test为clientid即连接MQTT的客户端ID,一般以客户端唯一标识符表示,MemoryPersistence设置clientid的保存形式,默认为以内存保存
System.out.println(">>>" + host_url);
System.out.println(">>>" + client_id);
//connectMqtt(targetServer, mqttclientId, mqttUsername, mqttPassword);
client = new MqttClient(host_url, client_id, new MemoryPersistence());
//MQTT的连接设置
options = new MqttConnectOptions();
//设置是否清空session,这里如果设置为false表示服务器会保留客户端的连接记录,这里设置为true表示每次连接到服务器都以新的身份连接
options.setCleanSession(false);
//设置连接的用户名
options.setUserName(user_name);
//设置连接的密码
options.setPassword(password.toCharArray());
// 设置超时时间 单位为秒
options.setConnectionTimeout(10);
// 设置会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端发送个消息判断客户端是否在线,但这个方法并没有重连的机制
options.setKeepAliveInterval(60);
//设置回调
client.setCallback(new MqttCallback() {
@Override
public void connectionLost(Throwable cause) {
//连接丢失后,一般在这里面进行重连
System.out.println("connectionLost----------");
}
@Override
public void deliveryComplete(IMqttDeliveryToken token) {
//publish后会执行到这里
System.out.println("deliveryComplete---------" + token.isComplete());
}
@Override
public void messageArrived(String topicName, MqttMessage message)
throws Exception {
//subscribe后得到的消息会执行到这里面
System.out.println("messageArrived----------");
Message msg = new Message();
//封装message包
msg.what = 3; //收到消息标志位
msg.obj =message.toString();
//发送messge到handler
handler.sendMessage(msg); // hander 回传
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
private void mqtt_connect() {
new Thread(new Runnable() {
@Override
public void run() {
try {
if (!(client.isConnected())) //如果还未连接
{
client.connect(options);
Message msg = new Message();
msg.what = 31;
// 没有用到obj字段
handler.sendMessage(msg);
}
} catch (Exception e) {
e.printStackTrace();
Message msg = new Message();
msg.what = 30;
// 没有用到obj字段
handler.sendMessage(msg);
}
}
}).start();
}
private void start_reconnect() {
scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
if (!client.isConnected()) {
mqtt_connect();
}
}
}, 0 * 1000, 10 * 1000, TimeUnit.MILLISECONDS);
}
private void publish_message(String message) {
if (client == null || !client.isConnected()) {
return;
}
MqttMessage mqtt_message = new MqttMessage();
mqtt_message.setPayload(message.getBytes());
try {
client.publish(pub_topic, mqtt_message);
} catch (MqttException e) {
e.printStackTrace();
}
}
}帮我修改完善上述代码,使得点击两个按钮能够通过阿里云平台控制灯的状态,其中阿里云平台中灯的状态标识符为LED_STATE,数据类型为bool型,0代表开,1代表关
|
222459e5b8749c029e835edcfd75914f
|
{
"intermediate": 0.29651495814323425,
"beginner": 0.5216310620307922,
"expert": 0.1818540394306183
}
|
30,376
|
how to cancel the current git add . stage
|
0665f6c3c03496b8d95f63b86abc1000
|
{
"intermediate": 0.3604528307914734,
"beginner": 0.2959727644920349,
"expert": 0.3435744047164917
}
|
30,377
|
Why this const handleObligation = (obligationName : number) =>{
setIncome(obligationName);
setTaxesForm(prev => {return ({...taxesForm,
healthRyc: ZusZdrowotnyRyczalt12(),
healthRycLinear: ZusZdrowotnyLiniowy19(),
healthRycCommon: ZusZdrowotnyOgolny(),
pensionContributions: (4161 * 0.1952),
pensionRentalContributions: (4161 * 0.08),
sicknessContributions: (4161 * 0.0245),
accidentPremiums: (4161 * 0.0167),
solidariyPremiums: (4161 * 0.0245)
})});
//ZusZdrowotnyRyczalt12();
//ZusZdrowotnyLiniowy19();
//ZusZdrowotnyOgolny();
// Pension contributions: PLN 210.82 (19.52% of PLN 1080) Pension
// contributions: PLN 86.40 (8% of 1080zl) Sickness contributions: PLN 26.46
// (2.45% of 1080zl) Accident premiums: PLN 18.04 (1.67% of 1080zl)
// setPensionContributions(4161 * 0.1952); setPensionRentalContributions(4161 *
// 0.08); setSicknessContributions(4161 * 0.0245); setAccidentPremiums(4161 *
// 0.0167); setSolidariyPremiums(4161 * 0.0245); zlicz zusy zdrowotne
var summary = taxesForm.pensionContributions + taxesForm.pensionRentalContributions + taxesForm.accidentPremiums + taxesForm.solidariyPremiums;
if (isSicknessContributionsCalculated)
summary = taxesForm.sicknessContributions;
//setZushealthRycSummary(healthRyc + summary);
//setZushealth19Summary(healthRycLinear + summary);
//setZushealthCommonSummary(healthRycCommon + summary);
setTaxesForm(prev =>{return{...taxesForm,
zushealth19Summary: taxesForm.healthRyc + summary,
zushealthCommonSummary: taxesForm.healthRycLinear + summary,
zushealthRycSummary: taxesForm.healthRycCommon + summary
}});
console.log('taxesForm ', taxesForm);
} does not update taxesForm object?
|
295f081a4ee6f3ac36eaae87675d3a6b
|
{
"intermediate": 0.3225184381008148,
"beginner": 0.5255680680274963,
"expert": 0.15191352367401123
}
|
30,378
|
hey, i'm new in opengl, help me with example code
|
275824643c390764e2d66390544f8f13
|
{
"intermediate": 0.4138396680355072,
"beginner": 0.35789546370506287,
"expert": 0.22826479375362396
}
|
30,379
|
what is mean "recurcive" in cte in sqlalchemy
|
e07871e840dca5aae45cd644eb664c09
|
{
"intermediate": 0.41919541358947754,
"beginner": 0.3665485382080078,
"expert": 0.21425603330135345
}
|
30,380
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarioController : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 5f;
public float ladderClimbSpeed = 2f;
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 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 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(rb2d.velocity.x, climbDirection * ladderClimbSpeed);
rb2d.gravityScale = 0f; // Disable gravity while climbing
}
else if (climbingLadder)
{
rb2d.gravityScale = 1f; // Enable gravity when not climbing
rb2d.velocity = new Vector2(rb2d.velocity.x, 0f);
}
else
{
rb2d.gravityScale = 1f; // Enable gravity when not climbing
}
// Move Mario horizontally
rb2d.velocity = new Vector2(movement * moveSpeed, rb2d.velocity.y);
// Flip Mario’s sprite based on his movement direction
if (movement > 0)
{
transform.localScale = new Vector3(1f, 1f, 1f); // Facing right
}
else if (movement < 0)
{
transform.localScale = new Vector3(-1f, 1f, 1f); // Facing left
}
}
}
make it so if a barrel collides with mario his health will be set to 0 and the scene will reset
|
adeb2dc3dfd4e1634fbaa89de1bcda40
|
{
"intermediate": 0.32432451844215393,
"beginner": 0.500567615032196,
"expert": 0.17510782182216644
}
|
30,381
|
make the game super mario bros wonder in c++
|
048b9d620f6402e66d5c15ad94037c37
|
{
"intermediate": 0.2833740711212158,
"beginner": 0.3505445420742035,
"expert": 0.3660813868045807
}
|
30,382
|
When I open a paticular worksheet, in the worksheet activate eevent,
I want cell D15 to be written with the text "Service Events"
Can you write the line of code that can do this
|
b84ac1dab6911c7b829a86ae3f29ff81
|
{
"intermediate": 0.4205182194709778,
"beginner": 0.26415154337882996,
"expert": 0.3153301775455475
}
|
30,383
|
how can I modify my totalSentiment method so that it produces more reasonable ratings
|
69a0886c7f55dbdcdc73bd3eca0223a2
|
{
"intermediate": 0.29766717553138733,
"beginner": 0.16994184255599976,
"expert": 0.5323910713195801
}
|
30,384
|
como le pongo una capa de normalizacion a este modelo? import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import numpy as np
def main():
# Cargar los datos
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
# Preprocesar los datos
x_train = x_train.reshape(x_train.shape[0], 784)
x_train = x_train.astype("float32") / 255
x_test = x_test.reshape(x_test.shape[0], 784)
x_test = x_test.astype("float32") / 255
datagen = ImageDataGenerator(rotation_range=10, zoom_range=0.1, width_shift_range=0.1, height_shift_range=0.1)
datagen.fit(x_train.reshape(-1, 28, 28, 1))
# Crear el modelo
model = Sequential()
model.add(Dense(512, activation='relu', input_shape=(784,)))
model.add(Dropout(0.2))
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(10, activation='softmax'))
# Compilar el modelo
model.compile(loss="sparse_categorical_crossentropy", optimizer="adam", metrics=["accuracy"])
# Entrenar el modelo
model.fit(datagen.flow(x_train.reshape(-1, 28, 28, 1), y_train, batch_size=32), epochs=10)
# Guardar el modelo en un archivo
model.save('models/mlpMNIST.h5')
# Evaluar el modelo
score = model.evaluate(x_test, y_test, verbose=0)
print("Pérdida:", score[0])
print("Precisión:", score[1])
if __name__ == "__main__":
main()
|
a4085faf6ee94426b15256906f17f793
|
{
"intermediate": 0.4227488934993744,
"beginner": 0.18562574684619904,
"expert": 0.39162537455558777
}
|
30,385
|
explain how indexOf() works in java
|
64c558ab9aac39251d9e3ebe77bb0ee5
|
{
"intermediate": 0.615809440612793,
"beginner": 0.2210332304239273,
"expert": 0.16315731406211853
}
|
30,386
|
const HOST = 'localhost'
const PORT = 8080
const express = require('express')
const app = express()
const sqlite = require('sqlite3').verbose()
const db = new sqlite.Database('database.db')
//theme atlantic night
db.serialize(() => {
db.run("CREATE TABLE IF NOT EXISTS users (id INTENGER PRIMARY KEY, username TEXT, password TEXT, email EMAIL)")
})
const parser = express.urlencoded({extended: false});
app.use('/static', express.static(__dirname + '/static'))
app.set('view engine', 'ejs')
app.get('/favicon.ico', (req, res) => {
res.sendFile(__dirname + '/static/img/favicon.png')
})
app.get('/auth/register', (req, res) => {
const q = req.query
const err = req.query.e
if (err) {
res.render('auth/register', {error: err})
}
res.render('auth/register')
})
app.post('/auth/register/submit', parser, (req, res) => {
const bd = req.body
const username = bd.username
const password = bd.password
const confirm = bd.confirm
const email = bd.email
var exists
db.get("SELECT * FROM users WHERE usename = " + username, (err, row) => {
try {
var id = row.id
exists = true
} catch {
exists = false
}
})
if (password != confirm) {
res.redirect('/auth/register?e=Passwords+don\'t+match')
} else if (exists) {
res.redirect('/auth/register?e=Username+already+exists')
} else {
db.run("INSERT INTO users (username, password, email) VALUES ('" + username + "', '" + password + "', '" + email + "')")
res.redirect('/account')
}
})
app.listen(PORT, HOST, () => {console.log(`Server started at http://${HOST}:${PORT}`)})
but when i register id is null
|
0f7431549ab2973a614ff16bba19c384
|
{
"intermediate": 0.5107932090759277,
"beginner": 0.30027109384536743,
"expert": 0.18893569707870483
}
|
30,387
|
peux tu me montrer le test unitaire de la fonction wihtdraw qui permet au gagnant de retirer la mise totale ? "function withdraw(uint256 _gameId, uint256 _amount) public payable {
require(state == State.finished, "game is not over");
require(msg.sender == games[_gameId].player1 || msg.sender == games[_gameId].player2, "You re not a player");
address winner = games[_gameId].winner;
require(msg.sender == winner, "You are not the winner");
require(!games[_gameId].player1HasWithdrawn || !games[_gameId].player2HasWithdrawn, "withdrawn balance");
require(playerBalances[_gameId][winner].balance >= _amount, "insufficient balance");
playerBalances[_gameId][winner].balance -= _amount;
(bool success, ) = payable(winner).call{value: _amount}("");
require(success, "The withdrawal failed");
if (winner == games[_gameId].player1) {
games[_gameId].player1HasWithdrawn = true;
} else {
games[_gameId].player2HasWithdrawn = true;
}
emit Withdraw(_gameId);
}"
|
92311af43063efd26805f65cca09de91
|
{
"intermediate": 0.49040016531944275,
"beginner": 0.2860180139541626,
"expert": 0.22358186542987823
}
|
30,388
|
I need a function that can make eigen::triplets from std::vector<size_t>. The rule of creating of one triplet is triplet(x=vector[i], y=i, value=1). The function must return triplets
|
39ff0fc3d9e4405df2fdda3a259eadd0
|
{
"intermediate": 0.3847920000553131,
"beginner": 0.32414036989212036,
"expert": 0.2910676598548889
}
|
30,389
|
can you sort a table of strings based on the column "Asset Name"
|
9bb27a3829feebc0e6e25b4408251907
|
{
"intermediate": 0.38273438811302185,
"beginner": 0.16768565773963928,
"expert": 0.4495798945426941
}
|
30,390
|
peux me montrer le test uintaire de la fonction "withdraw"en prenant en compte la fonction "proposeWord"? : "function proposeWord(uint256 _gameId, string memory _wordToGuess, string memory _letterToGuess) public {
require(state == State.inProgress, "Bad State");
require(msg.sender == games[_gameId].player1 || (msg.sender == games[_gameId].player2 &&
games[_gameId].isPlayer2Turn),"invalid address");
require(playerBalances[_gameId][msg.sender].balance > 0, "you didn't bet");
string memory filteredWord = wordFiltered(_wordToGuess);
address winner = isWinner(_gameId, msg.sender, filteredWord);
if (winner != address(0)) {
games[_gameId].winner = winner;
addBetToPlayer(_gameId, winner);
emit WordWin(_gameId, filteredWord);
emit GameFinished(_gameId);
updateStateFinished();
} else {
if (msg.sender == games[_gameId].player2) {
games[_gameId].isPlayer2Turn = false;
proposeLetter(_gameId, _letterToGuess, _wordToGuess);
} else {
if (msg.sender == games[_gameId].player1) {
games[_gameId].isPlayer2Turn = true;
proposeLetter(_gameId, _letterToGuess, _wordToGuess);
}
}
}
}" "function withdraw(uint256 _gameId, uint256 _amount) public payable {
require(state == State.finished, "game is not over");
require(msg.sender == games[_gameId].player1 || msg.sender == games[_gameId].player2, "You re not a player");
address winner = games[_gameId].winner;
require(msg.sender == winner, "You are not the winner");
require(!games[_gameId].player1HasWithdrawn || !games[_gameId].player2HasWithdrawn, "withdrawn balance");
require(playerBalances[_gameId][winner].balance >= _amount, "insufficient balance");
playerBalances[_gameId][winner].balance -= _amount;
(bool success, ) = payable(winner).call{value: _amount}("");
require(success, "The withdrawal failed");
if (winner == games[_gameId].player1) {
games[_gameId].player1HasWithdrawn = true;
} else {
games[_gameId].player2HasWithdrawn = true;
}
emit Withdraw(_gameId);
}"
|
d48fb8db32dfd3617391f49dae29f6ed
|
{
"intermediate": 0.4102720022201538,
"beginner": 0.37584158778190613,
"expert": 0.21388646960258484
}
|
30,391
|
I have some Eigen::SparseMatrix<size_t> (let's call them matrix_blocks) with the same size of row, make a fuction that can combine them into one matrix. The user defines order of combaining matrix_blocks and defines which matrix_blocks he wants to combine
|
4498813a374dee4712de7fe772aacd83
|
{
"intermediate": 0.3674703538417816,
"beginner": 0.1840604692697525,
"expert": 0.4484691917896271
}
|
30,392
|
Can you give me a script for a main menu in roblox
|
32b3c70e48d41a1606c0b49f0e1b7fa3
|
{
"intermediate": 0.4357188642024994,
"beginner": 0.2563072443008423,
"expert": 0.3079738914966583
}
|
30,393
|
I need a function that can combine matrix blocks. Blocks has the same size of rows. The combined matrix will have the same number of rows as blocks and the number of cols will be the sum of all numbers of coll of each block. The user just defines which blocks he wants to combine (for example block A, block B, block C and block D)
|
3f925457bb65d7f37b9cce57b12acb0a
|
{
"intermediate": 0.43460598587989807,
"beginner": 0.2600439488887787,
"expert": 0.30535009503364563
}
|
30,394
|
Помоги мне правильно объединить 4 матрицы. Вот мой код но там есть ошибка: Eigen::SparseMatrix<size_t> combained(sou_matrix_block.rows(), sou_matrix_block.cols() + rec_matrix_block.cols() + cdp_matrix_block.cols() + off_matrix_block.cols());
//Eigen::MatrixXd result(S, N + M + K + L);
combained.block(0, 0, sou_matrix_block.rows(), sou_matrix_block.cols()) = sou_matrix_block;
combained.block(0, sou_matrix_block.cols(), sou_matrix_block.rows(), rec_matrix_block.cols()) = rec_matrix_block;
combained.block(0, sou_matrix_block.cols() + rec_matrix_block.cols(), sou_matrix_block.rows(), cdp_matrix_block.cols()) = cdp_matrix_block;
combained.block(0, sou_matrix_block.cols() + rec_matrix_block.cols() + cdp_matrix_block.cols(), sou_matrix_block.rows(), off_matrix_block.cols()) = cdp_matrix_block;
|
92a6285601531a96ae119b2916c0bee7
|
{
"intermediate": 0.37918010354042053,
"beginner": 0.3650726079940796,
"expert": 0.2557472884654999
}
|
30,395
|
Hi There I currently Have a Script that will delete the first two characters only if they are letters in the first column of a CSV File. It also Deletes the Header Row first before attempting this. I want to change this so that if there are more than 2 letters it will still delete them but only if they are letters leaving all numbers behind. Can you revise this for me? Leaving my UI and other Features?
|
a5aed7cb6398d7525266281e8620adc8
|
{
"intermediate": 0.5953734517097473,
"beginner": 0.15296441316604614,
"expert": 0.25166213512420654
}
|
30,396
|
Помоги мне правильно объединить 4 матрицы. Вот мой код но там есть ошибка C2338 "THIS_SPARCE_BLOCK_SUBEXPRESSION_IS_READ_ONLY":
Eigen::SparseMatrix<size_t> combained(sou_matrix_block.rows(), sou_matrix_block.cols() + rec_matrix_block.cols() + cdp_matrix_block.cols() + off_matrix_block.cols());
combained.block(0, 0, sou_matrix_block.rows(), sou_matrix_block.cols()) = sou_matrix_block;
combained.block(0, sou_matrix_block.cols(), sou_matrix_block.rows(), rec_matrix_block.cols()) = rec_matrix_block;
combained.block(0, sou_matrix_block.cols() + rec_matrix_block.cols(), sou_matrix_block.rows(), cdp_matrix_block.cols()) = cdp_matrix_block;
combained.block(0, sou_matrix_block.cols() + rec_matrix_block.cols() + cdp_matrix_block.cols(), sou_matrix_block.rows(), off_matrix_block.cols()) = off_matrix_block;
Возможно я неправильно объединяю Eigen::SparseMatrix<size_t> в один?
|
02cfffaef875ad8d3cbb5eedd7feb2b5
|
{
"intermediate": 0.3384021520614624,
"beginner": 0.27070048451423645,
"expert": 0.3908974230289459
}
|
30,397
|
привет мне в unity нужно считать json фаил а если его нет то создать, он должен хранить в себе словарь из key int и value string
|
d6177866fa31fe7a57841462a5494f49
|
{
"intermediate": 0.3384222388267517,
"beginner": 0.3852695822715759,
"expert": 0.27630820870399475
}
|
30,398
|
Помоги мне правильно объединить 4 матрицы. Вот мой код но там есть ошибка C2338 “THIS_SPARCE_BLOCK_SUBEXPRESSION_IS_READ_ONLY”:
Eigen::SparseMatrix<size_t> combained(sou_matrix_block.rows(), sou_matrix_block.cols() + rec_matrix_block.cols() + cdp_matrix_block.cols() + off_matrix_block.cols());
combained.block(0, 0, sou_matrix_block.rows(), sou_matrix_block.cols()) = sou_matrix_block;
combained.block(0, sou_matrix_block.cols(), sou_matrix_block.rows(), rec_matrix_block.cols()) = rec_matrix_block;
combained.block(0, sou_matrix_block.cols() + rec_matrix_block.cols(), sou_matrix_block.rows(), cdp_matrix_block.cols()) = cdp_matrix_block;
combained.block(0, sou_matrix_block.cols() + rec_matrix_block.cols() + cdp_matrix_block.cols(), sou_matrix_block.rows(), off_matrix_block.cols()) = off_matrix_block;
Возможно я неправильно объединяю Eigen::SparseMatrix<size_t> в один?
|
c20b3bf84e00467e5b3db29c10b142e5
|
{
"intermediate": 0.3304711878299713,
"beginner": 0.2925770878791809,
"expert": 0.37695178389549255
}
|
30,399
|
how to pull a single result per customer nbr knowing there are more than one row per customer (a Y if one of the columns meets the condition and N if none of the rows meet the condition)
|
ce397f4e971dbca84704218773753936
|
{
"intermediate": 0.27500155568122864,
"beginner": 0.16196712851524353,
"expert": 0.5630313754081726
}
|
30,400
|
Create a program SimpleMethod.java with method maxMinSumSquareRt() that takes three double
values as arguments, calculates the sum of the largest and smallest value and returns the square root
of the sum. In your method you can use methods of the class Math. Run (main method) the method
maxMinSumSquareRt(double a, double b, double c) in the same class with three parameters of your
choice and print out the result on the command line. write it shortly please without scanner
|
616b5ffee747acf90860079bce6da3be
|
{
"intermediate": 0.33877167105674744,
"beginner": 0.4420665204524994,
"expert": 0.21916185319423676
}
|
30,401
|
HI there I want to write a LSP routine that sets the layer state from a prompted selection of state to every drawing you have open in your session.
|
a0594affc439033c5ae2d236992fe531
|
{
"intermediate": 0.29066845774650574,
"beginner": 0.07066342979669571,
"expert": 0.6386681199073792
}
|
30,402
|
Hey there. I want to Create a LISP routine for Autodesk Civil 3D 2022 that will go into every viewport within the layouts of the drawing and set the layer state to a selection of my choice.
|
1c54345b590d82aa02c5d2b5cd14989a
|
{
"intermediate": 0.3868241310119629,
"beginner": 0.251456618309021,
"expert": 0.3617193400859833
}
|
30,403
|
give me a script for sprinting on roblox
|
1a60cbe51641aa435d0b96e53576e939
|
{
"intermediate": 0.5120988488197327,
"beginner": 0.24785932898521423,
"expert": 0.2400418072938919
}
|
30,404
|
I have a large workbook with numerous sheets.
The sheets contain a lot of formulas.
Is there a VBA code that can prevent all the cells that contain formulas from being edited, changed or deleted.
|
d1cc3698c1546f401d7143a66a7188d6
|
{
"intermediate": 0.4946853220462799,
"beginner": 0.13144280016422272,
"expert": 0.3738718330860138
}
|
30,405
|
I want to use Excel 365 VBA to open a Windows Explorer window to allow me to search for a document when I click a button in a cell
|
09d6b67e84de505db1ac74f4ae7451c1
|
{
"intermediate": 0.47841936349868774,
"beginner": 0.24913820624351501,
"expert": 0.27244237065315247
}
|
30,406
|
use recurcive cte
|
7b44c070de28ae73b616f8df2560d9c1
|
{
"intermediate": 0.2944158613681793,
"beginner": 0.4726431369781494,
"expert": 0.23294098675251007
}
|
30,407
|
у меня есть код который считывает json в unity но он не может считать его если сборка под webGL нужно все переделать с использованием UnityWebRequest
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class JsonManager : MonoBehaviour
{
private const string PathPDF = "PDFConfig/PathPDF.json";
private string jsonFilePath = Path.Combine(Application.streamingAssetsPath, PathPDF);
private Dictionary<int, string> myDictionary = new Dictionary<int, string>();
private void Awake()
{
// Проверяем, существует ли файл
if (File.Exists(jsonFilePath))
{
// Если файл существует, считываем его содержимое
string json = File.ReadAllText(jsonFilePath);
myDictionary = JsonUtility.FromJson<DictionaryWrapper>(json).ToDictionary();
}
else
{
// Если файла нет, создаем новый словарь
myDictionary = new Dictionary<int, string>();
// Добавляем пары ключ-значение в словарь
myDictionary.Add(1, "путь к пдф для первой зоны");
myDictionary.Add(2, "путь к пдф для второй зоны");
myDictionary.Add(3, "путь к пдф для третей зоны");
myDictionary.Add(4, "путь к пдф для четвертой зоны");
myDictionary.Add(5, "путь к пдф для ОД зоны");
// Сохраняем словарь в JSON файл
SaveDictionaryToJson();
}
}
public string GetPathPDF(int value)
{
return myDictionary[value];
}
private void SaveDictionaryToJson()
{
// Сериализуем словарь в JSON формат
string json = JsonUtility.ToJson(new DictionaryWrapper(myDictionary));
// Сохраняем JSON строку в файл
File.WriteAllText(jsonFilePath, json);
}
}
[System.Serializable]
public class DictionaryWrapper
{
public List<KeyValueWrapper> dictionaryList;
public DictionaryWrapper(Dictionary<int, string> dictionary)
{
dictionaryList = new List<KeyValueWrapper>();
foreach (var pair in dictionary)
{
dictionaryList.Add(new KeyValueWrapper(pair.Key, pair.Value));
}
}
public Dictionary<int, string> ToDictionary()
{
var dictionary = new Dictionary<int, string>();
foreach (var wrapper in dictionaryList)
{
dictionary.Add(wrapper.key, wrapper.value);
}
return dictionary;
}
}
[System.Serializable]
public class KeyValueWrapper
{
public int key;
public string value;
public KeyValueWrapper(int key, string value)
{
this.key = key;
this.value = value;
}
}
|
27ec3cc9541a2bd72e58e5fc96142e17
|
{
"intermediate": 0.41593047976493835,
"beginner": 0.42247942090034485,
"expert": 0.1615900993347168
}
|
30,408
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BarrelSpawner : MonoBehaviour
{
public GameObject barrelPrefab;
public Transform[] spawnPoints; // Points where barrels will be spawned
public float spawnInterval = 3f; // Interval between barrel spawns
private bool isSpawning = true;
private void Start()
{
InvokeRepeating("SpawnBarrel", 0f, spawnInterval);
}
private void SpawnBarrel()
{
int spawnIndex = Random.Range(0, spawnPoints.Length);
Transform spawnPoint = spawnPoints[spawnIndex];
Instantiate(barrelPrefab, spawnPoint.position, Quaternion.identity);
}
public void StopSpawning()
{
isSpawning = false;
CancelInvoke("SpawnBarrel");
}
}
Add to this script to make it so that upon the start function 4 barrels are spawned in at each of the respective positions: (-6, -3.25, 0), (6, 1.25,0), (-6, 0.75, 0), (6, 2.75, 0)
|
c102bd9b542cf976d682a815628a6689
|
{
"intermediate": 0.3664869964122772,
"beginner": 0.4466891288757324,
"expert": 0.18682384490966797
}
|
30,409
|
I want to create a LISP Routine for Autodesk Civil 3d 2022.
|
678794d97f4f7bdc6dcff7759422ac3e
|
{
"intermediate": 0.21303856372833252,
"beginner": 0.2437809407711029,
"expert": 0.5431804656982422
}
|
30,410
|
Writing a lisp for Autodesk Civil 3d 2022. I will send the script. On line 26 I'm getting a member not found Error. this script is to gather the data from a layer including the area of any present hatches. length of lines, and length of any poly lines. it will then sort that data and put it into a CSV that is saved to the desktop.
|
29f852e83959fbe5adffb7bf3ad6b15e
|
{
"intermediate": 0.5287931561470032,
"beginner": 0.2859139144420624,
"expert": 0.18529294431209564
}
|
30,411
|
Do you know which of the irregular verbs in Spanish are most common? I'd like to generate a deck in Anki I can use to learn the language.
I want to include 30 most common irregular verbs. For each of the verb there should be 6 cards generated. I want every card in the deck to provide one sentence (Spanish on one side, English on the other side). So for every verb I want to have one card per verb's conjugation in Present tense.
Example: one of the 30 verbs could be the verb "ser". I want one sentence with "soy", one with "eres", one with "es", one with "somos", one with "sois" and one with "son". This way I get one sentence for each verb's conjugation in the Present tense so I can fully learn all forms of the irregular verbs in Present tense.
I want to do this for 30 most common irregular verbs. So there should be 50 * 6 = 300 pairs of Spanish-English sentences (Anki cards).
Can you help me?
|
24c87cc92e802b64fb70b1c6926408b1
|
{
"intermediate": 0.2995086908340454,
"beginner": 0.24585019052028656,
"expert": 0.45464110374450684
}
|
30,412
|
залогиниться с помощью aiohttp asyncio на python URL Запроса:
https://xms.miatel.ru/oauth/token
Метод Запроса:
POST
Код Статуса:
201 Created
Удаленный Адрес:
91.206.88.70:443
Правило Для URL Перехода:
no-referrer
Access-Control-Allow-Origin:
*
Access-Control-Expose-Headers:
Request-Id
Content-Length:
295
Content-Type:
application/cbor
Date:
Wed, 08 Nov 2023 08:01:21 GMT
Request-Id:
651100ae3113e087cd17fca263dc0e1f
Request-Time:
0.030
Server:
nginx
Vary:
Origin
:authority:
xms.miatel.ru
:method:
POST
:path:
/oauth/token
:scheme:
https
Accept:
application/cbor
Accept-Encoding:
gzip, deflate, br
Accept-Language:
ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Content-Length:
53
Content-Type:
application/cbor
Origin:
https://xms.miatel.ru
Sec-Ch-Ua:
"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"
Sec-Ch-Ua-Mobile:
?0
Sec-Ch-Ua-Platform:
"Windows"
Sec-Fetch-Dest:
empty
Sec-Fetch-Mode:
cors
Sec-Fetch-Site:
same-origin
User-Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
|
61d89f56489dd42e0e5da01a1b2a4751
|
{
"intermediate": 0.40956538915634155,
"beginner": 0.32751771807670593,
"expert": 0.26291683316230774
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.