Last change
on this file since 4082 was
2325,
checked in by Sam Hocevar, 13 years ago
|
- Add statistical analysis to the testsuite to check our random number
generator.
|
File size:
854 bytes
|
Line | |
---|
1 | /* |
---|
2 | * zzero - check how many bits zzuf changes in a stream of zeroes |
---|
3 | * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id$ |
---|
7 | * |
---|
8 | * This program is free software. It comes without any warranty, to |
---|
9 | * the extent permitted by applicable law. You can redistribute it |
---|
10 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
11 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
12 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
13 | */ |
---|
14 | |
---|
15 | #include "config.h" |
---|
16 | |
---|
17 | #include <stdio.h> |
---|
18 | #include <stdlib.h> |
---|
19 | |
---|
20 | int main(void) |
---|
21 | { |
---|
22 | static const int lut[16] = |
---|
23 | { |
---|
24 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 |
---|
25 | }; |
---|
26 | |
---|
27 | int ones = 0, ch; |
---|
28 | |
---|
29 | while((ch = getc(stdin)) != EOF) |
---|
30 | ones += lut[ch & 0xf] + lut[(ch >> 4) & 0xf]; |
---|
31 | |
---|
32 | printf("%i\n", ones); |
---|
33 | |
---|
34 | return EXIT_SUCCESS; |
---|
35 | } |
---|
36 | |
---|
Note: See
TracBrowser
for help on using the repository browser.