instruction stringlengths 71 71.9k |
|---|
I had a test before and had to do this task:
Create classes: Cat, Dog and Petshop. Types Cat and Dog have fields Name and Breed and method Introduce() which prints text "I'm (Name) of (Breed). I'm a cat (or dog)".
The class Petshop collects different pets in its container.
We may add new pet to container using metho... |
I've put together another simple query that allows you to search post/comments with specific keywords. At the moment, only post bodies are checked.
DECLARE @search_keywords NVARCHAR(MAX) = ##SearchKeywords:string##;
DECLARE @search_type_id NVARCHAR(MAX) = ##SearchTypeId:string##;
IF (LOWER(@search_type_id) = 'post')
B... |
I am writing a unit test to be sure the code can connect to aws via boto, since I will be putting the credentials in place via some other process than code deployment. So far, I've only figured out how to check if I have a valid connection by looking at an S3 bucket, but am hoping someone has a more direct way to chec... |
I was thinking the other day how could I get the icon from a website and make it show and update when it is updated on the site so I made this code:
URL url2 = null;
boolean updateIcon = true;
try {
url2 = new URL("https://dl.dropboxusercontent.com/s/70rhm66myw8ay2v/Perception%20Logo.png");
} catch (MalformedU... |
For my website, I use the opengraph to send the right data to the crawler.
On the top of all pages on my website, I include the opengraph-script, like this:
if (preg_match("/facebookexternalhit/is", $_SERVER['HTTP_USER_AGENT'])) {
include("./facebook-crawler.php");
exit();
}
facebook-crawler.php:
## I... |
I have a piece of code that checks if two strings are anagrams. I would like this to be as pythonic as possible.
def are_two_string_anagram(string1, string2):
if len(string1) != len(string2):
return False
def char_count(string):
char_count = {}
for s in string:
char_count[s]... |
I built a small store site for learning purposes. I loaded my 'products' from the db into a Products class. I used a method from this class to display the products in HTML. Of course, the HTML contains 'Add to Cart' buttons which POST the product ID and quantity when a button is clicked. The result is that the POSTe... |
I have a homework question that asks me to get 2 integers from the user, put them in shared memory, fork a child, have the child add them and put the result in shared memory, and then the child will end and the parent will print out the sum. The program must also loop until the user does CTRL+C, at which point it shou... |
I was posed a question as follows:
Given a sentence like "John is a bad man", lets say all the formatting disappears and you are left with one string "johnisabadman". Given a dictionary of words, design an algorithm to find the optimal way of "unconcatenating" the sequence of words. The optimality stems from the parsi... |
I am new to C++ and programming in general. After reading through my first book, I decided to take on some programming exercises and test what I learned. The exercise is phrased as follows:
Find Cost of Tile to Cover W x H Floor - Calculate the total cost of tile it would take to cover a floor plan of width and heigh... |
I have implemented Dijkstra's Algorithm in C, using arrays instead of any structs.
Here is my implementation:
#include <stdio.h>
#include <stdlib.h>
int G[20][20], distance[20], inSet[20], q[20], parent[20];
void print(int V)
{
int i ;
for (i = 0; i < V; i++)
{
printf("i = %d parent = %d distanc... |
I have a piece of code that searches for XMLs in given folders, delete the ones older than X, zip the ones older than Y and delete zips older than X. It works perfectly but I have a terrible feeling that this is very inefficient code.
A little more information: It reads a config file for the times to delete/zip using ... |
I am currently learning javascript and I attempted to make a Person class (note - this was part of a practice exercise, so some of the design decisions may have been due to the requirements).
Specifically, I am looking for feedback on:
Usage of prototypes (i.e. from my understanding, prototype should be used when th... |
This is my first program in Python and first time I'm writing in dynamically typed language. I have substituted real detectPeaks function with a simple placeholer. I'm aware of several problems with this program.
I still don't quite know how to 'live with' Python scoping, hence the qFixfunction. I didn't bother to find... |
The script is intended to return an array with texts containing specific words in English and the equivalent texts in Polish from EUR-Lex - a website with EU documents.
The script downloads the page which address is specified by the passed variable. Then this page is parsed using regular expressions for the document co... |
I have written this code for a two input calculator. Is there anything I can do to make this code more efficient?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CalcGui extends JFrame {
private JButton buttonZero;
private JButton buttonOne;
private JButton buttonTwo;
p... |
I have recently started researching some computer vision, and in the process of discovering some interesting things I have been compiling some functions that allow me to manipulate images at a low level. I am not interested in replacing any of these functions with already existing, built-in functionality of canvas (but... |
This code is used for displaying only certain content of the form instead of displaying all the form content. I am using it to stop the users from filling all the form fields if those are irrelevant to the user.
var checkbox = document.getElementById('checkbox');
var checkbox1 = document.getElementById('checkbox1');
... |
A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, and closes every other locker. Student S3 begins with the third locker and chan... |
I would appreciate some help with camera movement and zoom. Is there any easier way with cleaner code, or simply how can I improve it?
Window size: 800x600
Image size: 1200x900
This is my code so far (you can move with the camera only around the image and use zoom):
package game.engine.gui;
import game.engine.Engine... |
Recently, I implemented an RenderBatch class, which renders any objects, using a specific shader (with its configuration). I'd like to improve on the way my render process works.
RenderBatch.h:
#pragma once
#include "alpha/Shader.h"
#include "alpha/RenderComponent.h"
#include <glm/glm.hpp>
#include "alpha/Mesh.h"
#inc... |
I was asked to create a function that return first UNIQUE integer from given array of integers. In a case of success the function return the unique number in a case of failure return -1. The complexity should be \$O(n \log(n))\$. How can this be improved?
function solution(A) {
var returnNumber = -1;
var tempA... |
I wrote some code to translate numbers ( for now just positive, up to the 32bit limit ) into English words.
Everything works and I'm happy. I searched through the site looking for a comparison code but I couldn't find a C++ version that goes above 999 to use as example
I had a few assumptions:
No need for and, just sp... |
I've built a simple decorator that wraps a function in a general Pygame game loop. It also allows for the programmer to set the tick rate.
import pygame
import sys
pygame.init()
def game_loop(tick_rate=60):
"""
This simple decorator wraps functions
with a pygame game loop. Here's an
example of usage... |
I'm creating a JavaScript app for a esoteric language, Marbelous. One of the features of this language are the devices. Each cell has a device, and each device has certain properties.
In order to represent this, I've created a massive object (or in my mind: HashMap) to store all of this data. This object stores stat... |
I don't like how transforming the data requires a bunch of nested functions. It's not very readable. Is there a more readable way to do the same transformations in Lodash?
var templates = {
"fullRenderV80": {
"stuff": "stuff",
"screenshots": [
{
"device": "iPhone 6",
"position": 1
... |
This code allows me to compare two complex objects, which are stored in a relational database, to see what has been removed from the objects. These objects have a unique integer primary key. They are also composed of other objects hierarchically.
The Difference method is used within a database application (code not ... |
I am currently trying to learn Lambdas and following the book Java SE8 for the really Impatient and just finished Chapter 1 of it. This is the question, I am trying to get done with:
Didn’t you always hate it that you had to deal with checked exceptions
in a Runnable? Write a method uncheck that catches all checked
... |
I wrote this program where you can input x amount of words that of length x that checks if the grid formed is the same words vertically as they are horizontally:
F I L E
I C E D
L E A D
E D D Y
The words can be entered in any order and the letters must stay in the same order. i.e. F I L E can't be F E L I
The permut... |
I am currently preparing for my exam and I am trying to implement some abstract data types with linked lists as preparation for the exam. I found an older exam from my prof. and he wants us to implement an ADT stack with an inner class ListElement.
He has given us the interface, so it doesn't need to be implemented. He... |
I'm having to dabble with caching and multithreading (thread per request), and I am an absolute beginner in that area, so any help would be appreciated.
My project requirements are:
Cache one single large object that has ether interval refresh or refresh from user
Because retrieving object data is very time consuming ... |
void chrrem (char arr[], size_t len, size_t pos)
{
memmove(arr + pos, arr + (pos + 1), (len - pos) + 1);
}
It is supposed to be just fast.
Erases the character pointed by pos (starting from 0)
Note that this function works with a statically allocated array like so:
char arr [256] = "Mystring";
// >>
chrrem (arr... |
This is a small object that allows you to pass an obj and a property name using its helper functions to create a typed var that won't save a value to the property if it isn't the right type.
This was just for fun, and I am interested on getting some feedback on what I could have done better/cleaner.
/* JSTypes is the... |
I'm implementing several data structures in an attempt to learn C++. Below is a binary search tree that I've implemented to learn about pointers, dangling pointers, and memory leaks. I was hoping someone could critique my code, point out any problems that they may find, or any inconsistencies. Please, be as harsh you f... |
I call these text updates "Feeds". A Feed object has some basic attributes like its content string, how many lives it has and its priority in the queue. I haven't made a unittest for this one, but below I have added a small test function for the purpose of posting this question. I use this to update statusbar in GUI ap... |
Please ignore row "B. and C." as it works in the environment where it was implemented and is missing the JavaScript reference. The rows highlighted in light blue are the issue. I injected row "A." to calculate (addition) the input of the rows above it. I am appealing to experts who know how to better recognize loops... |
I have a Controller which uses an application service to accomplish its tasks. The service class is starting to grow big and developing multiple dependencies. So I am thinking of replacing the single big service class with multiple command handlers, each handling a single responsibility. This is how the old and the new... |
I created 3 different implementations (which produce the same results) using the count_if function from STL. I wish to check the number of elements in the vector which are strictly less than 6.
These are:
C++ lambda function
Global function (no functor)
Using class and creating my own functor
These implementations ... |
The purpose of this script is to enforce some rules for validating a keyboard shortcuts definition. In my case I want to reject duplicates keys improperly added in the combo properties. This code rejects key combinations like CtrlAltPPwhich are not valid.
I would like to know what are the best practices regarding varia... |
I have a function that breaks up a source file and checks each token against a keyword list to determine whether its a particular file type. How can I improve this function? Tokenization is a class that contains a function to break up the source code.
public static boolean validationTypeOfSQL(String sourceFile, Tokeniz... |
I'm learning regex with sed to extract the last field from file named "test". The method I'm trying gives desired output.
Please suggest if this method Im trying is effective way of doing it. Also when should we use "-e" option with sed (please give an example — I couldn't find examples)
~# ] cat test
example.com. ... |
This is a Python library for efficiently tracking span information while parsing source code, and generating errors on those spans.
I intend to use it in my rewrite of mypy's Python parser to add column tracking and better diagnostics, but this code could be used by any parser.
I am using PEP 484 type hinting (which ca... |
I tried to answer the question "How to print a hash in Perl, such that 3 key value pairs are printed on each line?" like this.
As I got an uncommented downvote, I'd like to ask: What's wrong with/How to improve:
use Modern::Perl;
my %h = ();
for (0..7) {
$h{$_} = chr(65 + $_);
}
print %h, "\n";
my $cols = +$ARGV[0... |
I have a Swing vector-program similar to Dia targeting RAD. There are some plug-ins that let you
create structures like Rectangle, Text and Circle but also complex types like Table-Columns.
generate files like Spring-Roo-Script, grails-script, SQL-Files and svg-Files.
In the Center you have the Drawing-Panel (DrawPa... |
I'm learning JavaScript and I've made a very simple little document-modifying script that prints a message as if it was someone typing into a console. It practices recursion and in my opinion, I feel a bit iffy about the number of if-cases in the code. My main concern is the JavaScript though I know there's still a lot... |
I'm working on an upload file program in PHP in OOP style. I need some feedback about code.
index.php
<?php
require_once('./lib/upload.php');
?>
<?php
if(isset($_FILES['file'])){
$fileupload = new upload();
if(!$fileupload -> sizeck()){
if($fileupload -> extens()){
if($fileupload -> upload... |
I wrote this code to De- and serialise structures afap using IL generation (comments describes C# analogue). What can be improved here?
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
namespace StructInterop
{
public static class StructInterOp
{
... |
I implemented a D-ary max heap backed by a vector for resizing. I would like to know any possible improvements in performance, design, and in the code in general.
#pragma once
#include <vector>
#include <iostream>
#include "Comparators.h"
template<typename T>
class DHeap
{
public:
DHeap();
DHeap(unsigned);
... |
The purpose of this file is to make an Ajax call to a certain endpoint, and update a certain fields on the HTML page, auto populate the dropdown-menu, table, and piechart.
My script will turn this:
to this:
I'm not sure whether or not I should do all my logic within my Ajax success. Should I separate it? This is what... |
My logic is as follow:
Convert actual time to minutes.
Extract seconds from minutes (30:04 -> 4 seconds).
Subtract seconds value from minutes (step1-step2) to get time only in seconds.
Convert time in minutes (step 3 output/60) to hours.
Now suppose i got time as 5404 which corresponds to 1:30:04. When I divide 5404... |
I am working on an algorithm, which should group connected Arcs. The situation is described via code examples below.
I have Arcs:
public class Arc
{
public Point StartPoint { get; set; }
public Point EndPoint { get; set; }
public bool Visited { get; set; }
public Arc Successor { get; set; }
public A... |
My problem statement is:
Write a function to indicate if a given Sudoku board is legal. This function takes a Sudoku board (which you may assume is a N2xN2 2d list of integers, where N is an integer), and returns True if the board is legal, as described above.
And here's my solution:
import time, random
def solve_al... |
I wanted to render the textures that comprise a bitmap font glyph onto the screen directly as an Image in libGDX. When you make a bitmap font using a program (such as Hiero), it generates a text readable .fnt file along with a .png file that is the sprite sheet for the font. The only thing missing is a matching .atlas... |
I have a button dropdown that you can select different currencies from. When you select one, it replaces the button value with that currency type, and displays the currency symbol in a span in front of an input.
I have done some refactoring where I now have just one function getCurrency() that accepts parameters and i... |
I create blog posts as blog1.php...blog20.php...blog500.php etc and redirect users from blog.php (code below) to the most recent blog post as determined by the blog post with the highest number in the filename.
Here's how I'm doing it, but I have the sense this could be much cleaner and more elegant:
$directory = "/va... |
I am writing a piece of code in c# that mimics the behaviour of following SQL function STR in the following case:
declare @number numeric(19,15) = 219.37345462345234235
SELECT str(@number,9,9) -- 219.37345
declare @number numeric(19,15) = 19.37345462345234235
SELECT str(@number,9,9) -- 19.373455
Following is an... |
I never took an application in a Model-View-Controller architecture and have some difficulties in front-end. The following code works fine, but what can I do to make "layers" of better code and even the application directories?
This is a single file located in /resources/js/controller.js.
Controller.js
var app = angul... |
Quite a little while ago, I wrote a VBA macro to generate fiscal calendar date records. That macro did the job all this time, but I needed to be able to generate fiscal years from an ETL overnight process, so I rewrote it in a small C# console application.
I went with full-on dependency injection and IoC, wrote dozens ... |
I have come up with a solution to the equilibrium index problem with help from the answers off here:
val in = Stream(-7, 1, 5, 2, -4, 3, 0)
val sum = in.scan(0)(_ + _)
val hash = (in zip sum) map { case (e, lsum) => 2*lsum + e }
val target = sum.last
hash.zipWithIndex.collect { case (e, i) if e == target => i }
It's u... |
I've made about 2 forms that have a server side action using PHP. For the first one, I made a variable for every form field and mapped it to $_POST["name"]. For small amount of fields, it's not a problem, but it's tiring for large amounts.
For my second form, I used the scripts below. The problem I had with it was how... |
I use the following code to convert ۱۲۳۴۵ to 12345, effectively transliterating the persian numbers into latin numbers:
String.prototype.toEnglishDigits = function () {
var num_dic = {
'۰': '0',
'۱': '1',
'۲': '2',
'۳': '3',
'۴': '4',
'۵':... |
I am a Java programmer trying to learn the ways of Swift. A few days ago, I posted the code for a very simple app that draws a Sierpinski triangle and implements a pretty buggy zoom. I was told to work on organization, delegation, and creating global functions, all of which I tried to do. I also added some new features... |
This is a simple program to convert a number, from 0 up to 99999999, to English words.
Example:
If the input is:
1234
The output would be:
one thousand two hundred thirty four
I would like to get feedback regarding this small program.
#include <iostream>
#include <vector>
#include <string>
const std::vector<std::s... |
I have some Field objects that need to be serialized. Their primary string identifier is called a Tag and starts with a number, so it's not suitable for use as a class name. Thus, for a field bearing tag 32A, I am using the name Field32A. However, during serialization, I need access to the literal string value "32A".
I... |
Deferred allocation is a memory optimizing trick of using the Node** as Node* when there is only one item in the "bucket". Thus "item" member holds either the index of such lonely item, or a negative value if the bucket is fully allocated.
Cache-awareness here is merely adding a compiler's __builtin_prefetch() in the r... |
My usual disclaimer, I'm new to Python and scripting and I'm still studying the PEP8 guide, so please forgive any huge failures with respect to syntax, formatting and style. I'm open to any suggestions in regards to pretty much anything so let me have it!
That said, I've been building little games to learn so far, but ... |
Could anyone provide any constructive criticism? I'm trying to get a jump on data structures before classes start.
One thing is that I should add a copy constructor and assignment operator. Changes made: got rid of using namespace std.
As the code allows users to specify a cap, if they wish, for their stack any ideas o... |
I'm trying to make a programme that reads graphs from a .txt file, puts them in a vector, and finally puts the frequent closed graphs in another resulting file.
I'd like to adjust this program to make it faster and more performant for memory.
#include<boost/version.hpp>
#include <boost/graph/adjacency_list.hpp>
#includ... |
I have an interview coming up in the next few weeks, and I'm choosing to be interviewed in Python. I began programming in Python (it was about four years ago), so the syntax is natural to me, but I only learned about some useful tools of Python just this past year, when I took a class that recommended using it.
The Pro... |
What it is doing basically is reading an std::string from a given pointer.
I was told that using a StringBuilder as I am is not the best way to achieve this, so I would like to know how this would be best written.
As additional information, that is a pointer of a std::string and I've made that because I was originally ... |
I'm making a class that takes a path to a text file as an argument in its constructor, and then parses the text file and pulls out a lot of data that it stores as private members. Most of these members are vectors of ints, floats, and strings.
The class will be used by different versions of VS, so my understanding is t... |
My interview question was that I need to return the length of an array that removed duplicates but we can leave at most 2 duplicates.
For example, [1, 1, 1, 2, 2, 3] the new array would be [1, 1, 2, 2, 3]. So the new length would be 5. I came up with an algorithm with \$O(2n)\$ I believe.
def removeDuplicates(nums):
... |
rags-to-riches of Convert seconds to hours, minutes and seconds.
In that question, BigDecimal was chosen to be the model class, which doesn't seem like a right fit for temporal amounts.
Sure, doing arithmetic should be the simpler and faster way, but I thought of using the Duration class to make this more 'API-driven'.... |
I want to implement an Agent-like object in C#. An Agent wraps some memory location (ideally storing an immutable object) and receives updates to that location. All these updates are performed asynchronously, but sequentially. In other words
At any point in time, at most one [update submitted to an] Agent is
being e... |
I'm writing 2x2x2 rubics cube simulator. In my code I have a concept of Face which is individual side of the cube, and State which is agregate of all six sides. When I create new State, in addition to creating faces I need to set all neighbour faces for a given face. Currently I do this in manual way, as in:
faces[Side... |
For the Matasano CryptoPals Challenges Set 1 Problem 8, which states:
In this file are a bunch of hex-encoded ciphertexts.
One of them has been encrypted with ECB.
Detect it.
Remember that the problem with ECB is that it is stateless and deterministic; the same 16 byte plaintext block will always produce the same 16 b... |
I have a small piece of code that checks some data but I suspect one of the if statements is unnecessary:
bool meldControleGereed = false;
bool allProductionDone = true;
int controleBewerkingId = 0;
foreach (DataRow row in controleTable.Rows)
{
string code = row.Field<string>("CODE");
bool productionDone = row.... |
I'm new to OOP, so I tried to learn from tutorials how to create a class in JavaScript/jQuery. But tutorials don't give you feedback from experienced coders. Is the approach to create a pop-up OK (see below)? I know it works (it's tested), but is it prone to errors or does it have redundancies?
var Popup = function (){... |
A list that contains one or more lists as elements is called a deep
list. For example, [1, [2, 3], 4] is a deep list.
Write a function deep_len that takes a list and returns its deep
length. See the doctests for the function's behavior.
Hint: you can check if something is a list by using the built-in
type functi... |
I have image slider with thumbnails, simple one where I account for left and right arrow clicks that show respective images and thumbnail clicks that load related image. Functions have a lot in common and I'm trying to figure out how to put them into one and use it for all 3 different events, but am having trouble as t... |
A little while back I had an interview where they posed a problem, in summary:
Watch a certain directory, and process incoming JSON files
These JSON files have various "Type" fields
Every second report out how many files of each "Type" were processed, and the average processing time (from added to disk, to added to su... |
I am doing a lightsaber app for fun. I followed a tutorial to learn how to get information from the accelerometer to play lightsaber sounds. It instructed me to have the Activity where I get the accelerometer data implement the SensorEventListener interface.
I have a custom dialog that I want to use which allows the ... |
The following code takes either a URL or the title to an existing news article.
Searches Google News using the title.
Collects all links from search results.
import urllib2
from lxml import html
import requests
def get_page_tree(url=None):
page = requests.get(url=url, verify=False)
return html.fromstring(pag... |
I created an API to load, save and read user configuration in my application. I've a Configuration interface which provides the basic methods to read, save and read configuration data and then in the application I've the implementation JsonConfiguration.
I tried to keep the Configuration interface as generic as possib... |
I have this class which mostly holds a bunch of properties and their setters. I also have wrappers for some functions of another module. Here is the class:
class ARCArduino(object):
"""
Class to manage Arduino functionality
"""
def __init__(self, tree_item, port, identifier):
self.__i2c = Ardui... |
Took me a couple of days (in between working on other projects) to get the code working, but now that I do have it working I would like to know if there is a way that I could make it work better, or clean up my act JavaScript/jQuery surrounding my JSON utilization skills.
I am using ASP.NET if that means anything to th... |
I need to write a very basic file/directory browser. The data structure I'm using is pretty simple - a Node with an optional parent and children. Along with the data structure I also need a simple function that will recurse a file system building up the tree of nodes. This is what I have come up with so far and I'd rea... |
Following a challenge on HackerRank, I want to find the sum of all numbers that have no more than x 4's, y 5's, and z 6's module 10^9 + 7. I'd like to know how I could improve this code below both for style and performance. Also, what's the canonical way to get unique permutations of a list that can include repeated el... |
This retrieves result sets from a MySQL table. The objective of this function is to correctly retrieve any number of rows (with $sql) from a MySQL table, binding the needed values accordingly ($params[]), having the possibility to choose the column/s you want to retrieve ($cols[]).
$db = new PDO('mysql:host=127.0.0.1;d... |
I've noticed that whenever a shader program class is implemented (from some questions on this site, as well as more reputable implementations), that:
The class tries to do too much. Binding to the current context, setting attribute variable values, and much more.
Use the JavaBeans pattern in one form or another, allow... |
Today, I sat down to write a tiny performance test to quickly assess a hunch I had regarding an optimization. The resulting code eventually got rather large for my taste; thus I subsequently tried to abstract it to a degree that allowed me to keep ledgibility, ease of maintenance and extensibility, reduced redundancy a... |
I am writing a generic C++14 multi dimensional array for computational science purpose.
The "features" so far for the class tries to:
store multi-dimensional grid values into a flatten array
provide grid values access and flat index access from multi dim coordinates with \$O(1)\$ average complexity (worst case is \$O(... |
I am trying to replicate Bruce B. de Mesquita's (BDM) results on political game theory for prediction. Based on where actors stand on issues, their capabilities, salience, BDM's method attempts to find the eventual decision point by simulating a game. He reportedly used this method with much success; and published his ... |
I have managed to implement an ADTStack with a circular doubly linked list. I would like to know whether there are things I could have done better or, I should improve.
public class QueueCircularDLL<T> implements ADTQueue<T> {
private ListElement<T> head;
private ListElement<T> tail;
public QueueCircul... |
After our recent election, I got elected as a moderator here on Code Review (Thank you, community members!). One of the first things I missed among the moderator tools was desktop notifications for when there were any flags.
As no current tool existed, I figured that I just have to create one...
Following the approach ... |
I've written the following code to print all the permutations of a list. For example:
\$[1, 2, 3]\$ has these permutations: \$[1,2,3]\$, \$[1,3,2]\$, \$[2,1,3]\$, \$[2,3,1]\$, \$[3,1,2]\$, and \$[3,2,1]\$.
def insert_each_position(self, nums, insert_one):
res, len_of_nums = [], len(nums)
for idx in range(len_... |
This code works, but I'm curious what feedback you have about style and doing things in a more "pythonic" way.
def printUsage():
print("Usage: goodproxy.py -f <proxyfile> -u <url> -t <timeout>")
def main(argv):
filename = ""
url = ""
timeout = None
try:
# USE GETOPS F... |
I'm new to python and created this small program. It's basically a skeleton for a simple text-based RPG. The program is one menu that allows you to:
Create a Character
View Character Stats/Attributes
Load Character
Battle
Save
Quit
I'm looking for constructive criticism from any angle, be that if I comment too much, ... |
I'm working on a grammar for the Visual Basic for Applications (VBA) programming language. I've discovered a way to make assertions about how a parse tree should be generated by using the Antlr ToStringTree method.
My method is this:
Create a parser and give it a code snippet.
Obtain the parse tree result and turn it... |
During my holiday I decided to implement a solver for those puzzles my girlfriend likes to do. They are called Takuzu, but "binero" in Dutch.
The puzzle gives you a grid in which you have to fill in either a 1 or a 0. The constraints are the following:
No 3 adjacent values may be the same in a row or column
No two row... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.