Update
This commit is contained in:
parent
767b52f354
commit
d9a9d8158f
6 changed files with 47 additions and 75 deletions
67
exercises.md
67
exercises.md
|
@ -1,66 +1,21 @@
|
|||
# Exercises
|
||||
|
||||
Here let be listed exercises for the readers of the wiki. You can allow yourself to as many helpers and resources as you find challenging: with each problem you should either find out you know the solution or learn something new while solving it.
|
||||
Here there should be a set of exercise problems for those wishing to pursue [LRS](lrs.md) in any way.
|
||||
|
||||
Problems in each category should follow from easiest to most difficult. The listed solutions may not be the only possible solutions, just one of them.
|
||||
{ Hmmm, it's hard to figure out exactly what to put here. ~drummyfish }
|
||||
|
||||
## General Knowledge
|
||||
## Programming Projects
|
||||
|
||||
1. What is the difference between [free software](free_software.md) and [open source](open_source.md)?
|
||||
Here you will find suggestions for programming projects depending on your skill level.
|
||||
|
||||
### Solutions
|
||||
### Easy
|
||||
|
||||
1. The [free software](free_software.md) and [open source](open_source.md) movements are technically very similar but extremely different in spirit, i.e. while most free software licenses are also open source and vice versa (with small exceptions such as [CC0](cc0.md)), free software is fundamentally about pursuing user freedom and ethics while open source is a later capitalist fork of free software that removes talk about ethics, aims to exploit free licenses for the benefit of business and is therefore unethical.
|
||||
- TODO
|
||||
|
||||
## Programming
|
||||
### Medium
|
||||
|
||||
1. Write a [C](c.md) program that prints out all [prime numbers](prime.md) under 1000 as well as the total count of these prime numbers.
|
||||
- TODO
|
||||
-
|
||||
### Hard
|
||||
|
||||
### Solutions
|
||||
|
||||
1:
|
||||
|
||||
```
|
||||
// Sieve of Eratosthenes algorithm, one possible way to generate prime numbers
|
||||
#include <stdio.h>
|
||||
#define N 1000
|
||||
|
||||
char primeMap[N];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int primeCount = 0;
|
||||
|
||||
for (int i = 0; i < N; ++i)
|
||||
primeMap[i] = 1;
|
||||
|
||||
for (int i = 2; i < N; ++i)
|
||||
{
|
||||
if (primeMap[i])
|
||||
{
|
||||
primeCount++;
|
||||
printf("%d\n",i);
|
||||
}
|
||||
|
||||
int j = i;
|
||||
|
||||
while (1) // mark all multiples of i non-primes
|
||||
{
|
||||
j += i;
|
||||
|
||||
if (j >= N)
|
||||
break;
|
||||
|
||||
primeMap[j] = 0; // can't be a prime
|
||||
}
|
||||
}
|
||||
|
||||
printf("prime count under %d: %d\n",N,primeCount);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## Math
|
||||
|
||||
### Solutions
|
||||
- TODO
|
Loading…
Add table
Add a link
Reference in a new issue