Browse Source

Merge branch 'master' into readmes

pull/95/head
Frenchris 5 years ago committed by GitHub
parent
commit
f09d55f5db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 56
      docs/modular-steps-management.md
  2. 64
      docs/ubuntu-installation.md
  3. 59
      scripts/bash_tweaks.sh
  4. 55
      scripts/clean.sh
  5. 64
      scripts/common_packages.txt
  6. 131
      scripts/dconfig.txt
  7. 15
      scripts/firewall.sh
  8. 9
      scripts/fx.sh
  9. 24
      scripts/go.sh
  10. 25
      scripts/grub.sh
  11. 87
      scripts/install_client.sh
  12. 10
      scripts/nodejs.sh
  13. 34
      scripts/set.sh
  14. 25
      scripts/ssh.sh
  15. 17
      scripts/sublime.sh
  16. 74
      scripts/system/etc/gdm3/PostLogin/Default
  17. 25
      scripts/system/etc/gdm3/PostSession/Default
  18. 1
      scripts/system/etc/udev/rules.d/10-local.rules
  19. 13
      scripts/system/usr/local/bin/lock_screen
  20. 13
      scripts/system/usr/local/bin/suspend_session
  21. 8
      scripts/system/usr/share/applications/lock_screen.desktop
  22. 8
      scripts/system/usr/share/applications/suspend_session.desktop
  23. 22
      scripts/system/usr/share/initramfs-tools/hooks/copy_mkfs
  24. 20
      scripts/system/usr/share/initramfs-tools/scripts/init-premount/reformat
  25. 118
      scripts/ubuntu_tweaks.sh
  26. 35
      scripts/vscode.sh
  27. 6
      subjects/addprimesum.en.md
  28. 37
      subjects/brainfuck.en.md
  29. 1
      subjects/doop.en.md
  30. 9
      subjects/doop.fr.md
  31. 28
      subjects/doop.md
  32. 28
      subjects/expandstr.en.md
  33. 4
      subjects/gcd.en.md
  34. 28
      subjects/hiddenp.en.md
  35. 15
      subjects/itoa.en.md
  36. 24
      subjects/itoabase.en.md
  37. 21
      subjects/paramcount.en.md
  38. 6
      subjects/printhex.en.md
  39. 24
      subjects/range.en.md
  40. 20
      subjects/range.md
  41. 24
      subjects/reverserange.en.md
  42. 27
      subjects/reversestrcap.en.md
  43. 12
      subjects/sortlist.en.md
  44. 4
      subjects/tabmult.md

56
docs/modular-steps-management.md

@ -36,7 +36,8 @@
<img width="1073" alt="Capture d’écran 2019-04-22 à 15 59 33" src="https://user-images.githubusercontent.com/35296671/56507445-3936ef00-6519-11e9-90c8-d85056e9330b.png">
* Add a new key **subtype** of type `String` with the exact value 'onb-adm-form-generator'
* Add a new key **subtype** of type `String` with the exact value 'form-step'
* Add a new key **form** of type `Object`
* Form can have several sections. Each section is displayed with a title, and its inputs.
> NB: The submission of the form will check the required inputs of all the sections created for the form.
@ -48,13 +49,16 @@
> The values will be considered as the properties of your input.
#### Defining an input:
* A **type** key of type `String` must be declared. It defines the type of the input : `tel`, `text`, `date`, `select`, `radio`, `switch`, `checkbox`, `textarea` (and soon a special type `countries`).
* A **type** key of type `String` must be declared. It defines the type of the input : `tel`, `text`, `date`, `select`, `radio`, `switch`, `checkbox`, `textarea`, `countries`.
* All other attributes needed for the input can be added to the object, according to the input type: `placeholder`, `id`, `required`, `label`, `items`, `emptyItems`, `index`, etc...
#### Important indication:
* The **index** property is used to order the inputs. It will not be passed onto the input. Be mindful not to set the same index twice.
* The **type** property is required. It will be used to determine the kind of input should be generated. It is passed onto the input only if the input type attribute is required (type 'tel' or 'text' for example, but not for type 'select' - in this case, we will generate a select element)
* At the moment, our team is creating a special type 'countries' (a `Select` displaying all the countries). Documentation will be updated as soon as it is available.
* A special type 'countries' has been added to the classicals. It generate a `Select` (containing all the countries) with a search bar. 'Items' property is handled by the app.
* It's recommended to add 'min' and 'max' properties to input type 'date' (no default value are set).
* `onChange` prop are ignored as the event is handled by the app.
* For `switch` and `checkbox` input types, the default value has to be set as a boolean property named **value**.
* More information for each inputs is available in the design documentation:
@ -68,18 +72,20 @@
### Examples
Here is an example of the form step's attributes. It presents a form with two sections, and an example of each kind of input type.
> NB : this example object will soon be provided in the admin.
> NB : this example object is provided in the admin, in the onboarding section: 'Form step example'.
```json
{
"subtype": "onb-adm-form",
"subtype": "form-step",
"form": {
"section1": {
"title": "My section title",
"identification": {
"title": "Identification",
"inputs": {
"firstName": {
"index": 0,
"placeholder": "First name",
"maxLength": 50,
"type": "text",
"required": true
},
@ -93,8 +99,9 @@ Here is an example of the form step's attributes. It presents a form with two se
},
"medicalInfo": {
"label": "Medical informations",
"index": 6,
"placeholder": "Medical Informations",
"placeholder": "Your medical Informations",
"index": 7,
"maxLength": 250,
"type": "textarea"
},
"dateOfBirth": {
@ -102,8 +109,17 @@ Here is an example of the form step's attributes. It presents a form with two se
"required": true,
"type": "date",
"label": "Date of birth",
"min": "1621-07-08",
"max": "1900-01-01",
"value": "2000-01-01"
},
"country": {
"index": 4,
"id": "countries",
"type": "countries",
"required": true,
"emptyItem": { "label": "Select your country label" }
},
"gender": {
"index": 3,
"type": "select",
@ -116,7 +132,7 @@ Here is an example of the form step's attributes. It presents a form with two se
]
},
"environment": {
"index": 4,
"index": 5,
"type": "radio",
"required": true,
"label": "Which environment do you live in ?",
@ -127,25 +143,25 @@ Here is an example of the form step's attributes. It presents a form with two se
]
},
"programmingAbilities": {
"index": 5,
"index": 6,
"type": "switch",
"label": "I am new in programming",
"value": true
},
"generalConditions": {
"index": 7,
"index": 8,
"type": "checkbox",
"label": "I have read and I accept the general conditions",
"value": false
}
}
},
"section2": {
"title": "My second section title",
"moreAboutYou": {
"title": "More about you",
"inputs": {
"firstName": {
"favoriteColor": {
"index": 0,
"placeholder": "First name",
"placeholder": "Your favorite color",
"type": "text",
"required": true
}
@ -157,7 +173,8 @@ Here is an example of the form step's attributes. It presents a form with two se
This 'form' step would look like this:
![form step example](https://user-images.githubusercontent.com/35296671/56503976-012aae80-650f-11e9-82c8-dd7d026b6eb1.png)
![form step example](https://user-images.githubusercontent.com/35296671/56816457-7cf06800-683b-11e9-9003-6f83b4545033.png)
## Settings for a `document to sign` step
The newly created child can be customized with these attributes :
@ -176,7 +193,8 @@ The newly created child can be customized with these attributes :
1. Edit you step object
2. Go to *Object attributes*
3. Add the following attributes:
* Add a new key **subtype** of type `String` with the exact value 'onb-adm-sign'
* Add a new key **subtype** of type `String` with the exact value 'sign-step'
* Add a new key **text** of type `String` with the text of your document to sign as value
* Add a new key **buttonText** of type `String` with the text that you want to display in the submit button of your step. Default value for this attribute is 'Sign'.
* Add a new key **checkbox** of type `Object`, if the user has to be forced to click on a checkbox before validating his document (ex: 'I have read and accepted the conditions'). In the checkbox object, the following attributes should be defined:
@ -191,7 +209,7 @@ Here is an example of the structure a 'document to sign' step could have:
```json
{
"subtype": "onb-adm-sign",
"subtype": "sign-step",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ornare non sem eu pretium. Integer porttitor risus eget nibh iaculis, ac lacinia orci dictum. Nunc ullamcorper consequat enim in posuere. Aliquam volutpat est odio, vel maximus arcu maximus sit amet. Donec ultricies faucibus magna id luctus. Duis et dapibus elit. In vestibulum ipsum erat, at commodo tortor convallis vel. Nunc ut ultrices nulla. Etiam lorem justo, consequat a consectetur a, porttitor non turpis. Mauris eu mollis nisl, id dignissim quam. Curabitur condimentum sollicitudin rutrum. Aenean blandit, arcu nec ullamcorper rhoncus, lectus sem lacinia lorem, venenatis dignissim velit mi et sapien. Nullam posuere augue ut magna ullamcorper dignissim. Ut rhoncus sapien vel nulla commodo finibus. Cras non leo vel urna finibus volutpat. Praesent et ex eget diam tincidunt suscipit. Phasellus bibendum neque vel placerat iaculis. Vestibulum bibendum ultrices ipsum, non sodales lectus. Cras eget orci eget elit blandit scelerisque at ut nulla. Integer ligula eros, eleifend quis sodales a, porttitor sit amet neque. Fusce mollis magna at lectus varius, quis suscipit mi cursus. Etiam id imperdiet metus, in malesuada quam. Aliquam facilisis nunc non sapien condimentum, quis iaculis nisl auctor. Nunc lorem sapien, interdum vel efficitur ac, dapibus a diam. Ut ante urna, sodales in bibendum vel, lacinia ut mauris. In vel placerat leo. In libero dui, tincidunt at sem id, faucibus sollicitudin elit.",
"buttonText": "Sign chart",
"checkbox": {

64
docs/ubuntu-installation.md

@ -0,0 +1,64 @@
# Ubuntu
## OS Installation
Download and boot the [last Ubuntu release](http://releases.ubuntu.com/19.04/ubuntu-19.04-desktop-amd64.iso).
Follow the steps :
![img1](https://user-images.githubusercontent.com/32063953/56804679-85867580-681e-11e9-8965-e87c6a89fac0.png)
![img2](https://user-images.githubusercontent.com/32063953/56963599-3eb3bb00-6b51-11e9-9778-4f3bb9993c74.png)
![img3](https://user-images.githubusercontent.com/32063953/56963600-3eb3bb00-6b51-11e9-94cc-279406f37def.png)
The partitioning is :
- 256 MB : EFI partition
- 20 GB : system partition
- 32 GB : unused partition (will be used later)
- rest : unused partition (will be used later)
![img4](https://user-images.githubusercontent.com/32063953/56963602-3eb3bb00-6b51-11e9-8977-38e4e67d6ce1.png)
![img5](https://user-images.githubusercontent.com/32063953/56963603-3f4c5180-6b51-11e9-9349-46ab90287691.png)
![img6](https://user-images.githubusercontent.com/32063953/56963604-3f4c5180-6b51-11e9-8df2-5016771e6e07.png
)
Remove the installation disk and then reboot.
Skip the welcoming window.
Don't install updates if Ubuntu asks to. The scripts will.
![img8](https://user-images.githubusercontent.com/32063953/56804701-8d461a00-681e-11e9-8825-dfc69f8268bf.png)
![img9](https://user-images.githubusercontent.com/32063953/56804703-8d461a00-681e-11e9-840c-498ccab7d911.png)
![img10](https://user-images.githubusercontent.com/32063953/56804704-8ddeb080-681e-11e9-96ff-6c8783c5aacc.png)
![img11](https://user-images.githubusercontent.com/32063953/56804706-8ddeb080-681e-11e9-85e1-20c5b6956a36.png)
## OS configuration
```shell
student@tmp-hostname:~$ wget github.com/01-edu/public/archive/master.zip
student@tmp-hostname:~$ unzip master.zip
student@tmp-hostname:~$ cd public-master/scripts
student@tmp-hostname:~$ sudo ./install_client.sh
[...]
Ask for student user password (will be removed later)
[...]
Ask to set the root password
[...]
Long installation/configuration process
[...]
student@tmp-hostname:~$ cat dconfig.txt | dconf load /
student@tmp-hostname:~$ reboot
```
The system is now read-only, every data is written to a temporary partition.
The session is password-less.
To gain a superuser terminal with read/write access to the filesystem, type these commands:
```shell
student@tmp-hostname:~$ su -
Password:
root@tmp-hostname:~# overlayroot-chroot
```

59
scripts/bash_tweaks.sh

@ -0,0 +1,59 @@
#!/bin/bash
# Configure Terminal
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
# Makes bash case-insensitive
cat <<EOF>> /etc/inputrc
set completion-ignore-case On
EOF
# Enhance Linux prompt
cat <<EOF> /etc/issue
Kernel build: \v
Kernel package: \r
Date: \d \t
IP address: \4
Terminal: \l@\n.\O
EOF
# Enable Bash completion
apt-get -y install bash-completion
cat <<EOF>> /etc/bash.bashrc
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
EOF
# Set-up all users
for DIR in $(ls -1d /root /home/* 2>/dev/null || true)
do
# Hide login informations
touch $DIR/.hushlogin
# Add convenient aliases & behaviors
cat <<-'EOF'>> $DIR/.bashrc
HISTCONTROL=ignoreboth
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="%F %T "
alias l="ls $LS_OPTIONS -al --si"
alias df="df --si"
alias du="du -cs --si"
alias free="free -h --si"
alias pstree="pstree -palU"
EOF
# Fix rights
USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev)
chown -R $USR:$USR $DIR || true
done

55
scripts/clean.sh

@ -0,0 +1,55 @@
#!/bin/bash
# Clean system
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
# Purge useless packages
apt-get -y autoremove --purge
apt-get autoclean
apt-get clean
apt-get install
rm -rf /root/.local
# Remove connection logs
> /var/log/lastlog
> /var/log/wtmp
> /var/log/btmp
# Remove machine ID
> /etc/machine-id
# Remove logs
cd /var/log
rm -rf alternatives.log*
rm -rf apt/*
rm -rf auth.log
rm -rf dpkg.log*
rm -rf gpu-manager.log
rm -rf installer
rm -rf journal/d6e982aa8c9d4c1dbcbdcff195642300
rm -rf kern.log
rm -rf syslog
rm -rf sysstat
# Remove random seeds
rm -rf /var/lib/systemd/random-seed
rm -rf /var/lib/NetworkManager/secret_key
# Remove network configs
rm -rf /etc/NetworkManager/system-connections/*
rm -rf /var/lib/bluetooth/*
rm -rf /var/lib/NetworkManager/*
# Remove caches
rm -rf /var/lib/gdm3/.cache/*
rm -rf /root/.cache
rm -rf /home/student/.cache
rm -rf /home/student/.sudo_as_admin_successful /home/student/.bash_logout
rm -rf /tmp/*
rm -rf /tmp/.* || true

64
scripts/common_packages.txt

@ -0,0 +1,64 @@
apache2-utils
apt-utils
arp-scan
autossh
bash-completion
binutils
build-essential
console-data
console-setup
cron
curl
dialog
dmidecode
dnsutils
file
firmware-linux-nonfree
git
hdparm
iftop
ifupdown
iotop
iptables
iputils-ping
isc-dhcp-client
isc-dhcp-common
jq
less
linux-headers-amd64
linux-image-amd64
lm-sensors
locales
lsb-release
lshw
lsof
lzop
man
mc
mdadm
moreutils
nano
net-tools
nmap
ntpdate
nvme-cli
pciutils
psmisc
python
python3
rsync
rsyslog
ssh
stress
sudo
sysstat
telnet
tig
traceroute
tree
tzdata
unzip
usbutils
wget
zerofree
zip

131
scripts/dconfig.txt

@ -0,0 +1,131 @@
[org/gnome/desktop/calendar]
show-weekdate=true
[org/gnome/desktop/wm/preferences]
resize-with-right-button=true
[org/gnome/desktop/peripherals/keyboard]
delay=uint32 350
[desktop/ibus/panel/emoji]
unicode-hotkey=@as []
hotkey=@as []
[org/gnome/desktop/peripherals/touchpad]
two-finger-scrolling-enabled=true
disable-while-typing=false
[org/gnome/login-screen]
enable-smartcard-authentication=false
enable-fingerprint-authentication=false
[org/gnome/desktop/privacy]
report-technical-problems=false
remember-recent-files=false
[org/gnome/desktop/screensaver]
lock-enabled=false
[org/gnome/desktop/search-providers]
disable-external=true
[org/gnome/desktop/interface]
gtk-im-module='gtk-im-context-simple'
clock-show-seconds=true
enable-animations=false
cursor-blink=false
clock-show-weekday=true
gtk-theme='Yaru-dark'
[org/gnome/terminal/legacy]
menu-accelerator-enabled=false
[org/gnome/desktop/media-handling]
automount-open=false
automount=false
autorun-never=true
[org/gnome/terminal/legacy/keybindings]
reset-and-clear='<Primary>l'
[org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9]
allow-bold=false
default-size-rows=48
bold-is-bright=true
audible-bell=false
scrollback-lines=2147483647
cursor-shape='ibeam'
default-size-columns=160
[org/gnome/desktop/background]
show-desktop-icons=false
[org/gnome/desktop/peripherals/mouse]
accel-profile='flat'
[org/gnome/settings-daemon/plugins/color]
night-light-enabled=true
night-light-schedule-automatic=true
[org/gnome/desktop/lockdown]
disable-print-setup=true
disable-printing=true
disable-user-switching=true
user-administration-disabled=true
[org/gnome/settings-daemon/plugins/media-keys]
custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']
screensaver=''
[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0]
binding='<Super>l'
command='lock_screen'
name='Lock screen'
[org/gnome/settings-daemon/plugins/smartcard]
active=false
[org/gnome/settings-daemon/plugins/remote-display]
active=false
[org/gnome/settings-daemon/plugins/sharing]
active=false
[org/gnome/settings-daemon/plugins/screensaver-proxy]
active=false
[org/gnome/settings-daemon/plugins/gsdwacom]
active=false
[org/gnome/settings-daemon/plugins/power]
sleep-inactive-ac-type='nothing'
sleep-inactive-ac-timeout=0
[org/gnome/shell]
enable-hot-corners=true
favorite-apps=['firefox.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop', 'sublime_text.desktop', 'vscodium.desktop', 'org.gnome.Calculator.desktop', 'gnome-control-center.desktop', 'org.gnome.tweaks.desktop', 'lock_screen.desktop', 'suspend_session.desktop', 'yelp.desktop']
[org/gnome/system/location]
enabled=false
[org/gnome/desktop/session]
idle-delay=uint32 0
[org/gnome/mutter]
center-new-windows=true
[org/gnome/calculator]
source-currency=''
source-units='degree'
button-mode='advanced'
word-size=64
show-zeroes=false
base=10
angle-units='degrees'
accuracy=9
show-thousands=false
window-position=(1906, 826)
refresh-interval=604800
target-units='radian'
number-format='fixed'
target-currency=''

15
scripts/firewall.sh

@ -0,0 +1,15 @@
#!/bin/bash
# Install firewall
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
SSH_PORT=${1:-521}
apt-get -y install ufw
ufw logging off
ufw allow in "$SSH_PORT"/tcp
ufw --force enable

9
scripts/fx.sh

@ -0,0 +1,9 @@
#!/bin/bash
# Install FX: command-line JSON processing tool (https://github.com/antonmedv/fx)
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
npm install -g fx

24
scripts/go.sh

@ -0,0 +1,24 @@
#!/bin/bash
# Install Go
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
apt-get -y install golang
# Set-up all users
for DIR in $(ls -1d /root /home/* 2>/dev/null || true)
do
# Add convenient aliases & behaviors
cat <<-'EOF'>> $DIR/.bashrc
GOPATH=$HOME/go
PATH=$PATH:$GOPATH/bin
alias gobuild='CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w"'
EOF
# Fix rights
USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev)
chown -R $USR:$USR $DIR || true
done

25
scripts/grub.sh

@ -0,0 +1,25 @@
#!/bin/bash
# Install Grub
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
DISK=$1
apt-get -y install grub-efi-amd64
sed -i -e 's/message=/message_null=/g' /etc/grub.d/10_linux
cat <<EOF>> /etc/default/grub
GRUB_TIMEOUT=0
GRUB_RECORDFAIL_TIMEOUT=0
GRUB_TERMINAL=console
GRUB_DISTRIBUTOR=``
GRUB_DISABLE_OS_PROBER=true
GRUB_DISABLE_SUBMENU=y
EOF
update-grub
grub-install $DISK

87
scripts/install_client.sh

@ -0,0 +1,87 @@
#!/bin/bash
# Configure Z01 client
# Log stdout & stderr
exec > >(tee -i /tmp/install_client.log)
exec 2>&1
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
# Set root password
passwd root
# Remove user password
passwd -d student
cp /etc/shadow /etc/shadow-
SSH_PORT=521
DISK=$(lsblk -o tran,kname,hotplug,type,fstype -pr |
grep -e nvme -e sata |
grep '0 disk' |
cut -d' ' -f2 |
sort |
head -n1)
apt-get update
apt-get -y upgrade
apt-get -y autoremove --purge
. bash_tweaks.sh
. ssh.sh
. firewall.sh
. ubuntu_tweaks.sh
. grub.sh "$DISK"
. go.sh
. nodejs.sh
. fx.sh
. sublime.sh
. vscode.sh
# Install additional packages
PKGS="
emacs
f2fs-tools
golang-mode
vim
xfsprogs
"
apt-get -y install $PKGS
# Remove fsck because the system partition will be read-only (overlayroot)
rm /usr/share/initramfs-tools/hooks/fsck
# Copy system files
cp -r system /tmp
cd /tmp/system
sed -i -e "s|::DISK::|$DISK|g" etc/udev/rules.d/10-local.rules
# Fourth local partition
PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr |
grep -v usb |
grep '0 part' |
cut -d' ' -f2 |
sort |
head -n4 |
tail -n1)
sed -i -e "s|::PART::|$PART|g" usr/share/initramfs-tools/scripts/init-premount/reformat
apt-get -y install overlayroot
echo overlayroot=\"device:dev=$PART,recurse=0\" >> /etc/overlayroot.conf
# Fix permissions
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
find . -type f -exec /bin/sh -c "file {} | grep -q 'shell script' && chmod +x {}" \;
cp --preserve=mode -RT . /
cd $SCRIPT_DIR
rm -rf /tmp/system
update-initramfs -u
. clean.sh

10
scripts/nodejs.sh

@ -0,0 +1,10 @@
#!/bin/bash
# Install Node.js
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get -y install nodejs

34
scripts/set.sh

@ -0,0 +1,34 @@
#!/bin/bash
# Set scripting variables
# Treat unset variables as an error when substituting.
set -u
# Exit immediately if a command exits with a non-zero status.
set -e
# Set the variable corresponding to the return value of a pipeline is the status
# of the last command to exit with a non-zero status, or zero if no command
# exited with a non-zero status
set -o pipefail
# Separate tokens on newlines only
IFS='
'
# The value of this parameter is expanded like PS1 and the expanded value is the
# prompt printed before the command line is echoed when the -x option is set
# (see The Set Builtin). The first character of the expanded value is replicated
# multiple times, as necessary, to indicate multiple levels of indirection.
# \D{%F %T} prints date like this : 2019-12-31 23:59:59
PS4='-\D{%F %T} '
# Print commands and their arguments as they are executed.
set -x
# Skip dialogs during apt-get install commands
export DEBIAN_FRONTEND=noninteractive # DEBIAN_PRIORITY=critical
export LC_ALL=C LANG=C
export SHELL=/bin/bash

25
scripts/ssh.sh

@ -0,0 +1,25 @@
#!/bin/bash
# Install OpenSSH
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
SSH_PORT=${1:-521}
# Install dependencies
apt-get -y install ssh
cat <<EOF>> /etc/ssh/sshd_config
Port $SSH_PORT
PasswordAuthentication no
AllowUsers root
EOF
mkdir -p /root/.ssh
chmod -f 700 /root/.ssh
# echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH30lZP4V26RVWWvAW91jM7UBSN68+xkuJc5cRionpMc' >> /root/.ssh/authorized_keys
chmod -f 600 /root/.ssh/authorized_keys || true
systemctl restart sshd.service

17
scripts/sublime.sh

@ -0,0 +1,17 @@
#!/bin/bash
# Install Sublime Text & Sublime Merge
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | apt-key add -
apt-get install -y apt-transport-https
cat <<EOF> /etc/apt/sources.list.d/sublime-text.list
deb https://download.sublimetext.com/ apt/stable/
EOF
apt-get update
apt-get install -y sublime-text sublime-merge libgtk2.0-0

74
scripts/system/etc/gdm3/PostLogin/Default

@ -0,0 +1,74 @@
#!/bin/bash
# Mount home as an overlay filesystem
# Log stdout & stderr
exec > >(tee -i /tmp/gdm3_postlogin.log)
exec 2>&1
# Treat unset variables as an error when substituting.
set -u
# Exit immediately if a command exits with a non-zero status.
set -e
# Separate tokens on newlines only
IFS='
'
# The value of this parameter is expanded like PS1 and the expanded value is the
# prompt printed before the command line is echoed when the -x option is set
# (see The Set Builtin). The first character of the expanded value is replicated
# multiple times, as necessary, to indicate multiple levels of indirection.
# \D{%F %T} prints date like this : 2019-12-31 23:59:59
PS4='-\D{%F %T} '
# Print commands and their arguments as they are executed.
set -x
sleep 0.5
# Find the first removable F2FS partition
PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr |
grep -e '1 part f2fs' -e '1 disk f2fs' |
cut -d' ' -f2 |
sort |
head -n1)
# Make sure the mountpoints are free
(
lsof -t $HOME | xargs kill -9
umount $HOME
umount /mnt
) || true
if test "$PART"
then
mount -o noatime "$PART" /mnt
else
# No removable F2FS partition found, use the third local partition instead
PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr |
grep -v usb |
grep '0 part' |
cut -d' ' -f2 |
sort |
head -n3 |
tail -n1)
if test -z "$PART"
then
# No local partition found, error
exit 1
fi
# We don't care about data consistency since the partition is temporary
/sbin/mke2fs -t ext4 -O ^has_journal -F "$PART"
mount -o noatime,nobarrier "$PART" /mnt
fi
USER_PATH=/mnt/.01/$USER
TEMP_PATH=/mnt/.01/tmp
mkdir -p $USER_PATH $TEMP_PATH
chown -R $USER:$USER $USER_PATH $TEMP_PATH
mount -t overlay -o lowerdir=$HOME,upperdir=$USER_PATH,workdir=$TEMP_PATH overlay $HOME

25
scripts/system/etc/gdm3/PostSession/Default

@ -0,0 +1,25 @@
#!/bin/bash
# Log stdout & stderr
exec > >(tee -i /tmp/gdm3_postsession.log)
exec 2>&1
# Exit immediately if a command exits with a non-zero status.
set -e
# The value of this parameter is expanded like PS1 and the expanded value is the
# prompt printed before the command line is echoed when the -x option is set
# (see The Set Builtin). The first character of the expanded value is replicated
# multiple times, as necessary, to indicate multiple levels of indirection.
# \D{%F %T} prints date like this : 2019-12-31 23:59:59
PS4='-\D{%F %T} '
# Print commands and their arguments as they are executed.
set -x
passwd -d $USER
sync
sleep 0.5
lsof -t $HOME | xargs kill || true
umount -l $HOME
umount -l /mnt

1
scripts/system/etc/udev/rules.d/10-local.rules

@ -0,0 +1 @@
KERNEL=="::DISK::*", ENV{UDISKS_IGNORE}="1"

13
scripts/system/usr/local/bin/lock_screen

@ -0,0 +1,13 @@
#!/bin/bash
# Exits if a command fails
set -e
if passwd -S | grep NP
then
# No password set, so ask user to set one
gnome-terminal.real -t "" --geometry=40x10 --wait -- passwd
sleep 1
fi
i3lock -c000000

13
scripts/system/usr/local/bin/suspend_session

@ -0,0 +1,13 @@
#!/bin/bash
# Exits if a command fails
set -e
if passwd -S | grep NP
then
# No password set, so ask user to set one
gnome-terminal.real -t "" --geometry=40x10 --wait -- passwd
sleep 1
fi
systemctl suspend

8
scripts/system/usr/share/applications/lock_screen.desktop

@ -0,0 +1,8 @@
[Desktop Entry]
Name=Lock Screen
Comment=Sets a password if needed and then lock screen
Exec=/usr/local/bin/lock_screen
Icon=system-lock-screen
Terminal=false
Type=Application
StartupNotify=true

8
scripts/system/usr/share/applications/suspend_session.desktop

@ -0,0 +1,8 @@
[Desktop Entry]
Name=Suspend session
Comment=Sets a password if needed and then suspend session
Exec=/usr/local/bin/suspend_session
Icon=media-playback-pause
Terminal=false
Type=Application
StartupNotify=true

22
scripts/system/usr/share/initramfs-tools/hooks/copy_mkfs

@ -0,0 +1,22 @@
#!/bin/sh
set -e
PREREQ=""
prereqs () {
echo "${PREREQ}"
}
case "${1}" in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
copy_exec /sbin/mke2fs /bin
exit 0

20
scripts/system/usr/share/initramfs-tools/scripts/init-premount/reformat

@ -0,0 +1,20 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /scripts/functions
/bin/mke2fs -F -t ext4 -O ^has_journal ::PART:: > /dev/null 2>&1
exit 0

118
scripts/ubuntu_tweaks.sh

@ -0,0 +1,118 @@
#!/bin/bash
# Configure ubuntu desktop systems
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd "$SCRIPT_DIR"
. set.sh
# Install dependencies
apt-get -y install lz4
# Change ext4 default mount options
sed -i -e 's/ errors=remount-ro/ noatime,nodelalloc,errors=remount-ro/g' /etc/fstab
# Disable GTK hidden scroll bars
echo GTK_OVERLAY_SCROLLING=0 >> /etc/environment
# Reveal boot messages
sed -i -e 's/TTYVTDisallocate=yes/TTYVTDisallocate=no/g' /etc/systemd/system/getty.target.wants/getty@tty1.service
# Speedup boot
sed -i 's/MODULES=most/MODULES=dep/g' /etc/initramfs-tools/initramfs.conf
sed -i 's/COMPRESS=gzip/COMPRESS=lz4/g' /etc/initramfs-tools/initramfs.conf
# Reveal autostart services
sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop
# Remove password complexity constraints
sed -i 's/ obscure / minlen=1 /g' /etc/pam.d/common-password
# Remove splash screen (plymouth) and hide kernel output
sed -i 's/quiet splash/quiet vt.global_cursor_default=0 console=ttyS0/g' /etc/default/grub
update-initramfs -u
update-grub
# Disable swapfile
swapoff /swapfile || true
rm -f /swapfile
sed -i '/swapfile/d' /etc/fstab
# Prevent gnome-shell segfault from happening
sed -i 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm3/custom.conf
# Purge unused Ubuntu packages
PKGS="
apport
bind9
bolt
cups*
exim*
fprintd
friendly-recovery
gnome-initial-setup
gnome-online-accounts
gnome-power-manager
gnome-software
gnome-software-common
memtest86+
orca
popularity-contest
python3-update-manager
secureboot-db
snapd
spice-vdagent
ubuntu-report
ubuntu-software
unattended-upgrades
update-inetd
update-manager-core
update-notifier
update-notifier-common
whoopsie
xdg-desktop-portal
"
apt-get -y purge $PKGS
apt-get -y autoremove --purge
SERVICES="
apt-daily-upgrade.timer
apt-daily.timer
console-setup.service
keyboard-setup.service
motd-news.timer
remote-fs.target
"
systemctl disable $SERVICES
SERVICES="
grub-common.service
NetworkManager-wait-online.service
plymouth-quit-wait.service
"
systemctl mask $SERVICES
# Install packages
PKGS="$(cat common_packages.txt)
baobab
blender
chromium-browser
dconf-editor
firefox
gimp
gnome-calculator
gnome-system-monitor
gnome-tweaks
i3lock
mpv
zenity
"
# Replace debian packages with ubuntu's
PKGS=${PKGS/linux-image-amd64/linux-image-generic}
PKGS=${PKGS/linux-headers-amd64/linux-headers-generic}
PKGS=${PKGS/firmware-linux-nonfree}
apt-get -y install $PKGS

35
scripts/vscode.sh

@ -0,0 +1,35 @@
#!/bin/bash
# Install VSCode
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)"
cd $SCRIPT_DIR
. set.sh
wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | apt-key add -
echo 'deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main' > /etc/apt/sources.list.d/vscodium.list
apt-get update && apt-get -y install vscodium
# Set-up all users
for DIR in $(ls -1d /home/* 2>/dev/null || true)
do
# Disable most of the telemetry and auto-updates
mkdir -p $DIR/.config/VSCodium/User
cat <<-'EOF'> $DIR/.config/VSCodium/User/settings.json
{
"telemetry.enableCrashReporter": false,
"update.enableWindowsBackgroundUpdates": false,
"update.mode": "none",
"update.showReleaseNotes": false,
"extensions.autoCheckUpdates": false,
"extensions.autoUpdate": false,
"workbench.enableExperiments": false,
"workbench.settings.enableNaturalLanguageSearch": false,
"npm.fetchOnlinePackageInfo": false
}
EOF
# Fix rights
USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev)
chown -R $USR:$USR $DIR || true
done

6
subjects/addprimesum.md → subjects/addprimesum.en.md

@ -4,9 +4,9 @@
Write a program that takes a positive integer as argument and displays the sum of all prime numbers inferior or equal to it followed by a newline.
- If the number of arguments is not 1, or the argument is not a positive number, just display 0 followed by a newline.
- If the number of arguments is not 1, or if the argument is not a positive number, the program displays 0 followed by a newline.
Example of output :
Examples of outputs :
```console
student@ubuntu:~/piscine/test$ go build
@ -17,4 +17,4 @@ student@ubuntu:~/piscine/test$ ./test 7
student@ubuntu:~/piscine/test$ ./test 57
0
student@ubuntu:~/piscine/test$
```
```

37
subjects/brainfuck.en.md

@ -0,0 +1,37 @@
## brainfuck
### Instructions
Write a Brainfuck interpreter program.
The source code will be given as first parameter.
The code will always be valid, with no more than 4096 operations.
Brainfuck is a minimalist language. It consists of an array of bytes
(in our case, let's say 2048 bytes) initialized to zero,
and a pointer to its first byte.
Every operator consists of a single character :
- '>' increment the pointer ;
- '<' decrement the pointer ;
- '+' increment the pointed byte ;
- '-' decrement the pointed byte ;
- '.' print the pointed byte on standard output ;
- '[' go to the matching ']' if the pointed byte is 0 (while start) ;
- ']' go to the matching '[' if the pointed byte is not 0 (while end).
Any other character is a comment.
Examples of outputs :
```console
student@ubuntu:~/student/brainfuck$ go build
student@ubuntu:~/student/brainfuck$ ./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e
Hello World!$
student@ubuntu:~/student/brainfuck$ ./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e
Hi$
student@ubuntu:~/student/brainfuck$ ./brainfuck "++++++++++[>++++++++++>++++++++++>++++++++++<<<-]>---.>--.>-.>++++++++++." | cat -e
abc$
student@ubuntu:~/student/brainfuck$ ./brainfuck | cat -e
$
student@ubuntu:~/student/brainfuck$
```

1
subjects/doop.en.md

@ -35,5 +35,4 @@ student@ubuntu:~/piscine/test$ ./doop 1 % 0
No modulo by 0
student@ubuntu:~/piscine/test$ ./doop 1 * 1
1
```

9
subjects/doop.fr.md

@ -10,10 +10,13 @@ Le programme doit être utilisé avec trois arguments:
- Un opérateur
- Une autre valeur
En cas d'argument invalide le programme affiche `0`.
En cas d'opérateur invalide le programme affiche `0`.
En cas de nombre invalide d'arguments le programme affiche rien.
Le programme doit géré les opérations modulo et division par 0 comme dans les examples ci-dessous.
`fmt.Print` est autorisé.
### Utilisation
@ -23,8 +26,8 @@ student@ubuntu:~/piscine/test$ go build doop.go
student@ubuntu:~/piscine/test$ ./doop
student@ubuntu:~/piscine/test$ ./doop 1 + 1
2
student@ubuntu:~/piscine/test$ ./doop hello + 1
0
student@ubuntu:~/piscine/test$ ./doop hello + 1 | cat -e
0$
student@ubuntu:~/piscine/test$ ./doop 1 p 1
0
student@ubuntu:~/piscine/test$ ./doop 1 + 1

28
subjects/doop.md

@ -1,28 +0,0 @@
## doop
### Instructions
Write a program that takes three strings:
- The first and the third one are representations of base-10 signed integers that fit in an int.
- The second one is an arithmetic operator chosen from: `+ - * / %`
- The program must display the result of the requested arithmetic operation, followed by a newline. If the number of parameters is not 3, the program just displays a newline.
- You can assume the string have no mistakes or extraneous characters. Negative numbers, in input or output, will have one and only one leading `-`. The result of the operation fits in an int.
Example of output :
```console
student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ ./test "123" "*" 456
56088
student@ubuntu:~/piscine/test$ ./test "9828" "/" 234
42
student@ubuntu:~/piscine/test$ ./test "10" "+" "-43"
33
student@ubuntu:~/piscine/test$ ./test
student@ubuntu:~/piscine/test$
```

28
subjects/expandstr.en.md

@ -0,0 +1,28 @@
## expandstr
### Instructions
Write a program that takes a string and displays it with exactly three spaces
between each word, with no spaces or tabs at either the beginning nor the end.
The string will be followed by a newline.
A word is a sequence of alphanumerical characters.
If the number of parameters is not 1, or if there are no words, the program displays
a newline.
Examples of outputs :
```console
student@ubuntu:~/student/expandstr$ go build
student@ubuntu:~/student/expandstr$ ./expandstr "you see it's easy to display the same thing" | cat -e
you see it's easy to display the same thing$
student@ubuntu:~/student/expandstr$ ./expandstr " only it's harder " | cat -e
only it's harder$
student@ubuntu:~/student/expandstr$ ./expandstr " how funny it is" "did you hear, Mathilde ?" | cat -e
$
student@ubuntu:~/student/expandstr$ ./expandstr | cat -e
$
student@ubuntu:~/student/expandstr$
```

4
subjects/gcd.en.md

@ -10,6 +10,8 @@ strictly positive integer).
If the number of parameters is not 2, display a newline.
All arguments tested will be valid positive `int` values.
Example of output :
```console
@ -24,5 +26,7 @@ student@ubuntu:~/student/gcd$ ./gcd 17 3 | cat -e
1$
student@ubuntu:~/student/gcd$ ./gcd | cat -e
$
student@ubuntu:~/student/gcd$ ./gcd 50 12 4 | cat -e
$
student@ubuntu:~/student/gcd$
```

28
subjects/hiddenp.en.md

@ -0,0 +1,28 @@
## hiddenp
### Instructions
Write a program named hiddenp that takes two strings and that, if the first string is hidden in the second one, displays 1
followed by a newline, otherwise it displays 0 followed by a newline.
Let s1 and s2 be strings. It is considered that s1 is hidden in s2 if it is possible to
find each character from s1 in s2, **in the same order as they appear in s1.**
If s1 is an empty string it is considered hidden in any string.
If the number of parameters is not 2, the program displays a newline.
Example of output :
```console
student@ubuntu:~/student/hiddenp$ go build
student@ubuntu:~/student/hiddenp$ ./hiddenp "fgex.;" "tyf34gdgf;'ektufjhgdgex.;.;rtjynur6" | cat -e
1$
student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "2altrb53c.sse" | cat -e
1$
student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "btarc" | cat -e
0$
student@ubuntu:~/student/hiddenp$ ./hiddenp | cat -e
$
student@ubuntu:~/student/hiddenp$
```

15
subjects/itoa.en.md

@ -0,0 +1,15 @@
## itoa
### Instructions
- Write a function that simulates the behaviour of the `Itoa` function in Go. `Itoa` transforms a number represented as an`int` in a number represented as a `string`.
- For this exercise the handling of the signs + or - **does have** to be taken into account.
## Expected function
```go
func Itoa(n int) string {
}
```

24
subjects/itoabase.en.md

@ -0,0 +1,24 @@
## itoabase
### Instructions
Write a function that:
- converts an integer value to a string using the specified base in the argument
- and then returns this string
The base is expressed as an integer, from 2 to 16. The characters comprising
the base are the digits from 0 to 9, followed by uppercase letters from A to F.
For example, the base `4` would be the equivalent of "0123" and the base `16` would be the equivalent of "0123456789ABCDEF".
If the value is negative, the resulting string has to be preceded with a
minus sign `-`.
### Expected function
```go
func ItoaBase(value, base int) string {
}
```

21
subjects/paramcount.en.md

@ -0,0 +1,21 @@
## paramcount
### Instructions
Write a program that displays the number of arguments passed to it. This number will be followed by
a newline.
If there are no arguments, just display a 0 followed by a newline.
Examples of outputs :
```console
student@ubuntu:~/student/paramcount$ go build
student@ubuntu:~/student/paramcount$ ./paramcount 1 2 3 5 7 24
6
student@ubuntu:~/student/paramcount$ ./paramcount 6 12 24 | cat -e
3$
student@ubuntu:~/student/paramcount$ ./paramcount | cat -e
0$
student@ubuntu:~/student/paramcount$
```

6
subjects/printhex.md → subjects/printhex.en.md

@ -2,11 +2,11 @@
### Instructions
Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 (lowercase letters) followed by a newline.
Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 ( with lowercase letters) followed by a newline.
- If the number of parameters is not 1, the program displays a newline.
Example of output :
Examples of outputs :
```console
student@ubuntu:~/piscine/test$ go build
@ -19,4 +19,4 @@ student@ubuntu:~/piscine/test$ ./test "5156454"
student@ubuntu:~/piscine/test$
student@ubuntu:~/piscine/
```
```

24
subjects/range.en.md

@ -0,0 +1,24 @@
## range
### Instructions
Write the function Range which must:
- allocate (with make()) an array of integers.
- fill it with consecutive values that begin at `start` and end at `end` (Including `start` and `end` !)
- finally return that array.
### Expected function
```go
func Range(start, end int) []int {
}
```
Examples of outputs :
- With (1, 3) you will return an array containing 1, 2 and 3.
- With (-1, 2) you will return an array containing -1, 0, 1 and 2.
- With (0, 0) you will return an array containing 0.
- With (0, -3) you will return an array containing 0, -1, -2 and -3.

20
subjects/range.md

@ -1,20 +0,0 @@
## range
### Instructions
Write the following functions :
```go
func Range(start, end int) []int{
}
```
It must allocate (with malloc()) an array of integers, fill it with consecutive values that begin at start and end at end (Including start and end !), then return a pointer to the first value of the array.
Example of output :
- With (1, 3) you will return an array containing 1, 2 and 3.
- With (-1, 2) you will return an array containing -1, 0, 1 and 2.
- With (0, 0) you will return an array containing 0.
- With (0, -3) you will return an array containing 0, -1, -2 and -3.

24
subjects/reverserange.en.md

@ -0,0 +1,24 @@
## reverserange
### Instructions
Write the function ReverseRange which must:
- allocate (with make()) an array of integers.
- fill it with consecutive values that begin at `end` and end at `start` (Including `start` and `end` !)
- finally return that array.
### Expected function
```go
func ReverseRange(start, end int) []int {
}
```
Examples of output :
- With (1, 3) the function will return an array containing 3, 2 and 1.
- With (-1, 2) the function will return an array containing 2, 1, 0 and -1.
- With (0, 0) the function will return an array containing 0.
- With (0, -3) the function will return an array containing -3, -2, -1 and 0.

27
subjects/reversestrcap.en.md

@ -0,0 +1,27 @@
## reversestrcap
### Instructions
Write a program that takes one or more strings and that, **for each argument**:
-puts the last character of each word (if it is a letter) in uppercase and the rest
in lowercase
-then it displays the result followed by a `\n`.
A word is a sequence of alphanumerical characters.
If there are no parameters, the program displays a `\n`.
Examples of outputs :
```console
student@ubuntu:~/student/reversestrcap$ go build
student@ubuntu:~/student/reversestrcap$ ./reversestrcap "First SMALL TesT" | cat -e
firsT smalL tesT$
student@ubuntu:~/student/reversestrcap$ ./reversestrcap go run reversestrcap.go "SEconD Test IS a LItTLE EasIEr" "bEwaRe IT'S NoT HARd WhEN " " Go a dernier 0123456789 for the road e" | cat -e
seconD tesT iS A littlE easieR$
bewarE it'S noT harD wheN $
gO A dernieR 0123456789 foR thE roaD E$
student@ubuntu:~/student/reversestrcap$ ./reversestrcap | cat -e
$
student@ubuntu:~/student/reversestrcap$
```

12
subjects/sortlist.md → subjects/sortlist.en.md

@ -14,17 +14,17 @@ func SortList(l *node, func cmp(a,b int) bool) *node{
}
```
This function must sort the list given as a parameter, using the function `cmp` to select the order to apply, and returns a pointer to the first element of the sorted list.
This function must sort the list given as a parameter using the function `cmp` to select the order to apply. It must then return a pointer to the first element of the sorted list.
- Duplications must remain.
- Inputs will always be consistet.
- Inputs will always be consistent.
- You must use the type `Node`
- The type `Node` must be used.
- Functions passed as `cmp` will always return a boolean. If `a` and `b` are in the rigth order it returns `true`, otherwise it returns `false`.
- Functions passed as `cmp` will always return a boolean. If `a` and `b` are in the right order it returns `true`, otherwise it returns `false`.
- For example, the following function used as cmp will sort the list in ascending order :
- For example; the following function used as cmp will sort the list in ascending order :
```go
func ascending(a, b int) {
@ -34,4 +34,4 @@ func ascending(a, b int) {
return false
}
}
```
```

4
subjects/tabmult.md

@ -6,7 +6,7 @@ Write a program that displays a number's multiplication table.
- The parameter will always be a strictly positive number that fits in an int, and said number times 9 will also fit in an int.
Example of output :
Examples of outputs :
```console
student@ubuntu:~/piscine/test$ go build
@ -33,4 +33,4 @@ student@ubuntu:~/piscine/test$ ./test 19
student@ubuntu:~/piscine/test$
student@ubuntu:~/piscine/
```
```

Loading…
Cancel
Save