instruction stringlengths 71 39k |
|---|
As you will see from the code below, I have a base model.
public class BasePDV
{
public int CaseID { get; set; }
public string CustContactTel { get; set; }
public string CustMobileTel { get; set; }
public string PropertyType { get; set; }
public string PremisesStatus { get; set; }
public int Loc... |
(Inspired by this question)
The digits of the cube, 41063625 (3453), can be permuted to produce
two other cubes:
56623104 (3843) and 66430125 (4053). In fact, 41063625 is the
smallest cube which has exactly three permutations of its digits which
are also cube.
Find the smallest cube for which exactly five permu... |
I've create a basic Shader class in modern OpenGL (3.1) which works perfectly, though it is not feature complete yet. It still lacks the functionality to allow the user registering uniform variables in the shader and update them by calling a method.
Suggestions on how to further advance the implementation are welcome, ... |
Can you comment, review or suggest things for this? Maybe it should be broken into two methods?
friends is a list of strings of 'T' or 'F' characters representing a friendship relation.
For example for 3 people we could have
friends = ['FTF','TFT','FTF']
This means that
person 0 is friends with person 1 (since frien... |
I have written code for graph traversal using adjacency matrices in an iterative approach. The code should print the graph in a DFS way.
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
int c[n][n];
int i,j;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cin>>c[i][j];
... |
I have the recursive function below to cache all the folders of my company Drive into a file. It works like a charm but takes too long, specifically >30 secs to read and save the 300 folders.
What I need is to make it faster somehow. I don't know if it is possible to make the folder reading asynchronous, or if it possi... |
In light of this months Community Challenge, I've taken a stab at building something related. Keep in mind, this isn't a submission for the challenge, just a utility to help in the later process of completing the challenge.
What we have here is your simple encryption and decryption (with a given key) tool. I'd like to ... |
I have to create a quiz of showing questions from a JSON and post back the answers.
Here's the structure of JSON:
{
"pp": [
{
"profile_property": {
"circle_value": 4,
"created_at": null,
"id": 1,
"name": "THIS IS THE QUESTION TO DISPLAY",
"updated_... |
I'm working on a city building simulation game, and I have reached the point where I need to check whether tiles are connected to a power source. I decided on a flood fill for this, since it seemed simple enough to implement. For reference, I used this flood fill algorithm, and I also found this question on code revi... |
The function's job is to load a vertex attribute buffer or an element buffer from a specified path, and upload it to OpenGL. Also, optionally, return the number of vertices/indices loaded through an output parameter.
Signature:
GLuint loadBufferFromFile(std::string const& bufferPath, unsigned char vertexElementCount, G... |
I made a program that asks for a specified amount of numbers and checks if the input number is in the primitive type range. If it is, it "fits" on the primitive type.
Each input number, it checks if the number is in the range of each primitive type MIN and MAX range. If it is between the range, it prints the type(s) i... |
Given a binary tree, it's quite common to perform some operation on all nodes while traversing pre-order, in-order, post-order or level-order, depending on the task at hand. For example you might want to extract sorted elements from a binary search tree, for which in-order traversal is handy. Or do a breadth first sear... |
My objective is to take a string as input and determine if it is a palindrome. I'm wondering how I could improve this code (efficiency, bugs, etc). I'm relatively new to Java so I'm expecting that my code will contain some errors.
import java.util.Scanner;
/**
* Created by Adam on 6/5/2015.
*/
public... |
I repeat here this answer on Stack Overflow.
I first posted an answer with not finalized code, as a simple description of the solution I could think, without any test. But later I remained interested, so I worked to make it (hopefully) perfectly functional.
To precisely define what it is meant to do, let me cite my pre... |
Please critique my code. (Specifically, I'm not sure if my use of member variables is appropriate.)
Here is the main structure of my BST class:
public class bst {
private Node root;
public class Node {
int data;
Node left, right;
private Node(int data) {
this.data = data;... |
The title says it all. This is yet another FizzBuzz implementation where you can specify the words you want to use, though it autoselects the divisors as the first n primes other than 2, rather than having you enter them.
I'm looking for tips on variable/function naming and that kind of thing; I couldn't think of good ... |
Below is my source code for the implementation of a Ring/Circular buffer for use in audio processing. I have been using this implementation for several months now but I have some doubts about the efficiency of the insertion and removal functions as well as the correctness/necessity of my usage of std::atomic<size_t>typ... |
I'm trying to learn dynamic programming and the most popular one is to find the minimum number of coins for the change. I come up with this but I just want to improve this code which I think it could be shorter in Python but I'm new to Python too.
import sys
coins = [1, 3, 5]
min_coin = [sys.maxint] * 20
min_coin[0] =... |
The problem was to find which \$n\$ for which \$\varphi(n)\$ is a permutation of \$n\$ and \$n/\varphi(n)\$ is minimum,now as we all know that means (simple conclusions from mathematics):
\$\varphi(n)\$ should be a permutation of n.
\$n\$ should have least number of prime factors (2 cannot be one of the prime factor a... |
I am creating a true or false quiz game and when the user chooses an answer a tick or cross will appear on the screen telling the user whether they are right or wrong and then automatically bring the next question in.
Currently I am using 2 almost identical functions that draw the next question from my question array (... |
As a new Java learner I would like to improve my coding style.
I wrote a program which gets as an input a file name, and asks for two file names for the output.
The first output file includes all the words from the input file with their number of occurrences.
The second output file includes the words in lexicographic o... |
I have a couple of models - User & Score. I am displaying data from those models to my template. Data from Score is filtered based on data from User. I am using nested for loops and an if condition within the template to get my desired result. However, I want to know if there is a better way of coming up with the same ... |
I'm developing a small programming language for use in any project I have where I feel a small scripting language could be used well. I've written two emulators for the language, one in C++ and one in Java. The C++ performs faster except for any recursion in the language, in which it suddenly performs terribly!
Here is... |
Generate as many distinct primes P such that reverse (P) is also prime
and is not equal to P.
Output: Print per line one integer( ≤ 10^15 ). Don't print more than
10^6 integers in all.
Scoring: Let N = correct outputs. M = incorrect outputs. Your score
will be max(0,N-M).
Note: Only one of P and reverse(P) will ... |
I am doing FizzBuzz on a take home test (in Unity). I am sure this is just a competency check, but I went ahead and followed some coding conventions such as using constant fields, dependency injection, comments, etc. Is this overkill? If I should "dumb it down", how should I do so? Also, as seen in the directions, ... |
I took the code from kostyas benchmarks for the Rust Brainfuck interpreter and tried to optimize it. There is also a discussion on Reddit about the poor performance of Rust in the Benchmark.
Before my improvements the code needed 16.81s to complete the benchmark and used 6.2Mb of memory, after that the code only needs ... |
I was hoping someone could check the library I 'm working on to see if they could give any suggestions. My biggest issue right now is getting tuple to work with more than just the basic types and I also wanted to add exception safety; is this only necessary for the file save/load functions? I also still need to add the... |
My concern is speed, since this may be used in an e-commerce website I want it to be as quick as possible. Where can I improve?
def get_queryset(self):
search_terms = self.request.GET.getlist('search', None)
if not search_terms:
return []
# removing trailing slash on restangular calls
sea... |
Dilemma
The code below is in its infancy, but for now is an effort to crawl my entire file system and find duplicates whilst adhering to a variety of exclusion criteria. My current strategy for determining if two files are identical—comparing their checksums—seems unfeasible because it takes far too long to run (days, ... |
I am using Callable in my code which will be called by multiple threads as shown below. Given a user id in DataKey object, I will find out what are the hostnames I can use to get the data and then I will iterate that hostnames list one by one to get the data.
As of now, whenever any RestClientException is thrown on a ... |
This is a Python 3 solution to the problem stated in Sales Tax Problem, rejected for not being up to their standards. It also seems like the same thing as the problem stated in Sales tax calculator, rejected for being not OOP. I'm not bothering with the requirement to round sales tax to the nearest 5 cents, and I'm tak... |
I went through a question on SO, and optimized the code according to OP's requirements. I would like a review if it is done properly or not.
Here is the code snippet, there are 2 level buttons, when clicked 1st level button, it toggles second level button group.
Second level button group toggles div, which contains che... |
Lights Off is a puzzle game consisting of an \$n\times n\$ grid of lights. At the beginning of the game, some of the lights are switched on. When a light is activated, it and its four neighbors in the cardinal directions are toggled. The objective is to turn off all the lights.
Input:
000
110
010
Output should be
000... |
I wrote a PHP function that generates salts for use with password hashing:
function getSalt() {
$charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/\\][{}\'";:?.>,<!@#$%^&*()-_=+|';
$randString = "";
$randStringLen = 64;
while(strlen($randString) < $randStringLen) {
... |
I've created a simple command-line program that downloads the Bing Image of the Day, then sets it as my desktop background.
It is a console application, and closes immediately after setting my desktop background. It runs daily via Task Scheduler.
I've been working on this as a mini project for a while and would like to... |
I am just a beginner in C++ and I tried solving this problem:
What is the first number of the form 1 + 2 + 3 + … + n that has over five hundred factors?
But it seems my code is not that efficient because its taking ages to find the answer:
#include<iostream>
using namespace std;
void triNum(int);
int main()
{
i... |
I want to ask you if my PHP code is safe enough. I don't know if I should escape special characters in string after regex validation:
<?php
require_once '../../../wp-load.php';
$errors = [];
if (preg_match('/[^a-ząćęółśżźń ]/i', $_POST['name']) || strlen(trim($_POST['name'])) == 0 || strlen($_POST['name']) > 60) {
... |
I am reading variable length messages where each message is an int + msg bytes. Messages could be any size.
Right now my strategy is to have a direct buffer that reads from the socket, which then transfers the bytes read into an array-backed nondirect buffer. However my solution has a lot of copying, some loops and jus... |
I have come up with this code to do level order traversal recursively for a binary search tree.
private void printLevelOrder_Recursive(Node root2) {
Queue<Node> queue = new LinkedList<Node>();
queue.add(root2);
Stack<Node> stack = new Stack<Node>();
stack.add(root2);
if(stack.isEmpty() == false) {... |
I have a small program in Java with GUI, which is generating passwords using Secure Random. I am posting my code here because I want to correct myself in style and, eventually, in efficiency of writing code.
Should I use try catch in, for example, button handling or password generating? I saw some user answers who disc... |
I am a beginner in Access SQL. I am in need of writing a parameter query for Access SQL and found a few tutorials and links for that but that wouldn't satisfy my requirement.
DB: Access DB
This updates a 'PD' column based on the values of 'OG', 'CPTY-BA' in an INPUT table. I need to calculate PD values from other refer... |
I am looking for a way to merge two files with a list of distinct words, one word per line. I have to create a new txt file that would contain all the words of the first list and all the words from the second list. I don't have any other specifications. The order of words in the result doesn't matter.
public class tes... |
A follow-on, rags-to-riches implementation of The most efficient way to merge two lists in Java
The original requirements are to:
Identify the distinct values from two input files, and output the
distinct values to an output file. There is no specification for the
order of the output, only that each line should be... |
I wrote a Java program implementing a neural network with backpropagation. For anyone who isn't familiar with Neural Networks and Backpropagation, here is a good resource. Here is another informational site with some code. (A great book/code that uses python is neuralnetworksanddeeplearning.com) Also the backpropagatio... |
Things to deal with this problem.
An infinite Arithmetic progression.
A prime number. - p.
The starting number of an Arithmetic Progression. - a.
Common difference in the arithmetic progression given to him. - d.
You have to print the first index
of a number in that Arithmetic Progression, which is a multiple of t... |
I picked up a programming game, TIS-100. Programming manual can be found on Steam as well, but I have described the relevant syntax in my question.
Basically, you're dealing with some old machine that uses its own variant of assembly. It's a gamification of learning assembly, almost.
The machine consists of nodes. Eac... |
var phi=function(n){var count=" " //an empty string
for(var i =1;i<=n;i++){
if(for(var j=1;j<=i;j++){
i%j===0;n%j===0;count += j.str;}) //appended the j as string into count
{return count.length;}}
};
The Euler totient function phi(n) gives the number of numbers <= n which are relatively prime to n.
|
I've finally written my own Shader class. It's a basic implementation based on a tutorial, and it works perfectly. Any suggestions on how to improve, or correct my code are welcome!
Shader.h
#pragma once
#include <GL/glew.h>
#include <map>
#include <string>
#include "LogManager.h"
#include "bindable.h"
#include "dispo... |
For this program, the user needs to enter an exponent and the program will calculate \$e\$ (Euler's number) to the power of the exponent the user inputs.
This is done by two ways:
By the math.h library
By a for loop (Series)
Then the program calculates the difference of these two functions (which we now call \$d\$) ... |
I was wondering if you would be willing to give me some suggestions on shortening this code. I feel as if the amount of if statements I have is a bit much.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Speech.AudioFormat;
using System.Speech.Synthesis;
using System.Text;
using System.T... |
<?php
function filterExactPhrase($input, $phrase)
{
$phrase = explode("\t", $phrase);
$phrases = count($phrase);
for($i = 0; $i < $phrases;)
{
if(preg_match("/(" . $phrase[$i] . ")\b/", $input))
{
$out[] = ['INPUT' => $input, 'FOUN... |
It adds and removes classes from animate.css when mouse events occur. Though I hate how I had to write the same thing twice in both events.
var item = $('.work-item');
item.mouseenter(function(event) {
var $this = $(this);
var cover = $(this).find('.item-cover'),
coverTitle = cover.find('.title');
cove... |
I wrote a script which changes names of last downloaded songs and copy them to music directory. Can it be written better?
#!/bin/bash
IFS=$'\n'
for file in $(find "/home/stanek/Downloads/" -iname "*.mp3" -mtime -7 | sort)
do
nowy=$(echo $file \
| sed "s/_/ /g" \
| sed "s/\s*(*[A-z0-9.]*.pl)*//g" \
#leav... |
Can anyone offer any criticism on the following at a simple FizzBuzz in terms of Ruby idioms or otherwise?
class FizzBuzz
def initialize(fizz = 'Fizz', buzz = 'Buzz')
@fizz = fizz
@buzz = buzz
end
def is_number_divisible_by?(number, divisor)
number % divisor == 0
end
def get_text(number)
fi... |
I am working with a little project intended to allow applications to benefit from aspect oriented programming. The first aspect is logging, which is already working. However I want this code to be more performatic and cleaner.
Whole project
The basic goals is to annotate methods - private/public static or instance - wi... |
I generally like to be Rubocop-clean, but it seems like breaking up the first case statement will only make things harder to read. Any suggestions?
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--memory', host_hardware[:memory],
... |
I enjoy making silly programs every once in a while. This is one of them. It makes nice sounding notes that vary slightly depending on the key being entered into a TextArea. When you press enter, it plays back all the notes you have entered. That's pretty much all it does. I'm looking for constructive criticism regardi... |
I currently have three buttons, perhaps more to come. When I click on a button, I want a toast notification or message (popup message) to show up with some text. What I have works perfectly but it is very redundant.
How I refactor what I have below to prevent redundant code?
@Override
protected void onCreate(... |
I got a very unusual problem of adding and multiplying very big numbers (≥ 1e+100). So I've written simple functions that would operate on string representations of numbers, both as an input and an output.
Multiplication:
function multiply(a, b) {
if ((a | 0) == 0 || (b | 0) == 0) {
return '0';
}
a... |
I have a lookup table "RequestTypes" that has the following data:
ID Type
---- -----
1 Leave
2 Loan
3 BlahBlah
Using EF, and whenever the need arise to check the type of the request, I used to do something like:
if (row.RequestType.ID == 1)
{
// request is leave
}
else if (row.RequestType.I... |
I wrote a Java NIO Echo Server and want to maximize the number of connections to the server.
The problem is that when I try to connect more than 10k clients the clients get their connections refused:
error Connection Refused : no further information available.
The client program that I use generates a batch of 50 cl... |
I have different roles in my system.
HOD
Staff
Non staff
I am having a form at the front end and fields shall be visible to only users with specific roles.
The ShowInGui levels are like this:
Show to All
Show to staff/HOD
Show to HOD
Any other do not show
I am planning to write a method which will take the user rol... |
This is Conway's Game of Life written in Python and using Tkinter for GUI.
Problems are:
The "Play" button works so slowly. I can see how the canvas is redrawing from top to bottom. But when I quickly click on the "step" button - I see that I want to get from "play" button: I don't see redrawing process. How can I mak... |
I decided to make a script that will evaluate a user input and attempt to figure out what keyword they meant to type, by checking what characters are next to the ones they entered.
ie. On a QWERTY keyboard, d is surrounded by e,r,s,f,x and c, so if you wrote selete, this script would be able to check if you actually m... |
This function calculates the standard deviation of a patch, given a kernel size and greyscale OpenCV image. The middle pixel of the patch is kept if stdev of the patch is below the given threshold, else it is rejected. This is done for each pixel except the border.
I have never worked with OpenMP or optimization of C++... |
I have a class Currency, where I want to store business logic for working with currencies:
public class Currency implements Comparable<Currency> {
public static final int NAME_MAX_STRING_LENGTH = 50;
public static final int ISO_CODE_STRING_LENGTH = 3;
public static final int SYMBOL_STRING_LENGTH = 1;
pu... |
I have written some template helpers to check if a class has a certain method with a certain signature. The code is based on this answer. I attempted to extend it for generic methods. An important feature is that it also detects inherited methods.
#include <type_traits>
#include <string>
#include <iostream>
template <... |
I recently did an interview task. I was rejected because of bad code quality. There was two tasks. Here I will present the first, second will be posted in time.
This project is avalible on GitHub
First: Table view
Please create an iPhone application that will present the list of most popular wikis from wikia.com
Requir... |
This loops through folder to open files and get important info from the columns of names "HOLDER" and "CUTTING TOOL" and printing all the info to one excel document, masterfile.
It utilizes a dictionary and collection. I am very new to VBA So I do not know if I have stayed consistent with my naming of sheets and files ... |
#include <stdio.h>
int main(void) {
int a[100],n,sum,i,j,b[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
b[i]=0;
for(j=0;j<i;j++)
{
if(a[i]>a[j]) b[i]++;
else b[j]++;
}
}
for(i=0;i<n;i++)
printf("%d ",b[i]);
... |
Here I'm instantiating different classes based on the value of a type property. This type property will determine what view is rendered and displayed on screen to the user.
As you can see there's a lot of repetition here. The main problem I'd like to eliminate is all those else ifs.
onShow: function() {
var type =... |
Requirement primes numbers which do not have digit 1 in it.
Input
The first line contains T, the number of test cases. Followed by T
lines each contain two numbers M and N
Output
For every test case print the total count of prime numbers which does
not contain 1 as a digit.
If all prime number with digit 1 between... |
I have two arrays of variable lengths: people1 and people2. I want to create an array of arrays where each inner array is a pair of elements from people1 and people2 The pairing should be based on a matching key. I'm using Ruby 2.2.0.
For example, given this input:
people1 = [{ name: :jon, id: 1 }, { name: :jay, id: 3 ... |
As part of an exercise by Jamal to clean up old questions on Code Review that have no code in them, I helped by writing this query on Stack Exchange Data Explorer: CodeLess Questions
select Id as [Post Link], CreationDate
from Posts
where PostTypeId = 1 --questions
and Body not like '%</code></pre>%'
and ClosedDate... |
This is a short and simple Python written to help me sharpen my dulling recursion skills. It expects a sorted permutation of integers n1..n2 in list format, with a single step missing (e.g., [10,11,13]). I know it does nothing to check errors; I'm more interested in theory here.
from __future__ import division
from mat... |
Use case: I sometimes write programs that want to store a little state between runs, e.g., "What was the last file selected last time this program ran?" I wanted a convenient way to track this state. Python's built-in shelve module is pretty good but I wanted a way to restrict the possible set of keys in the shelf so t... |
I'm developing a shop system and using this method to store the customers with their respective orders:
try
{
$connection = new PDO("mysql:host={$HOST};dbname={$DB_NAME}", $USERNAME, $PASS);
}
$connection->beginTransaction();
$sql = "INSERT INTO orders (customer_id, customer_name, order_value, order_date)
... |
I'm working on my first Clojure project, which is a parser. Since it's my first project I'm unsure of many aspects, from my general approach to solving this problem to the small implementation details. I also don't know anyone proficient in Clojure so any guidance is welcome.
In higher terms, my implementation will tak... |
I'm introducing someone to JavaFX. It still feels relatively new and I don't take being someone's first exposure to something lightly. I want to know if there's anything I'm doing unconventionally, inefficiently, or just plain oddly in this code? Although it is relatively simple, If fresh eyes could discern something u... |
I have created two classes to help me work with images in C#. I decided to wrap the System.Drawing.Bitmap so I don't have to deal with different file formats (let the framework open/save them), but the Get/Set methods of System.Drawing.Bitmap are far too slow.
I created an abstract class instead of an interface so I do... |
I would like a review of a Scala validation library I am writing. For now we can focus on the regular expression component.
The usage is described in RegexExample.scala
There is an outline of the interface in RegexRuntime.scala
But the macro and most of the craziness lives in RegexValidator.scala
The idea being, if ... |
I have an class definition:
class ScoreDetail(Document):
location = StringField(help_text = "province")
school = StringField(help_text = "school")
spec = StringField(help_text = "major")
bz = IntField(help_text = "1: Bachelor, 2: Academy, 0: except... |
I have this code below which establishes connection to server (from device).
Basically assembles some buffer, sends it to server, gets response, parses and prints it. I would appreciate if someone can review it critically - see potential bugs, undefined behaviour, etc.
First some declarations:
typedef int s32;
typedef ... |
After a little work, I've finally ironed this out... Though could I get someone to go over this and see if there is a better way to present this library within the code, before I publish it?
Premise: Kimchi (a Korean transliteration library)
Kimchi, apart from being a delicious Korean side dish is also a Korean transli... |
I have done the following kata in TDD style and would appreciate it if someone could review my code and my tests.
String Calculator
Create a simple String calculator with a method int Add(string numbers). The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0). For exam... |
I've been working on learning React, and so like most people do when they get started on something new. I created an arbitrary simple project to get a bit more familiar with the concepts.
It's so simple that it shouldn't really require any explanation. Here's the React code.
var TestInput = React.createClass({
prop... |
Given a string array that either contains empty strings or non-empty
strings, arrange the contents such that all the empty strings are at
front and non-empty strings at back, retaining their order from
original array.
For example, input:
{"","a","","d","","o","","g",""}
{"d","o","g"}
{"","","",""}
Output:
[, , ... |
Follow up from General Game Loop 2.0
It has been quite a while. Some major changes involve:
Removed dependancy on Swing. The more I read up on Swing, the more I understood it was meant for handling forms. Directly "Swing is a GUI widget toolkit for Java". As games generally depend a on GUI but aren't solely based on i... |
I have a sheet that order a bunch of information on individual orders. Order numbers are in column A, other information is in columns B-P, and then product numbers are the headers for columns Q-DL. The cells within the order number and product number contains an integer that corresponds to the location that product is ... |
I have this string containing this block of code:
[General]
StartWithLastProfile=0
Profilist.notifications=true
Profilist.dev=true
Profilist.dev-builds=80k
Profilist.launch_on_create=true
[Profile0]
Name=Dev Profilist
IsRelative=1
Path=Profiles/j0a1zjle.Unnamed Profile 1
Profilist.tie=0
[Profile55]
Name=Main
IsRelati... |
I am building a login using an API call to a URL that returns JSON data. The login works and is functional but in terms of "correctness" and "professionalism", I am looking to get input from some of the devs here. Please give me an tips that could possibly aide in making the most functional program here possible. (Plea... |
I am looking for advice if the below code is a good idea or not. If not, why? I am building a website which allows a user to purchase items. The user account and cart items will be stored in Session. My approach is to create a singleton class that will manage all the sessions. Is this approach good or bad?
public class... |
I just want to return the first word in the image name (before the dash, dog in my example). Now I use it like this but believe it can be done in a simpler way (like one line of code):
$live_site_image = "http://example.net/wp-content/themes/example/images/dog-in-park.jpg";
$live_site_image = substr( strrchr( $live_sit... |
I have code for googly eyes that is too long. Basically I have variables for each element pupils (one for right -other for left), eyesockets (left, right). I wish I could compress my code so I can call a function animateEye (eye).
function animateEye(eye) {
console.log(eye);
var pupille = eye.fin... |
Is there any room for improvement?
import random
def play_again():
while True:
replay = input('Play again? Yes or No?\n')
if replay.lower() == 'yes':
return True
elif replay.lower() == 'no':
return False
print('Invalid input.')
def main():
print('Welcome... |
Goal:
I needed to calculate the salted hash of a password, where the password is stored as a SecureString. There doesn't seem to be much .NET framework support for SecureString. In particular, none of the crypto functions have overloads that take a SecureString.
The goal is to provide a way to salt and hash a SecureStr... |
This is how I write all my database interactions now in Lucee:
storedproc
procedure='OrderDetail.WhereOrderHeaderID' {
procparam value=session.Usr.UsrID;
procparam value=url.OrderHeaderID;
procresult resultset=1 name='OrderDetail';
procresult resultset=2 name='OrderHeader';
}
Assuming I've done th... |
Modify the maxmin.c program so that the max min function uses a
pointer instead of an integer to keep track of the current position in
the array.
maxmin.c
/* Finds the largesy and smallest elements in an array */
#include <stdio.h>
#define N 10
void max_min(int a[], int n, int *max, int *min);
int: main (voi... |
Problem:
Data:
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 6... |
I have a relatively simple problem: I have an IEnumerable<T>, which takes considerable time to yield each term. This is then used by another piece of code, which takes considerable (but not identical) time to process each term.
As I understand it, this is a classic producer-consumer scenario, so I'm choosing to use a B... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.