instruction stringlengths 71 71.9k |
|---|
I have written the following code as the level rendering part of a game engine I am writing. I am very happy how it works but as it is the background / level graphics made up of individual blocks it needs to be quick.
What it does it look take the graphics from a resource loaded elsewhere and scales it onto the block i... |
I have two lists of the same type and I want to be able view a list of both lists:
public List<Page> HeaderPages;
public List<Page> SurveyPages;
public IReadOnlyList<Page> AllPages
{
get
{
List<Page> allPages = new List<Page>();
allPages.AddRange(this.HeaderPa... |
I have a piece of code which grabs data from an SQL database and displays it in a DataGridView. This code works perfectly fine for me.
It has been pointed out to me that the below code is bad programming:
Imports System.Data.SqlClient
Public Class Form1
Dim dbConnection As SqlConnection
Dim dbCommand As SqlCommand
D... |
Could you give any suggestion on the following unit tests? How to make it more readable, maintainable and trustworthy. If it is not a problem - post some code with the suggestions.
[TestClass]
public class PropertyBagCompositeTests
{
private readonly IFixture fixture;
private readonly Mock<IPropertyBag> secondP... |
I have this code which runs when an Async HTTP call is made on a HorizontalScrollView
//These 3 defined outside of the method
ObjectAnimator animatorR = null;
ObjectAnimator animatorL = null;
boolean loop = true;
Inside the method
if (animatorL !=... |
I have a RoR 4 app, and its model have these associations:
has_many :accreditations
has_one :legal, -> { where(kind_cd: Accreditation.legal) }, class_name: 'Accreditation'
has_many :departments, -> { where(kind_cd: Accreditation.department) }, class_name: 'Accreditation'
So, you see that these associations similar, bu... |
I want users to enter their code into my blog and keep original styling tags intact. So I had to develop a function that extracts user's code (between two tags) and convert special characters to HTML entities, then remove unwanted tags using purifyHTML.
I want to know if it is safe to use it like that, and if there are... |
I am working on my first HTML5/CSS web site and, like all of my first-time projects, they end up cumbersome, crude, and hard to work with when changes need to be made later in the life cycle. I am attaching some code with a small amount of HTML and CSS. I have read up on CSS and HTML and, after quite alot of effort, ha... |
I want to group the two very similar jQuery functions into just one. Any idea?
HTML:
<input id="progress" type="text" class="spinner-input form-control" maxlength="3" readonly value="<?php echo $progreso['progress'] ?>">
<div class="spinner-buttons input-group-btn btn-group-vertical">
<button id=... |
The problem is to input, divide 2 ints and display the result.
Please, review my program. It worth noting, I've intentionally used goto, not while.
int main(){
int a, b;
ab_input:
cout << "Enter 2 numbers: ";
cin >> a >> b;
try {
if (!cin) throw std::runtime_error("Bad input");
if (b ... |
I had to look up some other solutions online because I could not figure it out on my own. I really wish I could have come up with it completely on my own, but that didn't happen. Nevertheless, please review my prime number program and let me know if there are any improvements I should make or advice your would like to ... |
I'm trying to write a regular expression to check names for invalid entries. Basically I'm trying to eliminate people entering random junk as their name. I know I can't completely eliminate it but I'm trying to make it a little harder at the very least. Here is what I have so far. It works fine I'm wondering if there's... |
I have written the following C code for calculating the Shannon Entropy of a distribution of 8-bit ints. But obviously this is very inefficient for small arrays and won't work with say 32-bit integers, because that would require literally gigabytes of memory. I am not very experienced in C and don't know what would be ... |
I'm writing a bash script to handle the PPA's on Ubuntu & derivatives. I was wondering how to know if I'm handling this the right way.
So, the script works (flawlessly), but I posted it to a blog and got this feedback :
The way you wrote you script is the one we all use when we begin : we don't know the variables, s... |
Ideally the Code Review would target the correctness of the approach implementing the Swing TreeModel.
In particular, is the structural separation[1], event message passing, threading[2], object synchronisation, etc. all best practice ?
[1] My understanding is that the TreeModel should have separation between the unde... |
I'm trying to design a binary relation interface in Java and then implement it, but I'm not sure if I'm doing it right. I'd really appreciate a little feedback just so I know if I'm way in the wrong direction or not.
This is what I've got so far:
Interface:
public boolean compare(Object that, Object ths);
// compares r... |
Below is some code which verifies a credit card number using the checksum as well as check if number of digits are appropriate as well if digits start with right numbers. I am not sure if converting the double into a string was the best bet. I wasn't going to at first but had trouble figuring out the modulo math to get... |
I've watched quite a few videos and read a couple of articles on unit testing and I've tried my best to make this test case as good as possible. In which areas can it still be improved?
I should probably add that SM2Scheduler is an implementation of the SM2 algorithm, which is used in flashcard software such as Anki an... |
I am trying create an algorithm for finding the zero crossing (check that the signs of all the entries around the entry of interest are not the same) in a two dimensional matrix, as part of implementing the Laplacian of Gaussian edge detection filter for a class, but I feel like I'm fighting against Numpy instead of wo... |
I had posted this here and was asked to move it to code review since my code works and am looking for the best possible solution : original post
NOTE: I have seen the JOIN in GAE related posts but GROUP BY in my requirements made me make a new post and I have made a solution of my own which I wanted to check how good i... |
This is the stored procedure I'm using to list some places in my website. How can I optimize it to perform well? Which functions in query is taking much time for its execution?
ALTER PROCEDURE [dbo].[PlaceListSelect] @cateID int, @searchTxt varchar(50), @userID int, @RowIndex int, @MaxRows int, @Location varchar(50), @... |
Recently I worked on one of the Codility Training - Genomic Range Query (please refer to one of the evaluation report for the detail of this training).
The proper approach for this question is using prefix sum. Here is the implementation:
struct Results solution(char *S, int P[], int Q[], int M) {
struct Results re... |
I start with an array containing some 'ids' and some 'values'.
What I need is to organize the 'ids' in a new array to be, if possible, apart when the 'values' they are associated with are alike.
So I came up with a solution. If there is too much of a value type, the spreading is uneven. So if one of you has a differe... |
I'm currently having this code & looking for a simpler and shorter way of showing, hiding & disabling my elements...
$("#chReportData").click(function(){
if($(this)[0].checked){
$("#reportDataOptions").show();
} else {
$("#ReportDataStatusOptions").hide();
... |
Since my project is getting bigger every day and I am just a starter in the wonderful world of makefiles, I need some help improving mine because, although it works (almost) as I wish, it really started looking like a mess. So it would be nice if someone could help me with it (and of course, advice is welcome).
Basical... |
I currenctly have a class which does several requests to a database with several methods (called from main method) sharing this pattern :
public int getSomething(String id, File file) {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
int lines = 0;
try {
conn = ope... |
I'm sharing C# code with a fellow programmer who is more use to writing C++. He uses #if and #endif directives (which I do not tend to use) and when they occur they have no indentation, for example
private void dumpToDisplay()
{
#if false
ushort[] ScanStatus = new ushort[6];
for... |
I have been trying various formats of namespaces and modules patterns, however I have not come across a solution that I would use for all my projects.
I've been developing the following, that would allow me to separate my application through applications, modules, functions and global variables. Possibly I'm going to a... |
Here's the first functional version of my Python 2 script for processing comments in C++ source files. It's a personal project, I expect to expand it later with more advanced options (mainly about replacing comments with whitespace or marking their original positions in the comment-only output).
It's also intended as a... |
You are given a polynomial of degree n. The polynomial is of the form
P(x) = an · xn + an-1 · xn-1 + … + a0
where the ai‘s are the coefficients. Given an integer
x, write a program that will evaluate P(x).
You are provided with a function named power( ) that takes two
positive integers x and y and returns xy. I... |
I'm the maintainer of the following library on github: https://github.com/edi9999/docxtemplater/blob/master/coffee/docxgen.coffee
I want to maintain a library that works on node and in the browser, however I don't want to have to update two separate repositories.
The ugliest code looks like this:
root= global ? window
... |
I have always suffered with too many conditionals in some of my methods. The following is a pseudocode/skeleton of one of my method like that:
private List<ReturnType> DoSth(string name = null)
{
List<ReturnType> names = new List<ReturnType>();
for (int i = 0; i < somearray.Length; i++)
{
if (somec... |
I've got a Python script which is meant to launch several other shell scripts with the appropriate setup and parameters. I construct the file paths from other variables so that it's easier to change one setting and have it apply everywhere, rather than hardcoding everything.
So, for example:
HOME_DIRECTORY = os.path.d... |
I was asked the following interview question over the phone:
Given an array of integers, produce an array whose values are the
product of every other integer excluding the current index.
Example:
[4, 3, 2, 8] -> [3*2*8, 4*2*8, 4*3*8, 4*3*2] -> [48, 64, 96, 24]
and I gave the following answer
import java.math.BigI... |
I made this bit of code that uses jQuery in a simple HTML file to see if my son would think it is fun/interesting and to help me with my jQuery skills. The thing that was hard was the selectors towards the bottom of the script block. I am wondering if there is a better way to do this. Warning: it auto-refreshes to 'r... |
So I am trying to make a Object oriented Node.js class for store information about riddles.
Please feel free to be harsh as possible. Would love to hear your ideas about how to make this class better!
function RiddleInfo(riddle, answer, hint1, hint2, hint3, ohFactor, difficulty) {
this.riddle = riddle || null;
... |
I was unable to find how to get current URL so here's what I've made. Brief tests didn't reveal anything bad. Your thoughts, educated opinions, suggestions, and comment on potential bugs or improvements is highly appreciated!
Especially take a look at $_SERVER['HTTPS'] marked with // ???. I have found many different ... |
I've overridden Backbone.Collection.add for my Collection to ensure that the Collection never has two PlaylistItems who share a Song ID. My implementation seems incredibly verbose and I was curious if there's a better way to express my desires:
var PlaylistItems = MultiSelectCollection.extend(_.extend({}, SequencedColl... |
Background: I'm designing a system (VB/WinForms) that uses a database(MS SQL Server 2008 R2) to track people, their stock account #'s, which stocks they are investing in, and the payout of those stocks.
Basically, just reading/writing to the database and some time-elapsed functionality. (One payout per year, etc.) I h... |
I have the following 3 different versions of code.
Version 1 is overly verbose and contains redundancy but on the other hand seems easier to read. Version 2 is somewhere in the middle, and Version 3 is shortened and straight to the point.
Their all equivalent in terms of functionality. I am not sure about readability. ... |
Now that we have the nice new foreach loop in Java, the old-style loop looks ugly be comparison.
I like the way Python has a range() generator that allows the foreach construct to iterate over a range of integers.
I have written a Range class which allows this. Please provide comments.
package highland.mark;
import ... |
I'm an experienced programmer but not too great at JavaScript so I'm looking to see if I'm doing this 'right'. I want to have several files loaded in (Ajax or really AJAJ) and, once loaded, run some final code. My basic idea is:
var jobsToDo = 2; // global
function getAsync(url, func) {
var client = new XMLHttpReq... |
I would like advice if this is a good implementation of an application for maintaining information about people (first name, last name, and age).
The index.html contains an empty div and 2 templates (1 for listing people and the other for entering/editing a user):
<div id="app">
</div>
<script type="text/template" id=... |
From a previous question I got an answer that included some template magic (that to be blunt was mind-boggling (as I could not understand it)).
So I have been trying to achieve the same results (because trying helps me learn).
To make sure I have learn correctly I am putting it here for comment. Hopefully it will also ... |
My code calculates primes from one to n. I have verified that the code always produces all the primes in that range correctly.
Are there any optimizations that I can make? Are there any bad programming practices besides variable names (e.g. l is close to 1)? Any better normal Windows API? I am using the Sieve of Eratos... |
I am just starting to get my feet wet with C; and am rather enjoying myself in doing so. This is sort of a follow up to my last question here. I am posting this ordinate to hopefully getting some feedback on the logic itself, and possibly also some feedback on coding style. I do, however insist on making everything exp... |
Using LaTeX creates a bunch of auxiliary files like foo.aux, foo.log, etc. Sometimes, I want to create a clean run of my document. I usually manually execute this in the terminal as
$ ls foo*
foo.tex
foo.aux
foo.log
foo.bbl
foo-blx.bib
$ rm foo{.aux,.log,.bbl,-blx.bib}
This works fine. However, it is error-prone and I... |
This is my very first program that using threads. I use C++11 standard threads and I run it on Linux.
The program creates two threads that sums all the elements in a vector together. The first created thread sums the left half of the vector and the other thread sums the right part of the vector.
The main thread runs un... |
I would like the program to ask the user if they want to add a color. If they say yes, then ask what color to add. Then after that happens, once the program would ask if you want to, run it again. If they say no to add a color, the program ask if you want to remove a color from the list. If they say yes, it would then... |
Grab the input file, and output the second to last word on every line.
Can I make it shorter and/or more efficient?
I'm surprised by the performance. While the runtime, +2s, is likely dominated by start up, it also requires +40M.
(use 'clojure.java.io)
(use '[clojure.string :only (join split)])
(with-open [rdr (reade... |
For the past week I have been studying and improving a ray tracer that I ported from JavaScript. The bare finished port was only exactly what was written in JavaScript and rendered at around 20fps at 100x100 resolution with a scene of just one plane and two spheres, over the week I have implemented very simple frustum ... |
I have a class called Mailer which has some properties like this
public static string Cname
{
get
{
return HttpUtility.HtmlDecode(HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["cname"]));
}
set
{
HttpUtility.HtmlDecode(HttpContext.Current.Server.UrlDecode(HttpContext.Curre... |
I wrote a utility method to override equals() using reflection. This works fine, but I wonder if this code will pass all the tests.
public static boolean checkObjectsEqualityFromInstance(Object currentObj,Object otherObj) throws Exception{
if(currentObj==null || otherObj==null){
return false;
}
... |
I've noticed I've got quite a few repeated lines in my code.
$start = mktime(0, 0, 0, 3, 1, 2014);
$rate = 1 / 30;
$amount = number_format(floor((time() - $start) * $rate));
$id = array(
array("42706686", "rebel2america"),
array("100004055720670", "marquez.candace"),
array("100000756492404", "vince.goode.3... |
I've got a piece of code that takes an element, checks where it is, and if it's beyond a set place in the viewport, make the opacity increase to 1. I've made the code so that it only runs the checks if they're needed, the problem is that the code looks atrocious, and I suspect there's a better way for me to be doing it... |
What would be the best way to format this code? It looks a bit messy to me in regards to indentation etc.
if (typeof _srwc != 'undefined') {
for (var i=0; i < _srwc.length; i++){
var currentArg = _srwc[i];;
if (typeof window[currentArg[0]] == 'function') {
window[currentArg[... |
Below I have two players that win or lose and their score fluctuates using the Elo function. I have adapted this code from something closer to my language which is ActionScript. I found the functions here. It is an older example and I didn't really get the point of it. My code is in ColdFusion. The problem I have with ... |
I am not very familiar with JavaScript and I'am a little confused with the object oriented peculiarities of it. I am trying to create a Caesar shift using the concepts of objects, methods and properties in JavaScript. I am using an HTML form to take input from user and OnClick return the encoded cipher text to user. Th... |
I have this old project I wrote years ago and it's all classes and methods all over the place. I am trying to learn/understand how I can apply a more OOP principle. It is very large and can't paste all the code here. Instead I will demonstrate what I have as a basic.
Checkup.cs
public class CheckUp
{
//General inf... |
I have the following function defined in a program that implements the 2048 game. I tried condensing the repeating part of the code into one loop containing +1 offset variables for the indices, which are either set to 0 or 1 depending on the direction passed into the function, but the outer and inner loop variables swa... |
I've been working on a game prototype for a couple days and I think that code review would be really helpful. The basic idea of the game is that you are controlling some dwarves, and you dig up resources underground in order to build a tower above ground.
I'm doing this in Sprite Kit, and initially I wanted to have th... |
I have created my first ping-pong game with JavaScript and Canvas. I will be glad if anybody can tell me how to optimize the code and functionality.
https://github.com/nikitalarionov/js-pong
First collision detection:
//Function to check collision between ball and one of
//the paddles
function collides(b, p) {
if(... |
Like many ASP.NET developers, I use the Newtonsoft library to convert C# objects into JSON. Is this use of Newtonsoft.Json.JsonConvert.SerializeObject secure?
Here is how I use it in a Razor view:
<script type="text/javascript">
var json = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model))
</script>
In ... |
I have written a code for an application/website that I wanted to be structured similarly to MVC design pattern (but I think it's rather MVP based on comparison I read). This functions as a kind of intranet where users can log in, see some news, short info about them - all on one page (some of the content is static and... |
I know that there may be better ways of writing this do you think that this code is written well enough to be used in a real world application?
var pow = function ( base, power ) {
var result = 1;
if ( power < 0 ) {
return ( 1 / pow( base, -(power)) );
}
for ( var i = 1; i <= power; i++ ) {
... |
I am looking to speed up the exchange from vba to IE. The sendkeys works, but I was curious if there were a better way to do this?
The site that it routes to is a form, but there is no submit button. The only way to pull the data is to tab to the next box or click somewhere on the screen. I was hoping, however, to have... |
I was asked this recently, and I couldn't figure out the best way. We are trying to replicate Google's search results where the search terms are bolded (using a b tag) in the results.
Input Terms Output
The search is cool {sea} The <b>sea</b>rch is cool
Origi... |
This is a baseline tagger coed I have written. How can I optimize this code?
public class Tagger {
private ArrayList<List> copyTagsList = new ArrayList<List>();
public Tagger(WordChecker tagsList){
for(int i =0; i<tagsList.getCheckedTags().size();i++){
copyTagsList.add(i,tagsList.getCheckedTags().get(i));
... |
I'm creating an app where the user will be able to create HTTP request matchers. So the RequestMatchers will match HTTP method, path, query parameters, etc., for incoming requests.
Can someone look over this gist to see if you think I'm on the right track for making it very extensible? Currently it only supports match... |
For a school project I am tasked to decrypt DES passwords. I have sample code provided below and I want to know if this is the best method. Also should I code in error handling for the dictionary file or does the while condition take care of this?
#include <stdio.h>
#include <crypt.h>
#include <unistd.h>
#include <str... |
Expected behavior of the code below:
There will be one static SessionManager accessed by many threads.
Multiple calls to SessionManager.UseTheSession for a given session ID must be processed on a first come first serve basis (similarly, calling EndSession should allow any currently executing UseTheSession's to finish)... |
Unfortunately I get 3 warnings at jslint. Could someone please help?
I already tried a lot, but didn't get it yet.
Here's a jsfiddle: http://jsfiddle.net/KYjF9/21/
JSlint options:
/*jslint browser: true indent: 2 */ /*global $ jQuery alert*/
JavaScript:
var Typing = function (el, toType, period) {
"use strict";
t... |
In the code below, I take the number of square the user wants, then calculate the size of each square (so that they all fit in the container.)
I then define var square as in the 3rd line of code. I find this string pasting technique very hard to read and error-prone. The general question is thus: Is there a better way ... |
In order to implement my own Dictionary<TKey, TValue> in VB6, I've implemented a KeyValuePair class, which can accomodate any type as its key, or value.
This KeyValuePair class implements the IComparable and IEquatable interfaces which I'm also using in this custom List<T> implementation
KeyValuePair.cls
Private Type t... |
This class encapsulates a List<KeyValuePair> (see List<T> implementation here, and KeyValuePair implementation here) and exposes a richer set of members than the typical Scripting.Dictionary, ..not to mention the anemic Collection class.
The class enforces some "type safety", in the sense that if you add a KeyValuePair... |
I need to split up a sequence into equal segments of a given size (yes, the last one may be shorter), and I'm trying to find an efficient and idiomatic way to do it.
I have two versions of the function; segment is the F# version of an awkward and probably quite inefficient old C# extension method that I wrote, while ch... |
I'm writing a jQuery plugin.
I'm allowing the user to pass options (optionally-- argument 2 to extend) but I also require some defaults (argument 1), and some things user is not allowed to modify (argument 3).
I follow the global override pattern recommended by most jQuery plugins. But I'm running into something I'v... |
I've tried to make a portable way of ensuring endian-specific code gets generated at compile time using C++11, however I only have a computer with Windows on it to test at the moment. Because of this, I'm a bit limited in the amount of places where I can test my code. Also, would anyone be able to offer some best-pract... |
Given a directed connected graphs, find all paths from source to destination.
Looking for code review, optimizations and best practices. Also need help figuring out complexity, which in my best attempt is O(E!), where E is the number of edges.
class GraphFindAllPaths<T> implements Iterable<T> {
/* A map from node... |
With a positive outlook, I posted this challenge at Programming Puzzles & Code Golf. I tried to come up with my own solution to the challenge which is as follows:
The output is displayed (not yet exported to GIF) on a class extending JPanel:
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics... |
I have tried to implement a Least Recently Used cache with only C++ STL containers. The main thing that I keep asking my self the static variable called garbage_val. Is it a good practice to have such a static variable just for garbage values?
template<typename Key, typename Value>
class LRU_Cache
{
struct Node
{
... |
Functionality that overwrite standard error message with trace to user friendly message with error number stored in DB.
Not yet completed some stuff with trx...
Please review this.
DB table:
CREATE TABLE stored_error_msg
(
id number PRIMARY KEY
,msg VARCHAR2(2000)
,trace CLOB
,browser VARCHAR2(2000)
,date date
,user... |
Below is a full working code example of code which is used to compute stats on two class vectors (partitions).
There are two functions:
pairwise_indication and
to_clust_set.
The first one is the function in question and the second is just for completeness, since it's apparently not so time consuming. pairwise_indi... |
I implemented an unordered_set like container for storing small sets of unsigned integers. It uses a trivial hash table for lookups and an unordered array for quickly iterating over small sets.
I'm looking for suggestions on best practices and correctness.
#pragma once
#include <array>
#include <random>
#include <bitse... |
I looked at a search filter code code and edited it to catered to my functional needs. I understood most of the JavaScript except the extend method bit. Can someone explain that? Also, is this the best way to create such a filter? Please let me know of any ways to improve the code.
<style type="text/css">
/* Clearfix... |
The options for the 'cat' command are as follows:
-b Number the non-blank output lines, starting at 1.
-e Display non-printing characters (see the -v option), and display
a dollar sign (`$') at the end of each line.
-n Number the output lines, starting at 1.
-s Squeeze multiple adja... |
I have a link (avatar)#qam-account-toggle and div.qam-account-items, the div containing user account links. I am toggling div on avatar click as well as click anywhere but div.qam-account-items
Here is my code. How can I optimize this better?
$('#qam-account-toggle').click(function(e){
e.stopPropagation();
$(th... |
Got this question in a test.
Display the following number pattern using Java.
User inputs number of rows. For example 3
1112
3222
3334
For 5
111112
322222
333334
544444
555556
and so on.
This is the solution I came up with:
public static void NumberPattern(int n) {
int myarray[][] = new int[n][n + 1];
i... |
I would like to display this data, callable at any time, but I'm not sure if this is the best practice to do so.
countries = [
dict(Name = "China", Population = "1,363,560,000"),
dict(Name = "India", Population = "1,242,070,000"),
dict(Name = "United States", Population = "317,768,000"),
dict(Name = "Indo... |
Question:
One of Scotland Yard’s most wanted criminal (Mister X) is on the run
and needs to reach a certain destination safely. There are three modes
of transport available for him - By air, by train or by cab. With air
travel, he can go from station i to station i+3. Using a train would
make him reach stati... |
I'm not much of a jQuery coder (more of a PHP coder), except to call a few get values out of class and id and Ajax calls. However, I need to make a checkout system work and one thing I would like to do is to put a loading wait while I send a form through Ajax. When it's finished, it would redirect the user.
So on cli... |
I'm doing my homework and it says to write a test program that prompts the user to enter ten double values, invokes this method, and displays the average value.
I was able to get this program working with an overloaded method... but I'm curious to hear your feedback on where I can improve and what I'm not understanding... |
The code here will be directly pasted from this project. Quick summary: it is related to a Stack Overflow question.
So, basically, all the code below aims to implement CharSequence over a large text file, within the limitation of CharSequence itself (that is, up to Integer.MAX_VALUE chars). All the code below is extrac... |
Solved the ford-fulkerson algorithm, which is too vast to explain it comprehensively here. Check Wikipedia for Ford-Fulkerson and Princeton lecture on Ford-Fulkerson.
Looking for code review, optimizations and best practices. Also I request you avoid mentioning renaming GraphFordFuklerson and unit tests not done in se... |
I have a function initialize_path_statistics(). I have used openMP to make it parallel. I am not sure where certain lines such as
float length_enclosed = Nodes::get_length_enclosed(i);
need additional pragma like #pragma omp atomic.
void Path_Statistics :: initialize_Path_statistics()
{
path_match_score.resiz... |
Task:
Given a dictionary of words, and a set of characters, judge if all the
characters can form the words from the dictionary, without any
characters left. For example, given the dictionary {hello, world, is,
my, first, program}, if the characters set is "iiifrssst", you should
return 'true' because you can ... |
I've been trying to create a calculator to find mass using any and all known equations. The program will also return the steps used to find mass so the user can 'check their work' on physics assignments.
My biggest problem so far (and was solved by much copy-pasta) is the equations themselves. I'd like to be able to c... |
I am not sure about the place where flush should be used (if it is used at all here).
int Window_Shift :: get_window_shift()
{
int window_shift = INFINITE;
#pragma omp parallel for
for(unsigned int node_id = 0;node_id< no_of_valid_nodes ;node_id++)
{
//for all the nodes that can be extende... |
How can I test this C program for "efficiency"? The most interesting usage is that it returns negative output for large enough input, otherwise the behavior is about expected. Will you suggest how to improve the code, both the ui used in main that should be both efficient and preferably platform-indepedent and not use ... |
This is self-explaining example with usage in doctests (it's not that fast as implementation with dict key-lookups, but it's a lot more readable, and don't require callables and lambdas):
class Switch(object):
"""
Switch, simple implementation of switch statement for Python, eg:
>>> def test_switch(val):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.