instruction stringlengths 71 95.1k |
|---|
I am trying to write a NDK program for quicksorting an array. However, in my benchmarks C is doing consistently worse than Java, as indicated by my results:
Java 1190625
C 1809218
Java 895104
C 1372656
Java 1104792
C 1491198
Java 10766875
C 14929115
Java 9200104
C 9770833
Java 5740782
C 9177135
Could someone help me?
p... |
I have implemented mathematical functions using a C# library. I basically need to output data by the RiskMatrixByFunds in the following format.
Key will contain Id and value will contain collection of string, double, double
For example:
Id 1
value
{'ArithmeticMean', 12.34, 3.44},
{'AverageGain', 12.35, 3.45},
{'Aver... |
I wrote my own implementation of the linux cat command in C for my computer laboratory class. We were asked to replicate its functionality with no options passed as arguments or with just the -b, -n and -s options.
I'm posting the code here because, although it works fine, i feel a little bit insecure about. Firstly b... |
For an Information System Security course I've applied to, I need to learn C and decided to start learning it yesterday.
Conway's Game of Life has historically been a good project to start with, so I picked it. Here's a GIF of the end result (sorry about the wobble; it's just simple console printing so the result isn't... |
I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the p... |
I'm trying to find pangrams ie sentences that contain all the letters of the alphabet, for instance "The quick brown fox jumps over the lazy dog".
I'm an absolute beginner in elisp, and it ended up being a really difficult exercice for me. My idea what to put all the letters in a set check if all the letters of the alp... |
This project is... a little ridiculous. It's working, but it's a complete mess.
Data about Factorio's game economy are pulled from the wiki via the MediaWiki API, scrubbed, preprocessed, and thrown into Scipy for linear programming analysis using the MOSEK interior point method.
The pull script only depends on requests... |
I would like to do the following:
I have a list data of 3-tuples that I need to go through, for each tuple base_tuple I want to know the index index_max of the maximum value held in base_tuple and replace base_tuple with a new 3-tuple new_tuple that only holds 0s except for the value at index index_max which is set at ... |
I'm not good at English.
It's gonna be hard to read.
I apologize in advance.
I need expression parser for draw diagram(fault tree).
In order to do that I have to create data structure from custom expression
( (123-A1) AND (123-A2) AND (123-A3) OR (123-A4 AND (123-A5 OR 123-A6)) )
The above example was written ... |
I need a function that checks how different are two different strings. I chose the Levenshtein distance as a quick approach, and implemented this function:
from difflib import ndiff
def calculate_levenshtein_distance(str_1, str_2):
"""
The Levenshtein distance is a string metric for measuring the differenc... |
Being unable to easily read the output of /proc/net/tcp I made a small C# console app that modifies the output to be in decimal notation instead of the standard hexadecimal, show the corresponding enum states of the state code and added the ability to filter out remote addresses. With the ability to further tweak to yo... |
This is a c# class I use to implement web database applications with Microsoft IIS and Microsoft SQL server. It passes the http context to a selected SQL stored procedure, and writes a response based on the result sets generated by the stored procedure. Thus the entire application is coded as SQL stored procedures, apa... |
I'm writing a service for a ORPG and I expect traffic of about 10kb of packets per second from multiple clients. I just want to know if my approach is correct? Are there areas I can improve?
This is a bit basic the full app would have a lot more handlers and packet structs.
package main
import (
"bytes"
"encod... |
The task:
Given a string which we can delete at most k, return whether you can
make a palindrome.
For example, given 'waterrfetawx' and a k of 2, you could delete f and
x to get 'waterretaw'.
The following solution is partially inspired by @Oh My Goodness's answer.
const s = "waterrfetawx";
const del = 2;
functi... |
I wrote two versions of vector class for my ray tracer. Non-SIMD version and SIMD version. You can find the code below. I want to ask what things should I keep in mind to get max performance with SIMD. I am not getting any performance gain with this. I turned off compiler optimizations and still no results.
#ifndef INC... |
Review for optimization, code standards, missed validation.
What's in this version:
Rewritten, instead of large complex script - few tools with each own
task.
Solid CLI tool and GUI script on top of it.
Apply all previous code reviews on new code.
Some improvements from myself
Input arguments as usual and pass users/p... |
I created a universal OpenGL object RAII wrapper class, that only takes care of object creation and destruction. Here's my code and reasoning behind it:
I first wrote a class that would take glCreate/Delete*() function pointers as constructor arguments, but I quickly realized that's not the right way to go. I'd have to... |
How do I simplify else if statements? I want the code to be able to run a bunch of code based on the users input, such as bring to link for some of them, so I am not looking for
alert (prompt)
BELOW IS AN EXAMPLE
var prompt = prompt ("Test");
if (prompt == "test1"){
alert ("test1")
}
else if (prompt == "Test2"){
al... |
This method takes a comment object and displays it correctly depending on what columns are available. EVENT_TEXT and REASON_TEXT are hashes that map properties to more human readable strings, like so
EVENT_TEXT = { edit_item: 'edited an item' }
REASON_TEXT = { pickup_date: 'a pickup date change' }
The method that call... |
I'm working on my implementaion of the linux wc command. I finally have something that is working properly (with no options yet) but i think it needs a lot of "cleaning". I mean, i highly disrespect the "do not repeat yourself rule" and i want to hear some ideas on how can i polish this up a bit.
Here 's the code:
#inc... |
I have a list of objects each with a unique Key and a display name (Label). The list needs to remain sorted by the keys of each object but unfortunately the keys need to be strings rather than numerical and as such 'sorted' here refers to the keys being sorted alphabetically rather than numerically. (Although the keys ... |
I want to pass time interval as a string (to program args) and then I want to parse it to TimeSpan. I created simple class:
public static class TimeSpanConverter
{
public static TimeSpan Convert(string input)
{
var units = new Dictionary<string, int>()
{
{@"(\... |
Problem Statement
You are given a string, S , consisting of lowercase English letters.
A string is beautiful with respect S to if it can be derived from S by removing exactly 2 characters.
Find and print the number of different strings that are beautiful with respect to S.
Input Format
A single string of lowercase En... |
I've been trying to learn Groovy lately and I tried to solve a problem which involves designing a routine that will calculate the average Product price per Group.
I have the following data:
// contains information about [Product, Group, Cost]
products = [
["A", "G1", 20.1],
["B", "G2", 98.4],
["C", "G1", 49... |
I implemented a card game using pygame, the game is a game of war and using png files that I made in Microsoft paint. I tried to keep the object classes as separated from the pygame module as possible. The idea of this is so I can use the CardClasses module with other graphical interfaces, and to reuse it on different ... |
I'm in the process of creating a n-puzzle solver in Clojurescript. I have the basic model up and running and can move tiles on the screen. I plan to implement A* or such an algorithm to solve a given puzzle. Before I do that, I welcome any general comments for improving the quality of the code right now.
I am just past... |
I have a working script that will batch add users to an instance of nextcloud running on top of docker. This version is the result of changes made after asking this question.
I guess I'm looking for a re-review to ensure that I haven't missed anything. I'm also interested if there are areas where I could make things be... |
I have below code which will fetch the text from json & onclick text , display pop up box in page.... Now i need to give options to change font-family, font color....
But Adding the code in the place of Content is going to be extremely difficult....
Is there any way so that i can improve code structure or write same co... |
I am new to spark. I have two dataframes df1 and df2. df1 has three rows. df2 has more than few million rows. I want to check whether all items in df2 are in transaction of df1, if so sum up the costs. Example as follows:
df1 = spark.createDataFrame(
[(1, [(1), (4), (2) ,(3)])],
("id", "transaction")
)
df2 = spar... |
I am trying to apply a function to each group in a pandas dataframe where the function requires access to the entire group (as opposed to just one row). For this I am iterating over each group in the groupby object. Is this the best way to achieve this?
import pandas as pd
df = pd.DataFrame({'id': [1,1,1,1,2,2,2],
... |
I was presented with an interview question described as follows:
Receiving an int[] A of cities, where each A[i] has an appeal value. We want to plan our trip based on the highest appeal possible, taking in mind that is calculated as follows A[i] + A[j] + (i - j). This means the appeal values of 2 cities summed, plus t... |
I have come up with the following method to remove sensitive information with the help of the garbage collector:
def wipe_sensitive_info(d, keys):
"""
In Python we are not able to overwrite memory areas. What we do is:
- remove references to the specified objects, in this case keys in a dictionary
- imm... |
So, I am new to VS and C#, I am self-teaching to get a better understanding of the back-end of the product I work with. I have created a small database with some information and a Login form. Everything appears to compile correctly but is that the security way to do that or there is another way, any help is appreciated... |
Description
Given a class, return all its subclasses (recursively).
As you can see I've eliminated recursion using a stack.
What I want reviewed
Is there a better way to do this?
How can I make this code more generic and easier to use?
Is it pythonic?
Better way to eliminate recursion?
Code
def all_subclasses(cls):... |
#!/bin/bash
reset
echo "Creating output folder to Desktop/CombinedText and final passwordlist will show up as Final0Duplicates.txt"
##Functions##
##output file detection and creation##
function Dependency_Check
{
file2='~/Desktop/backupwordlist'
if [ ! -f "$file2" ]
touch "$file2"
file2='~/Des... |
I'm a python dev by day trying to learn C.
This is a simple implementation of a singly linked list. As a noob I would like comments on style and C conventions as well as functional remarks on memory management etc.
#include <stdio.h>
#include <stdlib.h>
/*
--------linkedList---------
| ... |
This code is one of the models developed for the Book Inventory application that is open for review. It is also based on a comment on this answer to a C# question. Based on the comment I did some research and found this stackoverflow question.
The code presented for review is the database model for a series of books in... |
I made my first Python project with the help of Tkinter. I was trying to make it works like iPhone calculator. I am a beginner and I am looking for ways to improve my code.
I use PyCharm and got rid of all warnings, but I still think that code isn't clear enough. I know that I must comment my code, but I am going to d... |
I wrote a program for a problem in Harvard's CS50 course, Vigenere (week 2).
Here is a description of what the program needs to do:
Design and implement a program that encrypts messages using Vigenère’s cipher.
Implement your program in a file called vigenere.c in a directory
called vigenere.
Your program must acce... |
I'm currently a 3rd year computer science student and lecturers have never checked the readability and maintainability of code. We were only marked on our outputs and as such I've written some truly horrible looking code in the past. I'm trying to work on that and one thing I've learned is that it's a good idea to put ... |
I created my cross-platform implementations of getline function in C.
It takes different arguments and have different return values than 'original' getline function, but aim is the same. The only argument input_file is file from which the line have to be read. Return value is the line read from file or NULL if nothing... |
I wrote a function that joins a collection of Strings with a delimiter. It's based on Java's version of the function. I'm assuming C has some similar built-in.
Example:
int main() {
char* coll[] = {"Hello", "World", "This", "Should", "Be", "Joined!"};
char* joined = awfulJoinStr(", ", coll, 6);
printf("%s\... |
I need help simplifying this Python code. I'm new, this adventure game is one of my first projects. I have tried simplifying my code already and this was the best result I could get.
import time
import random
r = random.randrange(10)
#r is the weapon being used for gun
#pauses the story
def print_pause(lines):
fo... |
I created a class to automate some requests for an API. Can I improve this code in any way?
The code itself is very simple and easy to understand.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Thread... |
New to Java, just finished the Helsinki MOOC course. I programmed a basic mortgage calculator as my first solo project and while it works, I have a few questions about coding style:
The listener and ui classes are cluttered with variables at the top. Is this acceptable or is there a cleaner way of organizing it?
Is in... |
I'm new to C language and never got my self into the details of UTF-8, and after reading some articles about it, I wanted to try and play with UTF-8 with C language for both fun and practicing purposes. This is a little C library that is supposed to validates UTF-8 strings, counts chars, guesses the language of the str... |
The task:
You are given an array of length n + 1 whose elements belong to the
set {1, 2, ..., n}. By the pigeonhole principle, there must be a
duplicate. Find it in linear time and space.
const lst = [1,2,3,4,5,6,7,8,7];
My functional solution:
const findDuplicate = lst => {
const set = new Set();
let ret;
... |
Brief Preface
I recognize that there are many nuances and requirements for a standard-compatible allocator. There are a number of questions here covering a range of topics associated with allocators. I realize that the requirements set out by the standard are critical to ensuring that the allocator functions correctl... |
I want to get version from Cargo.toml and use the value inside my app. Here is a function I wrote:
use std::fs;
pub fn get_version() -> &'static str {
let text = fs::read_to_string("Cargo.toml").unwrap();
for line in text.split("\n") {
if line.starts_with("version") {
let start = line.find(... |
I am using the music metadata-browser npm package to retrieve audio metadata from files. This library is being used in an Electron and React desktop app.
To get the metadata of audio files, (and add it to the redux state), I use the following function to get metadata and add the file to redux state. This method works ... |
I am new to rust and to start learning the language I decided to implement a simple one-time pad encryption program.
The part I am least sure about is the reading and writing from the files. Ideally this would run efficiently on large files.
use clap::{Arg, App};
use std::{
error::Error,
fs::File,
io::{
... |
The task:
Given an array of integers, return a new array where each element in
the new array is the number of smaller elements to the right of that
element in the original input array.
For example, given the array [3, 4, 9, 6, 1], return [1, 1, 2, 1, 0],
since:
There is 1 smaller element to the right of 3
There... |
I have two different series in pandas that I have created a nested for loop which checks if the values of the first series are in the other series. But this is time consuming in pandas and I cannot work out how to change it to a pandas method. I thought to use the apply function but it did not work with method chaining... |
I have a web application where my users can upload text documents and emails into what I call Streams. A stream is like a "stack", that holds all emails / documents.
My users can then add fields to the stream, and field_rules. This means, that every time a new document or email is added, the text content of the documen... |
I have a function to check if a character is a delimiter and I wonder if it is consistent or can be improved:
int chDelimit(int ch)
{
return
(ch == '\n' || ch == '\t') ||
(ch >= ' ' && ch <= '/') ||
(ch >= ':' && ch <= '@') ||
(ch >= '[' && ch <= '`') ||
(ch >= '{' && ch <= '... |
I want some JavaScript code to take 3 things as parameters:
A function returning a Promise.
The maximum number of attempts.
The delay between each attempt.
What I ended up doing is using a for loop. I did not want to use a recursive function : this way, even if there are 50 attempts the call stack isn't 50 lines long... |
UPDATE
New regex - covers escaped slashes and uses lazy qualifiers:
/(?>(')(?>(?>\\\\)|\\'|.)*')|(?>(")(?>(\\\\)|(?>\\")|.)*")|(?>((?>\/\/|#)).*^)|(?>(\/\*).*\*\/)/msU
Here are the different parts:
Single quotes: (?>(')(?>(?>\\\\)|\\'|.)*')
Double quotes: (?>(")(?>(\\\\)|(?>\\")|.)*")
Single line comments: (?>((?>\/\/... |
I am using Python 3 and pandas 0.24.2 to do some data processing and ETL flows. I have followed this pattern a couple of times and it is really bothering me but I am not sure which direction to go to majorly improve it. Any advice for what to do differently is greatly appreciated. This is a toy example but the logic is... |
Context
I am trying to get some practice with Django and Django REST framework.
As a toy example I want to set up a server to which I can POST results of automated test runs.
In the simplest version, a test result contains the following information:
a testcase id, which is unique and will never change
a testcase name,... |
This is based off the popular Pokemon Turn Based project (here).
GOAL
Write a simple game that allows the user and the computer to take
turns selecting moves to use against each other. Both the computer and
the player should start out at the same amount of health (such as
100), and should be able to choose betw... |
In an Ionic App a user can open a new browser via "inAppBrowser". I'm trying to get the stats of the user before they go into to the inAppBrowser, get the stats again when browser closes, and then run a function to compare the before and after.
What I have right now is working but I feel like I'm not doing it the prop... |
I wrote a generator class which implements Fast Poisson Disk Sampling algorithm in Python. I did some optimizations like, x ** 2 -> x * x, using unpacking instead of indexing, move unpacking outside of loops and precalculating of constants (like 2 * pi), but still not very pleased with results. Is it possible to speed ... |
Can someone help me to create a generic method that validates common fields/variables comes from multiple objects, if that is possible?
The below code validates some bunch of variables/fields from a schema object, so here the requirement is I have two different schema objects which has common Fields/variables, Is it po... |
This is my first program written outside of using books and tutorials. Any help on style and functionality would be helpful.
import sys
from textwrap import dedent
import os
import random
os.system('CLS')
# board number setup
board = [0,1,2,
3,4,5,
6,7,8]
# Defines the board layout printed to t... |
I am currently study the basic data structure and trying to implement everything as I go. can anyone give me some feedback about class BinarySearchTree how to make the code more elegant. any review are appreciated.
class TreeNode:
def __init__(self, value=None, left=None, right=None):
self.val = value
... |
I'm starting using hooks, and I have a specific scenario that I'm thinking useEffectis appropriate for.
Essentially what I'm doing is:
I have some ssiData in the redux store.
If that data has an invite code, and the invite isn't already accepted, then I want to display a QR code
If the invite is accepted, then this... |
The task:
Given a string of parentheses, write a function to compute the minimum
number of parentheses to be removed to make the string valid (i.e.
each open parenthesis is eventually closed).
For example, given the string "()())()", you should return 1. Given
the string ")(", you should return 2, since we must ... |
This is my first program with C# and VS and was originally a VBA Add-In I wrote. I have embarked on this as a learning exercise. The code does work and provides the desired output in a new workbook.
The code below is called from a button on a custom ribbon created in Excel. It collects data from other workbooks w/o ope... |
Requirements
Display movie datas inside all tags that have the class movie_list
Make an ajax call for fetching movie datas
Fill loading text before fetch data
If any error occurs during loading, the content should be empty
What I did
Cached all elements which have the class movie_list
Made functions which have only... |
I am trying to clear my localstorage when I am logging out of the application. I want to write a unit test case in Jasmine to check if this task is performed when logout function is run. I am writing test cases for the first time so got stuck in the approach.
In my compoment.ts file I have a logout function:
logout() {... |
In this post, I attempted to compare the performance of two concurrency constructs:
java.util.concurrent.Semaphore,
ReentrantReadWriteLock.
The idea is to increment/read an int in a thread-safe manner.
net.coderodde.concurrent.fun.ConcurrentInt:
package net.coderodde.concurrent.fun;
import java.util.logging.Level;
... |
Problem
I have written code to solve this challenge:
Given a formula:
GCD(x,y) means the GCD (Greatest Common Divisor) of x and y.
For example: if N=2, then:
f(2) = 1/GCD(1, 4) + 2/GCD(2, 4) + 3/GCD(3, 4) + 4/GCD(4,4)
f(2) = 1/1 + 2/2 + 3/1 + 4/4
f(2) = 1 + 1 + 3 + 1
f(2) = 6
Given N, find f(N).
Output:
Value of f(... |
I'm pretty new to Qt but already have a little experience with C++ so the first "project" I wanted to try out was a GUI random number generator.
I am looking for some advices either in naming conventions or OOP architecture, what should I do better and what I'm already doing good. The code is really short so there is ... |
I've created a JavaFX app to the data about Vessels, Employees and Jobs. The current version works but it is quite slow which I need to fix. I understand the root of my problems but I do not know how to avoid it
I have several entities
class Vessel
{
IntegerProperty id;
StringProperty name;
//and some other... |
I've been working on a way to optimize pixel computation in OpenGL with C. If this information helps, my current environtment = Linux (terminal) + GPU (Nvidia 1080Ti). I'm working with old OpenGL (with GLUT) and not Modern OpenGL. Here's what I'm doing, this function will take image input, this is how I call the image
... |
I have a fully working Python server that utilizes Tornado, asyncio, websockets and tweepy(Twitter's Streaming api). The main point of this server is to receive a query from the user, call upon tweepy to track the query, perform sentiment analysis on any message received and send it back to the client.
All messages sen... |
I've done some research, reviewed countless SO questions that appeared similar, leading me to endless rabbit holes.
My solution is working, but I don't like it. I want to create a random IV for AES and store it with my cipher. You'll see various approaches based on the comments in my code. This final version is mostly ... |
I tried to solve the question at https://leetcode.com/problems/roman-to-integer/ i.e Converting an Roman Digit to a Integer using C#. It passes all the test cases but any suggestions to reduce run time and memory usage would be appreciated.
public static int RomanToInt(string s)
{
if (s.Length>=2)
... |
I have built a real estate management system with Django. I want to know if my design database was wrong. Please let me know how to improve it.
Should I make the models use more than two tables (classes)?
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
name = models.Char... |
The Task
is taken from codewars:
Write a function that takes a string of braces, and determines if the
order of the braces is valid. It should return true if the string is
valid, and false if it's invalid.
All input strings will be nonempty, and will only consist of
parentheses, brackets and curly braces: ()[]{}... |
Application Logic
The software take odds data from an internet site and store them inside my own database, this application is basically a scraper.
There are different types of odds, eg:
FullTime
Under / Over
Double Chance
My goal
I want avoid code redundancy, for doing so, I created a method called GetOddsRow which ... |
Let's consider you want to clone all items of a vector orig except the item of index i should be taken from alternative value alt.
Lets say the items are of the type
struct Bla{
// Some fields
}
Using for loop
On simple solution would be:
fn clone(orig: &Vec<Bla>, i: usize, alt: Bla) -> Vec<Bla> {
let cloned = Vec... |
I am a beginner in programming. To rotate the array to left, I have written the below code. Please point out how to optimize the code and anything I am doing which is not good programming practice.
package arrays;
import java.util.Scanner;
public class ArrayLeftRotation {
public static int[] LeftRotation(int num... |
Github
Github for easy testing
I'm currently undertaking a training course to try & further develop my skills in
C#. The latest exercise was to create a basic stopwatch class that meets the following criteria -
Design a class called Stopwatch. The job of this class is to simulate
a stopwatch. It should provide two... |
I have an angular 7 app that is data focused and as a result has dozens of grids. These grids are from the Kendo UI for ANgular component library made by Telerik. These grid components expose hooks for the sort, filter, group functions of the grid. 90% of the grids I have are a very simple CRUD grid with next to no ... |
At the end of each billing cycle, Amazon generates a raw transaction file for my store's orders that cycle. I am converting that raw transaction file into a .csv file to be imported into my accounting software. My converter program takes two input files.
The first input, the Amazon data file, contains hundreds of lines... |
I asked this question here: https://stackoverflow.com/q/55640147/5202255 and was told to post on this forum. I would like to know whether my solution can be improved or if there is another approach to the problem. Any help is really appreciated!
I have a pandas dataframe in which the column values exist as lists. Each ... |
My code exceeds the time limit on the second test set. A suggestion/hint of a better algorithm would be appreciated.
Problem
Thanh wants to paint a wonderful mural on a wall that is N sections long. Each section of the wall has a beauty score, which indicates how beautiful it will look if it is painted. Unfortunately... |
I am reading an Excel file using Pandas and I feel like there has to be a better way to handle the way I create column names. This is something like the Excel file I'm reading:
1 2 # '1' is merged in the two cells above 'a'and 'b'
Date a b c d # likewise for '2'. As oppos... |
I'm attempting to parse an SVG file to get all of the colors that are present in the file. SVGs are XML based and their structure can vary a bit. For example:
<svg viewBox="-80 -80 160 160">
<g stroke="black" fill="none">
<path d='...' fill='#0FF'/>
<path d='...' fill='#F0F'/>
...
</g>
</svg>
and
<sv... |
This is meant to present main content in the carousel above with a painless navigation below where the moment you start dragging the content keeps up.
I was trying to avoid having to drag once per slide or press "next" many times. Also the previous and next classes are added for effect. Will look quite different in pro... |
I wrote this for a class project, the backend for this dog voting website. I noticed duplicate code among multiple functions I was writing to be deployed as a cloud function: they all were wrapped in try/except blocks that returned either 200 and JSON or 500 and a traceback. (I understand that it would be better to ret... |
I am unsure if I followed the the suggestions on my previous post.
I have only been working on programming for about 3 weeks so any more suggestions or insight would be more than welcomed.
import sys
from textwrap import dedent
import os
import random
os.system('CLS')
# board number setup
board = [0, 1, 2,
3... |
Simple class to simpify runtime file loading of ressources. The class reads all files from a given directory including all subdirectories and stores the name together with the path in a simple struct. If a file needs to be used by the program just pass the name to GetPath() and the class returns the location of the fil... |
I have been practicing competitive coding for a while now and am using codeforces.com. I recently encountered a problem called "One Dimensional Japanese Crossword" on that site.
The problem is as follows:
The judge provides an integer (up to 100) and then a string with that many characters being either 'B' or 'W'. We ... |
I am working on Valid Perfect Square - LeetCode
and wrote a standard leftmost bisect search to solve the problem:
class Solution:
def isPerfectSquare(self, num: int) -> bool:
#base case 1
if num == 1: return True
lo = 1
hi = num
#recur case
while lo < hi:
... |
I have the following working code, but it is too slow because I have to run the same code for several files inside a folder. Please help me avoid the nested for loop or make it more efficient.
columnNames = {33:"boy", 24: "girl"}
events = [{1:"bo", 2: "irl"}, {1:"oy", 207: "gir"}, {1:"bboy", 2: "girly"}]
def create_ga... |
I am calculating parameters for a time series and the data size is very big. How can I make my function faster? The following function, param, calculates parameters for a time series model.
Input:
import pandas as pd
import statsmodels.api as sm
data = [['01-01-2018', 150,661,396,286,786],['01-02-2018',231,341,57,... |
I work in marketing and I am currently trying to aggregate data for 50 facebook pages on the same Business Page.
I have a loop that tries a series of requests to grab all data. I am not sure I am handling exceptions in the best way possible, so I was wondering if somebody had any idea on how to improve the situation.
M... |
The Hashset uses open addressing, linear probing and Robin Hood hashing for handling collisions. It comes with insert and remove operations, iteration (back and forward using a single iterator), min and max keys (this is to interface with a treeset that I've made, but not very useful) and set operations like union, int... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.