instruction stringlengths 71 71.9k |
|---|
Is there a better way to write this? This is a class that displays a preferences menu. We do this when the user first installs the app during a walk-through where we only show them some of the settings with additional guidance on how to set them. We also show the entire preferences menu if the user selects our preferen... |
Is the MoveNext operation inefficient here? I really just want to increment an index. Originally, I had a mutable variable locally in ExtractTokens to accommodate this. I would have to believe that a mutable variable there would have been pretty efficient, but I'm trying hard not to have them. I can't help but feel... |
Last week I wrote a C++ program on Ultimate Tic Tac Toe. The issue was that the program was a bit lengthy (~230 lines) and it is needed to be around 150 lines.
I absolutely am not asking you to go through the whole code. Just skimming through might reveal possible contractions to code, and tips in general to write shor... |
Java allows methods to make recursive calls. This can be dangerous because an infinite recursive call will fill up the stack. It can be useful, however, for calculations that need iteration when the number of "self calls" is limited (it save a few keystrokes as well). The code below, although not very useful, does dem... |
The Julia set is the set of complex numbers z that do not diverge under the following iteration:
$$ z = z^2 + c $$
Where c is a constant complex number.
Different values of z reach infinity at different rates. A colourful fractal is produced by colouring the complex plane based on the number of iterations required to r... |
The question that sparked this question, was one on Stack Overflow in which the OP was looking for a way to find a common prefix among file names( a list of strings). While an answer was given that said to use something from the os library, I began to wonder how one might implement a common_prefix function.
I deiced to... |
I have a class that is all about doing HTTP requests, and logging (in file system & database). It's only using 3 dependencies to do these things, so I'm fine with the code so far.
Here it is for convenience :
<?php
namespace App\Services\Pivotal\Request;
use App\Core\Request\HttpRequest;
use App\Core\Request\Log\Requ... |
I've written this basic TCP socket server that uses SSL. This is my first experience with sockets in C++. The client is a Qt desktop application.
Code overview:
Receive incoming connection.
Check if connection is from an existing socket, if so reply via that socket, otherwise, create, bind and send response via new so... |
I was working on Haskell Problem 21:
Insert an element at a given position into a list.
Example:
* (insert-at 'alfa '(a b c d) 2)
(A ALFA B C D)
I have two different solutions:
--Problem 21 (also not tail recursive)
insertAt :: a -> [a] -> Int -> [a]
insertAt v [] n = [v]
insertAt v arr 1 = (v:arr)
insertAt v (x:xs)... |
I have a custom template class Array<T>, and am currently implementing the assignment operator.
However, I've come across a design decision: When assigning two arrays, must I require them to have the same size, or adjust the LHS Array size to the RHS?
Pros and Cons of Requiring Equal Size
Pro
Most of the time, the ar... |
I find that I use this pattern a lot where I have a dictionary which I would only read from and update and wouldn't add/remove keys.
In that case, using ConcurrentDictionary is not necessary and could hinder performance.
I wrote a simple class which implements such dictionary by using a wrapper class as its values:
cla... |
For a personal programming challenge, I wanted to try writing simple bubble sort and insertion sort functions in Python 3. I haven't looked at the standard pseudo-code, I just read about how they worked. Are these good implementations?
def bubble_sort(array):
"""
Sorts array using a bubble sort.
>>> bubb... |
I am still learning tikz and often have to use complicated solutions where I am sure are more simple ones. From my latest tikz files I picked one to ask for tips what I can do better, to learn about features of tikz.
The general layout should stay the same. Slight changes are fine. Suggestions should be about syntax.
I... |
Yes, I realize there are many, many, many, many, many, prime generators on the Code Review SE. However, I have been unable to find any using this method for generating primes inside a vector, so I figure it should be covered.
Here's the C++ code:
long int primeCap = 1e10;
std::vector<long int> primes;
primes.push_back(... |
I'm working on a Node.js HTTP server on my iPhone:
var fs = require("fs");
var http = require('http');
const port = 8080;
var readFile = function(name, response) {
var read = function(err, dat) {
var rv = null;
var nope = "./redirect.html";
if (err) {
if (name == nope)
... |
I've got bored, so I decided to write a code using ancient knowledge of sentinels.
Sentinel based find
Basically what we do is put value that is needed to find at the end, and then write an endless loop. Breaking from loop happens in the body of it, so one branch (which probably won't make much, since it is a loop bran... |
I have a helper function I wrote, but it feels like something _.lodash already does or could do if I knew the library better.
function changed(before:any[], after:any[]):boolean[]
{
if (before.length !== after.length)
{
throw new Error(`Length of arrays are not equivalent: ${before.length}, ${after.leng... |
This is a continuation of my LINQ stories from Pangrams-Hackerrank. Similarly, this challenge has been asked before in python Pangrams python Implementation but I have tried to accomplish this challenge using LINQ.
Here is a summary of the question
Roy wanted to increase his typing speed for programming contests. So, ... |
I'm in the process of learning Scala, and started working through a series of coding puzzles that I've done previously in other languages.
For example, this solution, coded in Erlang:
sum_multiples(Max, Max, Acc) -> io:format("The sum of all the multiples of 3 or 5 below ~p: ~p~n", [Max, Acc]);
sum_multiples(Current, ... |
I've completed a program that tests whether two words are anagrams. The program seems to work, but I was just wondering if there is anything I could be doing to make the code better. Everything is below, there is a main program and one class.
Main:
import java.util.Scanner;
public class StringTesting
{
public s... |
This is actually not something new, but I think many people wanted something useful and not incredibly complicated. So, here it is:
#pragma once
#include <utility>
#define concat_impl(x, y) x##y
#define concat(x, y) concat_impl(x, y)
#ifdef __COUNTER__
#define ANONYMOUS_VARIABLE(NAME) concat(NAME, __COUNTER__)
#else... |
I recently made this simple server in C for Linux systems and was wanting to get another set of eyes on it for a review of the design. I am new to socket programming and used a textbook from school to guide my way.
It is for GET requests from browsers and serves from a public folder (or other destination of choice). It... |
From my tests:
AABB-Sphere: 2954.8 tests per ms.
AABB-AABB: 1087.0 tests per ms.
The sphere test is almost 3 times faster, but the two intersection tests seem to perform about the same number of operations (or even more in the sphere test).
My question is: why? I can't seem to figure this one out. Is there a better a... |
I have written a code which works very good for small data-files (see below). The data file 'WSPL.dat' which I want to evaluate has a size of 2.6 GB and the data file 'VELOC.dat' has a size of 4.3 GB. The production of the data 'inputv.dat' takes almost 45 minutes and it has a size of 2.6 GB. At the final step, the co... |
I am trying to improve the performance of this password cracking method:
def search_method_2(num_pass_wheels):
global totalguesses
result = False
starttime = time.time()
tests = 0
still_searching = True
print("Using method 2 and searching with "+str(num_pass_wheels)+" password wheels.")
whee... |
At now I have such code, creating or updating some entity by dto items.
public void Upsert(List<Object> items)
{
var existings = _db.Get().Where().ToList();
foreach (var item in items)
{
var existing = existings.FirstOrDefault(x => x.Id == item.SomeId);
if (existing == null)
{
... |
I have refactored the code for this game thanks to some great suggestions from woxxom
Now, once again, any suggestions still welcome. I am going to be improving the UX as a next phase (giving hints to the user etc).
I have also improved the consistency of naming IDs and using single/double quotes etc.
There was one s... |
I figured out a alternative way to make embedded videos responsive and I like to have some feedback on it.
Would this be considered a hack or just bad coding to add a extra piece of html to make this work?
.video-wrapper {
position: relative;
}
.make-video-responsive-img {
width: 100%;
height: auto;
display: ... |
Anything I can improve?
def main():
word = 'nedim'
hidden_word = list('_'*len(word))
wrong_guess, amount_of_letters, guesses, done = 0, 0, 4, False
while(wrong_guess != 5 and not done):
guess = raw_input("Guess a letter: ")
if len(guess) == 1 and guess.isalpha():
while(guess... |
if (TextArea1.gettext().length() > 0) {
String TextToChange = TextArea3.getText();
TextToChange = TextToChange.replace(TextArea1.getText(), TextArea2.getText());
TextArea3.setText(TextToChange);
} else {
JOptionPane.showMessageDialog(null, "Text to Replace field is empty", "WARNING"... |
I've been more than likely doing this entirely wrong for quite awhile and would like to correct that.
With the code review I would like to get critiqued on everything. This includes:
JQuery syntax/structuring
Additionally, if there are different/better/newer libraries let me know
HTML5 syntax/structuring
PHP struct... |
I would like to see what you think of a password generator I coded in Python.
#A password generator in Python...Coded by Mcoury(python-scripter)
#import the necessary modules:
import base64
from Crypto.Hash import SHA512
import random
import pyperclip
print('+++Pypwd is a password generator in Python...Coded by Mcoury... |
I want to shorten my code. You can see the following code i used many function for addClass, removeClass. But it is not usefully. Can do my work in one hover function ? If yes can anyone help me ?
$(document).ready(function() {
$('.star-one').hover(function() {
$('.star-one').removeClass('rate-btn-hover');... |
I have made a simple sliding puzzle/game of fifteen using SDL. I originally attempted this to learn about game states, but it turned into a general exercise in code organisation and SDL use. Therefore, I would especially appreciate comments regarding organisation and clarity, but general suggestions or comments are ver... |
My class has a method that does some stuff, and then wants to recursively operate on some data. Specifically, I'm generating an XML report whose output includes a flat list of elements derived from a hierarchical data structure.
Example Input (a Score)
{'wrapper':True, 'sub_scores':[
{'wrapper':True, 'sub_scores':[
... |
I have the following function count.ones that takes in a data frame data.l in which the observations have been subdivided into bins defined by indices, a vector of consecutive indices x, and the length of the sliding window width over consecutive indices. The goal of this function is to slide over the indices and count... |
In the ROOT framework (originally a C++ framework, but python bindings are also supplied), colors are objects (ROOT.TColor) identified with an integer index.
This short class creates a new such color, given the r, g, b values which stores the object inside an int sub-type (to prevent the gc from deleting it).
#colors.p... |
I did not add generics to my code because I am new to Java. I am on my way in learning data structures and algorithms. I just want to make sure that my code is clean and efficient.
package Double_LinkedList;
class Node{
int data;
Node prev;
Node next;
void setData(int data){
this.data = data;
... |
An easy to use type feature that uses the placeholder attribute and setTimer to give the effect of a user typing. Helpful if you need to draw attention to the search box field.
I'm looking to know if this type of implementation would be a performance impact or cause browser lag. Help in making this more condensed would... |
I work for a service desk and change A LOT of passwords. Most the time the end user is a complete fool that doesn't understand the requirements for the password they want to use. So I created a program that will generate random passwords based on a randomness level (1 - 3).
Here's how the levels work:
Reads the passwo... |
UPDATE: I have refactored the code into a Gist using @Dmitry's answer as a guide. The update is much simpler to grok, implements IDisposable, and is roughly thirty lines shorter.
I wrote this over the weekend for fun and am looking for critique. Style and readability comments are welcome but what I truly need to know ... |
Playing off Robust Bubble Sort in VBA and as suggested by @Henrik, I took a look at comb sort and tried to create an algorithm based on the documentation solely on Wikipedia.
Basically, the first procedure is just for the testing:
Take a string of numbers and create an array
Sort the array ascending or descending
Bu... |
I have a project for which I need to parse BibTeX strings. In v0.2.9 and before, I used Regex, and I want to change that. I set up a while loop system that reads the file char by char, but it seems slow.
I wonder if there is a better way to use while loops, or to parse in general.
Note: I'll worry about escaped charact... |
Inspired by the learn you a haskell exercise to express map with fold I wrote an implementation of scanl by means of a fold.
scanl2 :: (b -> a -> b) -> b -> [a] -> [b]
scanl2 f z xs = reverse $ foldl (\a x -> (f (head a) x): a) [z] xs
I have the idea that in terms of performance it kinda is up to par with standard sca... |
I'm trying to make my code smaller and less verbose.
The pass in the if statement are there because I need to check specifics on the dice roll.
The code is running a game of craps where on the first roll if I get a 7 or 11 I win, or if I get a 2,3,12 I lose. Any other number I keep rolling till I either get what I rol... |
That's gonna take long.
This program solves 8 puzzle game (mini version of 15 puzzle) using A* algorithm. Program consists of 2 parts:
Board.java - which serves as a representation for the board (N-by-N grid, not limited to 9 tiles)
Solver.java - as the name implies, this class solves the given puzzle (if it is solvab... |
I recently answered a question
on Stack Overflow about finding the k-largest element in an array, and
present my implementation of the Quickselect algorithm in Swift for review.
This is essentially the iterative version described in
Wikipedia: Quickselect, only that the
paritioning does not move the pivot element to ... |
I know there are probably thousands of INI parser implementations in C.
Nevertheless I want to implement one to learn the art of parsing grammar.
I just wrote a small piece of the INI parser and wanted to ask if I am on the right track:
void parse_line(const char *str, char **name) {
size_t length = strlen(str);
... |
I currently am writing a query which retrieves the max amount of rows for a junction table. I'll use the following example in SQL Fiddle:
MyTable
┌─────────┬─────────┐
│ a_field │ b_field │
├─────────┼─────────┤
│ a │ 1 │
│ b │ 2 │
│ c │ 3 │
└─────────┴─────────┘
JunctionTable
┌──... |
I am new to C, but have experience with Python and R. The following code implements the Game of Life and represents my first finger exercise in C. I would like to have some feedback regarding the coding style and conventions in the C community. (I commented out the two Windows specific lines, in case someone wants to r... |
I made a simple form with an option of adding one text field dynamically on mouse click. And I will be grateful for suggestions on how I may improve the code.
@Controller
public class MyController {
public ArrayList<NewField> fieldArrayList;
@RequestMapping(value="/create", method= RequestMethod.GET)
public String myF... |
Given an integer , print the next smallest and next largest number that have the same number of 1 bits in their binary representation.
How can I improve this?
void printNextNumber(int num){
int inputNumOfBits = calcBits(num);
int nextLargest = num + 1, nextSmallest = num - 1;
//nextLargest
while (tru... |
This solves Project Euler #11: In the 20×20 grid below, four numbers along a diagonal line have been marked as bold.
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 6... |
I am required to write a simple matrix program and swap the diagonal.
Given the input
1 2 3
4 5 6
7 8 9
After swapping the diagonal it should be
3 2 1
4 5 6
9 8 7
Here is my code:
public static void main(String[] args) {
int i,j = 0,m,k;
int Number[][] = new int [3][3];
Scanner scanner = new Scanner(Sys... |
This is a program to solve: Images with all Colors from Code Golf:
Make images where each pixel is a unique color (no color is used twice
and no color is missing).
Create the image purely algorithmically.
Image must be 256×128 (or grid that can be screenshot and saved at 256×128)
Use all 15-bit colors (15-bit color... |
The visual board game is currently a game in unity, where I've created a map and a grid. The visualization is like this:
Making this code obviously needed nested for loops and the like, but developing this I mainly had the attitude "just go with it", which means I now have rather confusing code.
I have created a class... |
Is there any other way to write this separation?
public Parent Method()
{
Parent parent = new Parent { ChildA= new List<Child>(),
ChildB= new List<Child>()};
List<Child> allChildren = _manager.GetChildren();
foreach (Child child in allChildren)
{
... |
I was inspired by this answer and the explanation and decided to support negative numbers. While testing, I noticed that the solution didn't handle the case with one number in the given range. A quick way to fix it was just adding
else if (a == b) {
return 0;
}
Here is what I have:
package xor;
public class Xor ... |
I am working with a lot of DOM manipulation and need to know several values of an element to determine its position within the DOM and I have written the following to help scrape several of the bits of information I need to proceed.
To me this looks very heavy and there might be some room to help improve the speed / ac... |
There's a need to have a mechanism in place that will process messages received from the network concurrently. However, only X number of messages can be allowed to be processed concurrently and there's a restriction: Similar messages must be processed sequentially. For simplicity's sake, similarity can be identified by... |
Can someone please review this algo and say if it has some weak places and/or what kind of algo is this (caesar, block etc)?
std::vector<unsigned char> TestCryptDecrypt(const std::vector<unsigned char>& data, const std::vector<unsigned char>& key, bool decrypt)
{
std::vector<unsigned char> result;
unsigned int ... |
I've got a database table in my application called "periods". The structure of the table is:
Year (Number)
Month (Number)
Period (Text)
The Year column stores years (Say, 2016), Month stores months (1-12), and period stores the period of the month/year - eg; November 2016 = 11/16, so period = 1116.
In the table, it s... |
I call many dataframes (using pickle), then I extract the interesting values of each one and finally combine them. Is there a better way to do it? For example with a for loop call them automatically instead of having to repeat the code many times?
#Dataframe 1
df_NB_E = pd.read_pickle('/Dataframes/Total Accuracy NB_E... |
My .htaccess redirects everything to my index.php, but I wonder if it's vulnerable to XSS attacks. Am I safe?
.htaccess file
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*$ index.php/$1 [L]
php_value auto_append_file none
index.php
<?php
require_once 'dbliteconnec... |
I work mainly at developing MSSQL databases but I've been trying to teach myself C# for a bit now and I wrote some simple code that prints a list of colleagues and their coffee preference.
I just went through it with my precarious knowledge and I can't find much more to add or remove from it, I thought maybe I can pos... |
We were given a homework assignment to create a C++ program that generates 3 different random numbers each time and the user is supposed to guess the three of them AND in order. I already achieved that, however I'm not very satisfied with how long my code is, especially with the fact that I had so many if statements. W... |
I was working on adjusting some variable naming on an Excel project and ran into an issue that the MSForm control names needed to be updated. When you change the properties of the control on the form, the underlying code for the form doesn't seem to update accordingly.
Examples:
You rename btn_button1 to btn_populate... |
I've been working on a simple neural network implemented in python. Currently, it seems to be learning, but unfortunately it doesn't seem to be learning effectively. The graph below shows the output of my neural network when trained over about 15,000 iterations, with 1000 training examples (it's trying to learn x2). Th... |
This code iterates through the table @Table1 to get the Purchaser, PurchaserID, SaleID store the values in a variable, then queries a secondary table to get data for the specific purchaser. 2 different data sets (one for daily, one for weekly) checks if a folder for the purchaser already exists. If not, it creates the... |
I have some elixir code I am using to score a ping pong game. Since I am new to functional programming I was hoping there might be a more elegant solution to this.
This part of the code is used in a GenServer to check if the next point could result in a win. So that means will the leading players next point meet the mi... |
Is there an alternative possibly cleaner way (without so much repetition) to write the following? I'm thinking about the headache it's going to be when I have to remove all of my even listers.
customCursor() {
const prevButton = document.querySelector('.previous');
const nextButton = document.querySelector('.next');
co... |
I've used multiple tutorials to get the exact look for show/hide using jQuery, but now that I've done it's too repetitive, I've tried to edit it using variables, but it didn't work. Is there a way to avoid repetitiveness here?
$(document).ready(function() {
$(document).click(function(event) {
if ($(event.target).... |
I have a number of functions that follow the basic pattern below. The intent is to provide a MongoDB implementation for a storage interface in a TypeScript application.
Is there a better way to clean this up so that is is simpler or more readable?
find(collection: string, query: any, sort = {}): Observable<[SyncedObje... |
As a programming exercise I made a square root function in C# using recursion, here is the function:
static double root(double x, double increment, double num)
{
num += increment;
if ((num * num).ToString() == x.ToString())
return num;
else if (num * num < x)
return root(x, Math.Abs(incremen... |
Would you consider this to be idiomatic Scala? If not, what would you do to improve it?
def fibonaccis(max: Int): List[Int] = { fibonaccis(max, 2, 1) }
private def fibonaccis(max: Int, prev: Int, prevPrev: Int): List[Int] = prev >= max match {
case true => List[Int](prevPrev)
case false => prevPrev :: fibonaccis(ma... |
I recently published a library for advanced awk-like file manipulation in Python 3. The code can be found here and here is the documentation. It is also available for download from pip (pip install awk). I would like to know if the code is well designed and how it can be improved to enforce readability and code reuse. ... |
I am almost completely done with this program. Now I just need to figure out how to use tkinter to put this in a GUI but here is what I have thus far. Constructive criticism is always welcome.
another_word = " "
sentence = " "
new_list = [ ]
def global_reset(): #I had to do this function to reset the variables becau... |
I recently learned how generators can be infinite in Python. For example, the infinite sequence can be the triangular numbers:
$$1, 3, 6, 10,...$$
def triangle_stream():
""" Infinite stream of triangle numbers. """
x = step = 1
yield x
while True:
step += 1
x += step
yield x
I ... |
I'm trying to solve a Hackerrank problem where you perform k array[n] rotations, and at the end, ask for m and print array[m]. My program is probably correct (it runs perfectly for most of tests, but some of them terminate due to timeout), but is inefficient and I don't know how to improve it.
#include <math.h>
#includ... |
I want to make some kind of file vault. I want to store encrypted files in a MySQL table, and the key to encrypt/decrypt them is never stored but only known to the user (that's the goal, anyway).
The user has to be logged in to view a list of his files. Then, to view a file, the user has to enter a key to decrypt a fil... |
I have posted here my working and accepted solution to the intepreter programming challenge (detailed here) for your review. The challenge is as follows:
A certain computer has 10 registers and 1000 words of RAM. Each register or RAM location holds a 3-digit integer between 0 and 999. Instructions are encoded as 3-dig... |
I pretty sure it should be shoter solution.
(defun modulename-vinlist(val lst)
"Check if value in list"
(let ((res "no"))
(let (vv)
(dolist (pi lst vv)
(when (string-equal pi val)
(setq res "yes")
(return))
(setq vv (cons pi vv))))
(when (string-equal res "yes")
... |
The code below is loading an svg into the canvas via RaphaelJS. There are mouseover/mouseout events, on click on an element of the svg, and drag/zoom.
I would like to know, what are some good practices, or how to improve the productivity and maybe shorten my code. One issues may be that I use a lot of iterations throug... |
Here is the pseudo code used inside a Rails controller:
defined_hash_10000_records.each do |data|
account = Account.where(account_identifier: params[:account_id]).first
program = Program.where(program_identifier: data[:id]).first
unless participant_account.present? || utility_program.present?
# this i... |
I'm using the following code in order to cite the images used in my android apps. My main concern is to never accidentally present an image as if it were mine, while it's not.
Questions:
The images I created are separately stored from third parties' images. The code in ignore_build_ensure_images_cited.py is run every ... |
I have an Android application which needs to retrieve JSON files from a server and then display the information in my app. To accomplish this I have the following architecture:
The main activity adds a job to the job queue requesting certain information from the server.
The job gets run, retrieving the specified info... |
I was given the following code challenge as part of an interview process, unfortunately I did not get through to the next stage. Any advice on how I could improve would be very much appreciated.
Here is the spec:
Our client is an online marketplace, here is a sample of some of the products available on our site:
Produ... |
Below stored procedure implemented for filtering and sorting operation.But number of table column increases below query becomes complex to read/maintain. This is good for small tables.
I want to modify the below one by using dynamic sql query. I will pass the parameter from front-end to here.
CREATE PROCEDURE [uspProdu... |
I've been learning Python for a few weeks and I created a simple game where you convert binary numbers to decimal. It shows you n binary numbers and you are supposed to enter the numbers in decimal system in sequence as a password. After failing three times you lose. I'd like to implement it into a bigger game later.
H... |
Firstly, would appreciate some code-review feedback, from a TDD and design perspective.
Secondly, what are your thoughts on implementing test case: testNumbersAreUnique()? The fact that API returns a Set of immutable objects means elements will be unique, but just wanted to know your thoughts. The reason I used a do-wh... |
I have a c# WinForms application in which I have tried to implement the Model View Presenter pattern with Passive View. The View derives from a parent IView which propagates the public members and events of the View to its Presenter. In this way, the Presenter can utilize these field and react to the events without rel... |
I recently found the Google Foobar challenges and am having a problem with level 3. The goal of the task is the find the minimum number of operations needed to transform a group of pellets down into 1, while following these rules:
1) Add one fuel pellet
2) Remove one fuel pellet
3) Divide the entire
group of fuel ... |
Write a function setbits(x,p,n,y) that returns x with the n bits that begin at position p set to the rightmost n bits of y, leaving the other bits unchanged.
#include <stdio.h>
unsigned setbits(unsigned x, int p, int n,unsigned y);
int main(void){
unsigned result=setbits(0, 4, 3, ~0);
printf("%d\n",result);... |
I have question regarding online PCA implemented in the paper. I am interested in the Algorithm 2. I am not certain if there is a bug in my code can someone confirm if my code is correct? The algorithm is as follows:
input: \$X\$,\$\Delta\$
\$U\leftarrow\$ all zero matrix (dimensions are not given in the paper , ... |
Scope is to throw any mail, html or plain or multipart into this and receive a readable formatted text that deals with special characters and html issues. Field of usage: System that imports mails into a mysql db, or prints them to pdf etc.
What can I improve here?
import imapclient, pyzmail, html2text
"""
Connect to... |
I have this simple IDE for playing with Brainf_ck. It has no file functionality; only the code, input and output fields are present, and the "compiler" is integrated. Here is how it looks like:
My code is as follows:
App.java
package net.coderodde.brainfuckide;
import javafx.application.Application;
import javafx.app... |
I am a beginner in Pygame (and programming in general) and tried to make a Flappy Bird game. It works fine, but I'm sure the code has a lot of scope for improvement. It is completely procedural, and while I do want to make it object oriented to clean it up, I'm not sure how to go about it.
For example: Bird will be an ... |
This code acts as an infinite generator of prime numbers.
As new prime numbers are found, they are added to a set. Then, a number x is found to be prime if none of the numbers in the prime set are factors of x. Only the primes less than or equal to the square root of x need to be checked.
import itertools
from math im... |
I'm solving a programming challenge that essentially consists of finding the highest product of elements in a set.
This is my current solution, and is passing all the test cases but one. The test case that is failing is not available to me, so I kinda have to guess what is wrong with my code.
public static String sol... |
This is an exercise in using ReactiveX in Python. I want to create an Observable in RxPy with the following characteristics:
Emits items through a custom function
Runs asynchronously
Sets up resources upon start and it cleans up at the end
Runs a loop indefinitely (until cancelled)
Can be cancelled
Shared among observ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.