instruction stringlengths 71 71.9k |
|---|
I am very new to programming (using C++) and coded a sudoku solver as a weekend challenge. I guess there are so many things to criticize, but I would really appreciate some constructive criticism. Just what strikes you the most. If you want to run the code, a "sudoku.txt" has to be in the same directory. It's content a... |
I am training a colleague who is familiar with Python but has a limited knowledge of C# and complexity. I thought the following problem could be a good start.
You are in a desert, there is a (infinite) wall in front of you and you know there is exactly one door, but you don't know if it is on the left or on the right.
... |
I've written a simple tabbed component in ReactJS, whose purpose was to make defining different tabs very simple. My implementation does this very well in my opinion, since defining tabs becomes very simple:
<TabbedComponent>
<Tab>
<Name>Tab 1</Name>
<Content>
<h1>This is the first tab</h1>
<p>Thi... |
The objective of this code is to make the difference inbetween two lists of items, that is knowing which items are missing in the second list in regards to the first one.
The first list is built from an enumerator with the following method:
keysToPress = Enum.GetValues(enumType).ToList();
Once this list is built, no... |
This is a rags-to-riches attempt from this question, based on the popular 99 Bottles of Beer, by (lightly) using Java 8's stream-based processing.
Any room for improvement in terms of readability? I can only think of two concerns:
It's not immediately obvious what the placeholders for each Line value are expecting.
I ... |
I'm developing a web application for simulating electronic circuits and I'm trying to add backward propagation options (guess you can immagine why). During refactoring I came up with a base class for logic operations and wanted to ask for some feedback (whatever pops up in your mind) on it. The class code is the follow... |
Started working with CSS animations and I'm wondering if there's a more elegant way to manage (with class names) when an animation is on or off. The general pattern I have is like this:
<div class="base-class"></div>
<div class="base-class base-class-rest"></div>
<div class="base-class base-class-active"></div>
I real... |
Having read "Effective Java" and "Clean Code" I wanted to apply these principles in a manageable scenario. To this end I refactored a Java library that calculates similarities between strings.
The code below is that of a cosine metric. Documents are tokenized into multisets of strings. These are passed onto the metric... |
I wanted to write a function findDeep that would perform a recursive, depth-first search on plain objects and arrays.
Comments and criticism welcome.
function findDeep(dict, test, index = 0, keys = Object.keys(dict)) {
var item = dict[keys[index]];
if(index > keys.length) {
return null; ... |
I have made a time format converter which converts 12 hour format to 24 hour format. My convert_to_24() takes a string in format of HH:MM:SS followed by AM or PM. It returns a converted string to 24 hours format without the AM/PM string.
Note: Let us assume that input will always have no space between them e.g. 07:05:4... |
I'm developing backend for my mobile app by using gin-gonic and gorm ORM (mysql). But I'm not sure api and db handle huge amount requests if clients increased. for example I'm using my db struct as parameter, is this a problem for concurrency ?
Here is my implementation:
main.go:
var i Impl
func main() {
// #GIN... |
The app will allow users to login and upload a CSV file that contains temperature data from a device. This data will be stored and the user can view all these downloads and select one from a list to view using Highcharts.
Where I am getting hung up is with the temperature recorder device model. Each device has a unit s... |
Is there anyone who can help me improve the time complexity of this backpack algorithm, for which I already use sliding array to improve the space complexity.
The problem is as follows:
Given n items with size A[i], an integer m denotes the size of a backpack. How full you can fill this backpack?
Example:
If we have... |
Problem Statement
You are situated in an N dimensional grid at position (x1, x2, …, xN).
The dimensions of the grid are (D1, D2, …, DN). In one step, you can
walk one step ahead or behind in any one of the N dimensions. (So
there are always 2×N possible different moves). In how many ways can
you take M steps s... |
I've already made an implementation of unsorted List but I'm not happy with results it gives. It looks like Big-O is nearly \$N^2\$ which is, I suppose, not correct for my list.
Here's the graph that shows the problem:
The X axis represents number of total operations: adding new elements and same number of deleting ma... |
This is purely testing my skills; I am not actually coding for a bank. This is part of a bank account class.
public void withDraw(double amount)
{
if(balance - amount >= odLimit)
{
balance -= amount;
}
else
{
Console.WriteLine("Error. Withdrawing wil... |
I have written this code that takes input from a file and creates an output file that reports each person's name, percentage of B answers, and personality. However, the my computePersonality method, which takes the contents of an integer array and converts it into a string of \$4\$ letters based on if the number in the... |
I have implemented a basic stack just for fun. I've just started learning about move constructors and assignment and move semantics as a whole, so I would really appreciate some feedback as to whether I've done it right, and if not, some tips as to how I should do it would be most welcome!
I'm also following the examp... |
I do need to use jquery autocomplete for two inputs. But I have use same processing script for these two elements.
At this stage I am doing it like this.
$("#suburb").autocomplete({
source: function(request, response) {
$.ajax({
url: "includes/state_au_ajax.php",
dataType: "jso... |
I wrote a solution in Java to solve the problem here. I use BigInteger to convert first from base 16 to base 10, then base 10 to base 64.
This seems quite inefficient to me, and I would have no idea how to do this if I couldn't use BigInteger. I'm sure there's a nice and clever way to do this using a lot more bit ma... |
I have spent a few days coding an ATM. What I'm looking for is some critique of my work. Is there anything I can do better here?
The entire project has 9 files and one class, a checking account and savings accounts. It also has a section for loans (thought it was different). Any advice, or input would be greatly appre... |
I have implemented class which manages communication with measuring device, which sends list of assignments, like variableName=value. These assignments are always separated by space. There are two options, the first is simple assignment variableName=value (without space around equal sign), the second is "array assignme... |
This is my first programming project with real world application. It's purpose is to take a file from a directory, encrypt it with a predetermined password, and email to appropriate recipient.
ID Email and Password are found in a CSV file that I created EmailDict from.
ID and Filename are parsed and dropped into File... |
The evaluate_guess function below returns the evaluation of a guess with respect to Mastermind game rules:
# sample secret code and guess
secret_code = ["a", "a", "c", "a"]
guess = ["c", "a", "a", "b"]
def evaluate_guess(secret_code, guess):
score = []
temp_list = secret_code.copy()
for i in range(len(se... |
I have a file that at some point contains a line of the following form:
OutputFilename output.root
I want to write a Python function that replaces the text after "OutputFilename" and saves to a new file.
I have made the following attempt, which works, but I'm sure there must be a more efficient, Pythonic way to do thi... |
How can I improve the style to avoid so many float64()s?
func IsInTimeRange(tvalue int32,timeout int){
t := time.Now().Unix()
return int(math.Abs(float64(t)-float64(tvalue))) < timeout
}
|
So I've completely changed how BrainfuckSharp does things, and added some features. This is obviously a follow up to: Interpreting Brainfuck code to C#, then compiling to a .exe
It now features an OptimizationLevel (currently hardcoded, will fix for the future) that allows you to indicate how far you want the interpret... |
Needing a way to read the number of lines on a web page for the purpose of a progress bar the following method is created:
private static int countPageLines(String url) throws IOException {
URL page = null;
BufferedReader in = null;
int count = 0;
try {
page = new URL(url);
... |
I've been reading about Memory Pools since I came across them in the book Game Programming Complete 4th Edition, and I decided to try and spin my own since I didn't quite understand how the one they presented in the book worked at the time.
One thing I'm uncertain of is defining the deleter in the shared_ptr. I don't l... |
I just want to confirm that my ISO8583 format is correct.
Example:
For the data field 35, the length of the data is 36, so I put 36 before the 4842. Then all the data is inserted in a string (dataISO). This dataISO variable is then sent to another function SendISO().
private void btnSend_Click(object sender, RoutedEven... |
I was asked a question to write a optimal program that would determine the total number of stops a elevator has taken to serve X number of people.
There is a elevator in a building with M floors. This elevator can take a max of X people at a time or max of total weight Y. Given that a set of people has arrived and thei... |
I have this code below that needs to query multiple database tables.
import mysql.connector
import itertools, time
cnx = mysql.connector.connect(host="host", port=3306, user="user", passwd="pass", db="factory")
cursor = cnx.cursor()
cursor.execute("select distinct(batch) from batchdata where equipment = 'DUV001'"... |
I developed a javascript component to display a tree, based on D3.js
I'm not sure how clean my code is, I'm not used to code a lot of javascript and I'm constrained to write everything in 1 file.
So I'd take every advice on how to make this code better.
And in particular, there's a behaviour I don't understand: a "magi... |
My code implementing rock, paper and scissors in Python, using dicts to hold choices.
import random
choices = ['rock', 'paper', 'scissors']
def choice():
player_choice = raw_input('Choose rock, paper or scissors: ')
if player_choice.lower() in choices:
computer_choice = random.choice(choices)
... |
How to know if my code is spaghetti or not?
Is this is spaghetti code?
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
((Core) getActivity()).emailCore();
((Core) getActivity()).messengerSharer();
... |
Is static imports making my code incomprehensible?
If I have static a variable in a class, and I call it in another class:
MainClass.java :
public static String NAME = "Jack";
and:
AnotherClass.java :
textView.setText(MainClass.NAME);
What if I just made that in AnotherClass?
import static com.example.MainClass.NAME;... |
I have an API for managing an email mailbox. There is a class called Message, and it has two Move overloads:
/// <summary>
/// Move this message to the mailbox folder whose path is provided.
/// </summary>
/// <param name="toFolderPath">The path to the mailbox folder to which this message will be moved.</param>
/// <p... |
When a user registers (creates a new account), I want to encrypt password before storing in a database, and when a user logs on (with username & password) I want to check password. I did it in the following way:
function password_encrypt($pass) {
$hash_format = "$2y$10$"; // Tells PHP to use Blowfish with a "cost" ... |
I need to return True if a page contains any of a list of element types. This code works.
var elements = 0;
var content = $('.TestModule');
if (content !== null && typeof (content) !== "undefined") {
elements += content.first().find('.btn').length;
elements += content.first().find('.textbox').length;
elemen... |
I have the following code, that groups similar todos into an array of arrays, using lodash (https://lodash.com). Here is a plnkr http://plnkr.co/edit/t4J5bKGjMlQxW2z9Zh7x?p=preview (open your console and look into script.js)
function Todo(value) {
this.value = value;
this.isSimilar = function(todo) {
return thi... |
I have a project, that creates a custom DataBaseConnection pool as below:
public abstract class ObjectPool<T> {
private final long expirationTime;
private final Integer minimumConnection;
private final Integer maximumConnection;
private final Integer overFlowWaitTime;
/**
* Hash tables t... |
I've built an appointment manager and would like to notify clients 2 hours ahead of time by via email of their scheduled appointment time. I am storing their scheduled time in a MySQL Datetime field.
Example:
2015-11-24, 10:59:05
I currently have a cron scheduled to run every minute and collect the emails to be sent:... |
To get started with C++11/14/17, I decided to write a program that brute forces the problem described in this video (and gives a progress update every few seconds):
Divide the numbers [0, 31] into two sets A and B such that
\$\sum_A {a} = \sum_B{b}\$
\$\sum_A {a^2} = \sum_B{b^2}\$
\$\sum_A {a^3} = \sum_B{b^3}\$
\$\su... |
I need to create a byte array with 100 bytes from a string. The length of the string is unknown but it is always less than 100 bytes. So if the string is 65 bytes then i need the array to be 35 zero bytes and then the String bytes to follow.
At the moment i have something like this, that does the job, but maybe someth... |
I want to make it lightweight (fastest, best performance) as it possible for browser, but I have no idea - I haven't huge knowledge about JavaScript.
That code run parallax effect on my web page. I have three parallax containers, which are different position background image. Script call on scroll event and when some c... |
I'm working on small Javascript code that adds text from a clicked-href to the top right corner of the Wikipedia page. So for example, if I click the "Jamaican" link in Sly and Robbie, a textbox would be appended to the page on the top right.
Note: to test this code, copy it and paste it to your console, then click som... |
I have a form that I submit with these variables: category_time, date_month, date_year, and status_time.
Here is an example of different form possibilities:
CATEGORY_TIME 1
DATE_MONTH Month:
DATE_YEAR Year:
FIELDNAMES DATE_MONTH,DATE_YEAR,SUBMIT
STATUS_TIME Select:
SUBMIT submit
----------------
CA... |
I've written a bit of code designed to go through a log file and determine successes and failures for certain criteria for each server in an environment. The code works just fine, except that on environments of larger size, it's just too slow. Currently it's running on a 2000 server environment with 18 criteria and 500... |
I wrote this code to find if a directed graph contains a loop or not. I am pretty new to graphs and I saw some examples on the internet but couldn't actually understand their implementations. So I read somewhere that you can colour mark the nodes. So this is my iterative implementation of that method. Is it an okay'ish... |
My aim is to write a C program (I must create a function) that, given a string and a character, returns another string without the given char value.
For example: function("Hello World!", 'l'); /* Prints "Heo Word!" */
So I've programmed a lot with Java and I am used to programming but I am not used to C and in particu... |
I have removed a lot of the code, but you should get an idea of what I am doing:
<?php
$upOne = realpath(__DIR__ . '/..');
require_once $upOne . '/vendor/autoload.php';
use phpseclib\Net\SFTP;
$errors = array();
$fileData = array();
$inputArray = array();
$config = new CONFIG\Config();
if (empty($_POST['emailAdd']... |
Originally I had tried to implement this topic after having learned about Inheritence and posted it on here, but that forced complexity and the main suggestion was that this was ideal for templates. Now that I've learnt about templates I was hoping someone could review my code for a basic implementation of mathematical... |
I have the following code that works great, but takes 40 mins to 1 hours to finish the task. It has at least 30 rules for blocking lines, and 30k+ orders to check. I'm new to Python (3 months working with it), so I don't know what can I change to make it run faster. The version in my computer is Python 2.7.9.
import co... |
Given two strings, for example
s1 = "Valentino Rossi" (which may contain as many spaces between the 2 words as I like)
s2 = "Vale"
I have to create a function that requests these two strings and that it outputs another one like this one: "Valentino (Vale) Rossi".
So for example if I have
s1 = "Mario Belli... |
I've been playing around with some basic algorithms in Swift. Here I am trying to generate phone words, words which can be mapped from phone numbers using the characters under each digit. I was trying to use map/filter etc.. as much as possible, do you think the result ended up being more readable or less?
First step, ... |
I come from a PHP object oriented framework background (Laravel, Symfony, Silex...). With that, validation comes in pre-built classes mechanism in a framework that validates for you parameters that you define and validates against. If it fails validation, you don't proceed.
Example from Laravel:
public function store... |
There are 12 gates. Using our face recognition system, we check every person who tries to enter each gates. My MVC web application is to show the result data to the gate-keeper. And this is the important part. The people in the control center look closely at the current situations in real time.
To put it simply, always... |
I have some JS code that when the user clicks the "add" button, some text is displayed to a textarea.
The code seems to be working OK. However, I realize I must refactor the code so that I am using only the one on click function instead of the six that I have for each of the 6 add buttons.
$('#row_split_id_cover_letter... |
My Java is very rusty and I have been unlucky finding a better way to accomplish this task. I have two different methods which get called based on which radio button is selected. Is there a cleaner way to store/determine which radio button is currently selected in order to call the appropriate method? Here is the seg... |
I am a beginner in C and wrote this code to implement ARP.
3 threads are present - one to respond/receive any ARP packet targeted to me, one to refresh the ARP table on a periodic basis, and one to transmit packets present in the buffer.
An ARP table is implemented in a hash table. The sensitive areas are:
A reply nee... |
I have two functions for writing data to binary file using BinaryWriter.
The first function has single data object as argument and looks as below:
// write single data object to binary file
public void AddHeaderToIndexer(string path, RollHeader header)
{
bool isDone = false;
bool error = fal... |
I found a way to solve my problem, but I want to see if there is any better or clear solution for this. I have two associative arrays like this:
$person= [
"A" => [
"sur" => "a",
"fir" => "andras"
],
"C" => [
"sur" => "b",
"fir" => "balint"
... |
This CalendarService is part of a little node-bot I wrote today which sends out reminder-emails if a team member forgets to submit his weekly schedule in time. Calendar backend is using Google Calendar.
I'm interested in feedback, what I could simplify, where are the code smells, etc.
index.js
import CalendarService fr... |
I had a problem that I posted on StackOverflow about that I could not connect to windows phone 7 from a 64-bit application. I got one response that said I should try to create a WCF Service over named pipe transport. Now, I have something that is working but since I am new to C#, WCF and COM, I would be happy for any g... |
So my this class is one in which is used to find rectangles in images that have already been pre-processed. For example the images are to be deskewed, greyscale etc. Following feedback off of various people I have been told to try and conform it to c# coding standards. I have tried to do my best but was wondering what ... |
I decided to step out of my comfort zone (Java) and try out Python. I wrote a very simple reverser.py and want it to be reviewed.
"""
This python script basically takes a string and reverses it.
This python script can be used as a command line script as well as a separate
module.
"""
import sys
def reverse(message):... |
I was working on a timer code in pure JavaScript and would like to know any pointers to improve:
Features
Start/ Stop/ Reset on click of a button.
Set limit to clock.
Update class name for warning and error based on threshold timer.
JSFiddle
function timer() {
var time = {
sec: 00,
min: 00,
hr: 00
}... |
For my fellow Computer Science and Media students at my university, I build a link collection which soon a lot of people used. It basically served as a central place for all the links we needed to get access to lecture and exercise scripts, etc.
To step it up a bit, I decided to throw some JavaScript at it so folks cou... |
I want to ask if you can review the code for a simple contact form and the PHP code which sends me an email once a visitor fills the form and is validated through Recaptcha
On my index.php file here are the form and php code
HTML:
<form id="contactform" action="index.php#contact" method="post" class="form" role="form">... |
Everything works, but my hard coding is worse:
Codepen
<div class="header__search">
<form action="">
<div class="search__input-wrapper">
<div class="search__dropdown">
<div class="search__dropdown-trigger btn-default">
<span>Portfolio</span>
<i class="search__dropdown-icon"></i>
</div>... |
Are there any memory leaks in this linklist implementation.Also is the implementation correct?Can the time complexity be optimized?
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
struct node
{
int n;
node* point;
};
node* first=NULL;
void search(int n);
void insert(int n);
void del(int... |
I'm currently processing xml messages with C#. It is working But I'm not confident that my code is fast enough. There are 3 possible messages I can receive. When I receive one the message an event is triggered and I can access the object outside of this thread and do the necessary processing. The method start is runnin... |
I wrote a python script that converts English to Entean language from an anime called "The Devil is a part timer". I am sloppy at coding and know that the script can be made better.
In the anime, the language in Ente Isla is called Entean, which is basically most of the consonants in the English alphabet switched aroun... |
I've reached a point in an application where I need to initialize some coordinates to an array and I wound up using nested for-in loops to accomplish the task.
Is there is a better way to accomplish this?
class Coord {
let xVal : Int
let yVal : Int
init(x: Int, y: Int) {
xVal = x
yVal = y... |
I made two player objects (p1 and p2):
public class tttmodimproved{
static int turn=0;
public static void main(String[] args){
System.out.println("Let's play TicTacToe");
char isWin=' ';
Board b= new Board();
Player p1=new Player('X');
Player p2= new Player('O');
... |
I'm trying to test an elevator simulator program that runs in the console and requires user interaction. At the moment, my tests look like this:
gem 'minitest', '>= 5.0.0'
require 'minitest/spec'
require 'minitest/autorun'
require_relative 'elevator'
class SingleFloorElevator < Elevator
@@moves = ["2", "N"].each
d... |
I created the below script to help break apart large flat files; to save myself effort opening files which are several gigs in a text editor and manually split them.
So far I've only tested on sample files, so I can't yet comment on the performance, but wanted to share my work so far / get feedback on whether I've miss... |
I feel like I'm overdoing the async await stuff. I'm just learning. Maybe this isn't the best instance to be using this stuff.
I have a system with sensors that detect the completion of some action. I decided to approach this solution using asynchronous programming since I still need to communicate with other contro... |
This is my Player file. It is mainly for saving purposes. Is it easy to understand and read? Anything I should add or change for improvements?
#Programmer: DeliriousSyntax
#Player.py
#Date: November 22, 2015
import math
class User:
def __init__(self, user, class_type):
self.user = user
self.level... |
I've created a program for my job that unlocks spreadsheet files quickly and efficiently. What we use to have to do before this program is we'd have to go into the system, search for the file, kill the users process containing the file, unlock the file, then the user can finally get back into their spreadsheet. With my... |
This code is just some exercise code printing questions and waiting for answers. It is working perfectly well as far as I can tell. I would like to know if this code could be considered acceptable or how it could be improved.
import java.util.ArrayList;
import java.util.Scanner;
public class MainClass {
public st... |
I had written with very few PHP skills a conjugator script.
It was not good, so I decided to start it from scratch with a help from a friend. I'm using the code formatter from eclipse.
Now I need your reviews and improvement tips.
I know all my long arrays with the all verbs and many more long arrays aren't a good way,... |
This is a simple 4-stage pipeline that partially implements the RV32I ISA.
All instructions are supported, except jalr, those relating to memory (l*, l*u, s*, fence and fence.i), or system calls (sbreak and scall).
The pipeline stages are more or less the classic RISC ones without the memory access stage (i.e. fetch ... |
I designed a "Ticker" based on how I imagine Minecraft's tick system works. My ticker calls a method tickRate times a second and provides a Delta Time value (deltaTime) to the method being called.
The issue I have with my code is that I find the update method (which handles timing) to be ugly but I'm not sure what I ca... |
I wrote a simple function to sort an array of integers in ascending order. Here is the code -
void sort(int* begin, int* end) {
int* it = begin;
int num1 = 0, num2 = 0;
while (it != end) {
num1 = *it;
num2 = *(it + 1);
if (num1 > num2) {
*it = num2;
*(it... |
The goal of this game is to not say the number 21.
Rules:
You must only say numbers consecutive to the previous said number.
You may say 1, 2, or 3 numbers at a time.
For example:
Player 1 says 1
Player 2 says 2, 3
Player 1 says 4, 5, 6
Player 2 says 7, 8
And so on...
You will be playing AI, and you will start. T... |
I wrote this code for a multiplayer game I am developing to transmit floats over the network. It works, on the systems that I have tested it with. What I am worried about is the little-endian big-endian thing and the possibility of different float representations in general over computers. So here it goes:
private stat... |
I'm building a small game in pure JS for my own learning purposes, using sprites to model players.
Before I go further, I want to try to get the animation down. The below code should produce a blank page with a skelton sprite that responds to arrow key presses. It should work in both firefox and chromium (but no other... |
New Approach
My previous question may have had a little too much going on and I realized I could simplify the problem by constructing the data a bit differently thanks to @Gentian Kasa . Previously, the code was filtering data constantly and causing a big bottle neck in the processing time. I have now constructed the ... |
I wrote a module with 3 services that execute the oauth (and set the api key) for the google api and return the token object if the promise is positive.
Here is the whole working module:
angular.module('gapiOAuth', [])
.controller('gapiOAuthController', ['$scope', function($scope){
}])
.factory('gapiCredentials... |
I have a DAL class full of LINQ queries which I would like to improve as I found that I'm repeating myself couple of times.
As you can see the part below is repeated couple of times and I was wondering if it is possible to reduce the number of repetitions (passing the query somehow?) and/or improve the queries overall... |
This is a program to read and store the data from a Excel file (.xlsx) which is uploaded by users.
Any better approach to reduce the usage of if-else to return the error message?
How to design or construct a good coding pattern before I code? What kind of aspects I should pay more attention on ?
Excel file uploaded b... |
I am working on architecture where I can have any client + server API. I need to call API as clean as possible and get, post, put any object I want to.
For me, it is important to have clean secure code with good practice. This is how I implemented it and I would like you to help me to improve this code.
Some of questio... |
I'm debating trying to take a crack at getting something similar to C#'s async-co-routine like nature over on JavaFX.
This is technically feasible since the Quantem toolkit exposes the enterNestedEventLoop and exitNestedEventLoop methods, but using them is tricky.
If you haven't seen it, C#'s await & task syntax (butch... |
I have figured out how to serialize multiple objects, however I am utterly convinced I can use some kind of loop for the if statements below, to avoid duplication. Please can someone advise how I would do this?
I have 20 objects in total, this code snippet shows the "if statements" for 4 of them.
import java.util.Inpu... |
I'm super new to PHP and I'm trying to get a functional login system together. This is the code I have:
class/user.php
<?php
class Users {
public $username = null;
public $password = null;
public $salt = "Zo4rU5Z1YyKJAASY0PT6EUg7BBYdlEhPaNLuxAwU8lqu1ElzHv0Ri7EM6irpx5w";
public function __construct... |
I am currently creating multiple games by adding objects of type Game as properties of an object called games. The names of these properties are set programmatically - for example, the first game will be a property of games called game1. Sockets joining this game will join the room room1.
Is this the right approach? It... |
I am not much experienced in Python, just write some small script. All my codes are procedural. They work fine, and I always check them with pep8.
One of them is:
#!/usr/bin/python3
import os
import sys
import numpy as np
import scipy as sp
import scipy.optimize
import matplotlib.pyplot as plt
def f(x, a, b, c, d):
... |
Here is a simple password generator in Java:
public class PasswordGenerator {
public static final String LOWER_CASE = "abcdefghijklmnopqrstuvwxyz";
public static final String UPPER_CASE = LOWER_CASE.toUpperCase();
public static final String DIGITS = "0123456789";
public static final String PUNCTUATION_... |
def search(a,b):
for d in b:
if a==d:
m=True
break
else:
m=False
return m
x=[1,4,5,7,9,6,2]
target=int(raw_input("Enter the number:"))
for i in x:
if i<target:
pair=int(target)-int(i)
in2=search(pair,x)
if in2==True:
pr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.