numbers

The number of matches between two rows mysql

纵然是瞬间 提交于 2019-12-23 06:47:23
问题 So, this is the challenge: I have two tables: Etalon: +-----+-----+-----+-----+----+ | e1 | e2 | e3 | e4 | e5 | +-----+-----+-----+-----+----+ | 01 | 02 | 03 | 04 | 05 | +-----+-----+-----+-----+----+ And Candidates: +-----+----+-----+-----+-----+----+----+ | ID | c1 | c2 | c3 | c4 | c5 | nn | +-----+----+-----+-----+-----+----+----+ | 00 | 03 | 08 | 02 | 01 | 06 | ** | +-----+----+-----+-----+-----+----+----+ | 01 | 05 | 04 | 03 | 02 | 01 | ** | +-----+----+-----+-----+-----+----+----+ | 02

Rounding values up or down in C#

混江龙づ霸主 提交于 2019-12-23 06:44:06
问题 I've created a game which gives a score at the end of the game, but the problem is that this score is sometimes a number with a lot of digits after the decimal point (like 87.124563563566). How would I go about rounding up or down the value so that I could have something like 87.12? Thanks! 回答1: Try using Math.Round. Its various overloads allow you to specify how many digits you want and also which way you want it to round the number. 回答2: Use Math.Ceiling(87.124563563566) or Math.Floor(87

Excluding $fields When Retrieving Document from MongoDB

Deadly 提交于 2019-12-23 05:59:22
问题 Is there a way to get the document from MongoDB as is rather than having some fields converted to object containing $ fields? For example, I have a field called timestamp where I store a long value. It used to return just a value and all the sudden it starts returning an object after about a week: { "$numberLong": "1474402633708" } This is the same with _id field for a nested object. It was returning "_id" and at some point switched to return an object with $oid like for the top level. I

Getting Numbers From A CFDictionary For Use In Calculations, iPhone

旧街凉风 提交于 2019-12-23 05:36:13
问题 I found this in my travels: http://www.opensource.apple.com/source/IOKitUser/IOKitUser-502/ps.subproj/IOPSKeys.h How would I get the values (as a number) of: #define kIOPSMaxCapacityKey "Max Capacity" and #define kIOPSDesignCapacityKey "DesignCapacity" I want to be able to use them throughout my app. What do I need to add to my project and how do extract the numbers? Many thanks, Stuart 回答1: Once you know where the actual dictionary is that it's storing these values, you can access the value

Batch rename # of week

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 04:32:04
问题 I want to rename a few files using batch. I need it to look like DD.MM.YY - # week randomname , so let's say 2.7.2013-27.week abcdefg.xls So far I'm using for /f "tokens=1-5 delims=/ " %%d in ("%date%") do ( rename "C:\TEST\123.xlsx" %%e%%f%%g.xlsx ) which comes up with DD.MM.YYYY and is perfect for the first part. Can you help with the rest? 回答1: @echo off for /F "tokens=1-5 delims=/" %%d in ("%date%") do ( set ddmmyy=%%e.%%f.%%g set /A dd=1%%e-100, mm=1%%f-100, yy=%%g, yyM1=yy-1 ) rem Get

Batch rename # of week

非 Y 不嫁゛ 提交于 2019-12-23 04:31:07
问题 I want to rename a few files using batch. I need it to look like DD.MM.YY - # week randomname , so let's say 2.7.2013-27.week abcdefg.xls So far I'm using for /f "tokens=1-5 delims=/ " %%d in ("%date%") do ( rename "C:\TEST\123.xlsx" %%e%%f%%g.xlsx ) which comes up with DD.MM.YYYY and is perfect for the first part. Can you help with the rest? 回答1: @echo off for /F "tokens=1-5 delims=/" %%d in ("%date%") do ( set ddmmyy=%%e.%%f.%%g set /A dd=1%%e-100, mm=1%%f-100, yy=%%g, yyM1=yy-1 ) rem Get

Project Euler 76 - List All Partitions For a Given Number

南楼画角 提交于 2019-12-23 03:57:15
问题 Here is how Project Euler Problem #76 sounds like: "How many different ways can one hundred be written as a sum of at least two positive integers?" I've struggled to get it right for a couple of days, tried to solve in different ways and got mostly the same results for small numbers (those that are easy to check). I ended up with an algorithm that lists all partitions for a given number in alphabetical order, descending (starting from "N-1 + 1"). Written in VB.NET: Dim ub As Integer = 6 Dim

Find all possible arrangements of a n numbers in an array

陌路散爱 提交于 2019-12-23 01:21:30
问题 I have an array which contains lets say [25,15,8,20] I want to find all possible arrangements of numbers that is possible. expected output: 25 15 8 20 25 15 20 8 25 20 15 8 25 20 8 15 25 8 20 15 25 8 15 20 15 25 8 20 15 25 20 8 15 20 25 8 15 20 8 25 15 8 20 25 15 8 25 20 20 25 15 8 20 25 8 15 20 8 25 15 20 8 15 25 20 15 25 8 20 15 8 25 8 15 20 25 8 15 25 20 8 25 15 20 8 25 20 15 8 20 15 25 8 20 25 15 void print(int *num, int n) { int i; for ( i = 0 ; i < n ; i++) printf("%d ", num[i]); printf

How can I distort the distribution of a set of random numbers?

ぐ巨炮叔叔 提交于 2019-12-22 18:36:33
问题 I want to craft an algorithm that will give me numbers that are random in the sense that I have no idea what they'll be, but at the same time, numbers that are closer to 0 have to be more likely to occur as output while those closer to 1 must be less likely. I'd like to play around with both linear and exponential distributions, so please give at least hints for implementing both. I've thought and thought about how to approach this issue, but I still don't even have a clue, so any pointers

How to create N-tuples in Python?

谁说胖子不能爱 提交于 2019-12-22 18:31:03
问题 What would be the easiest way to create a list of n-tuples in Python? For example, if I want to create for a number n (for e.g. 3): I'd want to generate the following set of tuples: (1,1,1) (1,1,2) (1,1,3) (2,1,1) (2,1,2) (2,1,3) (3,1,1) (3,1,2) (3,1,3) (1,2,1) (1,2,2) (1,2,3) (2,2,1) (2,2,2) (2,2,3) (3,2,1) (3,2,2) (3,2,3) (1,3,1) (1,3,2) (1,3,3) (2,3,1) (2,3,2) (2,3,3) (3,3,1) (3,3,2) (3,3,3) 回答1: Use itertools.product: >>> from itertools import product >>> list(product(range(1, 4), repeat