Writing
How many? is a typical question that comes up when programming. I use a variety of software
for projects and there are subtly different ways to answer that question depending on the context.
Here is an alphabetical list of ways I’ve recently answered that question.
A more detailed comparison of programming languages can be found on Wikipedia .
Command Line
# How many rows are in this file?
wc -l < file
Golang
// How many elements are in this array?
len ( array )
JavaScript
// How many elements are in this array?
array . length
// How many elements in this array are greater than 5?
d3 . count ( array , ( d ) => d > 5 )
// How many rows are in this Apache Arrow table?
table . numRows
<!-- How many elements are in this array? -->
array | size
Python
# How many elements are in this list?
len ( list )
# How many elements are in this pandas dataframe?
df . size # including missing values
df . count () # excluding missing values
# How many elements are in this numpy array?
ndarray . size
Ruby
# How many elements are in this array?
array . length
array . count
array . size
# How many rows are in this Active Record table?
table . count
SQL
-- How many elements are in this PostgreSQL array?
array_length ( array , 1 )
-- How many elements are in this DuckDB list?
len ( list )
-- How many rows are in this table?
select count ( * ) from table
# How many elements are in this list?
length ( list )
Update : Flickr has released version 2.0.1 so this is no longer necessary. Thanks Flickr :D
read more »
There is an undocumented case where the output of an internal function is different in PHP 5.2 vs PHP 5.3 when you pass it an invalid argument.
read more »
The term 'load-bearing code' can be used to refer to software that exhibits the following attributes.
Has no documentation or automated tests
Written by an ex-developer
Used by a large portion of the code base
Supports critical system processes
Jerry, these are load-bearing walls, they're not gonna come down!
Cosmo Kramer in the Seinfeld episode "The Chicken Roaster"
I have encountered load-bearing code in legacy open source applications, inherited projects, or debugging production software.
How many different Mii designs are possible? I started counting the options, did the math, and here are the results.
Attribute Options
1 Genders 2
2 Clothing Colors 12
3 Heights 10
4 Weights 10
5 Face Shapes 8
6 Makeup Types 12
7 Skin Colors 6
8 Hair Styles 72
9 Hair Parts 2
10 Hair Colors 8
11 Eyebrows 24
12 Eyebrow Colors 8
13 Eyebrow Vertical Steps 16
14 Eyebrow Size Steps 9
15 Eyebrow Rotation Steps 12
16 Eyebrow Horizontal Steps 13
17 Eye Types 42
18 Eye Colors 6
19 Eye Vertical Steps 19
20 Eye Size Steps 8
21 Eye Rotation Steps 8
22 Eye Horizontal Steps 13
23 Noses 12
24 Nose Vertical Steps 19
25 Nose Sizes 9
26 Lips 24
27 Lips Colors 3
28 Lips Vertical Steps 19
29 Lips Sizes 9
30 Glasses 9
31 Glasses Colors 6
32 Glasses Vertical Steps 21
33 Glasses Sizes 8
34 Mustaches 4
35 Mustache Colors 8
36 Mustache Vertical Steps 17
37 Mustache Sizes 9
38 Moles 2
39 Mole Vertical Steps 31
40 Mole Sizes 9
41 Mole Horizontal Steps 17
42 Goatee Types 4
43 Goatee Colors 8
Total 568
Exceptions
1 hair style (bald) has no color or part
49 hair styles have no part
1 eyebrow style(none) has no color, vertical step, size, rotation or horizontal step
7 eye types have no color
17 lips have no color
1 glasses type (none) has no color, vertical step, or size
1 mustache type (none) has no color, vertical step, or size
1 mole (none) has no vertical step, size, or horizontal step
1 goatee type (none) has no color
Combinations
To determine the number of distinct
combinations I used the formula: 568! / (43! * (568-43)!)
Result
Using
Wolfram Alpha to solve 568! / (43! * (568-43)!) , we can see that there are 88 vigintillion, 613 novemdecillion, 583 octodecillion, 674 septendecillion, 758 sexdecillion, 947 quindecillion, 813 quattuordecillion, 475 tredecillion, 143 duodecillion, 744 undecillion, 24 decillion, 970 nonillion, 165 octillion, 692 septillion, 788 sextillion, 754 quintillion, 421 quadrillion, 531 trillion, 161 billion, 395 million, 650 thousand and 32 Mii Combinations.