diff --git a/docs/modular-steps-management.md b/docs/modular-steps-management.md new file mode 100644 index 00000000..280f6daf --- /dev/null +++ b/docs/modular-steps-management.md @@ -0,0 +1,220 @@ +# Sign up & onboarding's Administration section - Modular steps management + +## Usage +> After their first authentication in the app, every candidate has to do his **sign up** and his **onboarding**. The steps that compose the **sign up** and the **administration** section of the onboarding are either: +> * Forms (identification, medical information, etc.) +> * Documents to sign (general conditions, charts, regulations, etc.) +> +> All the sections are modular: you can add, update, delete and order them as you wish. +> +> This documentation explains how to manage these steps. + +## Create your step child object +### Create a new object for your step in the admin +> Information is available for object's creation: [Object creation](https://github.com/01-edu/public/blob/master/doc/object-creation.md) + +* This object must have the same type as its future parent object (*signup* or *onboarding*). + +> Your step is then available in the *Admin*. You can find it in the section of its type (*SignUp* or *Onboarding*) or thanks to the search bar of the cursus object's page. + + +### Add this new object as a child of your parent's object + +* Edit the parent object: *Sign up* or *Administration* + +> Information is available for object's creation: [Child object creation](https://github.com/01-edu/public/blob/master/doc/child-object-creation.md) + +## Settings for a `form` step +> In the step object you have created, 2 attributes must be filled: +> 1. Subtype +> 2. Form + +### Description + +#### Edit the step object you have created : +> in *Object attributes* + +Capture d’écran 2019-04-22 à 15 59 33 + +* 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. + * To create a section, add a new key to the form object, of type `Object`, that contains: + * A **title** key of type `String`. The value of this property will be the title displayed in the top of the form section. + > If there is only one section in the form step, and no section title is needed, this property can be ignored. + * An **inputs** key of type `Object`, which will contain all the inputs of the section. For each wanted input, add a new `Object` element in the "inputs" object. + > The key of this object will be used as the "name" attribute of your input. + > 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`, `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) + * 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: + * [textInput documentation](https://alem.01-edu.org/design/Components/FormInputs/TextInput) - used for inputs type 'text', 'tel', and 'date' + * [textArea documentation](https://alem.01-edu.org/design/Components/FormInputs/TextArea) + * [select documentation](https://alem.01-edu.org/design/Components/FormControls/Select) + * [radio button documentation](https://alem.01-edu.org/design/Components/FormControls/Radio) + * [switch documentation](https://alem.01-edu.org/design/Components/FormControls/Switch) + * [checkbox documentation](https://alem.01-edu.org/design/Components/FormControls/Checkbox) + +### 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 is provided in the admin, in the onboarding section: 'Form step example'. + +```json +{ + "subtype": "form-step", + "form": { + "identification": { + "title": "Identification", + "inputs": { + "firstName": { + "index": 0, + "placeholder": "First name", + "maxLength": 50, + "type": "text", + "required": true + }, + "tel": { + "index": 1, + "required": true, + "type": "tel", + "label": "Phone number", + "placeholder": "+333 33 33 33 33", + "pattern": "[+][3][0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" + }, + "medicalInfo": { + "label": "Medical informations", + "placeholder": "Your medical Informations", + "index": 7, + "maxLength": 250, + "type": "textarea" + }, + "dateOfBirth": { + "index": 2, + "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", + "id": "genders", + "required": true, + "emptyItem": { "label": "Select your gender" }, + "items": [ + { "label": "Male", "data": "male" }, + { "label": "Female", "data": "female" } + ] + }, + "environment": { + "index": 5, + "type": "radio", + "required": true, + "label": "Which environment do you live in ?", + "inlineBlock": true, + "items": [ + { "label": "City", "data": "city" }, + { "label": "Countryside", "data": "countryside" } + ] + }, + "programmingAbilities": { + "index": 6, + "type": "switch", + "label": "I am new in programming", + "value": true + }, + "generalConditions": { + "index": 8, + "type": "checkbox", + "label": "I have read and I accept the general conditions", + "value": false + } + } + }, + "moreAboutYou": { + "title": "More about you", + "inputs": { + "favoriteColor": { + "index": 0, + "placeholder": "Your favorite color", + "type": "text", + "required": true + } + } + } + } +} +``` + +This 'form' step would look like this: + +![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 : + +| name | fullfillment | +| ---------- | --------- | +| subtype | **required** | +| text | **required** | +| buttonText | optionnal | +| checkbox | optionnal | + +### Description + +#### To set up the child object you have created with these elements: + +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 '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: + * A **label** key of type `String`, for the text associated to the checkbox + * A **required** key of type `Boolean`, set at true if the user has to check it + * A **name** key of type `String` + * All other attributes wanted for the checkbox. + +### Examples + +Here is an example of the structure a 'document to sign' step could have: + +```json +{ + "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": { + "name":"acceptChart", + "label":"I have read and accepted the Chart 01", + "required":true + } +} +``` + +This 'document to sign' step would look like this: + +![document to sign step example](https://user-images.githubusercontent.com/35296671/56504782-8f079900-6511-11e9-9a0e-bb638b6d7d03.png) + diff --git a/docs/object-attribute-system.md b/docs/object-attribute-system.md new file mode 100644 index 00000000..8aea0fc1 --- /dev/null +++ b/docs/object-attribute-system.md @@ -0,0 +1,162 @@ +# Object Attributes System + +> This document cover two notions, the edition of attributes and the impact it has relatively to the others Objects. + +## Edition of Attributes + +> There is no limit to how many attributes can be defined to an Object. + +In the "Object Attributes" section of the "Object Edit" Page, the first row is a form to create and append a new attribute. It requires two elements, the name of the attribute and its type (`String`, `Number`, `Boolean`, `Array`, `Object`, `Function`, `Null`). Click 'Add' to create the attribute. + +> Within a same Object, each attribute's name must be unique. + +Once created, the new attributes appears right bellow and the ability to associate a value to it is now available. Depending on the type of the attribute, the interface will vary. + +- String value input is type String. +- Number value input is type Number. +- Booleans value input appears as a switch, true by default. +- Arrays and Objects content are hideable / showable via the "Show/Hide content" button on the right of the attribute. There is no limit on the depth of Object/Array, however, after a certain level, the interface will start to feel narrow. +- String value input is type String. +- Null will not display any input. +- Function will offer to select from all available functions, save on select. + +Any attribute can be delete by clicking on the 'trash' icon on the right hand of it. + +Here an example of how the section looks like. +![object-attributes](https://user-images.githubusercontent.com/15313830/56677487-88675600-66b8-11e9-9781-26dc0ee6301d.png) + +## Attributes and RelationShips + +When an attributes is set to an Object, other Objects, associated to this particular Object, will have access to it. Which means that, if an Object A is added as a child of an Object B, A will embed its attributes within the instance of B. + +Object's attributes follow a hierarchy when associated to an other Object. +The **defaults attributes** of a child, the ones defined in the original Object are the weakest ones. A **children attribute** is applied to all the children and override the default attributes. Finally, **relation attribute** is the strongest one, it override Default Attributes and Children Attributes. + +When an object and its relationship are resolved, the three structures (`attrs`, `childrenAttrs`, `childAttrs`) are merged. + +The following json shows how the object would be represented: + +```json +{ + "children": { + "printalphabet": { + "duration": 3600, + "xp": 800, + "isBonus": true + } + } +} +``` + +Children +![children](https://user-images.githubusercontent.com/15313830/56679319-b189e580-66bc-11e9-8f2a-3d51eb1486d4.png) + +Child +![chilld-capture](https://user-images.githubusercontent.com/15313830/56679320-b189e580-66bc-11e9-90ab-c8f69f531876.png) + +## Detailed example + +Let's create a few `exercises` objects + +> swap + +```js +{ + "id": 12344, + "title": "swap", + "attrs": { + "language": "go", + "duration": 7200 + } +} +``` + +> printalphabet + +```js +{ + "id": 12345, + "title": "printalphabet-v2", + "attrs": { + "language": "go", + "duration": 3600 + } +} +``` + +We can now create a parent object that will reference them and link them. + +This allow you to specify the structuration of your pedagocial content. + +I'll make a quest that regroup those 2 exercises: + +> quest-03 + +```js +{ + "id": 12346, + "title": "quest-03", + "attrs": {}, + "childrenAttrs": { + "xp": 800, + "duration": 4800, + }, + "children": { + "printalphabet": { + "ref": 12345, + "index": 0, + "attrs": { + "duration": 7200 + } + }, + "swap": { + "ref": 12344, + "index": 1, + "attrs": {} + } + } +} +``` + +All done, now when rendering an object, attributes are merged like so: + +> rendered quest object + +```js +{ + "id": 12346, + "title": "quest-03", + "attrs": {}, + "children": { + "printalphabet": { + "ref": 12345, + "index": 0, + "attrs": { + "language": "go", + "xp": 800, + "duration": 7200 + } + }, + "swap": { + "ref": 12344, + "index": 1, + "attrs": { + "language": "go", + "xp": 800, + "duration": 4800 + } + } + } +} +``` + +First we apply the **default attributes** from the referenced object. +> Here `duration` and `language` are applied. + +Then we apply the **children attributes** to every child. +> In this case we override every `duration` to 4800 and add the new `xp` attribute. + +After that we apply the **relation attributes**, that are the most specific and as such, +override all others attributes. +> In this case only the `printalphabet` relation had attributes and so we apply +the given `duration` to the final merged object. diff --git a/docs/object-child-creation.md b/docs/object-child-creation.md new file mode 100644 index 00000000..45c8d7e8 --- /dev/null +++ b/docs/object-child-creation.md @@ -0,0 +1,33 @@ +# Admin object's management - create a child object + +## Usage +> Objects of the Admin can be configured : +> * By setting particular **attributes** to the object +> * By associating **children** to the object +> +> Children can be added, deleted, reordered in the list. Also, it's possible to configure it in a special way for the parent object, by setting children attributes for all the children. +> +> This documentation explains how to associate a child to a parent object. + +### Create a new object for your child in the admin +> Information is available for object's creation: [Modular step management](https://github.com/01-edu/public/blob/master/doc/object-creation.md) + +### Add this new object as a child of your parent's object + +#### 1. Edit the parent object +Capture d’écran 2019-04-22 à 19 24 23 +Capture d’écran 2019-04-22 à 19 24 10 + +#### 2. Go to *Children* > *Add a child* +![add child to parent object](https://user-images.githubusercontent.com/35296671/56506977-de50c800-6517-11e9-9c71-d19a1ec4e5cd.png) + +#### 3. Set up the new child: +* Enter its name in the input "Add a child name" +* Select your step object in the select input +* Click on "ADD" + +> Your step is then related to its parent. You can see it in the *Children* section of the parent's object. There, you can now: +> * Delete the child from its parent (the actual object of your child will not be deleted). +> * Reorder it in the children's list, by dragging it to the place you want. +> * Update its original settings by clicking on the eye icon of its reference (redirection to object edit page of the child). +Capture d’écran 2019-04-22 à 19 51 12 diff --git a/docs/object-creation.md b/docs/object-creation.md new file mode 100644 index 00000000..1fa5d31f --- /dev/null +++ b/docs/object-creation.md @@ -0,0 +1,53 @@ +# Admin object's management - create an object + +## Usage +> Elements of the app are managed through objects in *Admin*. + +> Objects of the Admin are first created and defined: +> * By their **title**, +> * By their **type**. + +> Then it can be configured through: +> * Attributes, +> * Children. + +> This documentation explains how to create an object. + +### Create a new object in the admin +> (in *Admin* > *Add new object*) + +Capture d’écran 2019-04-22 à 15 57 37 +Capture d’écran 2019-04-22 à 15 58 21 + + +* The **title** of your object will be the title displayed to your candidates. Use an intellegible title for your user. + > NB: you can always edit it in the *Admin* + +* The **type** depends on the nature of your object: + * **Campus** is used to declare a school. + * Examples: *Alem*, *Madeira*, etc. + * Campus can contains cursus: *Alem* contains for example *01-classical* and *Piscine Go*. + * **Cursus** is used to declare a course. + * Examples: *01-classical*, *Piscine Go*, etc. + * Cursuses can contains cursuses: the main cursus *01-classical*, for example, contains cursuses like *Piscine Go*, but also all the branches that the student have access to, as *Web*, *Security*, *Algorythm*, *Design*, etc. + * Cursuses can contains quests: *Piscine Go* of *01-classical* contains quests like *Quest 1* or *Quest 2*. + * **Quest** is used to declare a project. + * Examples: *Quest 1*, *Quest 2*, etc. + * Quest contains exercises: *Quest 1* of *Piscine Go* contains exercises like *printalphabet* or *printcomb*. + * Exercise is used to declare exercises + * Examples: *printalphabet*, *printcomb*, *atoi*, etc. + * Exercises doesn't contains any children. + * Signup is used to declare steps of the registration. + * Examples: *Using our services*, *Tell us more about you*, etc. + * One major object *Sign up* contains all the sign up's modular steps : *Using our services*, *Tell us more about you*, etc. + * Onbaording is used to declare steps of the onbaording. + * Examples: *Toad*, *Administration*, *Additional Informations*, *Chart 01*, etc. + * Three main objects define the major steps of the onboarding : *Toad*, *Administration*, *Piscine*. + * *Administration* contains modular steps: *Additional Informations*, *Chart 01*, etc. + +> The child object is then available in the *Admin*. It can be found in the section of its type or thanks to the search bar of the cursus object's page. + +> More information is available: +> * for setting attributes of an object: (soon available) +> * for setting children of an object: [Child object creation](https://github.com/01-edu/public/blob/master/doc/child-object-creation.md) +> * for creation of modular steps in Sign up and onboarding's Administration object: [Modular step management](https://github.com/01-edu/public/blob/master/doc/modular-steps-management.md) diff --git a/docs/object-edit.md b/docs/object-edit.md new file mode 100644 index 00000000..272ca098 --- /dev/null +++ b/docs/object-edit.md @@ -0,0 +1,34 @@ +# Objects Edition + +> Allow you to edit an object, see and manage its relations. + +## Page Composition + +![object-edit-overview](https://user-images.githubusercontent.com/15313830/56667480-ceff8500-66a5-11e9-98c7-792d598f2394.png) + +### Pin 1 + +- Link back to the "Objects" page ; +- Editable name field, hit 'enter' or 'cmd + s' or click on the floppy-disk icon to save ; +- Major dependencies visualisation, (where my object is used as a child), click the label to navigate to the dependence ; +- External URL, this is an optional parameter, it's use to point at an other source of content or information needed by the object. We generaly use to point at a Git repository ; + +### Pin 2 + +- Delete Button, Warning there, it will destroy your object! ; +- Type of your Object (`organisation`, `campus`, `onboarding`, `cursus`, `quest`, `exercise`), save on select ; +- Status of your Object (`draft`, `online`, `offline`), save on select ; +- The first and last name of the original author ; + +### Pin 3 + +- Object Attribute edition area, manage all the attributes relative to this Object. These attributes will be exposed to its relationship ; + +### Pin 4 + +- Object Children edition area ; +- Children Attributes edition area, these attributes impact and overload all the following children. Works the same way as standard attributes ; +- Add a child, allows to add a child to the children list, more information here -> [Object Child creation](https://github.com/01-edu/public/blob/master/doc/object-child-creation.md) ; +- Children List, allows you to reorganise, delete and edit child. Each child can be overload with its own attributes, the edition works the same way as the original attributes ; + +More informations about attribute overload system [here] ((https://github.com/01-edu/public/blob/master/doc/object-attribute-overload-system.md) diff --git a/docs/objects.md b/docs/objects.md new file mode 100644 index 00000000..21cb3a7a --- /dev/null +++ b/docs/objects.md @@ -0,0 +1,29 @@ +# Objects + +> Allow you to create, manage and organize your pedagical and onboarding content. + +## Definition + +An Object is an highly customizable element, which can be use in many situations. We use it to compose cursuses and onboarding processes. +Objects can be associated together and then share a vertical or horizontal relationship, which allows to build complex structure of multiple objects. + +It structure can be visualized in two parts. The first one is the definition of the object itself and attributes, called `attrs`. The second part is the definition of minor relationships, called `children` and attributes applied to them, called `childrenAttrs`. + +This is the minimal structure of an object: + +- name +- type (`organisation`, `campus`, `onboarding`, `cursus`, `quest`, `exercise`) +- status (`draft`, `online`, `offline`) +- attrs {} +- childrenAttrs {} +- children {} + +## Browse Objects: + +To access your Objects, go to the admin dashboard and then click on the _manage object_ link within the "Object" card. + +![go-to-objects](https://user-images.githubusercontent.com/15313830/56653756-46bdb780-6686-11e9-98ba-18e382987e9c.png) + +Objects are sorted by type in different sections. This page offer a search bar that allow you query the objects by name. In the top-right corner, click the _add a new object_ button to create a new object. Fill a name, select a type and click _create_ to validate your creation. You will be redirected to the Object Edition page (document is here). + +![all-object-page](https://user-images.githubusercontent.com/15313830/56654475-137c2800-6688-11e9-880b-75092397890d.png) diff --git a/docs/ubuntu-installation.md b/docs/ubuntu-installation.md new file mode 100644 index 00000000..9799cadf --- /dev/null +++ b/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 +``` diff --git a/examples/call-graphql.go b/examples/call-graphql.go new file mode 100644 index 00000000..9ef6af54 --- /dev/null +++ b/examples/call-graphql.go @@ -0,0 +1,88 @@ +package main + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + "os" +) + +func jsonPrettyPrint(in []byte) string { + var out bytes.Buffer + err := json.Indent(&out, in, "", " ") + if err != nil { + return string(in) + } + return out.String() +} + +var HASURA_GRAPHQL_ADDRESS = os.Getenv("HASURA_GRAPHQL_ADDRESS") +var HASURA_GRAPHQL_ADMIN_SECRET = os.Getenv("HASURA_GRAPHQL_ADMIN_SECRET") + +type GraphqlQuery struct { + Data interface{} +} + +var client = &http.Client{Transport: http.DefaultTransport} + +func hasura(query string, variables interface{}, data interface{}) (err error) { + variablesBytes, err := json.Marshal(variables) + if err != nil { + return + } + + v := string(variablesBytes) + requestBody := []byte(`{"query":"` + query + `","variables":` + v + `}`) + requestBytes := bytes.NewBuffer(requestBody) + req, err := http.NewRequest("POST", HASURA_GRAPHQL_ADDRESS, requestBytes) + if err != nil { + return + } + + req.Header.Add("X-Hasura-Admin-Secret", HASURA_GRAPHQL_ADMIN_SECRET) + + resp, err := client.Do(req) + if err != nil { + return + } + + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + // loggin the answer for debugging purposes + fmt.Println(jsonPrettyPrint(b)) + + if resp.StatusCode < 200 || resp.StatusCode > 299 { + return errors.New(http.StatusText(resp.StatusCode)) + } + + return json.Unmarshal(b, &GraphqlQuery{Data: data}) +} + +type User struct { + GithubLogin string +} + +const userQuery = ` +query { + user { + githubLogin + } +}` + +func getUsers() (users []User, err error) { + var data map[string][]User + err = hasura(userQuery, nil, &data) + return data["user"], err +} + +func main() { + fmt.Println(getUsers()) +} + +// HASURA_GRAPHQL_ADMIN_SECRET=VERYVERYSECRET HASURA_GRAPHQL_ADDRESS=http://localhost/graphql-engine/v1alpha1/graphql go run call-graphql.go diff --git a/scripts/bash_tweaks.sh b/scripts/bash_tweaks.sh new file mode 100755 index 00000000..88ec69e1 --- /dev/null +++ b/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 <> /etc/inputrc +set completion-ignore-case On +EOF + +# Enhance Linux prompt +cat < /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 <> /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 diff --git a/scripts/clean.sh b/scripts/clean.sh new file mode 100755 index 00000000..21a0834f --- /dev/null +++ b/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 diff --git a/scripts/common_packages.txt b/scripts/common_packages.txt new file mode 100644 index 00000000..2048b823 --- /dev/null +++ b/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 diff --git a/scripts/dconfig.txt b/scripts/dconfig.txt new file mode 100644 index 00000000..3057624f --- /dev/null +++ b/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='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='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='' diff --git a/scripts/firewall.sh b/scripts/firewall.sh new file mode 100755 index 00000000..78f1f66e --- /dev/null +++ b/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 diff --git a/scripts/fx.sh b/scripts/fx.sh new file mode 100755 index 00000000..07f724c2 --- /dev/null +++ b/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 diff --git a/scripts/go.sh b/scripts/go.sh new file mode 100755 index 00000000..c3a27a4a --- /dev/null +++ b/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 diff --git a/scripts/grub.sh b/scripts/grub.sh new file mode 100755 index 00000000..ad767811 --- /dev/null +++ b/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 <> /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 diff --git a/scripts/install_client.sh b/scripts/install_client.sh new file mode 100755 index 00000000..c5659782 --- /dev/null +++ b/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 diff --git a/scripts/nodejs.sh b/scripts/nodejs.sh new file mode 100755 index 00000000..c08f012a --- /dev/null +++ b/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 diff --git a/scripts/set.sh b/scripts/set.sh new file mode 100755 index 00000000..690e3018 --- /dev/null +++ b/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 diff --git a/scripts/ssh.sh b/scripts/ssh.sh new file mode 100755 index 00000000..3e0a5677 --- /dev/null +++ b/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 <> /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 diff --git a/scripts/sublime.sh b/scripts/sublime.sh new file mode 100755 index 00000000..b79ee4b1 --- /dev/null +++ b/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 < /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 diff --git a/scripts/system/etc/gdm3/PostLogin/Default b/scripts/system/etc/gdm3/PostLogin/Default new file mode 100755 index 00000000..d0fa55e0 --- /dev/null +++ b/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 diff --git a/scripts/system/etc/gdm3/PostSession/Default b/scripts/system/etc/gdm3/PostSession/Default new file mode 100755 index 00000000..803df884 --- /dev/null +++ b/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 diff --git a/scripts/system/etc/udev/rules.d/10-local.rules b/scripts/system/etc/udev/rules.d/10-local.rules new file mode 100644 index 00000000..dc335275 --- /dev/null +++ b/scripts/system/etc/udev/rules.d/10-local.rules @@ -0,0 +1 @@ +KERNEL=="::DISK::*", ENV{UDISKS_IGNORE}="1" diff --git a/scripts/system/usr/local/bin/lock_screen b/scripts/system/usr/local/bin/lock_screen new file mode 100755 index 00000000..d4f63f24 --- /dev/null +++ b/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 diff --git a/scripts/system/usr/local/bin/suspend_session b/scripts/system/usr/local/bin/suspend_session new file mode 100755 index 00000000..021e8bf1 --- /dev/null +++ b/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 diff --git a/scripts/system/usr/share/applications/lock_screen.desktop b/scripts/system/usr/share/applications/lock_screen.desktop new file mode 100644 index 00000000..2ff2a328 --- /dev/null +++ b/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 diff --git a/scripts/system/usr/share/applications/suspend_session.desktop b/scripts/system/usr/share/applications/suspend_session.desktop new file mode 100644 index 00000000..4691bf3c --- /dev/null +++ b/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 diff --git a/scripts/system/usr/share/initramfs-tools/hooks/copy_mkfs b/scripts/system/usr/share/initramfs-tools/hooks/copy_mkfs new file mode 100755 index 00000000..8f5f117f --- /dev/null +++ b/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 diff --git a/scripts/system/usr/share/initramfs-tools/scripts/init-premount/reformat b/scripts/system/usr/share/initramfs-tools/scripts/init-premount/reformat new file mode 100755 index 00000000..4a04b992 --- /dev/null +++ b/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 diff --git a/scripts/ubuntu_tweaks.sh b/scripts/ubuntu_tweaks.sh new file mode 100755 index 00000000..a1d4e139 --- /dev/null +++ b/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 diff --git a/scripts/vscode.sh b/scripts/vscode.sh new file mode 100755 index 00000000..43728442 --- /dev/null +++ b/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 diff --git a/subjects/abort.md b/subjects/abort.en.md similarity index 79% rename from subjects/abort.md rename to subjects/abort.en.md index ba029f93..5bda1b5c 100644 --- a/subjects/abort.md +++ b/subjects/abort.en.md @@ -1,20 +1,20 @@ -# abort -## Instructions +## abort + +### Instructions Write a function that returns the the value in the middle of 5 five arguments. This function must have the following signature. -## Expected function +### Expected function ```go func Abort(a, b, c, d, e int) int { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -22,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -38,5 +38,5 @@ And its output : student@ubuntu:~/student/abort$ go build student@ubuntu:~/student/abort$ ./abort 5 -student@ubuntu:~/student/abort$ +student@ubuntu:~/student/abort$ ``` diff --git a/subjects/activebits.md b/subjects/activebits.en.md similarity index 76% rename from subjects/activebits.md rename to subjects/activebits.en.md index e23c6b41..6722ffcc 100644 --- a/subjects/activebits.md +++ b/subjects/activebits.en.md @@ -1,21 +1,20 @@ -# activebits -## Instructions +## activebits + +### Instructions Write a function, ActiveBitsthat, that returns the number of active bits (bits with the value 1) in the binary representation of an integer number. The function must have the next signature. -## Expected function +### Expected function ```go - -func ActiveBits(n int) uint { +func ActiveBits(n int) uint { } - ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -23,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -39,5 +38,5 @@ And its output : student@ubuntu:~/student/activebits$ go build student@ubuntu:~/student/activebits$ ./activebits 10 -student@ubuntu:~/student/activebits$ +student@ubuntu:~/student/activebits$ ``` diff --git a/subjects/advancedsortwordarr.en.md b/subjects/advancedsortwordarr.en.md new file mode 100644 index 00000000..c6f7921d --- /dev/null +++ b/subjects/advancedsortwordarr.en.md @@ -0,0 +1,42 @@ +## advancedsortwordarr + +### Instructions + +Write a function `AdvancedSortWordArr` that sorts a `string` array, based on the function `f` passed in parameter. + +### Expected function + +```go +func AdvancedSortWordTab(array []string, f func(a, b string) int) { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} + piscine.AdvancedSortWordTab(result, piscine.Compare) + + fmt.Println(result) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[1 2 3 A B C a b c] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/advancedsortwordarr.fr.md b/subjects/advancedsortwordarr.fr.md new file mode 100644 index 00000000..71920f52 --- /dev/null +++ b/subjects/advancedsortwordarr.fr.md @@ -0,0 +1,42 @@ +## advancedsortwordarr + +### Instructions + +Écrire une fonction `AdvancedSortWordArr` qui trie un tableau de `string`, basé sur la fonction `f` passée en paramètre. + +### Fonction attendue + +```go +func AdvancedSortWordTab(array []string, f func(a, b string) int) { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} + piscine.AdvancedSortWordTab(result, piscine.Compare) + + fmt.Println(result) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[1 2 3 A B C a b c] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/advancedsortwordtab.en.md b/subjects/advancedsortwordtab.en.md new file mode 100644 index 00000000..e05f3ae5 --- /dev/null +++ b/subjects/advancedsortwordtab.en.md @@ -0,0 +1 @@ +## advancedsortwordtab diff --git a/subjects/alphamirror.en.md b/subjects/alphamirror.en.md new file mode 100644 index 00000000..15cdf45e --- /dev/null +++ b/subjects/alphamirror.en.md @@ -0,0 +1,29 @@ +## alphamirror + +### Instructions + +Write a program called alphamirror that takes a string as argument and displays this string +after replacing each alphabetical character with the opposite alphabetical +character. + +The case of the letter stays the same, for example : + +'a' becomes 'z', 'Z' becomes 'A' +'d' becomes 'w', 'M' becomes 'N' + +The final result will be followed by a newline. + +If the number of arguments is not 1, the program will display only a newline. + +Example of output : + +```console +student@ubuntu:~/student/alphamirror$ go build +student@ubuntu:~/student/alphamirror$ ./alphamirror "abc" +zyx +student@ubuntu:~/student/alphamirror$ ./alphamirror "My horse is Amazing." | cat -e +Nb slihv rh Znzarmt.$ +student@ubuntu:~/student/alphamirror$ ./alphamirror | cat -e +$ +student@ubuntu:~/student/alphamirror$ +``` diff --git a/subjects/any.en.md b/subjects/any.en.md new file mode 100644 index 00000000..4f94fdad --- /dev/null +++ b/subjects/any.en.md @@ -0,0 +1,48 @@ +## any + +### Instructions + +Write a function `Any` that returns `true`, for a `string` array: + +- if, when that `string` array is passed through an `f` function, at least one element returns `true`. + +### Expected function + +```go +func Any(f func(string) bool, arr []string) bool { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This", "is", "4", "you"} + + result1 := piscine.Any(piscine.IsNumeric, tab1) + result2 := piscine.Any(piscine.IsNumeric, tab2) + + fmt.Println(result1) + fmt.Println(result2) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +false +true +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/any.fr.md b/subjects/any.fr.md new file mode 100644 index 00000000..77afa5a1 --- /dev/null +++ b/subjects/any.fr.md @@ -0,0 +1,48 @@ +## any + +### Instructions + +Écrire une fonction `Any` qui retournes `true`, pour un tableau de `string`: + +- si, lorsque ce tableau de `string` est passé à travers une fonction `f`, au moins un element retournes `true`. + +### Fonction attendue + +```go +func Any(f func(string) bool, arr []string) bool { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This", "is", "4", "you"} + + result1 := piscine.Any(piscine.IsNumeric, tab1) + result2 := piscine.Any(piscine.IsNumeric, tab2) + + fmt.Println(result1) + fmt.Println(result2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +false +true +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/appendrange.en.md b/subjects/appendrange.en.md new file mode 100644 index 00000000..a521a708 --- /dev/null +++ b/subjects/appendrange.en.md @@ -0,0 +1,48 @@ +## appendrange + +### Instructions + +Write a function that takes an `int` min and an `int` max as parameters. +That function returns a slice of `int` with all the values between min and max. + +Min is included, and max is excluded. + +If min is superior or equal to max, a `nil` slice is returned. + +`make` is not allowed for this exercise. + +### Expected function + +```go +func AppendRange(min, max int) []int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.AppendRange(5, 10)) + fmt.Println(piscine.AppendRange(10, 5)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[5 6 7 8 9] +[] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/appendrange.fr.md b/subjects/appendrange.fr.md new file mode 100644 index 00000000..801e060f --- /dev/null +++ b/subjects/appendrange.fr.md @@ -0,0 +1,47 @@ +## appendrange + +### Instructions + +Écrire une fonction qui prend un `int` minimum et un `int` maximum comme paramètres. Cette fonction retournes une slice d'`int` avec toutes les valeurs comprises entre le minimum et le maximum. + +Le minimum est inclus, le maximum est exclu. + +Si le minimum est supérieur ou égal au maximum, une slice `nil` est retournée. + +`make` n'est pas autorisé pour cet exercice. + +### Fonction attendue + +```go +func AppendRange(min, max int) []int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.AppendRange(5, 10)) + fmt.Println(piscine.AppendRange(10, 5)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[5 6 7 8 9] +[] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/atoi.en.md b/subjects/atoi.en.md new file mode 100755 index 00000000..64271f6d --- /dev/null +++ b/subjects/atoi.en.md @@ -0,0 +1,77 @@ +## atoi + +### Instructions + +- Write a [function](TODO-LINK) that simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number represented as a `string` in a number represented as an `int`. + +- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **non-valid `string` chains will be tested**. Some will contain non-digits characters. + +- For this exercise the handling of the signs + or - **does have** to be taken into account. + +- This function will **only** have to return the `int` `nbr`. For this exercise the `error` return of atoi is not required. + +### Format required + +```go +func Atoi(s string) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "012 345" + s4 := "Hello World!" + s5 := "+1234" + s6 := "-1234" + s7 := "++1234" + s8 := "--1234" + + n := piscine.Atoi(s) + n2 := piscine.Atoi(s2) + n3 := piscine.Atoi(s3) + n4 := piscine.Atoi(s4) + n5 := piscine.Atoi(s5) + n6 := piscine.Atoi(s6) + n7 := piscine.Atoi(s7) + n8 := piscine.Atoi(s8) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) + fmt.Println(n4) + fmt.Println(n5) + fmt.Println(n6) + fmt.Println(n7) + fmt.Println(n8) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +0 +1234 +-1234 +0 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/atoi.fr.md b/subjects/atoi.fr.md new file mode 100755 index 00000000..4ccbff94 --- /dev/null +++ b/subjects/atoi.fr.md @@ -0,0 +1,77 @@ +## atoi + +### Instructions + +- Écrire une fonction qui reproduit le comportement de la fonction atoi en Go. Atoi transforme un nombre représenté en `string` (chaîne de caractères) en `int` (entier). + +- Atoi retourne `0` si la `string` n'est pas considéré un nombre valide. Pour cet exercice des **`string` non valides seront testées!**. Certaines contiendront d'autres charactères que des chiffres. + +- Pour cet exercice la gestion des signes + ou - **doit être** prise en compte. + +- Cette fonction aura **seulement** à retourner l'`int` (entier) `nbr`. Pour cet exercice le retour d'erreur d'atoi de go n'est pas demandé. + +### Fonction attendue + +```go +func Atoi(s string) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "012 345" + s4 := "Hello World!" + s5 := "+1234" + s6 := "-1234" + s7 := "++1234" + s8 := "--1234" + + n := piscine.Atoi(s) + n2 := piscine.Atoi(s2) + n3 := piscine.Atoi(s3) + n4 := piscine.Atoi(s4) + n5 := piscine.Atoi(s5) + n6 := piscine.Atoi(s6) + n7 := piscine.Atoi(s7) + n8 := piscine.Atoi(s8) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) + fmt.Println(n4) + fmt.Println(n5) + fmt.Println(n6) + fmt.Println(n7) + fmt.Println(n8) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +0 +1234 +-1234 +0 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/atoibase.en.md b/subjects/atoibase.en.md new file mode 100644 index 00000000..f582db42 --- /dev/null +++ b/subjects/atoibase.en.md @@ -0,0 +1,59 @@ +## atoibase + +### Instructions + +Write a function that takes a `string` number and its `string` base in parameters and returns its conversion as an `int`. + +If the base or the `string` number is not valid it returns `0`: + +Validity rules for a base : + +- A base must contain at least 2 characters. +- Each character of a base must be unique. +- A base should not contain `+` or `-` characters. + +Only valid `string` numbers will be tested. + +The function **does not have** to manage negative numbers. + +### Expected function + +```go +func AtoiBase(s string, base string) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.AtoiBase("125", "0123456789")) + fmt.Println(piscine.AtoiBase("1111101", "01")) + fmt.Println(piscine.AtoiBase("7D", "0123456789ABCDEF")) + fmt.Println(piscine.AtoiBase("uoi", "choumi")) + fmt.Println(piscine.AtoiBase("bbbbbab", "-ab") +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +125 +125 +125 +125 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/atoibase.fr.md b/subjects/atoibase.fr.md new file mode 100644 index 00000000..a6960561 --- /dev/null +++ b/subjects/atoibase.fr.md @@ -0,0 +1,59 @@ +## atoibase + +### Instructions + +Écrire une fonction qui prend un nombre `string` et sa base `string` en paramètres et retournes sa convertion en `int`. + +Si la base n'est pas valide elle retournes `0`: + +Régles de validité d'une base : + +- Une base doit contenir au moins 2 charactères. +- Chaque charactère d'une base doit être unique. +- Une base ne doit pas contenir les charactères `+` ou `-`. + +Seuls des nombres en `string` valides seront testés. + +La fonction **ne doit pas** gérer les nombres négatifs. + +### Fonction attendue + +```go +func AtoiBase(s string, base string) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.AtoiBase("125", "0123456789")) + fmt.Println(piscine.AtoiBase("1111101", "01")) + fmt.Println(piscine.AtoiBase("7D", "0123456789ABCDEF")) + fmt.Println(piscine.AtoiBase("uoi", "choumi")) + fmt.Println(piscine.AtoiBase("bbbbbab", "-ab") +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +125 +125 +125 +125 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicatoi.en.md b/subjects/basicatoi.en.md new file mode 100755 index 00000000..37685d33 --- /dev/null +++ b/subjects/basicatoi.en.md @@ -0,0 +1,57 @@ +## basicatoi + +### Instructions + +- Write a function that simulates the behaviour of the atoi function in Go. Atoi transforms a number defined as a `string` in a number defined as an `int`. + +- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **only valid** `string` chains will be tested. They will only contain one or several digits as characters. + +- For this exercise the handling of the signs + or - does not have to be taken into account. + +- This function will **only** have to return the `int` `nbr`. For this exercise the `error` return of atoi is not required. + +### Expected function + +```go +func BasicAtoi(s string) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "000000" + + n := piscine.BasicAtoi(s) + n2 := piscine.BasicAtoi(s2) + n3 := piscine.BasicAtoi(s3) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicatoi.fr.md b/subjects/basicatoi.fr.md new file mode 100755 index 00000000..1f9f0283 --- /dev/null +++ b/subjects/basicatoi.fr.md @@ -0,0 +1,57 @@ +## basicatoi + +### Instructions + +- Écrire une fonction qui reproduit le comportement de la fonction atoi en Go. Atoi transforme un nombre représenté en `string` (chaîne de caractères) en `int` (entier). + +- Atoi retourne `0` si la `string` n'est pas considéré un nombre valide. Pour cet exercice **seulement des** `string` **valides** seront testé. Elles ne contiendront que un ou plusieurs chiffres comme charact. + +- Pour cet exercice la gestion des signes + ou - ne doit pas être prise en compte. + +- Cette fonction aura **seulement** à retourner l'`int` (entier) `nbr`. Pour cet exercice le retour d'erreur d'atoi de go n'est pas demandé. + +### Fonction attendue + +```go +func BasicAtoi(s string) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "000000" + + n := piscine.BasicAtoi(s) + n2 := piscine.BasicAtoi(s2) + n3 := piscine.BasicAtoi(s3) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicatoi2.en.md b/subjects/basicatoi2.en.md new file mode 100755 index 00000000..16ba8ed3 --- /dev/null +++ b/subjects/basicatoi2.en.md @@ -0,0 +1,62 @@ +## basicatoi2 + +### Instructions + +- Write a function that simulates the behaviour of the atoi function in Go. Atoi transforms a number defined as a `string` in a number defined as an `int`. + +- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **non-valid `string` chains will be tested**. Some will contain non-digits characters. + +- For this exercise the handling of the signs + or - does not have to be taken into account. + +- This function will **only** have to return the `int` `nbr`. For this exercise the `error` return of atoi is not required. + +### Expected Function + +```go +func BasicAtoi2(s string) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "012 345" + s4 := "Hello World!" + + n := piscine.BasicAtoi2(s) + n2 := piscine.BasicAtoi2(s2) + n3 := piscine.BasicAtoi2(s3) + n4 := piscine.BasicAtoi2(s4) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) + fmt.Println(n4) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicatoi2.fr.md b/subjects/basicatoi2.fr.md new file mode 100755 index 00000000..7c9e0113 --- /dev/null +++ b/subjects/basicatoi2.fr.md @@ -0,0 +1,62 @@ +## basicatoi2 + +### Instructions + +- Écrire une fonction qui reproduit le comportement de la fonction atoi en Go. Atoi transforme un nombre représenté en `string` (chaîne de caractères) en `int` (entier). + +- Atoi retourne `0` si la `string` n'est pas considéré un nombre valide. Pour cet exercice des **`string` non valides seront testées!**. Certaines contiendront d'autres charactères que des chiffres. + +- Pour cet exercice la gestion des signes + ou - ne doit pas être prise en compte. + +- Cette fonction aura **seulement** à retourner l'`int` (entier) `nbr`. Pour cet exercice le retour d'erreur d'atoi de go n'est pas demandé. + +### Fonction attendue + +```go +func BasicAtoi2(s string) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "012 345" + s4 := "Hello World!" + + n := piscine.BasicAtoi2(s) + n2 := piscine.BasicAtoi2(s2) + n3 := piscine.BasicAtoi2(s3) + n4 := piscine.BasicAtoi2(s4) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) + fmt.Println(n4) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicjoin.en.md b/subjects/basicjoin.en.md new file mode 100644 index 00000000..b1cfa29c --- /dev/null +++ b/subjects/basicjoin.en.md @@ -0,0 +1,40 @@ +## basicjoin + +### Instructions + +Write a function that returns the concatenation of all the `string` of a table of `string` passed in argument. + +### Expected function + +```go +func basicJoin(strs []string) string { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + toConcat := []string{"Hello!", " How", " are", " you?"} + fmt.Println(piscine.BasicJoin(toConcat)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicjoin.fr.md b/subjects/basicjoin.fr.md new file mode 100644 index 00000000..8b1921c0 --- /dev/null +++ b/subjects/basicjoin.fr.md @@ -0,0 +1,40 @@ +## basicjoin + +### Instructions + +Écrire une fonction qui retourne la concaténation de toutes les `string` d'un slice de `string` passées en paramètres. + +### Fonction attendue + +```go +func BasicJoin(strs []string) string { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + toConcat := []string{"Hello!", " How", " are", " you?"} + fmt.Println(piscine.BasicJoin(toConcat)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/bool.md b/subjects/bool.en.md similarity index 86% rename from subjects/bool.md rename to subjects/bool.en.md index 9b75f86c..2c23b376 100644 --- a/subjects/bool.md +++ b/subjects/bool.en.md @@ -1,13 +1,12 @@ - # Boolean +## Boolean -## Instructions +### Instructions Create a `.go` file and copy the code below into our file - The main task is to return a working program. ```go - func printStr(str string) { arrayStr := []rune(str) @@ -18,7 +17,6 @@ func printStr(str string) { } func isEven(nbr int) boolean { - if even(nbr) == 1 { return yes } else { @@ -27,7 +25,6 @@ func isEven(nbr int) boolean { } func main() { - if isEven(lengthOfArg) == 1 { printStr(EvenMsg) } else { @@ -36,11 +33,14 @@ func main() { } ``` -## Expected output -```go +### Expected output + +```console I have an even number of arguments ``` -## Or -```go + +### Or + +```console I have an odd number of arguments -``` \ No newline at end of file +``` diff --git a/subjects/btreeapplybylevel.md b/subjects/btreeapplybylevel.en.md similarity index 82% rename from subjects/btreeapplybylevel.md rename to subjects/btreeapplybylevel.en.md index 410b518d..85cd3eb0 100644 --- a/subjects/btreeapplybylevel.md +++ b/subjects/btreeapplybylevel.en.md @@ -1,20 +1,20 @@ -# btreeapplybylevel -## Instructions +## btreeapplybylevel + +### Instructions Write a function, BTreeApplyByLevel, that applies the function given by fn to each node of the tree given by root. This function must have the following signature. -## Expected function +### Expected function ```go func BTreeApplyByLevel(root *TreeNode, fn interface{}) { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -22,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -44,5 +44,5 @@ student@ubuntu:~/student/btreeapplybylevel$ ./btreeapplybylevel 1 7 5 -student@ubuntu:~/student/btreeapplybylevel$ +student@ubuntu:~/student/btreeapplybylevel$ ``` diff --git a/subjects/btreeapplyinorder.en.md b/subjects/btreeapplyinorder.en.md new file mode 100644 index 00000000..25cc36a9 --- /dev/null +++ b/subjects/btreeapplyinorder.en.md @@ -0,0 +1,48 @@ +## btreeinsertdata + +### Instructions + +Write a function that applies a function in order to each element in the tree +(see in order tree walks) + +### Expected function + +```go +func BTreeApplyInorder(root *piscine.TreeNode, f func(...interface{}) (int, error)) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine "." +) + +func main() { + root := &piscine.TreeNode{Data: "4"} + piscine.BTreeInsertData(root, "1") + piscine.BTreeInsertData(root, "7") + piscine.BTreeInsertData(root, "5") + BTreeApplyInorder(root, fmt.Println) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreeinsertdata$ go build +student@ubuntu:~/piscine/btreeinsertdata$ ./btreeinsertdata +1 +4 +5 +7 +student@ubuntu:~/piscine/btreeinsertdata$ +``` diff --git a/subjects/btreeapplypostorder.en.md b/subjects/btreeapplypostorder.en.md new file mode 100644 index 00000000..e386d350 --- /dev/null +++ b/subjects/btreeapplypostorder.en.md @@ -0,0 +1,47 @@ +## btreeinsertdata + +### Instructions + +Write a function that applies a function using a postorder walk to each element in the tree + +### Expected function + +```go +func BTreeApplyPostorder(root *piscine.TreeNode, f func(...interface{}) (int, error)) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine "." +) + +func main() { + root := &piscine.TreeNode{Data: "4"} + piscine.BTreeInsertData(root, "1") + piscine.BTreeInsertData(root, "7") + piscine.BTreeInsertData(root, "5") + BTreeApplyPostorder(root, fmt.Println) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreeinsertdata$ go build +student@ubuntu:~/piscine/btreeinsertdata$ ./btreeinsertdata +1 +5 +7 +4 +student@ubuntu:~/piscine/btreeinsertdata$ +``` diff --git a/subjects/btreeapplypreorder.en.md b/subjects/btreeapplypreorder.en.md new file mode 100644 index 00000000..bbc17b7a --- /dev/null +++ b/subjects/btreeapplypreorder.en.md @@ -0,0 +1,47 @@ +## btreeinsertdata + +### Instructions + +Write a function that applies a function using a preorder walk to each element in the tree + +### Expected function + +```go +func BTreeApplyPreorder(root *piscine.TreeNode, f func(...interface{}) (int, error)) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine "." +) + +func main() { + root := &piscine.TreeNode{Data: "4"} + piscine.BTreeInsertData(root, "1") + piscine.BTreeInsertData(root, "7") + piscine.BTreeInsertData(root, "5") + BTreeApplyPreorder(root, fmt.Println) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreeinsertdata$ go build +student@ubuntu:~/piscine/btreeinsertdata$ ./btreeinsertdata +4 +1 +7 +5 +student@ubuntu:~/piscine/btreeinsertdata$ +``` diff --git a/subjects/btreedeletenode.md b/subjects/btreedeletenode.en.md similarity index 87% rename from subjects/btreedeletenode.md rename to subjects/btreedeletenode.en.md index 7220eeed..c367fe05 100644 --- a/subjects/btreedeletenode.md +++ b/subjects/btreedeletenode.en.md @@ -1,5 +1,6 @@ -# btreedeletenode -## Instructions +## btreedeletenode + +### Instructions Write a function, BTreeDeleteNode, that deletes 'node' from the tree given by root. @@ -7,16 +8,16 @@ The resulting tree should still follow the binary search tree rules. This function must have the following signature. -## Expected function +### Expected function ```go func BTreeDeleteNode(root, node *TreeNode) *TreeNode { - + } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -24,8 +25,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -56,5 +57,5 @@ After delete: 1 5 7 -student@ubuntu:~/student/btreedeletenode$ +student@ubuntu:~/student/btreedeletenode$ ``` diff --git a/subjects/btreeinsertdata.en.md b/subjects/btreeinsertdata.en.md new file mode 100644 index 00000000..ff319c89 --- /dev/null +++ b/subjects/btreeinsertdata.en.md @@ -0,0 +1,52 @@ +## btreeinsertdata + +### Instructions + +Write a function that inserts new data in a binary search tree +following the properties of binary search trees. +The nodes must be defined as follows: + +### Expected function + +```go +type TreeNode struct { + Left, Right, Parent *TreeNode + Data string +} + +func BTreeInsertData(root *TreeNode, data string) *TreeNode { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +func main() { + root := &TreeNode{data: "4"} + BTreeInsertData(root, "1") + BTreeInsertData(root, "7") + BTreeInsertData(root, "5") + fmt.Println(root.left.data) + fmt.Println(root.data) + fmt.Println(root.right.left.data) + fmt.Println(root.right.data) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreeinsertdata$ go build +student@ubuntu:~/piscine/btreeinsertdata$ ./btreeinsertdata +1 +4 +5 +7 +student@ubuntu:~/piscine/btreeinsertdata$ +``` diff --git a/subjects/btreeisbinary.md b/subjects/btreeisbinary.en.md similarity index 76% rename from subjects/btreeisbinary.md rename to subjects/btreeisbinary.en.md index 8f58fa9b..e57a11a9 100644 --- a/subjects/btreeisbinary.md +++ b/subjects/btreeisbinary.en.md @@ -1,20 +1,20 @@ -# btreeisbinary -## Instructions +## btreeisbinary + +### Instructions Write a function, BTreeIsBinary, that returns true only if the tree given by root follows the binary search tree properties. This function must have the following signature. -## Expected function +### Expected function ```go func BTreeIsBinary(root *TreeNode) bool { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -22,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -39,7 +39,7 @@ And its output : ```console student@ubuntu:~/student/btreeisbinary$ go build -student@ubuntu:~/student/btreeisbinary$ ./btreeisbinary +student@ubuntu:~/student/btreeisbinary$ ./btreeisbinary true -student@ubuntu:~/student/btreeisbinary$ +student@ubuntu:~/student/btreeisbinary$ ``` diff --git a/subjects/btreelevelcount.md b/subjects/btreelevelcount.en.md similarity index 81% rename from subjects/btreelevelcount.md rename to subjects/btreelevelcount.en.md index d3f8983c..2576e109 100644 --- a/subjects/btreelevelcount.md +++ b/subjects/btreelevelcount.en.md @@ -1,18 +1,18 @@ -# btreelevelcount -## Instructions +## btreelevelcount -Write a function, BTreeLevelCount, that return the number of levels of the tree (height of the tree) +### Instructions -## Expected function +Write a function, BTreeLevelCount, that return the number of levels of the tree (height of the tree) + +### Expected function ```go func BTreeLevelCount(root *piscine.TreeNode) int { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -20,8 +20,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { diff --git a/subjects/btreemax.md b/subjects/btreemax.en.md similarity index 83% rename from subjects/btreemax.md rename to subjects/btreemax.en.md index 46ee38df..dc389960 100644 --- a/subjects/btreemax.md +++ b/subjects/btreemax.en.md @@ -1,20 +1,20 @@ -# btreemax -## Instructions +## btreemax + +### Instructions Write a function, BTreeMax, that returns the node with the maximum value in the tree given by root This function must have the following signature. -## Expected function +### Expected function ```go func BTreeMax(root *TreeNode) *TreeNode { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -22,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -42,5 +42,5 @@ And its output : student@ubuntu:~/student/btreemax$ go build student@ubuntu:~/student/btreemax$ ./btreemax 7 -student@ubuntu:~/student/btreemax$ +student@ubuntu:~/student/btreemax$ ``` diff --git a/subjects/btreemin.md b/subjects/btreemin.en.md similarity index 83% rename from subjects/btreemin.md rename to subjects/btreemin.en.md index 2371c0fe..f3471856 100644 --- a/subjects/btreemin.md +++ b/subjects/btreemin.en.md @@ -1,20 +1,20 @@ -# btreemin -## Instructions +## btreemin + +### Instructions Write a function, BTreeMin, that returns the node with the minimum value in the tree given by root This function must have the following signature. -## Expected function +### Expected function ```go func BTreeMin(root *TreeNode) *TreeNode { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -22,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -42,5 +42,5 @@ And its output : student@ubuntu:~/student/btreemin$ go build student@ubuntu:~/student/btreemin$ ./btreemin 1 -student@ubuntu:~/student/btreemin$ +student@ubuntu:~/student/btreemin$ ``` diff --git a/subjects/btreeprintroot.en.md b/subjects/btreeprintroot.en.md new file mode 100644 index 00000000..433578ac --- /dev/null +++ b/subjects/btreeprintroot.en.md @@ -0,0 +1,48 @@ +## printroot + +### Instructions + +Write a function to print the value of the root node of a binary tree. +You have to create a new number and print the value of data +The nodes must be defined as follows: + +### Expected function + +```go +type TreeNode struct { + left, right *TreeNode + data string +} + +func PrintRoot(root *TreeNode){ + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +func main() { + //rootNode initialized with the value "who" + //rootNode1 initialized with the value "are" + //rootNode2 initialized with the value "you" + printRoot(rootNode) + printRoot(rootNode1) + printRoot(rootNode2) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/printroot$ go build +student@ubuntu:~/piscine/printroot$ ./printroot +who +are +you +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/btreesearchitem.en.md b/subjects/btreesearchitem.en.md new file mode 100644 index 00000000..abe4491e --- /dev/null +++ b/subjects/btreesearchitem.en.md @@ -0,0 +1,74 @@ +## btreeinsertdata + +### Instructions + +Write a function that searches for an item with a data element equal to elem and return that node + +### Expected function + +```go +func BTreeSearchItem(root *piscine_test.TreeNode, elem string) *piscine_test.TreeNode { + +} + +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine "." +) + +func main() { + root := &piscine_test.TreeNode{Data: "4"} + piscine_test.BTreeInsertData(root, "1") + piscine_test.BTreeInsertData(root, "7") + piscine_test.BTreeInsertData(root, "5") + selected := BTreeSearchItem(root, "7") + fmt.Print("Item selected -> ") + if selected != nil { + fmt.Println(selected.Data) + } else { + fmt.Println("nil") + } + + fmt.Print("Parent of selected item -> ") + if selected.Parent != nil { + fmt.Println(selected.Parent.Data) + } else { + fmt.Println("nil") + } + + fmt.Print("Left child of selected item -> ") + if selected.Left != nil { + fmt.Println(selected.Left.Data) + } else { + fmt.Println("nil") + } + + fmt.Print("Right child of selected item -> ") + if selected.Right != nil { + fmt.Println(selected.Right.Data) + } else { + fmt.Println("nil") + } +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreesearchitem$ go build +student@ubuntu:~/piscine/btreesearchitem$ ./btreesearchitem +Item selected -> 7 +Parent of selected item -> 4 +Left child of selected item -> 5 +Right child of selected item -> nil +student@ubuntu:~/piscine/btreesearchitem$ +``` diff --git a/subjects/btreetransplant.md b/subjects/btreetransplant.en.md similarity index 86% rename from subjects/btreetransplant.md rename to subjects/btreetransplant.en.md index 695fdc76..e8093914 100644 --- a/subjects/btreetransplant.md +++ b/subjects/btreetransplant.en.md @@ -1,20 +1,20 @@ -# btreetransplant -## Instructions +## btreetransplant + +### Instructions In order to move subtrees around within the binary search tree, write a function, BTreeTransplant, which replaces the subtree started by node with the node called 'rplc' in the tree given by root. This function must have the following signature. -## Expected function +### Expected function ```go func BTreeTransplant(root, node, rplc *TreeNode) *TreeNode { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -22,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -47,5 +47,5 @@ student@ubuntu:~/student/btreetrandsplant$ ./btreetransplant 4 5 7 -student@ubuntu:~/student/btreetrandsplant$ +student@ubuntu:~/student/btreetrandsplant$ ``` diff --git a/subjects/capitalize.en.md b/subjects/capitalize.en.md new file mode 100644 index 00000000..44f4d647 --- /dev/null +++ b/subjects/capitalize.en.md @@ -0,0 +1,41 @@ +## capitalize + +### Instructions + +Write a function that capitalizes the first letter of each word **and** lowercases the rest of each word of a `string`. + +A word is a sequence of **alphanumerical** characters. + +### Expected function + +```go +func Capitalize(s string) string { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Capitalize("Hello! How are you? How+are+things+4you?")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How Are You? How+Are+Things+4you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/capitalize.fr.md b/subjects/capitalize.fr.md new file mode 100644 index 00000000..526660aa --- /dev/null +++ b/subjects/capitalize.fr.md @@ -0,0 +1,41 @@ +## capitalize + +### Instructions + +Écrire une fonction qui met en majuscule la premiere lettre de chaque mot et en minuscule les autres lettres du reste du mot d'une `string`. + +Un mot est une suite de caractères **alphanumériques**. + +### Fonction attendue + +```go +func Capitalize(s string) string { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Capitalize("Hello! How are you? How+are+things+4you?")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How Are You? How+Are+Things+4you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cat.md b/subjects/cat.en.md similarity index 64% rename from subjects/cat.md rename to subjects/cat.en.md index 57e7ccf5..e285e01b 100644 --- a/subjects/cat.md +++ b/subjects/cat.en.md @@ -1,26 +1,26 @@ -# Cat +## Cat -## Instructions +### Instructions Write a program that does the same thing as the system's `cat` command-line. - You don't have to handle options. -- But if just call the program with out arguments it should take a input and print it back +- But if just call the program with out arguments it should take a input and print it back - In the program folder create two files named `quest8.txt` and `quest8T.txt`. - Copy to the `quest8.txt` file this : - - - "Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing -- Copy to the `quest8T.txt` file this : + - "Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing - - "Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence." +- Copy to the `quest8T.txt` file this : + + - "Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence." - In case of error it should print the error. -## Output: +### Output: ```console student@ubuntu:~/student/test$ go build diff --git a/subjects/cl-camp1.en.md b/subjects/cl-camp1.en.md new file mode 100644 index 00000000..866ff1a3 --- /dev/null +++ b/subjects/cl-camp1.en.md @@ -0,0 +1,21 @@ +## cl-camp1 + +### Instructions + +A little voice speaks in your head: + +"Now that you know who you are. You need to remember what you can do..." + +The instincts are coming back... + +Put in a file `mastertheLS` the command line that will: + +- list the files and folders of the current folder. +- Ignore the hidden files, the "." and the "..". +- Separates the resuls with commas. +- Order them by ascending order of creation date. +- Have the folders have a `/` in front of them. + +### Hint + +Read the man... diff --git a/subjects/cl-camp1.fr.md b/subjects/cl-camp1.fr.md new file mode 100644 index 00000000..8ffabc99 --- /dev/null +++ b/subjects/cl-camp1.fr.md @@ -0,0 +1,21 @@ +## cl-camp1 + +### Instructions + +Une petite voix dans votre esprit vous dit: + +"Maintenant que tu sais qui tu es. Tu dois te souvenir de ce que tu peux faire..." + +Les instincts resurgissent... + +Mettez dans un fichier `mastertheLS` la ligne de commande qui: + +- listera les fichiers et dossiers dans le dossier courant. +- Ignorera les fichiers cachés, le "." et le "..". +- Separarera le resultat avec des virgules. +- Les triera pas ordre croissant de date de création. +- Placera un `/` en face des dossiers. + +### Indice + +Lisez le man... diff --git a/subjects/cl-camp2.en.md b/subjects/cl-camp2.en.md new file mode 100644 index 00000000..9f7e7cca --- /dev/null +++ b/subjects/cl-camp2.en.md @@ -0,0 +1,17 @@ +## cl-camp2 + +### Instructions + +"keep training ..." + +Create a file `r`, which shows `R` on a line when the `cat` command is executed + +A line is a sequence of characters preceding the [end of line](https://en.wikipedia.org/wiki/Newline) character (`'\n'`). + +### Usage + +```console +student@ubuntu:~/piscine/test$ cat -e r +R$ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp2.fr.md b/subjects/cl-camp2.fr.md new file mode 100644 index 00000000..3442b3c2 --- /dev/null +++ b/subjects/cl-camp2.fr.md @@ -0,0 +1,17 @@ +## cl-camp2 + +### Instructions + +"Continue l'entrainement ..." + +Créez un fichier `r`, qui affiche `R` sur une ligne quand la commande `cat` command est exécutée. + +Une ligne est une suite de caractères précédant le caractère [fin de ligne](https://en.wikipedia.org/wiki/Newline) (`'\n'`). + +### Utilisation + +```console +student@ubuntu:~/piscine/test$ cat -e r +R$ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp3.en.md b/subjects/cl-camp3.en.md new file mode 100644 index 00000000..9fd36115 --- /dev/null +++ b/subjects/cl-camp3.en.md @@ -0,0 +1,15 @@ +## cl-camp3 + +### Instructions + +"start looking ..." + +Create a file `look`, which will look for and show, in the current directory and its sub-folders all the files : + +- starting with an `a` and, +- all the files ending with a `z` and, +- all files starting with `z` and ending with `a!`. + +### Hint + +Read the `find` man... diff --git a/subjects/cl-camp3.fr.md b/subjects/cl-camp3.fr.md new file mode 100644 index 00000000..7b420ffd --- /dev/null +++ b/subjects/cl-camp3.fr.md @@ -0,0 +1,15 @@ +## cl-camp3 + +### Instructions + +"commences à chercher ..." + +Créer un fichier `look`, qui cherchera et montrera, dans le répertoire courant et ses sous-répertoires, tous les fichiers qui: + +- commence avec `a` et, +- tous les fichiers qui se terminent avec `z` et, +- tous les fichiers qui commencent avec `z` et qui se finissenLisezele man dea!`. + +#Indice + +Lisez le man de `find`... diff --git a/subjects/cl-camp4.en.md b/subjects/cl-camp4.en.md new file mode 100644 index 00000000..0ffc7771 --- /dev/null +++ b/subjects/cl-camp4.en.md @@ -0,0 +1,24 @@ +## cl-camp4 + +### Instructions + +"someone familiar" + +Create a file `myfamily.sh`, which will show a subject's family (key: relatives). + +- The quotes have to be removed. + +- The subject will be decided depending on his ID which will be contained in the environment variable HERO_ID. + +* Where to look : https://raw.githubusercontent.com/kigiri/superhero-api/master/api/all.json + +* What to use : curl, jq and others... + +### Usage + +```console +student@ubuntu:~/piscine/test$ export HERO_ID=1 +student@ubuntu:~/piscine/test$ ./myfamily.sh +Marlo Chandler-Jones (wife); Polly (aunt); Mrs. Chandler (mother-in-law); Keith Chandler, Ray Chandler, three unidentified others (brothers-in-law); unidentified father (deceased); Jackie Shorr (alleged mother; unconfirmed) +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp4.fr.md b/subjects/cl-camp4.fr.md new file mode 100644 index 00000000..d57fd2d3 --- /dev/null +++ b/subjects/cl-camp4.fr.md @@ -0,0 +1,24 @@ +## cl-camp4 + +### Instructions + +"quelqu'un de familier" + +Créer un fichier `myfamily.sh`, qui montrera qui affichera la famille d'un individu (clef: relatives). + +- Les guillemets doivent être enlevés. + +- L'invidu sera choisi en fonction de son ID qui sera contenu dans la variable d'environment HERO_ID. + +* Où chercher : https://raw.githubusercontent.com/kigiri/superhero-api/master/api/all.json + +* Quoi utiliser : `curl`, `jq` et d'autres... + +### Utilisation + +```console +student@ubuntu:~/piscine/test$ export HERO_ID=1 +student@ubuntu:~/piscine/test$ ./myfamily.sh +Marlo Chandler-Jones (wife); Polly (aunt); Mrs. Chandler (mother-in-law); Keith Chandler, Ray Chandler, three unidentified others (brothers-in-law); unidentified father (deceased); Jackie Shorr (alleged mother; unconfirmed) +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp5.en.md b/subjects/cl-camp5.en.md new file mode 100644 index 00000000..36ad3bc0 --- /dev/null +++ b/subjects/cl-camp5.en.md @@ -0,0 +1,26 @@ +## cl-camp5 + +### Instructions + +"keep looking..." + +Create a file `lookagain.sh`, which will look for, from the current directory and its sub-folders all the files: + +- all the files ending with `.sh`. + +That command will only show the name of the files without the `.sh`. + +### Usage + +```console +student@ubuntu:~/piscine/test$ export HERO_ID=1 +student@ubuntu:~/piscine/test$ ./lookagain.sh | cat -e +file1$ +file2$ +file3$ +student@ubuntu:~/piscine/test$ +``` + +### Hint + +A little `cut`ing might be useful... diff --git a/subjects/cl-camp5.fr.md b/subjects/cl-camp5.fr.md new file mode 100644 index 00000000..cb1d0555 --- /dev/null +++ b/subjects/cl-camp5.fr.md @@ -0,0 +1,26 @@ +## cl-camp5 + +### Instructions + +"continues à chercher..." + +Créer un fichier `lookagain.sh`, qui cherchera et montrera, dans le répertoire courant et ses sous-répertoires, tous les fichiers qui: + +- qui finissent avec `.sh`. + +Cette commande montrera le nom des fichiers sans le`.sh`. + +### Utilisation + +```console +student@ubuntu:~/piscine/test$ export HERO_ID=1 +student@ubuntu:~/piscine/test$ ./lookagain.sh | cat -e +file1$ +file2$ +file3$ +student@ubuntu:~/piscine/test$ +``` + +### Indice + +Un petit `cut`ter pourrait être utile... diff --git a/subjects/cl-camp6.en.md b/subjects/cl-camp6.en.md new file mode 100644 index 00000000..bb2161c0 --- /dev/null +++ b/subjects/cl-camp6.en.md @@ -0,0 +1,15 @@ +## cl-camp6 + +### Instructions + +"Now, do your inventory" + +Create a file `countfiles.sh`, which will print the number **(and only the number)** of regular files and folders cointaned in the current directory and its sub-folders : + +### Usage + +```console +student@ubuntu:~/piscine/test$ ./countfiles.sh | cat -e +12$ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp6.fr.md b/subjects/cl-camp6.fr.md new file mode 100644 index 00000000..80f3f162 --- /dev/null +++ b/subjects/cl-camp6.fr.md @@ -0,0 +1,15 @@ +## cl-camp6 + +### Instructions + +"Maintenant, fais ton inventaire" + +Créer un fichier `countfiles.sh`, qui affichera will lenombre **(et seulement le nombre)** de fichiers réguliers et répertoires contenu dans le répertoire courant et ses sous-répertoires : + +### Utilisation + +```console +student@ubuntu:~/piscine/test$ ./countfiles.sh | cat -e +12$ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp7.en.md b/subjects/cl-camp7.en.md new file mode 100644 index 00000000..bbbfabed --- /dev/null +++ b/subjects/cl-camp7.en.md @@ -0,0 +1,15 @@ +## cl-camp7 + +### Instructions + +"Be accurate" + +Create a file `"\?$*'ChouMi'*$?\"` that will contain "01" and **nothing else**. + +### Usage + +```console +student@ubuntu:~/piscine/test$ ls | cat -e +"\?$*'ChouMi'*$?\" $ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp7.fr.md b/subjects/cl-camp7.fr.md new file mode 100644 index 00000000..c316524b --- /dev/null +++ b/subjects/cl-camp7.fr.md @@ -0,0 +1,15 @@ +## cl-camp7 + +### Instructions + +"Sois précis" + +Créer un fichier `"\?$*'ChouMi'*$?\"` qui contiendra "01" et **rien d'autre**. + +### Utilisation + +```console +student@ubuntu:~/piscine/test$ ls | cat -e +"\?$*'ChouMi'*$?\" $ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp8.en.md b/subjects/cl-camp8.en.md new file mode 100644 index 00000000..4749229d --- /dev/null +++ b/subjects/cl-camp8.en.md @@ -0,0 +1,11 @@ +## cl-camp8 + +### Instructions + +"pick your equipment" + +Write a command line in a `skip.sh` file that prints the result of a `ls -l` skipping 1 line out of 2, starting with the **first** one. + +### Hint + +`awk` or `sed` can do the job. diff --git a/subjects/cl-camp8.fr.md b/subjects/cl-camp8.fr.md new file mode 100644 index 00000000..95d9a135 --- /dev/null +++ b/subjects/cl-camp8.fr.md @@ -0,0 +1,11 @@ +## cl-camp8 + +### Instructions + +"Choisis ton équipement" + +écrire une ligne dans un fichier `skip.sh` qui affiche le résultat d'un `ls -l` qui saute 1 ligne sur 2, en commençant pas la **première**. + +### Indice + +`awk` ou `sed` peuvent faire le travail. diff --git a/subjects/cl.en.md b/subjects/cl.en.md new file mode 100644 index 00000000..866ff1a3 --- /dev/null +++ b/subjects/cl.en.md @@ -0,0 +1,21 @@ +## cl-camp1 + +### Instructions + +A little voice speaks in your head: + +"Now that you know who you are. You need to remember what you can do..." + +The instincts are coming back... + +Put in a file `mastertheLS` the command line that will: + +- list the files and folders of the current folder. +- Ignore the hidden files, the "." and the "..". +- Separates the resuls with commas. +- Order them by ascending order of creation date. +- Have the folders have a `/` in front of them. + +### Hint + +Read the man... diff --git a/subjects/collatzcountdown.md b/subjects/collatzcountdown.en.md similarity index 79% rename from subjects/collatzcountdown.md rename to subjects/collatzcountdown.en.md index 72c0522c..f717ca36 100644 --- a/subjects/collatzcountdown.md +++ b/subjects/collatzcountdown.en.md @@ -1,20 +1,20 @@ -# collatzcountdown -## Instructions +## collatzcountdown + +### Instructions Write a function, CollatzCountdown, that returns the number of steps to reach 1 using the collatz countdown. The function must have the following signature. -## Expected function +### Expected function ```go func CollatzCountdown(start int) int { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -22,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -38,5 +38,5 @@ And its output : student@ubuntu:~/student/collatzcountdown$ go build student@ubuntu:~/student/collatzcountdown$ ./collatzcountdown 10 -student@ubuntu:~/student/collatzcountdown$ +student@ubuntu:~/student/collatzcountdown$ ``` diff --git a/subjects/comcheck.md b/subjects/comcheck.en.md similarity index 91% rename from subjects/comcheck.md rename to subjects/comcheck.en.md index be897cfc..e76f2314 100644 --- a/subjects/comcheck.md +++ b/subjects/comcheck.en.md @@ -1,19 +1,20 @@ -# ROT 14 +## ROT 14 -## Instructions +### Instructions Write a function `rot14` that returns the string within the parameter but transformed into a rot14 string. - If you not certain what we are talking about, there is a rot13 already. -## Expected function +### Expected function ```go func rot14(str string) string { } ``` -## Usage + +### Usage Here is a possible [program](TODO-LINK) to test your function : diff --git a/subjects/commandments.en.md b/subjects/commandments.en.md new file mode 100644 index 00000000..e2fe4082 --- /dev/null +++ b/subjects/commandments.en.md @@ -0,0 +1,114 @@ +--- +tier: 0 +team: 1 +duration: 1 hour +objectives: reading the rules +skills: git, github, reading +--- + +## commandments + +A few basic principles to follow + +

+ +

+ +### The Commandements _(read them)_ + +- Le numérique est ta passion. + +- Ton objectif à 42 : développer ton talent et tes compétences pour le marché du numérique. + +- L’objectif de 42 pour toi : te faire accéder au marché de l’emploi, à une longue et pérenne carrière dans le numérique, et te faire progresser socialement. + +- L’ambition de 42 pour toi : être un pionnier du numérique de demain. + +- Il est de ta responsabilité de gérer ta progression : 42 te propose un parcours individualisé adapté à ton rythme. + +- Des challenges jalonnent ton parcours. 42 ne fournira aucun élément de solution. C’est ton rôle de chercher et trouver par toi-même ces solutions pour atteindre l’objectif. + +- Sois actif. N’attend pas que les choses se fassent pour toi. 42 est un parcours 100% pratique. + +- Sois autonome dans ton cursus. N’attend pas que l’on te dise quoi faire. + +- Sois collaboratif, autant sur les projets solos que les projets de groupe. Face aux challenges à resoudre, l’échange et le debat sont tes meilleures armes. + +- Ne "crois" pas. Sois sûr. Techniquement, relationnelement, organisationellement, administrativement. + +- Pour être sûr, teste, contrôle. + +- N’ai pas peur de te tromper, d’échouer. L’échec est une étape normale vers le succès. + +- Teste à nouveau. Collabore davantage pour tester davantage. + +- Ose. Le risque est de se tromper. Voir le commandement 12. + +- Sois rigoureux dans ton travail. + +- Sois investi dans ton cursus : 50 heures par semaine est un minimum. Ta capacité de travail est une valeur. L’école est ouverte 24h/24 et 7j/7. + +- Sois régulier dans ton travail. Un jour oui, un jour non, un coup nocturne, un coup diurne... le chaos t’empêche d’avancer. + +- Prévois un groupe de travail large et hétérogène pour y trouver facilement des idées neuves et des groupes de projet. + +- Pour tes collaborations et ton travail en groupe, privilégie des étudiants qui n’ont pas déjà la solution au problème. + +- Sois investi dans ton groupe de projet, et ne le laisse pas faire ton travail à ta place. + +- Ton groupe de projet est solidaire, son succès comme son échec est de la responsabilité de tous, et les conflits se règlent en interne. + +- Travaille à l’école. Faire du peer-learning, collaborer, cela demande d’être physiquement avec les autres. A distance cela ne fonctionne pas. + +- Implique toi dans les évaluations de tes projets. Elles te permettent de prendre du recul. + +- Implique toi dans tes évaluations des projets des autres. La qualité de la communauté en dépend. + +- Sois juste et teste rigoureusement tes projets comme ceux des autres en évaluation avec tes propres jeux de tests. + +- Joue pleinement le jeu de ta scolarité dans l’état d’esprit demandé, fait tous les exercices et projets demandés. + +- Ne cherche pas des biais et des failles dans le système. Tu vas fausser ta propre formation et ta valeur sur le marché. + +- Ne triche pas intentionellement. C’est amoral, cela contredit le commandement 12, et c’est du temps inutilement passé à ne pas développer tes compétences pour faire croire aux autres que tu sais coder alors que ce n’est pas le cas. + +- Ne rends pas un projet que tu ne serais pas capable de reproduire seul à huis clos. Même si c’est parfois involontaire, c’est aussi de la triche. + +- C’est pas pour tes parents que tu travailles, ni pour le staff. C’est pour toi. + +- Participe à la vie de la communauté, à son épanouissement, et sa qualité en sortie de formation. + +- Aide au respect de ces commandements par la communauté. + +- Sois bienveillant et empathique vis à vis de tes camarades comme des personnes avec qui tu interagis, échanges, débats. + +- N’ai pas peur du monde professionnel. + +- Respecte le matériel. Des consignes spécifiques sont données en ce sens. + +- Respecte les locaux. Des consignes spécifiques sont données en ce sens. + +- Respecte les gens, étudiants, staffs, partenaires, visiteurs. + +- Respecte la loi en vigueur dans le pays. + +- Respecte les lois et consignes en vigueur liées à la consommation d’alcool. + +- Respecte les lois et consignes en vigueur liées à la consommation de tabac, stupéfiants, ou produits assimilés. + +- N’hésite pas à interagir avec le staff, pour parler de tes problèmes, pour remonter des problèmes dans le cursus, pour contribuer au cursus. + +- Si tu t’interroges ou ne comprends pas nos choix pédagogiques, demande nous. On ne fait généralement rien au hasard. + +### Required + +You [clone](http://lmgtfy.com/?q=git+clone) your [fork](http://lmgtfy.com/?q=github+fork) of this [repository](http://lmgtfy.com/?q=git+repository) +and in it, you must create a file named `turn_in` () in which you write EXACTLY the following sentence ending by a line break. + +

+ +

+ +### Submiting your solution + +Your work should be commited and pushed in the master branch of your own fork of this repository. diff --git a/subjects/compact.md b/subjects/compact.en.md similarity index 81% rename from subjects/compact.md rename to subjects/compact.en.md index 20718a62..4f35ffe7 100644 --- a/subjects/compact.md +++ b/subjects/compact.en.md @@ -1,19 +1,20 @@ -# Compact +## Compact -## Instructions +### Instructions Write a function that will take a pointer to a array as parameter and overwrites any element that points to `nil`. -- If you not sure what the function does. It exists in Ruby. +- If you not sure what the function does. It exists in Ruby. -## Expected functions +### Expected functions ```go func Compact(ptr *[]string, length int) int { } ``` -## Usage + +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -28,7 +29,6 @@ func main() { ptr := &array fmt.Println(Compact(ptr, len(array))) } - ``` And its output : diff --git a/subjects/compare.en.md b/subjects/compare.en.md new file mode 100644 index 00000000..9133ea0c --- /dev/null +++ b/subjects/compare.en.md @@ -0,0 +1,43 @@ +## compare + +### Instructions + +Write a function that behaves like the [`Compare`](https://golang.org/pkg/strings/#Compare) function. + +### Expected function + +```go +func Compare(a, b string) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Compare("Hello!", "Hello!")) + fmt.Println(piscine.Compare("Salut!", "lut!")) + fmt.Println(piscine.Compare("Ola!", "Ol")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +-1 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/compare.fr.md b/subjects/compare.fr.md new file mode 100644 index 00000000..9f27f0c0 --- /dev/null +++ b/subjects/compare.fr.md @@ -0,0 +1,43 @@ +## compare + +### Instructions + +Écrire une fonction qui se comporte comme la fonction [`Compare`](https://golang.org/pkg/strings/#Compare). + +### Fonction attendue + +```go +func Compare(a, b string) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Compare("Hello!", "Hello!")) + fmt.Println(piscine.Compare("Salut!", "lut!")) + fmt.Println(piscine.Compare("Ola!", "Ol")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +-1 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/concat.en.md b/subjects/concat.en.md new file mode 100644 index 00000000..c5b4644c --- /dev/null +++ b/subjects/concat.en.md @@ -0,0 +1,40 @@ +## concat + +### Instructions + +Write a function that returns the concatenation of two `string` passed in arguments. + +### Expected function + +```go +func Concat(str1 string, str2 string) string { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Concat("Hello!", " How are you?")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/concat.fr.md b/subjects/concat.fr.md new file mode 100644 index 00000000..20f7feeb --- /dev/null +++ b/subjects/concat.fr.md @@ -0,0 +1,40 @@ +## concat + +### Instructions + +Écrire une fonction qui retourne la concaténation de deux `string` passées en paramètres. + +### Fonction attendue + +```go +func Concat(str1 string, str2 string) string { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Concat("Hello!", " How are you?")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/concatparams.en.md b/subjects/concatparams.en.md new file mode 100644 index 00000000..b9425ecd --- /dev/null +++ b/subjects/concatparams.en.md @@ -0,0 +1,44 @@ +## concatparams + +### Instructions + +Write a function that takes the arguments reveived in parameters and returns them as a `string`. + +The arguments must be **separated** by a `\n`. + +### Expected function + +```go +func ConcatParams(args []string) string { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + test := []string{"Hello", "how", "are", "you?"} + fmt.Println(piscine.ConcatParams(test)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello +how +are +you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/concatparams.fr.md b/subjects/concatparams.fr.md new file mode 100644 index 00000000..b5e5084c --- /dev/null +++ b/subjects/concatparams.fr.md @@ -0,0 +1,44 @@ +## concatparams + +### Instructions + +Écrire une fonction qui prend les arguments en paramètres et les retournes dans une `string`. + +Les arguments doivent être **séparés** par un `\n`. + +### Fonction attendue + +```go +func ConcatParams(args []string) string { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + test := []string{"Hello", "how", "are", "you?"} + fmt.Println(piscine.ConcatParams(test)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello +how +are +you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/convertbase.en.md b/subjects/convertbase.en.md new file mode 100644 index 00000000..760e3453 --- /dev/null +++ b/subjects/convertbase.en.md @@ -0,0 +1,43 @@ +## convertbase + +### Instructions + +Write a function that returns the convertion of a `string` number from one `string` baseFrom to one `string` baseTo. + +Only valid bases will be tested. + +Negative numbers will not be tested. + +### Expected function + +```go +func ConvertBase(nbr, baseFrom, baseTo string) string { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + result := piscine.ConvertBase("101011", "01", "0123456789") + fmt.Println(result) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +43 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/convertbase.fr.md b/subjects/convertbase.fr.md new file mode 100644 index 00000000..76899372 --- /dev/null +++ b/subjects/convertbase.fr.md @@ -0,0 +1,43 @@ +## convertbase + +### Instructions + +Écrire une fonction qui retourne la convertion d'un nombre `string` d'une baseFrom `string` à une baseTo `string`. + +Seules des bases valides seront testées. + +Les nombres négatifs ne seront pas testés. + +### Fonction attendue + +```go +func ConvertBase(nbr, baseFrom, baseTo string) string { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + result := piscine.ConvertBase("101011", "01", "0123456789") + fmt.Println(result) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +43 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/countdown.md b/subjects/countdown.en.md similarity index 68% rename from subjects/countdown.md rename to subjects/countdown.en.md index 36980c8d..58154f76 100644 --- a/subjects/countdown.md +++ b/subjects/countdown.en.md @@ -1,17 +1,17 @@ -# countdown +## countdown -## Instructions +### Instructions Write a program that displays all digits in descending order, followed by a newline. -## Expected main and function for the program +### Expected main and function for the program -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build student@ubuntu:~/piscine/test$ ./test 9876543210 student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` diff --git a/subjects/countif.en.md b/subjects/countif.en.md new file mode 100644 index 00000000..234987de --- /dev/null +++ b/subjects/countif.en.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Write a function `CountIf` that returns the number of elements of a `string` array for which the `f` function returns `true`. + +### Expected function + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/countif.fr.md b/subjects/countif.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/countif.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/createelem.md b/subjects/createelem.en.md similarity index 85% rename from subjects/createelem.md rename to subjects/createelem.en.md index 4743bf9c..ecdb9ea7 100644 --- a/subjects/createelem.md +++ b/subjects/createelem.en.md @@ -1,10 +1,10 @@ -# createelem +## createelem -## Instructions +### Instructions -Write a function `CreateElem` that creates a new element of type`Node`. +Write a function `CreateElem` that creates a new element of type`Node`. -## Expected function and structure +### Expected function and structure ```go type Node struct { @@ -14,10 +14,9 @@ type Node struct { func CreateElem(n *Node, value int) { } - ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : diff --git a/subjects/dispfirstpar.md b/subjects/dispfirstpar.en.md similarity index 85% rename from subjects/dispfirstpar.md rename to subjects/dispfirstpar.en.md index 900cc3b3..5ef10429 100644 --- a/subjects/dispfirstpar.md +++ b/subjects/dispfirstpar.en.md @@ -1,10 +1,10 @@ -# dispfirstpar +## dispfirstpar -## Instructions +### Instructions Write a program that takes strings as arguments, and displays its first argument. -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build @@ -14,4 +14,4 @@ student@ubuntu:~/piscine/test$ ./test "hello there" how are you hello there student@ubuntu:~/piscine/test$ ./test student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` diff --git a/subjects/displastpar.md b/subjects/displastpar.en.md similarity index 87% rename from subjects/displastpar.md rename to subjects/displastpar.en.md index 22e15ac2..42c394a3 100644 --- a/subjects/displastpar.md +++ b/subjects/displastpar.en.md @@ -1,10 +1,10 @@ -# displastpar +## displastpar -## Instructions +### Instructions Write a program that takes strings as arguments, and displays its last argument. -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build @@ -16,4 +16,4 @@ student@ubuntu:~/piscine/test$ ./test "hello there" hello there student@ubuntu:~/piscine/test$ ./test student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` diff --git a/subjects/displaya.md b/subjects/displaya.en.md similarity index 83% rename from subjects/displaya.md rename to subjects/displaya.en.md index 4f2b30ba..5695452f 100644 --- a/subjects/displaya.md +++ b/subjects/displaya.en.md @@ -1,15 +1,15 @@ -# displaya +## displaya -## Instructions +### Instructions Write a program that takes a string, and displays the first 'a' character it encounters in it, followed by a newline. If there are no 'a' characters in the string, the program just writes a newline. If the number of parameters is not 1, the program displays 'a' followed by a newline. -## Expected main and function for the program +### Expected main and function for the program -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build @@ -19,4 +19,4 @@ student@ubuntu:~/piscine/test$ ./test "bcvbvA" a student@ubuntu:~/piscine/test$ ./test "nbv" student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` diff --git a/subjects/displayalpham.md b/subjects/displayalpham.en.md similarity index 82% rename from subjects/displayalpham.md rename to subjects/displayalpham.en.md index 45e4b70e..99a72239 100644 --- a/subjects/displayalpham.md +++ b/subjects/displayalpham.en.md @@ -1,5 +1,6 @@ -# displayalpham -## Instructions +## displayalpham + +### Instructions Write a program that displays the alphabet, with even letters in uppercase, and odd letters in lowercase, followed by a newline. @@ -12,5 +13,5 @@ Example : student@ubuntu:~/student/displayalpham$ go build student@ubuntu:~/student/displayalpham$ ./displayalpham | cat -e aBcDeFgHiJkLmNoPqRsTuVwXyZ$ -student@ubuntu:~/student/displayalpham$ +student@ubuntu:~/student/displayalpham$ ``` diff --git a/subjects/displayalrevm.md b/subjects/displayalrevm.en.md similarity index 82% rename from subjects/displayalrevm.md rename to subjects/displayalrevm.en.md index 0cbe0f7b..f428f649 100644 --- a/subjects/displayalrevm.md +++ b/subjects/displayalrevm.en.md @@ -1,5 +1,6 @@ -# displayalrevm -## Instructions +## displayalrevm + +### Instructions Write a program that displays the alphabet in reverse, with even letters in uppercase, and odd letters in lowercase, followed by a newline. @@ -12,5 +13,5 @@ Example : student@ubuntu:~/student/displayalrevm$ go build student@ubuntu:~/student/displayalrevm$ ./displayalrevm | cat -e aBcDeFgHiJkLmNoPqRsTuVwXyZ$ -student@ubuntu:~/student/displayalrevm$ +student@ubuntu:~/student/displayalrevm$ ``` diff --git a/subjects/displayfile.md b/subjects/displayfile.en.md similarity index 85% rename from subjects/displayfile.md rename to subjects/displayfile.en.md index df3df99d..1f1bce84 100644 --- a/subjects/displayfile.md +++ b/subjects/displayfile.en.md @@ -1,6 +1,6 @@ -# Display File +## Display File -## Instructions +### Instructions Write a program that displays, on the standard output, only the content of the file given as argument. @@ -9,10 +9,10 @@ Write a program that displays, on the standard output, only the content of the f - The argument of the program should be the name of the file, in this case, `quest8.txt`. - In case of error it should print: - - `File name missing`. - - `Too many arguments`. + - `File name missing`. + - `Too many arguments`. -## Output: +### Output: ```console student@ubuntu:~/student/test$ go build diff --git a/subjects/displayz.md b/subjects/displayz.en.md similarity index 90% rename from subjects/displayz.md rename to subjects/displayz.en.md index 6a4acd42..c884bd6b 100644 --- a/subjects/displayz.md +++ b/subjects/displayz.en.md @@ -1,13 +1,13 @@ -# displayz +## displayz -## Instructions +### Instructions Write a program that takes a string, and displays the first 'a' character it encounters in it, followed by a newline. If there are no 'a' characters in the string, the program just writes a newline. If the number of parameters is not 1, the program displays 'a' followed by a newline. -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build @@ -19,4 +19,4 @@ student@ubuntu:~/piscine/test$ ./test "nbz" z student@ubuntu:~/piscine/test$ ./test z -``` \ No newline at end of file +``` diff --git a/subjects/divmod.en.md b/subjects/divmod.en.md new file mode 100755 index 00000000..1deb4ce1 --- /dev/null +++ b/subjects/divmod.en.md @@ -0,0 +1,50 @@ +## divmod + +### Instructions + +- Write a function that will be formatted as below. + +### Expected function + +```go +func DivMod(a int, b int, div *int, mod *int) { + +} +``` + +- This function will divide the int **a** and **b**. +- The result of this division will be stored in the int pointed by **div**. +- The remainder of this division will be stored in the int pointed by **mod**. + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 13 + b := 2 + var div int + var mod int + piscine.DivMod(a, b, &div, &mod) + fmt.Println(div) + fmt.Println(mod) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +6 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/divmod.fr.md b/subjects/divmod.fr.md new file mode 100755 index 00000000..5af68c2f --- /dev/null +++ b/subjects/divmod.fr.md @@ -0,0 +1,50 @@ +## divmod + +### Instructions + +- Écrire une fonction qui aura le format ci-dessous. + +### Fonction attendue + +```go +func DivMod(a int, b int, div *int, mod *int) { + +} +``` + +- Cette fonction divisera les int **a** et **b**. +- Le résultat de la division sera stocké dans l'int pointé par **div**. +- Le reste de cette division sera stocké dans l'int pointé par **mod**. + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 13 + b := 2 + var div int + var mod int + piscine.DivMod(a, b, &div, &mod) + fmt.Println(div) + fmt.Println(mod) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +6 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/doop.en.md b/subjects/doop.en.md index eb6abf9c..b26aa208 100644 --- a/subjects/doop.en.md +++ b/subjects/doop.en.md @@ -2,27 +2,37 @@ ### Instructions -Write a program that takes three strings: +Write a [program](TODO-LINK) that is called `doop`. -- The first and the third one are representations of base-10 signed integers that fit in an int. +The program has to be used with three arguments: -- The second one is an arithmetic operator chosen from: `+ - * / %` +- A value +- An operator +- Another value -- 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. +In case of an invalid entry the programs prints `0`. -- During tests the strings will have no mistakes or extraneous characters. Negative numbers, in input or output, will have one and only one leading `-`. The result of the operation will fit in an int. +In case of an invalid number of arguments the program prints nothing. -Examples of outputs : +`fmt.Print` is authorized. + +### Usage ```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$ +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 1 p 1 +0 +student@ubuntu:~/piscine/test$ ./doop 1 + 1 +2 +student@ubuntu:~/piscine/test$ ./doop 1 / 0 +No division by 0 +student@ubuntu:~/piscine/test$ ./doop 1 % 0 +No modulo by 0 +student@ubuntu:~/piscine/test$ ./doop 1 * 1 +1 ``` diff --git a/subjects/doop.fr.md b/subjects/doop.fr.md new file mode 100644 index 00000000..904d0217 --- /dev/null +++ b/subjects/doop.fr.md @@ -0,0 +1,41 @@ +## doop + +### Instructions + +Écrire un [programme](TODO-LINK) qui s'apelle `doop`. + +Le programme doit être utilisé avec trois arguments: + +- Une valeur +- Un opérateur +- Une autre valeur + +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 + +```console +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 | cat -e +0$ +student@ubuntu:~/piscine/test$ ./doop 1 p 1 +0 +student@ubuntu:~/piscine/test$ ./doop 1 + 1 +2 +student@ubuntu:~/piscine/test$ ./doop 1 / 0 +No division by 0 +student@ubuntu:~/piscine/test$ ./doop 1 % 0 +No modulo by 0 +student@ubuntu:~/piscine/test$ ./doop 1 * 1 +1 + +``` diff --git a/subjects/eightqueens.en.md b/subjects/eightqueens.en.md new file mode 100644 index 00000000..9964bfdd --- /dev/null +++ b/subjects/eightqueens.en.md @@ -0,0 +1,33 @@ +## eightqueens + +### Intructions + +Write a function that prints the solutions to the [eight queens puzzle](https://en.wikipedia.org/wiki/Eight_queens_puzzle). + +Recursivity must be used to solve this problem. + +It should print something like this : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +15863724 +16837425 +17468253 +... +``` + +Each solution will be on a single line. +The index of the placement of a queen starts at 1. +It reads from left to right and each digit is the position for each column. +The solutions will be printed in ascending order. + +### Expected function + +```go +package main + +func EightQueens() { + +} +``` diff --git a/subjects/eightqueens.fr.md b/subjects/eightqueens.fr.md new file mode 100644 index 00000000..927baa65 --- /dev/null +++ b/subjects/eightqueens.fr.md @@ -0,0 +1,33 @@ +## eightqueens + +### Intructions + +Écrire une [fonction](TODO-LINK) qui affiche toutes les solutions du [problème des huit dames](https://en.wikipedia.org/wiki/Eight_queens_puzzle). + +La récursion doit être utilisée pour résoudre ce problème. + +L'affichage sera quelque chose comme ça : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +15863724 +16837425 +17468253 +... +``` + +Chaque solution sera sur une ligne unique. +L'index du placement d'une reine commence à 1. +Elle se lit de gauche à droite et chaque chiffre est la position pour chacune des colonnes. +Les solutions seront affichées dans l'ordre croissant. + +### Fonction attendue + +```go +package main + +func EightQueens() { + +} +``` diff --git a/subjects/enigma.md b/subjects/enigma.en.md similarity index 88% rename from subjects/enigma.md rename to subjects/enigma.en.md index 27fb76c5..45cdb9cb 100644 --- a/subjects/enigma.md +++ b/subjects/enigma.en.md @@ -1,5 +1,6 @@ -# enigma -## Instructions +## enigma + +### Instructions Write a function called `Enigma` that receives poiters to functions and move its values around to hide them @@ -7,16 +8,15 @@ This function will put a into c; c into d; d into b and b into a This function must have the following signature. -## Expected function +### Expected function ```go func Enigma(a ***int, b *int, c *******int, d ****int) { - -} +} ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -24,8 +24,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -82,5 +82,5 @@ After using Enigma 6 5 7 -student@ubuntu:~/student/enigma$ +student@ubuntu:~/student/enigma$ ``` diff --git a/subjects/expandstr.en.md b/subjects/expandstr.en.md new file mode 100644 index 00000000..62be75bf --- /dev/null +++ b/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$ +``` diff --git a/subjects/fibonacci.en.md b/subjects/fibonacci.en.md new file mode 100644 index 00000000..47ad3862 --- /dev/null +++ b/subjects/fibonacci.en.md @@ -0,0 +1,50 @@ +## fibonacci + +### Intructions + +Write an **recursive** function that returns the value of fibonacci sequence matching the index passed as parameter. + +The first value is at index `0`. + +The sequence starts this way: 0, 1, 1, 2, 3 etc... + +A negative index will return `-1`. + +`for` is **forbidden** for this exercise. + +### Expected function + +```go +package main + +func Fibonacci(int index) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + fmt.Println(piscine.Fibonacci(arg1)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +3 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/fibonacci.fr.md b/subjects/fibonacci.fr.md new file mode 100644 index 00000000..c6b5b0a2 --- /dev/null +++ b/subjects/fibonacci.fr.md @@ -0,0 +1,51 @@ +## fibonacci + +### Intructions + +Écrire une fonction **récursive** qui renvoie la valeur de la suite de fibonacci correspondant à l'index passé en paramètre. + +La premiére valeur est à l'index `0`. + +La suite débute ainsi: 0, 1, 1, 2, 3 etc... + +Un index négatif renvoie `-1`. + +`for` est **interdit** pour cet exercice. + +### Fonction attendue + +```go +package main + +func Fibonacci(int index) int { + +} +``` + +### Utilisation + +Voici un éventuel `main.go` : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + fmt.Println(piscine.Fibonacci(arg1)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$go build +student@ubuntu:~/piscine/test$ ./test +3 +student@ubuntu:~/piscine/test$ + +``` diff --git a/subjects/findnextprime.en.md b/subjects/findnextprime.en.md new file mode 100644 index 00000000..5743622f --- /dev/null +++ b/subjects/findnextprime.en.md @@ -0,0 +1,41 @@ +## findnextprime + +### Intructions + +Write a function that returns the first prime number that is equal or superior to the `int` passed as parameter. + +### Expected function + +```go +func FindNextPrime(int nb) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.FindNextPrime(5)) + fmt.Println(piscine.FindNextPrime(4)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +5 +5 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/findnextprime.fr.md b/subjects/findnextprime.fr.md new file mode 100644 index 00000000..c1761842 --- /dev/null +++ b/subjects/findnextprime.fr.md @@ -0,0 +1,43 @@ +## findnextprime + +### Intructions + +Écrire une fonction qui renvoie le premier nombre premier qui est égal ou supérieur à l'`int` passé en paramètre. + +### Fonction attendue + +```go +func FindNextPrime(int nb) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 5 + arg2 := 4 + fmt.Println(piscine.FindNextPrime(arg1)) + fmt.Println(piscine.FindNextPrime(arg2)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +5 +5 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/firebase-demo.en.md b/subjects/firebase-demo.en.md new file mode 100644 index 00000000..e68fc092 --- /dev/null +++ b/subjects/firebase-demo.en.md @@ -0,0 +1 @@ +## firebase-demo diff --git a/subjects/firstrune.en.md b/subjects/firstrune.en.md new file mode 100644 index 00000000..f257da3d --- /dev/null +++ b/subjects/firstrune.en.md @@ -0,0 +1,42 @@ +## firstrune + +### Instructions + +Write a function that returns the first `rune` of a `string`. + +### Expected function + +```go +func FirstRune(s string) rune { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.FirstRune("Hello!")) + z01.PrintRune(piscine.FirstRune("Salut!")) + z01.PrintRune(piscine.FirstRune("Ola!")) + z01.PrintRune('\n') +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +HSO +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/firstrune.fr.md b/subjects/firstrune.fr.md new file mode 100644 index 00000000..932cbe45 --- /dev/null +++ b/subjects/firstrune.fr.md @@ -0,0 +1,42 @@ +## firstrune + +### Instructions + +Écrire une fonction qui retourne la première `rune` d'une `string`. + +### Fonction attendue + +```go +func FirstRune(s string) rune { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.FirstRune("Hello!")) + z01.PrintRune(piscine.FirstRune("Salut!")) + z01.PrintRune(piscine.FirstRune("Ola!")) + z01.PrintRune('\n') +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +HSO +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/firstword.md b/subjects/firstword.en.md similarity index 87% rename from subjects/firstword.md rename to subjects/firstword.en.md index fddd467c..d704bbbd 100644 --- a/subjects/firstword.md +++ b/subjects/firstword.en.md @@ -1,6 +1,6 @@ -# firstword +## firstword -## Instructions +### Instructions Write a program that takes a string and displays its first word, followed by a newline. @@ -10,7 +10,7 @@ Write a program that takes a string and displays its first word, followed by a n - If the number of parameters is not 1, or if there are no words, simply display a newline. -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build @@ -22,5 +22,5 @@ student@ubuntu:~/piscine/test$ ./test student@ubuntu:~/piscine/test$ ./test "hello" "there" -student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/fixthemain.md b/subjects/fixthemain.en.md similarity index 92% rename from subjects/fixthemain.md rename to subjects/fixthemain.en.md index 414fbd94..158edc10 100644 --- a/subjects/fixthemain.md +++ b/subjects/fixthemain.en.md @@ -1,10 +1,10 @@ -# Fix the Main +## Fix the Main -## Instructions +### Instructions Write and fix the folloing functions. -## Expected functions +### Expected functions ```go func PutStr(str string) { @@ -29,7 +29,8 @@ func IsDoorClose(ptrDoor *Door) bool { PutStr("Door is close ?") } ``` -## Usage + +### Usage Here is a possible [program](TODO-LINK) to test your function : diff --git a/subjects/foreach.en.md b/subjects/foreach.en.md new file mode 100644 index 00000000..d21c6ca0 --- /dev/null +++ b/subjects/foreach.en.md @@ -0,0 +1,36 @@ +## foreach + +### Instructions + +Write a function `ForEach` that, for an `int` array, applies a function on each elements of that array. + +### Expected function + +```go +func ForEach(f func(int), arr []int) { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + arr := []int{1, 2, 3, 4, 5, 6} + piscine.ForEach(piscine.PrintNbr, arr) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +123456 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/foreach.fr.md b/subjects/foreach.fr.md new file mode 100644 index 00000000..18ac85ac --- /dev/null +++ b/subjects/foreach.fr.md @@ -0,0 +1,36 @@ +## foreach + +### Instructions + +Écrire une fonction `ForEach` qui, pour un tableau d'`int`, applique une fonction sur chaque éléments de ce tableau. + +### Fonction attendue + +```go +func ForEach(f func(int), arr []int) { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + arr := []int{1, 2, 3, 4, 5, 6} + piscine.ForEach(piscine.PutNbr, arr) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +123456 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/functions.en.md b/subjects/functions.en.md new file mode 100644 index 00000000..c5ba5ff2 --- /dev/null +++ b/subjects/functions.en.md @@ -0,0 +1,3 @@ +## functions + +This repository aggregate every functions of the Zone 01 organization diff --git a/subjects/gcd.en.md b/subjects/gcd.en.md new file mode 100644 index 00000000..b4080384 --- /dev/null +++ b/subjects/gcd.en.md @@ -0,0 +1,32 @@ +## gcd + +### Instructions + +Write a program that takes two strings representing two strictly positive +integers that fit in an int. + +Display their greatest common divisor followed by a newline (It is always a +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 +student@ubuntu:~/student/gcd$ go build +student@ubuntu:~/student/gcd$ ./gcd 42 10 | cat -e +2$ +student@ubuntu:~/student/gcd$ ./gcd 42 12 | cat -e +6$ +student@ubuntu:~/student/gcd$ ./gcd 14 77 | cat -e +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$ +``` diff --git a/subjects/get-ready.en.md b/subjects/get-ready.en.md new file mode 100644 index 00000000..8086b1ce --- /dev/null +++ b/subjects/get-ready.en.md @@ -0,0 +1,7 @@ +## get-ready + +### Instructions + +Subscribe to [Discord](Discord-invite-link) and send a private message to the bot (TODO: find a name for the bot). + +If the bot likes you, the bot will greet you in a in a pleasant manner. diff --git a/subjects/go-say-hello.en.md b/subjects/go-say-hello.en.md new file mode 100644 index 00000000..d9242b47 --- /dev/null +++ b/subjects/go-say-hello.en.md @@ -0,0 +1,20 @@ +## go-say-hello + +### Instructions + +Write a [program](TODO-LINK) that says `hello` to your GitHub username. + +### Usage + +Where `{username}` is your GitHub username: + +```console +user@host:~/piscine/d01/go-say-hello$ go get -u github.com/{username}/piscine/d01/go-say-hello +user@host:~/piscine/d01/go-say-hello$ go run github.com/{username}/piscine/d01/go-say-hello +Hello, {username}! +<<<<<<< HEAD +$ +======= +user@host:~/piscine/d01/go-say-hello$ +>>>>>>> 95ba96142e4855232e0d1fbdf38a3bedae3ed625 +``` diff --git a/subjects/go-say-hello.fr.md b/subjects/go-say-hello.fr.md new file mode 100644 index 00000000..5aab8f02 --- /dev/null +++ b/subjects/go-say-hello.fr.md @@ -0,0 +1,15 @@ +## gosayhello + +### Instructions + +Écrire un [programme](TODO-LINK) qui vous dis `hello` à votre GitHub username. + +### Utilisation + +Ici `{username}` est votre GitHub username: + +```console +$ go run github.com/{username}/piscine/d01/gosayhello +Hello, {username}! +$ +``` diff --git a/subjects/hello.md b/subjects/hello.en.md similarity index 65% rename from subjects/hello.md rename to subjects/hello.en.md index 46ab635b..6031385e 100644 --- a/subjects/hello.md +++ b/subjects/hello.en.md @@ -1,16 +1,16 @@ -# hello +## hello -## Instructions +### Instructions Write a program that displays "Hello World!". -## Expected main and function for the program +### Expected main and function for the program -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build student@ubuntu:~/piscine/test$ ./test Hello World! student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` diff --git a/subjects/hiddenp.en.md b/subjects/hiddenp.en.md new file mode 100644 index 00000000..7a71d84e --- /dev/null +++ b/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$ +``` diff --git a/subjects/index.en.md b/subjects/index.en.md new file mode 100644 index 00000000..4210f76d --- /dev/null +++ b/subjects/index.en.md @@ -0,0 +1,43 @@ +## index + +### Instructions + +Write a function that behaves like the [`Index`](https://golang.org/pkg/strings/#Index) function. + +### Expected function + +```go +func Index(s string, toFind string) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Index("Hello!", "l")) + fmt.Println(piscine.Index("Salut!", "alu")) + fmt.Println(piscine.Index("Ola!", "hOl")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +2 +1 +-1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/index.fr.md b/subjects/index.fr.md new file mode 100644 index 00000000..fa256638 --- /dev/null +++ b/subjects/index.fr.md @@ -0,0 +1,43 @@ +## index + +### Instructions + +Écrire une fonction qui se comporte comme la fonction [`Index`](https://golang.org/pkg/strings/#Index). + +### Fonction attendue + +```go +func Index(s string, toFind string) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Index("Hello!", "l")) + fmt.Println(piscine.Index("Salut!", "alu")) + fmt.Println(piscine.Index("Ola!", "hOl")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +2 +1 +-1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/inter.md b/subjects/inter.en.md similarity index 85% rename from subjects/inter.md rename to subjects/inter.en.md index f4cfca6a..daf9625f 100644 --- a/subjects/inter.md +++ b/subjects/inter.en.md @@ -1,7 +1,6 @@ -# switchcase - -## Instructions +## switchcase +### Instructions Write a program that takes two strings and displays, without doubles, the characters that appear in both strings, in the order they appear in the first one. @@ -9,7 +8,7 @@ Write a program that takes two strings and displays, without doubles, the charac - If the number of arguments is not 2, the program displays `\n`. -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build @@ -17,5 +16,5 @@ student@ubuntu:~/piscine/test$ ./test "padinton" "paqefwtdjetyiytjneytjoeyjnejey padinto student@ubuntu:~/piscine/test$ ./test ddf6vewg64f twthgdwthdwfteewhrtag6h4ffdhsd df6ewg4 -student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isalpha.en.md b/subjects/isalpha.en.md new file mode 100644 index 00000000..92cc667f --- /dev/null +++ b/subjects/isalpha.en.md @@ -0,0 +1,46 @@ +## isalpha + +### Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains alphanumerical characters, and that returns `false` otherwise. + +### Expected function + +```go +func IsAlpha(str string) bool { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsAlpha("Hello! How are you?")) + fmt.Println(piscine.IsAlpha("HelloHowareyou")) + fmt.Println(piscine.IsAlpha("What's this 4?")) + fmt.Println(piscine.IsAlpha("Whatsthis4")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +false +true +false +true +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isalpha.fr.md b/subjects/isalpha.fr.md new file mode 100644 index 00000000..0bd3b2ce --- /dev/null +++ b/subjects/isalpha.fr.md @@ -0,0 +1,46 @@ +## isalpha + +### Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères alphanumériques, et qui retourne `false` autrement. + +### Fonction attendue + +```go +func IsAlpha(str string) bool { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsAlpha("Hello! How are you?")) + fmt.Println(piscine.IsAlpha("HelloHowareyou")) + fmt.Println(piscine.IsAlpha("What's this 4?")) + fmt.Println(piscine.IsAlpha("Whatsthis4")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +false +true +false +true +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/islower.en.md b/subjects/islower.en.md new file mode 100644 index 00000000..71d43576 --- /dev/null +++ b/subjects/islower.en.md @@ -0,0 +1,42 @@ +## islower + +### Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains lowercase characters, and that returns `false` otherwise. + +### Expected function + +```go +func IsLower(str string) bool { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsLower("hello")) + fmt.Println(piscine.IsLower("hello!")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/islower.fr.md b/subjects/islower.fr.md new file mode 100644 index 00000000..47b13436 --- /dev/null +++ b/subjects/islower.fr.md @@ -0,0 +1,42 @@ +## islower + +### Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères minuscules, et qui retourne `false` autrement. + +### Fonction attendue + +```go +func IsLower(str string) bool { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsLower("hello")) + fmt.Println(piscine.IsLower("hello!")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isnegative.en.md b/subjects/isnegative.en.md new file mode 100644 index 00000000..faa8b57c --- /dev/null +++ b/subjects/isnegative.en.md @@ -0,0 +1,40 @@ +## isnegative + +### Instructions + +Write a [function](TODO-LINK) that prints `'T'` (true) on a single line if the `int` passed as parameter is negative, otherwise it prints `'F'` (false). + +### Expected function + +```go +func IsNegative(nb int) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.IsNegative(1) + piscine.IsNegative(0) + piscine.IsNegative(-1) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +F +F +T +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isnegative.fr.md b/subjects/isnegative.fr.md new file mode 100644 index 00000000..9804e33b --- /dev/null +++ b/subjects/isnegative.fr.md @@ -0,0 +1,40 @@ +## isnegative + +### Instructions + +Écrire une [fonction](TODO-LINK) qui affiche `'T'` (true) sur une seule ligne si l'`int` passé en paramètre est négatif, sinon elle affiche `'F'` (false). + +### Fonction attendue + +```go +func IsNegative(nb int) { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + piscine.IsNegative(1) + piscine.IsNegative(0) + piscine.IsNegative(-1) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +F +F +T +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isnumeric.en.md b/subjects/isnumeric.en.md new file mode 100644 index 00000000..550dced3 --- /dev/null +++ b/subjects/isnumeric.en.md @@ -0,0 +1,41 @@ +## isnumeric + +### Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains numerical characters, and that returns `false` otherwise. + +### Expected function + +```go +func IsNumeric(str string) bool { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsNumeric("010203")) + fmt.Println(piscine.IsNumeric("01,02,03")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isnumeric.fr.md b/subjects/isnumeric.fr.md new file mode 100644 index 00000000..adaec9ba --- /dev/null +++ b/subjects/isnumeric.fr.md @@ -0,0 +1,42 @@ +## isnumeric + +### Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères numériques, et qui retourne `false` autrement. + +### Fonction attendue + +```go +func IsNumeric(str string) bool { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsNumeric("010203")) + fmt.Println(piscine.IsNumeric("01,02,03")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ispowerof2.en.md b/subjects/ispowerof2.en.md new file mode 100644 index 00000000..9454cb39 --- /dev/null +++ b/subjects/ispowerof2.en.md @@ -0,0 +1,15 @@ +## ispowerof2 + +### Instructions + +Write a function that determines if a given number is a power of 2. + +This function returns true if the given number is a power of 2, otherwise it returns false. + +## Expected function + +```go +func IsPowerOf2(n uint) bool { + +} +``` diff --git a/subjects/isprime.en.md b/subjects/isprime.en.md new file mode 100644 index 00000000..b5a2f91f --- /dev/null +++ b/subjects/isprime.en.md @@ -0,0 +1,41 @@ +## isprime + +### Intructions + +Write a function that returns `true` if the `int` passed as parameter is a prime number. Otherwise it returns `false`. + +### Expected function + +```go +func IsPrime(int nb) bool { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsPrime(5)) + fmt.Println(piscine.IsPrime(4)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isprime.fr.md b/subjects/isprime.fr.md new file mode 100644 index 00000000..be345292 --- /dev/null +++ b/subjects/isprime.fr.md @@ -0,0 +1,41 @@ +## isprime + +### Intructions + +Écrire une fonction qui renvoie `true` si l'`int` passé en paramètre est un nombre premier. Autrement elle renvoie `false`. + +### Fonction attendue + +```go +func IsPrime(int nb) bool { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsPrime(5)) + fmt.Println(piscine.IsPrime(4)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isprintable.en.md b/subjects/isprintable.en.md new file mode 100644 index 00000000..04c131f8 --- /dev/null +++ b/subjects/isprintable.en.md @@ -0,0 +1,43 @@ +## isprintable + +### Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains printable characters, and that returns `false` otherwise. + +### Expected function + +```go +package main +func IsPrintable(str string) bool { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsPrintable("Hello")) + fmt.Println(piscine.IsPrintable("Hello\n")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isprintable.fr.md b/subjects/isprintable.fr.md new file mode 100644 index 00000000..9927cbee --- /dev/null +++ b/subjects/isprintable.fr.md @@ -0,0 +1,43 @@ +## isprintable + +### Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères majuscules, et qui retourne `false` autrement. + +### Fonction attendue + +```go +package main +func IsPrintable(str string) bool { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsPrintable("Hello")) + fmt.Println(piscine.IsPrintable("Hello\n")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/issorted.en.md b/subjects/issorted.en.md new file mode 100644 index 00000000..5970788a --- /dev/null +++ b/subjects/issorted.en.md @@ -0,0 +1,51 @@ +## issorted + +### Instructions + +Write a function `IsSorted` that returns `true` if the slice of `int` is sorted, and that returns `false` otherwise. + +The function passed in parameter returns a positive `int` if `a`(the first argument) is superior to `b`(the second argument), +it returns `0` if they are equal and it returns a negative `int` otherwise. + +To do your testing you have to write your own `f` function. + +### Expected function + +```go +func IsSorted(f func(a, b int) int, tab []int) int { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function (without `f`): + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []int{0, 1, 2, 3, 4, 5} + tab2 := []int{0, 2, 1, 3} + + result1 := piscine.IsSorted(f, tab1) + result2 := piscine.IsSorted(f, tab2) + + fmt.Println(result1) + fmt.Println(result2) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/issorted.fr.md b/subjects/issorted.fr.md new file mode 100644 index 00000000..6c6471c2 --- /dev/null +++ b/subjects/issorted.fr.md @@ -0,0 +1,50 @@ +## issorted + +### Instructions + +Écrire une fonction `IsSorted` qui retourne `true` si la slice d'`int` est triée, et qui retourne `false` autrement. + +La fonction passée en paramètre retourne un `int` positive si `a` (le premier argument) est supérieur à `b`(le deuxième argument), elle retourne `0` si ils sont égaux et elle retourne un `int` négatif autrement. + +Pour faire vos tests, vous devez coder votre propre fonction `f`. + +### Fonction attendue + +```go +func IsSorted(f func(a, b int) int, tab []int) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction (sans `f`) : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []int{0, 1, 2, 3, 4, 5} + tab2 := []int{0, 2, 1, 3} + + result1 := piscine.IsSorted(f, tab1) + result2 := piscine.IsSorted(f, tab2) + + fmt.Println(result1) + fmt.Println(result2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isupper.en.md b/subjects/isupper.en.md new file mode 100644 index 00000000..66980bec --- /dev/null +++ b/subjects/isupper.en.md @@ -0,0 +1,42 @@ +## isupper + +### Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains uppercase characters, and that returns `false` otherwise. + +### Expected function + +```go +func IsUpper(str string) bool { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsUpper("HELLO")) + fmt.Println(piscine.IsUpper("HELLO!")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isupper.fr.md b/subjects/isupper.fr.md new file mode 100644 index 00000000..9b991785 --- /dev/null +++ b/subjects/isupper.fr.md @@ -0,0 +1,42 @@ +## isupper + +### Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères majuscules, et qui retourne `false` autrement. + +### Fonction attendue + +```go +func IsUpper(str string) bool { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsUpper("HELLO")) + fmt.Println(piscine.IsUpper("HELLO!")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +stude0t@ubuntu:~$ +``` diff --git a/subjects/iterativefactorial.en.md b/subjects/iterativefactorial.en.md new file mode 100644 index 00000000..2e882e55 --- /dev/null +++ b/subjects/iterativefactorial.en.md @@ -0,0 +1,42 @@ +## iterativefactorial + +### Intructions + +Write an **iterative** function that returns the factorial of the `int` passed as parameter. + +Errors (non possible values or overflows) will return `0`. + +### Expected function + +```go +func IterativeFactorial(int nb) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arg := 4 + fmt.Println(piscine.IterativeFactorial(arg)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +24 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/iterativefactorial.fr.md b/subjects/iterativefactorial.fr.md new file mode 100644 index 00000000..79f2a2f2 --- /dev/null +++ b/subjects/iterativefactorial.fr.md @@ -0,0 +1,42 @@ +## iterativefactorial + +### Intructions + +Écrire une fonction **itérative** qui renvoie la factorielle d'un `int` passé en paramètre. + +Les erreurs (valeurs non possibles ou overflows) renverront `0`. + +### Fonction attendue + +```go +func IterativeFactorial(int nb) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arg := 4 + fmt.Println(piscine.IterativeFactorial(arg)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +24 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/iterativepower.en.md b/subjects/iterativepower.en.md new file mode 100644 index 00000000..a7d30fea --- /dev/null +++ b/subjects/iterativepower.en.md @@ -0,0 +1,44 @@ +## iterativepower + +### Intructions + +Write an **iterative** function that returns the power of the `int` passed as parameter. + +Negative powers will return `0`. Overflows do **not** have to be dealt with. + +### Expected function + +```go +func IterativePower(int nb, int power) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.IterativePower(arg1, arg2)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +64 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/iterativepower.fr.md b/subjects/iterativepower.fr.md new file mode 100644 index 00000000..c4fac89d --- /dev/null +++ b/subjects/iterativepower.fr.md @@ -0,0 +1,44 @@ +## iterativepower + +### Intructions + +Écrire une fonction **itérative** qui renvoie la puissance de deux `int` passés en paramètre. + +Les puissances négatives renverront `0`. Les overflows **ne doivent pas** être gérés. + +### Fonction attendue + +```go +func IterativePower(int nb, int power) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.IterativePower(arg1, arg2)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +64 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/itoa.en.md b/subjects/itoa.en.md new file mode 100644 index 00000000..f613beb4 --- /dev/null +++ b/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 { + +} +``` diff --git a/subjects/join.en.md b/subjects/join.en.md new file mode 100644 index 00000000..cf5800d3 --- /dev/null +++ b/subjects/join.en.md @@ -0,0 +1,40 @@ +## join + +### Instructions + +Write a function that returns the concatenation of all the `string` of a table of `string` **separated** by the separator passed in argument. + +### Expected function + +```go +func Join(strs []string, sep string) string { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + toConcat := []string{"Hello!", " How", " are", " you?"} + fmt.Println(piscine.Join(toConcat, ":")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello!: How: are: you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/join.fr.md b/subjects/join.fr.md new file mode 100644 index 00000000..03317193 --- /dev/null +++ b/subjects/join.fr.md @@ -0,0 +1,40 @@ +## join + +### Instructions + +Écrire une fonction qui retourne la concaténation de deux `string` **séparées** par le séparateur passées en paramètres. + +### Fonction attendue + +```go +func Join(strs []string, sep string) string{ + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + toConcat := []string{"Hello!", " How", " are", " you?"} + fmt.Println(piscine.Join(toConcat, ":")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello!: How: are: you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/join.md b/subjects/join.md deleted file mode 100644 index 013afd3d..00000000 --- a/subjects/join.md +++ /dev/null @@ -1,44 +0,0 @@ -# join -## Instructions - -Write a function, Join, that returns the elements of a slice strings (arstr) join together in one string. Using the string 'sep' as a separator between each element of the array - -The function must have the next signature. - -## Expected function - -```go - -func Join(arstr []string, sep string) string { - -} - -``` - -## Usage - -Here is a possible [program](TODO-LINK) to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - arrStr := []string{"hello", "how", "are", "you"} - joined := student.Join(arrStr, "--") - fmt.Println(joined) -} -``` - -And its output : - -```console -student@ubuntu:~/student/join$ go build -student@ubuntu:~/student/join$ ./join -hello--how--are--you -student@ubuntu:~/student/join$ -``` diff --git a/subjects/lastrune.en.md b/subjects/lastrune.en.md new file mode 100644 index 00000000..03a11067 --- /dev/null +++ b/subjects/lastrune.en.md @@ -0,0 +1,42 @@ +## lastrune + +### Instructions + +Write a function that returns the last `rune` of a `string`. + +### Expected function + +```go +func LastRune(s string) rune { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.LastRune("Hello!")) + z01.PrintRune(piscine.LastRune("Salut!")) + z01.PrintRune(piscine.LastRune("Ola!")) + z01.PrintRune('\n') +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +!!! +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/lastrune.fr.md b/subjects/lastrune.fr.md new file mode 100644 index 00000000..da208207 --- /dev/null +++ b/subjects/lastrune.fr.md @@ -0,0 +1,42 @@ +## lastrune + +### Instructions + +Écrire une fonction qui retourne la dernière `rune` d'une `string`. + +### Fonction attendue + +```go +func LastRune(s string) rune { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.LastRune("Hello!")) + z01.PrintRune(piscine.LastRune("Salut!")) + z01.PrintRune(piscine.LastRune("Ola!")) + z01.PrintRune('\n') +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +!!! +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/lastword.md b/subjects/lastword.en.md similarity index 96% rename from subjects/lastword.md rename to subjects/lastword.en.md index 4e3fabb0..c1a68ead 100644 --- a/subjects/lastword.md +++ b/subjects/lastword.en.md @@ -1,5 +1,6 @@ -# lastword -## Instructions +## lastword + +### Instructions Write a program that takes a string and displays its last word, followed by a newline. diff --git a/subjects/listat.md b/subjects/listat.en.md similarity index 87% rename from subjects/listat.md rename to subjects/listat.en.md index deb54634..4518a82d 100644 --- a/subjects/listat.md +++ b/subjects/listat.en.md @@ -1,12 +1,12 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListAt` that haves one pointer to the list, `l`, and an `int` as parameters. This function should print a `Node` of the linked list, depending on the number, `nbr`. -- In case of error it should print `nil` +- In case of error it should print `nil` -## Expected function and structure +### Expected function and structure ```go type Node struct { @@ -20,7 +20,7 @@ func ListAt(l *Node, nbr int) *Node{ } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : diff --git a/subjects/listat.fr.md b/subjects/listat.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listat.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listclear.md b/subjects/listclear.en.md similarity index 90% rename from subjects/listclear.md rename to subjects/listclear.en.md index d95a3fa4..0da3b3c9 100644 --- a/subjects/listclear.md +++ b/subjects/listclear.en.md @@ -1,12 +1,12 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListClear` that delets all `nodes` from a linked list, deleting the link between the list. -- Tip: assign the list's pointer to nil +- Tip: assign the list's pointer to nil -## Expected function and structure +### Expected function and structure ```go type Node struct { @@ -24,7 +24,7 @@ func ListClear(l *List) { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : diff --git a/subjects/listclear.fr.md b/subjects/listclear.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listclear.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listfind.md b/subjects/listfind.en.md similarity index 50% rename from subjects/listfind.md rename to subjects/listfind.en.md index cdb5244f..4979b846 100644 --- a/subjects/listfind.md +++ b/subjects/listfind.en.md @@ -1,36 +1,36 @@ -# listpushback +## listpushback -## Instructions +### Instructions -Write a function `ListFind` that returns the value of the first link that the function in the arguments its equal. +Write a function `ListFind` that returns the address of the first link that the function in the arguments its equal. - For this you shoud use the function `CompStr`. -- Use pointers when ever you can. +- Use pointers wen ever you can. -## Expected function and structure +### Expected function and structure ```go -type Node struct { - Data interface{} - Next *Node +type node struct { + data interface{} + next *node } -type List struct { - Head *Node - Tail *Node +type list struct { + head *node + tail *node } func CompStr(l *list) bool { } -func ListFind(l *List, comp func(l *List) bool) *interface{} { +func ListFind(l *list, comp func(l *list) bool) *interface{} { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -43,14 +43,14 @@ import ( ) func main() { - link := &List{} + link := &list{} - piscine.ListPushBack(link, 1) piscine.ListPushBack(link, "hello") + piscine.ListPushBack(link, "hello1") piscine.ListPushBack(link, "hello2") piscine.ListPushBack(link, "hello3") - - fmt.Println(piscine.ListFind(link, CompStr)) + + fmt.Println(piscine.ListFind(link, compStr)) } ``` @@ -59,6 +59,6 @@ And its output : ```console student@ubuntu:~/piscine/test$ go build student@ubuntu:~/piscine/test$ ./test -hello +0xc42000a0a0 student@ubuntu:~/piscine/test$ ``` diff --git a/subjects/listfind.fr.md b/subjects/listfind.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listfind.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listforeach.md b/subjects/listforeach.en.md similarity index 73% rename from subjects/listforeach.md rename to subjects/listforeach.en.md index fb392dd1..025c0e52 100644 --- a/subjects/listforeach.md +++ b/subjects/listforeach.en.md @@ -1,29 +1,29 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListForEach` that applies a function given as argument to the information within each of the list's links. - The function given as argument must have a pointer as argument: `l *list` -## Expected function and structure +### Expected function and structure ```go -type Node struct { - Data interface{} - Next *Node +type node struct { + data interface{} + next *node } -type List struct { - Head *Node - Tail *Node +type list struct { + head *node + tail *node } func ListForEach(l *list, f func(l *list)) { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -36,7 +36,7 @@ import ( ) func main() { - link := &List{} + link := &list{} piscine.ListPushBack(link, 1) piscine.ListPushBack(link, 2) @@ -45,9 +45,9 @@ func main() { piscine.ListForEach(link, piscine.ListReverse) - for link.Head != nil { - fmt.Println(link.Head.Data) - link.Head = link.Head.Next + for link.head != nil { + fmt.Println(link.head.data) + link.head = link.head.next } } ``` diff --git a/subjects/listforeach.fr.md b/subjects/listforeach.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listforeach.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listforeachif.md b/subjects/listforeachif.en.md similarity index 92% rename from subjects/listforeachif.md rename to subjects/listforeachif.en.md index 7cce19ad..501d047f 100644 --- a/subjects/listforeachif.md +++ b/subjects/listforeachif.en.md @@ -1,8 +1,8 @@ -# listpushback +## listpushback -## Instructions +### Instructions -Write a function `ListForEachIf` that applies a function given as argument to the information within some links of the list. +Write a function `ListForEachIf` that applies a function given as argument to the information within some links of the list. - For this you will have to create a function `CompStr`, that returns a `bool`, to compare each elemente of the linked list, to see if it is a string, and than apply the function in the argument of `ListForEachIf`. @@ -10,7 +10,7 @@ Write a function `ListForEachIf` that applies a function given as argument to th - Use pointers wen ever you can. -## Expected function and structure +### Expected function and structure ```go type node struct { @@ -32,7 +32,7 @@ func ListForEachIf(l *list, f func(l *list), comp func(l *list) bool) { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : diff --git a/subjects/listforeachif.fr.md b/subjects/listforeachif.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listforeachif.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listlast.md b/subjects/listlast.en.md similarity index 90% rename from subjects/listlast.md rename to subjects/listlast.en.md index 329123bc..24503898 100644 --- a/subjects/listlast.md +++ b/subjects/listlast.en.md @@ -1,10 +1,10 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListLast` that returns the last element of the linked list. -## Expected function and structure +### Expected function and structure ```go type Node struct { @@ -21,7 +21,7 @@ func ListLast(l *list) *list { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : diff --git a/subjects/listlast.fr.md b/subjects/listlast.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listlast.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listmerge.en.md b/subjects/listmerge.en.md new file mode 100644 index 00000000..e29427f5 --- /dev/null +++ b/subjects/listmerge.en.md @@ -0,0 +1,78 @@ +## listpushback + +### Instructions + +Write a function `ListMerge` that places elements of a list `l2` at the end of an other list `l1`. + +- You can't create new elements! + +- Use pointers when ever you can. + +### Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +type list struct { + head *node + tail *node +} + +func ListMerge(l1 *list, l2 *list) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func PrintList(l *list) { + m := l.head + for m != nil { + fmt.Print(m.data, " -> ") + m = m.next + } + + fmt.Print(l.tail) + fmt.Println() +} + +func main() { + link := &list{} + link2 := &list{} + + piscine.ListPushBack(link, "a") + piscine.ListPushBack(link, "b") + piscine.ListPushBack(link, "c") + piscine.ListPushBack(link, "d") + + piscine.ListPushBack(link2, "e") + piscine.ListPushBack(link2, "f") + piscine.ListPushBack(link2, "g") + piscine.ListPushBack(link2, "h") + + piscine.ListMerge(link, link2) + PrintList(link) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +a -> b -> c -> d -> e -> f -> g -> h -> +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listmerge.fr.md b/subjects/listmerge.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listmerge.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listmerge.md b/subjects/listmerge.md deleted file mode 100644 index b9e153d6..00000000 --- a/subjects/listmerge.md +++ /dev/null @@ -1,78 +0,0 @@ -# listpushback - -## Instructions - -Write a function `ListMerge` that places elements of a list `l2` at the end of an other list `l1`. - -- You can't create new elements! - -- Use pointers when ever you can. - -## Expected function and structure - -```go -type NodeL struct { - Data interface{} - Next *NodeL -} - -type List struct { - Head *NodeL - Tail *NodeL -} - -func listMerge(l1 *List, l2 *List) { - -} -``` - -## Usage - -Here is a possible [program](TODO-LINK) to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func PrintList(l *List) { - m := l.Head - for m != nil { - fmt.Print(m.Data, " -> ") - m = m.Next - } - - fmt.Print(nil) - fmt.Println() -} - -func main() { - link := &List{} - link2 := &List{} - - student.ListPushBack(link, "a") - student.ListPushBack(link, "b") - student.ListPushBack(link, "c") - student.ListPushBack(link, "d") - - student.ListPushBack(link2, "e") - student.ListPushBack(link2, "f") - student.ListPushBack(link2, "g") - student.ListPushBack(link2, "h") - - student.ListMerge(link, link2) - PrintList(link) -} -``` - -And its output : - -```console -student@ubuntu:~/student/test$ go build -student@ubuntu:~/student/test$ ./test -a -> b -> c -> d -> e -> f -> g -> h -> -student@ubuntu:~/student/test$ -``` diff --git a/subjects/listpushback.md b/subjects/listpushback.en.md similarity index 90% rename from subjects/listpushback.md rename to subjects/listpushback.en.md index f67f8e1e..eada7bf9 100644 --- a/subjects/listpushback.md +++ b/subjects/listpushback.en.md @@ -1,10 +1,10 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListPushBack` that inserts a new element `Node` at the end of the list, using the structure `List` -## Expected function and structure +### Expected function and structure ```go type Node struct { @@ -21,7 +21,7 @@ func ListPushBack(l *List, data interface{}) { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -34,7 +34,7 @@ import ( ) func main() { - + link := &List{} piscine.ListPushBack(link, "Hello") diff --git a/subjects/listpushback.fr.md b/subjects/listpushback.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listpushback.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listpushfront.md b/subjects/listpushfront.en.md similarity index 90% rename from subjects/listpushfront.md rename to subjects/listpushfront.en.md index b1bc69fd..0e1e511b 100644 --- a/subjects/listpushfront.md +++ b/subjects/listpushfront.en.md @@ -1,10 +1,10 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListPushBack` that inserts a new element `node` at the beginning of the list using `list` -## Expected function and structure +### Expected function and structure ```go type Node struct { @@ -21,7 +21,7 @@ func ListPushFront(l *list, data interface{}) { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -34,7 +34,7 @@ import ( ) func main() { - + link := &list{} piscine.ListPushFront(link, "Hello") diff --git a/subjects/listpushfront.fr.md b/subjects/listpushfront.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listpushfront.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listpushpara.md b/subjects/listpushpara.en.md similarity index 75% rename from subjects/listpushpara.md rename to subjects/listpushpara.en.md index d5c78e51..08520796 100644 --- a/subjects/listpushpara.md +++ b/subjects/listpushpara.en.md @@ -1,19 +1,17 @@ -# listpushback +## listpushpara -## Instructions +### Instructions Write a program that creates a new linked list and includes each command-line argument in to the list. -- The first argument should be at the end of the list - -``` +- The first argument should be at the end of the list And its output : ```console student@ubuntu:~/piscine/test$ go build student@ubuntu:~/piscine/test$ ./listpushparams choumi is the best cat -cat +cat best the is diff --git a/subjects/listpushparams.en.md b/subjects/listpushparams.en.md new file mode 100644 index 00000000..c799dce2 --- /dev/null +++ b/subjects/listpushparams.en.md @@ -0,0 +1,22 @@ +## listpushback + +### Instructions + +Write a program that creates a new linked list and includes each command-line argument in to the list. + +- The first argument should be at the end of the list + +```` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./listpushparams choumi is the best cat +cat +best +the +is +choumi +student@ubuntu:~/piscine/test$ +```` diff --git a/subjects/listpushparams.fr.md b/subjects/listpushparams.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listpushparams.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listremoveif.en.md b/subjects/listremoveif.en.md new file mode 100644 index 00000000..b27311ed --- /dev/null +++ b/subjects/listremoveif.en.md @@ -0,0 +1,108 @@ +## listpushback + +### Instructions + +Write a function `ListRemoveIf` that removes all elements that are equal to the `data_ref` introduced in the argument of the function. + +- In case the list is empty print the message `no data on list`. + +- Use pointers wen ever you can. + +### Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +type list struct { + head *node + tail *node +} + +func ListRemoveIf(l *list, data_ref interface{}) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func PrintList(l *list) { + m := l.head + for m != nil { + fmt.Print(m.data, " -> ") + m = m.next + } + + fmt.Print(l.tail) + fmt.Println() +} + +func main() { + link := &list{} + link2 := &list{} + link3 := &list{} + + fmt.Println("------answer-----") + ListRemoveIf(link3, 1) + fmt.Println() + + fmt.Println("----normal state----") + piscine.ListPushBack(link2, 1) + PrintList(link2) + ListRemoveIf(link2, 1) + fmt.Println("------answer-----") + PrintList(link) + fmt.Println() + + fmt.Println("----normal state----") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "Hello") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "There") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "How") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "are") + piscine.ListPushBack(link, "you") + piscine.ListPushBack(link, 1) + PrintList(link) + + ListRemoveIf(link, 1) + fmt.Println("------answer-----") + PrintList(link) +} + +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +------answer----- +no data on list + +----normal state---- +1 -> +------answer----- + + +----normal state---- +1 -> Hello -> 1 -> There -> 1 -> 1 -> How -> 1 -> are -> you -> 1 -> +------answer----- +Hello -> There -> How -> are -> you -> +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listremoveif.fr.md b/subjects/listremoveif.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listremoveif.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listremoveif.md b/subjects/listremoveif.md deleted file mode 100644 index 2945f502..00000000 --- a/subjects/listremoveif.md +++ /dev/null @@ -1,101 +0,0 @@ -# listpushback - -## Instructions - -Write a function `ListRemoveIf` that removes all elements that are equal to the `data_ref` introduced in the argument of the function. - -- Use pointers wen ever you can. - - -## Expected function and structure - -```go -type NodeL struct { - Data interface{} - Next *NodeL -} - -type List struct { - Head *NodeL - Tail *NodeL -} - -func ListPushFront(l *List, data interface{}) { - -} -``` - -## Usage - -Here is a possible [program](TODO-LINK) to test your function : - -```go -package main - -import ( - "fmt" - piscine ".." -) - -func PrintList(l *List) { - m := l.Head - for m != nil { - fmt.Print(m.Data, " -> ") - m = m.Next - } - - fmt.Print(nil) - fmt.Println() -} - -func main() { - link := &List{} - link2 := &List{} - link3 := &List{} - - - fmt.Println("----normal state----") - student.ListPushBack(link2, 1) - PrintList(link2) - ListRemoveIf(link2, 1) - fmt.Println("------answer-----") - PrintList(link) - fmt.Println() - - fmt.Println("----normal state----") - student.ListPushBack(link, 1) - student.ListPushBack(link, "Hello") - student.ListPushBack(link, 1) - student.ListPushBack(link, "There") - student.ListPushBack(link, 1) - student.ListPushBack(link, 1) - student.ListPushBack(link, "How") - student.ListPushBack(link, 1) - student.ListPushBack(link, "are") - student.ListPushBack(link, "you") - student.ListPushBack(link, 1) - PrintList(link) - - ListRemoveIf(link, 1) - fmt.Println("------answer-----") - PrintList(link) -} - -``` - -And its output : - -```console -student@ubuntu:~/student/test$ go build -student@ubuntu:~/student/test$ ./test -----normal state---- -1 -> -------answer----- - - -----normal state---- -1 -> Hello -> 1 -> There -> 1 -> 1 -> How -> 1 -> are -> you -> 1 -> -------answer----- -Hello -> There -> How -> are -> you -> -student@ubuntu:~/piscine/test$ -``` diff --git a/subjects/listreverse.md b/subjects/listreverse.en.md similarity index 64% rename from subjects/listreverse.md rename to subjects/listreverse.en.md index 1f6092b7..a602a052 100644 --- a/subjects/listreverse.md +++ b/subjects/listreverse.en.md @@ -1,29 +1,29 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListReverse` that reverses the elements order of a given linked list. -- Use pointers when ever you can +- Use pointers when ever you can -## Expected function and structure +### Expected function and structure ```go -type Node struct { - Data interface{} - Next *Node +type node struct { + data interface{} + next *node } -type List struct { - Head *Node - Tail *Node +type list struct { + head *node + tail *node } func ListReverse(l *list) { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -36,7 +36,7 @@ import ( ) func main() { - link := &List{} + link := &list{} listPushBack(link, 1) listPushBack(link, 2) @@ -45,9 +45,9 @@ func main() { listReverse(link) - for link.Head != nil { - fmt.Println(link.Head.Data) - link.Head = link.Head.Next + for link.head != nil { + fmt.Println(link.head.data) + link.head = link.head.next } } ``` diff --git a/subjects/listreverse.fr.md b/subjects/listreverse.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listreverse.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listsize.md b/subjects/listsize.en.md similarity index 89% rename from subjects/listsize.md rename to subjects/listsize.en.md index 6e913860..c69f59f8 100644 --- a/subjects/listsize.md +++ b/subjects/listsize.en.md @@ -1,10 +1,10 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListSize` that returns the number of elements in the list. -## Expected function and structure +### Expected function and structure ```go type Node struct { @@ -18,11 +18,11 @@ type List struct { } func ListSize(l *List) int { - + } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : diff --git a/subjects/listsize.fr.md b/subjects/listsize.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listsize.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listsort.md b/subjects/listsort.en.md similarity index 58% rename from subjects/listsort.md rename to subjects/listsort.en.md index ceeab510..b690cb98 100644 --- a/subjects/listsort.md +++ b/subjects/listsort.en.md @@ -1,29 +1,29 @@ -# listpushback +## listpushback -## Instructions +### Instructions Write a function `ListSort` that sorts the linked list by ascending order. -- This time you only will have the `Nodee` structure. +- This time you only will have the `node` structure. - Try to use recursive. - Use pointers when ever you can. -## Expected function and structure +### Expected function and structure ```go -type Nodee struct { - Data int - Next *Nodee +type node struct { + data int + next *node } -func ListSort(l *NodeL) *NodeL { +func ListSort(l *node) *node { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -32,14 +32,14 @@ package main import ( "fmt" - student ".." + piscine ".." ) //Prints the list -func PrintList(l *Nodee) { +func PrintList(l *node) { m := l for m != nil { - fmt.Print(m.Data, " -> ") + fmt.Print(m.data, " -> ") m = m.next } @@ -48,10 +48,10 @@ func PrintList(l *Nodee) { } //insert elements -func listPushBack(l *Nodee, Data int) { +func listPushBack(l *node, data int) { - n := &Nodee{} - n.Data = Data + n := &node{} + n.data = data n.next = nil if l == nil { @@ -67,7 +67,7 @@ func listPushBack(l *Nodee, Data int) { } func main() { - link := &Nodee{} + link := &node{} listPushBack(link, 5) listPushBack(link, 4) @@ -75,7 +75,7 @@ func main() { listPushBack(link, 2) listPushBack(link, 1) - PrintList(student.ListSort(link)) + PrintList(piscine.ListSort(link)) } @@ -84,8 +84,8 @@ func main() { And its output : ```console -student@ubuntu:~/student/test$ go build -student@ubuntu:~/student/test$ ./test +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> -student@ubuntu:~/student/test$ +student@ubuntu:~/piscine/test$ ``` diff --git a/subjects/listsort.fr.md b/subjects/listsort.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/listsort.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/make-it-better.en.md b/subjects/make-it-better.en.md new file mode 100644 index 00000000..936388b5 --- /dev/null +++ b/subjects/make-it-better.en.md @@ -0,0 +1,32 @@ +## make-it-better + +### Instructions + +Create the files and directories so that when you use the command `ls` below the output will looks like this : + +```console +user@host:~/piscine/d01/make-it-better$ ls -l --time-style='+%F %R' | sed 1d | awk '{print $1, $6, $7, $8, $9, $10}' +dr-------x 1986-01-05 00:00 0 +-r------w- 1986-11-13 00:01 1 +-rw----r-- 1988-03-05 00:10 2 +lrwxrwxrwx 1990-02-16 00:11 3 -> 0 +-r-x--x--- 1990-10-07 01:00 4 +-r--rw---- 1990-11-07 01:01 5 +-r--rw---- 1991-02-08 01:10 6 +-r-x--x--- 1991-03-08 01:11 7 +-rw----r-- 1994-05-20 10:00 8 +-r------w- 1994-06-10 10:01 9 +dr-------x 1995-04-10 11:11 A +user@host:~/piscine/d01/make-it-better$ +``` + +Once it's done, use the command below to create the file `done.tar` to be submitted. + +```console +user@host:~/piscine/d01/make-it-better$ tar -cf done.tar * +user@host:~/piscine/d01/make-it-better$ ls +0 1 2 3 4 5 6 7 8 9 A done.tar +user@host:~/piscine/d01/make-it-better$ +``` + +**Only `done.tar` should be submitted.** diff --git a/subjects/make-it-better.fr.md b/subjects/make-it-better.fr.md new file mode 100644 index 00000000..a0c3885b --- /dev/null +++ b/subjects/make-it-better.fr.md @@ -0,0 +1,32 @@ +## make-it-better + +### Instructions + +Créer les fichiers et dossiers de tel sorte que lorsque cette commande `ls` ci-dessous est utilisée, l'`output` ressemble à cela : + +```console +user@host:~/piscine/d01/make-it-better$ ls -l --time-style='+%F %R' | sed 1d | awk '{print $1, $6, $7, $8, $9, $10}' +dr-------x 1986-01-05 00:00 0 +-r------w- 1986-11-13 00:01 1 +-rw----r-- 1988-03-05 00:10 2 +lrwxrwxrwx 1990-02-16 00:11 3 -> 0 +-r-x--x--- 1990-10-07 01:00 4 +-r--rw---- 1990-11-07 01:01 5 +-r--rw---- 1991-02-08 01:10 6 +-r-x--x--- 1991-03-08 01:11 7 +-rw----r-- 1994-05-20 10:00 8 +-r------w- 1994-06-10 10:01 9 +dr-------x 1995-04-10 11:11 A +user@host:~/piscine/d01/make-it-better$ +``` + +Une fois fini, utilisez la commande ci-dessous pour créer le fichier `done.tar` de rendu. + +```console +user@host:~/piscine/d01/make-it-better$ tar -cf done.tar * +user@host:~/piscine/d01/make-it-better$ ls +0 1 2 3 4 5 6 7 8 9 A done.tar +user@host:~/piscine/d01/make-it-better$ +``` + +**Seulement `done.tar` doit être rendu.** diff --git a/subjects/makerange.en.md b/subjects/makerange.en.md new file mode 100644 index 00000000..0c96b368 --- /dev/null +++ b/subjects/makerange.en.md @@ -0,0 +1,47 @@ +## makerange + +### Instructions + +Write a function that takes an `int` min and an `int` max as parameters. +That function returns a slice of `int` with all the values between min and max. + +Min is included, and max is excluded. + +If min is superior or equal to max, a `nil` slice is returned. + +`append` is not allowed for this exercise. + +### Expected function + +```go +func MakeRange(min, max int) []int { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.MakeRange(5, 10)) + fmt.Println(piscine.MakeRange(10, 5)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[5 6 7 8 9] +[] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/makerange.fr.md b/subjects/makerange.fr.md new file mode 100644 index 00000000..3e12b377 --- /dev/null +++ b/subjects/makerange.fr.md @@ -0,0 +1,46 @@ +## makerange + +### Instructions + +Écrire une fonction qui prend un `int` minimum et un `int` maximum comme paramètres. Cette fonction retournes une slice d'`int` avec toutes les valeurs comprises entre le minimum et le maximum. + +Le minimum est inclus, le maximum est exclu. + +Si le minimum est supérieur ou égal au maximum, une slice `nil` est retournée. + +`append` n'est pas autorisé pour cet exercice. + +### Fonction attendue + +```go +func MakeRange(min, max int) []int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.MakeRange(5, 10)) + fmt.Println(piscine.MakeRange(10, 5)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[5 6 7 8 9] +[] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/map.en.md b/subjects/map.en.md new file mode 100644 index 00000000..c1112463 --- /dev/null +++ b/subjects/map.en.md @@ -0,0 +1,40 @@ +## map + +### Instructions + +Write a function `Map` that, for an `int` array, applies a function of this type `func(int) bool` on each elements of that array and returns an array of all the return values. + +### Expected function + +```go +func Map(f func(int) bool, arr []int) []bool { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arr := []int{1, 2, 3, 4, 5, 6} + arr = piscine.Map(piscine.IsPrime, arr) + fmt.Println(arr) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[false true true false true false] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/map.fr.md b/subjects/map.fr.md new file mode 100644 index 00000000..6b518816 --- /dev/null +++ b/subjects/map.fr.md @@ -0,0 +1,40 @@ +## map + +### Instructions + +Écrire une fonction `Map` qui, pour un tableau d'`int`, applique une fonction de type `func(int) bool` sur chaque éléments de ce tableau et retournes un tableau de toutes les valeurs de retour. + +### Fonction attendue + +```go +func Map(f func(int) bool, arr []int) []bool { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arr := []int{1, 2, 3, 4, 5, 6} + arr = Map(piscine.IsPrime, arr) + fmt.Println(arr) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[false true true false true false] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/max.md b/subjects/max.en.md similarity index 80% rename from subjects/max.md rename to subjects/max.en.md index 7b2503f5..5b664526 100644 --- a/subjects/max.md +++ b/subjects/max.en.md @@ -1,21 +1,20 @@ -# max -## Instructions +## max + +### Instructions Write a function, Max, that returns the maximum value in a slice of integers The function must have the next signature. -## Expected function +### Expected function ```go - func Max(arr []int) int { } - ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -23,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -40,5 +39,5 @@ And its output : student@ubuntu:~/student/max$ go build student@ubuntu:~/student/max$ ./max 123 -student@ubuntu:~/student/max$ +student@ubuntu:~/student/max$ ``` diff --git a/subjects/now-get-to-work.en.md b/subjects/now-get-to-work.en.md new file mode 100644 index 00000000..6ac5d5be --- /dev/null +++ b/subjects/now-get-to-work.en.md @@ -0,0 +1,21 @@ +## now-get-to-work + +### Instructions + +"Something terrible happened" + +clone this repo : https://github.com/01-edu/the-final-cl-test + +Submit your solution in the file `my_answer.sh` that will print it when executed. + +### Utilisation + +```console +student@ubuntu:~/piscine/test$ ./my_answer.sh | cat -e +John Doe$ +student@ubuntu:~/piscine/test$ +``` + +### Hint + +"You could combine `head` and `tail`s..." diff --git a/subjects/now-get-to-work.fr.md b/subjects/now-get-to-work.fr.md new file mode 100644 index 00000000..c42efb01 --- /dev/null +++ b/subjects/now-get-to-work.fr.md @@ -0,0 +1,21 @@ +## now-get-to-work + +### Instructions + +"Quelque chose de terrible est arrivé" + +Faîtes un clone de repo : https://github.com/01-edu/the-final-cl-test + +Rendez votre solution dans un fichier `my_answer.sh` qui l'affichera quand exécuté. + +### Usage + +```console +student@ubuntu:~/piscine/test$ ./my_answer.sh | cat -e +John Doe$ +student@ubuntu:~/piscine/test$ +``` + +### Hint + +"Vous pouvez combinez `head` et `tail`s..." diff --git a/subjects/nrune.en.md b/subjects/nrune.en.md new file mode 100644 index 00000000..3cafbf16 --- /dev/null +++ b/subjects/nrune.en.md @@ -0,0 +1,42 @@ +## nrune + +### Instructions + +Write a function that returns the nth `rune` of a `string`. + +### Expected function + +```go +func NRune(s string, n int) rune { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.NRune("Hello!", 3)) + z01.PrintRune(piscine.NRune("Salut!", 2)) + z01.PrintRune(piscine.NRune("Ola!", 4)) + z01.PrintRune('\n') +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +la! +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/nrune.fr.md b/subjects/nrune.fr.md new file mode 100644 index 00000000..8e69dec2 --- /dev/null +++ b/subjects/nrune.fr.md @@ -0,0 +1,42 @@ +## nrune + +### Instructions + +Écrire une fonction qui retourne la énième `rune` d'une `string`. + +### Fonction attendue + +```go +func NRune(s string, n int) rune { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.NRune("Hello!", 3)) + z01.PrintRune(piscine.NRune("Salut!", 2)) + z01.PrintRune(piscine.NRune("Ola!", 4)) + z01.PrintRune('\n') +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +la! +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/onlya.md b/subjects/onlya.en.md similarity index 67% rename from subjects/onlya.md rename to subjects/onlya.en.md index 87824967..0c7ef855 100644 --- a/subjects/onlya.md +++ b/subjects/onlya.en.md @@ -1,5 +1,5 @@ -# onlya +## onlya -## Instructions +### Instructions -Write a program that displays a 'a' character on the standard output. \ No newline at end of file +Write a program that displays a 'a' character on the standard output. diff --git a/subjects/onlyz.md b/subjects/onlyz.en.md similarity index 61% rename from subjects/onlyz.md rename to subjects/onlyz.en.md index 5adccad0..23f0e34b 100644 --- a/subjects/onlyz.md +++ b/subjects/onlyz.en.md @@ -1,4 +1,5 @@ -# displayalpham -## Instructions +## displayalpham -Write a program that displays a 'z' character on the standard output. \ No newline at end of file +### Instructions + +Write a program that displays a 'z' character on the standard output. diff --git a/subjects/paramcount.en.md b/subjects/paramcount.en.md new file mode 100644 index 00000000..c11c7171 --- /dev/null +++ b/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$ +``` diff --git a/subjects/pilot.md b/subjects/pilot.en.md similarity index 79% rename from subjects/pilot.md rename to subjects/pilot.en.md index fd9649e8..1aa95a38 100644 --- a/subjects/pilot.md +++ b/subjects/pilot.en.md @@ -1,16 +1,17 @@ -# pilot -## Instructions +## pilot + +### Instructions Write a go file so that the following program compile -## Usage +### Usage ```go package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -23,4 +24,3 @@ func main() { fmt.Println(donnie) } ``` - diff --git a/subjects/point.md b/subjects/point.en.md similarity index 57% rename from subjects/point.md rename to subjects/point.en.md index dc1cfeaa..ba6b426e 100644 --- a/subjects/point.md +++ b/subjects/point.en.md @@ -1,34 +1,32 @@ - # Point +## Point -## Instructions +### Instructions Create a `.go` file and copy the code below into our file - The main task is to return a working program. -- - ```go func setPoint(ptr *point) { - ptr.x = 42 - ptr.y = 21 + ptr.x = 42 + ptr.y = 21 } func main() { - points := &point{} + points := &point{} + + setPoint(points) - setPoint(points) - - fmt.Printf("x = %d, y = %d",points.x, points.y) - fmt.Println() + fmt.Printf("x = %d, y = %d",points.x, points.y) + fmt.Println() } ``` -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build student@ubuntu:~/piscine/test$ ./test -x = 42, y = 21 +x = 42, y = 21 student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` diff --git a/subjects/pointone.en.md b/subjects/pointone.en.md new file mode 100755 index 00000000..0329c3f4 --- /dev/null +++ b/subjects/pointone.en.md @@ -0,0 +1,41 @@ +## pointone + +### Instructions + +- Write a function that takes a **pointer to an int** as argument and gives to this int the value of 1. + +### Expected function + +```go +func PointOne(n *int) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + n := 0 + piscine.PointOne(&n) + fmt.Println(n) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/pointone.fr.md b/subjects/pointone.fr.md new file mode 100755 index 00000000..1b02b779 --- /dev/null +++ b/subjects/pointone.fr.md @@ -0,0 +1,41 @@ +## pointone + +### Instructions + +- Écrire une fonction qui prend un **pointeur sur int** en argument et qui assignes à cet int la valeur 1. + +### Fonction attendue + +```go +func PointOne(n *int) { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + n := 0 + piscine.PointOne(&n) + fmt.Println(n) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printalphabet.en.md b/subjects/printalphabet.en.md new file mode 100644 index 00000000..bf9efc56 --- /dev/null +++ b/subjects/printalphabet.en.md @@ -0,0 +1,16 @@ +## printalphabet + +### Instructions + +Write a [program](TODO-LINK) that prints the Latin alphabet in lowercase on a single line. + +A line is a sequence of characters preceding the [end of line](https://en.wikipedia.org/wiki/Newline) character (`'\n'`). + +### Usage + +```console +student@ubuntu:~/piscine/printalphabet$ go build +student@ubuntu:~/piscine/printalphabet$ ./printalphabet +abcdefghijklmnopqrstuvwxyz +student@ubuntu:~/piscine/printalphabet$ +``` diff --git a/subjects/printalphabet.fr.md b/subjects/printalphabet.fr.md new file mode 100644 index 00000000..8275d980 --- /dev/null +++ b/subjects/printalphabet.fr.md @@ -0,0 +1,16 @@ +## printalphabet + +### Instructions + +Écrire un [programme](TODO-LINK) qui affiche l'alphabet latin en minuscule sur une seule ligne. + +Une ligne est une suite de caractères précédant le caractère [fin de ligne](https://en.wikipedia.org/wiki/Newline) (`'\n'`). + +### Utilisation + +```console +student@ubuntu:~/piscine/printalphabet$ go build +student@ubuntu:~/piscine/printalphabet$ ./printalphabet +abcdefghijklmnopqrstuvwxyz +student@ubuntu:~/piscine/printalphabet$ +``` diff --git a/subjects/printbits.en.md b/subjects/printbits.en.md new file mode 100644 index 00000000..f27dfaee --- /dev/null +++ b/subjects/printbits.en.md @@ -0,0 +1,19 @@ +## printbits + +### Instructions + +Write a function that takes a byte, and prints it in binary value **without a newline at the end**. + +### Expected function + +```go +func PrintBits(octe byte) { + +} +``` + +### Usage + +Example of output: + +If 2 is passed to the function PrintBits, it will print "00000010". diff --git a/subjects/printcomb.en.md b/subjects/printcomb.en.md new file mode 100755 index 00000000..a836e1a9 --- /dev/null +++ b/subjects/printcomb.en.md @@ -0,0 +1,42 @@ +## printcomb + +### Instructions + +Write a [function](TODO-LINK) that prints in ascending order on a single line all unique combinations of three different digits so that the first digit is less than the second and the second is less than the third. + +These combinations are separated by a comma and a space. + +### Expected function + +```go +func PrintComb() { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintComb() +} +``` + +This is the incomplete output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +012, 013, 014, 015, 016, 017, 018, 019, 023, ..., 689, 789 +student@ubuntu:~/piscine/test$ +``` + +`000` or `999` are not valid combinations because the digits are not different. + +`987` should not be shown because the first digit is not less than the second. diff --git a/subjects/printcomb.fr.md b/subjects/printcomb.fr.md new file mode 100755 index 00000000..f224897a --- /dev/null +++ b/subjects/printcomb.fr.md @@ -0,0 +1,42 @@ +## printcomb + +### Instructions + +Écrire une [fonction](TODO-LINK) qui affiche sur une seule ligne dans l'ordre croissant toutes les combinaisons possibles de trois chiffres différents tels que le premier est inférieur au second et le second est inférieur au troisième. + +Les combinaisons sont séparées par une virgule et un espace. + +### Fonction attendue + +```go +func PrintComb() { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintComb() +} +``` + +Voici la sortie tronquée : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +012, 013, 014, 015, 016, 017, 018, 019, 023, ..., 689, 789 +student@ubuntu:~/piscine/test$ +``` + +`000` et `999` ne sont pas des combinations valides parce que les chiffres ne sont pas différents. + +`987` ne doit pas être affiché parce que le premier chiffre n'est pas inférieur au second. diff --git a/subjects/printcomb2.en.md b/subjects/printcomb2.en.md new file mode 100755 index 00000000..356253bf --- /dev/null +++ b/subjects/printcomb2.en.md @@ -0,0 +1,38 @@ +## printcomb2 + +### Instructions + +Write a [function](TODO-LINK) that prints in ascending order on a single line all possible combinations of two different two-digit numbers. + +These combinations are separated by a comma and a space. + +### Expected function + +```go +func PrintComb2() { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintComb2() +} +``` + +This is the incomplete output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +00 01, 00 02, 00 03, ..., 00 98, 00 99, 01 02, 01 03, ..., 97 98, 97 99, 98 99 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printcomb2.fr.md b/subjects/printcomb2.fr.md new file mode 100755 index 00000000..fc32dabe --- /dev/null +++ b/subjects/printcomb2.fr.md @@ -0,0 +1,38 @@ +## printcomb2 + +### Instructions + +Écrire une [fonction](TODO-LINK) qui affiche sur une seule ligne dans l'ordre croissant toutes les combinaisons possibles de deux nombres différents à deux chiffres. + +Les combinaisons sont séparées par une virgule et un espace. + +### Fonction attendue + +```go +func PrintComb2() { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintComb2() +} +``` + +Voici la sortie tronquée : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +00 01, 00 02, 00 03, ..., 00 98, 00 99, 01 02, 01 03, ..., 97 98, 97 99, 98 99 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printcombn.en.md b/subjects/printcombn.en.md new file mode 100755 index 00000000..88154648 --- /dev/null +++ b/subjects/printcombn.en.md @@ -0,0 +1,46 @@ +## printcombn + +### Instructions + +- Write a function that prints all possible combinations of **n** different digits in ascending order. + +- n will be defined as : 0 < n < 10 + +below are your references for the **printing format** expected. + +- (for n = 1) '0, 1, 2, 3, ...8, 9' + +- (for n = 3) '012, 013, 014, 015, 016, 017, 018, 019, 023,...689, 789' + +### Expected function + +```go +func PrintCombN(n int) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintCombN(1) + piscine.PrintCombN(2) + piscine.PrintCombN(123) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +-1230123 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printcombn.fr.md b/subjects/printcombn.fr.md new file mode 100755 index 00000000..7cb65dbb --- /dev/null +++ b/subjects/printcombn.fr.md @@ -0,0 +1,21 @@ +## printcombn + +### Instructions + +- Écrire une fonction qui affiche toutes les combinaisons possibles de **n** chiffres différents en ordre croissant. + +- n sera défini tel que: 0 < n < 10 + +ci-dessous vos références pour le **format d'affichage** attendu. + +- (pour n = 1) '0, 1, 2, 3, ...8, 9' + +- (pour n = 3) '012, 013, 014, 015, 016, 017, 018, 019, 023,...689, 789' + +### Fonction attendue + +```go +func PrintCombN(n int) { + +} +``` diff --git a/subjects/printdigits.en.md b/subjects/printdigits.en.md new file mode 100755 index 00000000..1824df87 --- /dev/null +++ b/subjects/printdigits.en.md @@ -0,0 +1,16 @@ +## printdigits + +### Instructions + +Write a [program](TODO-LINK) that prints the decimal digits in ascending order (from `0` to `9`) on a single line. + +A line is a sequence of characters preceding the [end of line](https://en.wikipedia.org/wiki/Newline) character (`'\n'`). + +### Usage + +```console +student@ubuntu:~/piscine/printdigits$ go build +student@ubuntu:~/piscine/printdigits$ ./printdigits +0123456789 +student@ubuntu:~/piscine/printdigits$ +``` diff --git a/subjects/printdigits.fr.md b/subjects/printdigits.fr.md new file mode 100755 index 00000000..b81d59ec --- /dev/null +++ b/subjects/printdigits.fr.md @@ -0,0 +1,16 @@ +## printdigits + +### Instructions + +Écrire un [programme](TODO-LINK) qui affiche les chiffres décimaux dans l'ordre croissant (de `0` à `9`) sur une seule ligne. + +Une ligne est une suite de caractères précédant le caractère [fin de ligne](https://en.wikipedia.org/wiki/Newline) (`'\n'`). + +### Utilisation + +```console +student@ubuntu:~/piscine/printdigits$ go build +student@ubuntu:~/piscine/printdigits$ ./printdigits +0123456789 +student@ubuntu:~/piscine/printdigits$ +``` diff --git a/subjects/printnbr.en.md b/subjects/printnbr.en.md new file mode 100644 index 00000000..eefde512 --- /dev/null +++ b/subjects/printnbr.en.md @@ -0,0 +1,40 @@ +## printnbr + +### Instructions + +Write a function that prints an `int` passed in parameter. +All possible values of type `int` have to go through. +You cannot convert to `int64`. + +### Expected function + +```go +func PrintNbr(int n) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintNbr(-123) + piscine.PrintNbr(0) + piscine.PrintNbr(123) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +-1230123 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printnbr.fr.md b/subjects/printnbr.fr.md new file mode 100644 index 00000000..93101b86 --- /dev/null +++ b/subjects/printnbr.fr.md @@ -0,0 +1,40 @@ +## printnbr + +### Instructions + +Écrire une fonction qui affiche un `int` passé en paramètre. +Toutes les valeurs de type `int` doivent être affichables. +Vous ne pouvez pas convertir en `int64`. + +### Fonction attendue + +```go +func PrintNbr(int n) { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintNbr(-123) + piscine.PrintNbr(0) + piscine.PrintNbr(123) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +-1230123 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printnbrbase.en.md b/subjects/printnbrbase.en.md new file mode 100644 index 00000000..27ba70dc --- /dev/null +++ b/subjects/printnbrbase.en.md @@ -0,0 +1,63 @@ +## putnbrbase + +### Instructions + +Write a function that prints an `int` in a `string` base passed in parameters. + +If the base is not valid, the function prints `NV` (Not Valid): + +Validity rules for a base : + +- A base must contain at least 2 characters. +- Each character of a base must be unique. +- A base should not contain `+` or `-` characters. + +The function has to manage negative numbers. (as shown in the example) + +### Expected function + +```go +func PrintNbrBase(nbr int, base string) () { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + piscine.PrintNbrBase(125, "0123456789") + z01.PrintRune('\n') + piscine.PrintNbrBase(-125, "01") + z01.PrintRune('\n') + piscine.PrintNbrBase(125, "0123456789ABCDEF") + z01.PrintRune('\n') + piscine.PrintNbrBase(-125, "choumi") + z01.PrintRune('\n') + piscine.PrintNbrBase(125, "aa") + z01.PrintRune('\n') +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +125 +-1111101 +7D +-uoi +NV +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printnbrbase.fr.md b/subjects/printnbrbase.fr.md new file mode 100644 index 00000000..73bb5fa8 --- /dev/null +++ b/subjects/printnbrbase.fr.md @@ -0,0 +1,63 @@ +## putnbrbase + +### Instructions + +Écrire une fonction qui affiche un `int` dans une base en `string` passés en paramètres. + +Si la base n'est pas valide, la fonction affiche `NV` (Not Valid): + +Régles de validité d'une base : + +- Une base doit contenir au moins 2 charactères. +- Chaque charactère d'une base doit être unique. +- Une base ne doit pas contenir les charactères `+` ou `-`. + +La fonction doit gérer les nombres négatifs. (comme montré sur l'exemple) + +### Fonction attendue + +```go +func PrintNbrBase(nbr int, base string) () { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + piscine.PrintNbrBase(125, "0123456789") + z01.PrintRune('\n') + piscine.PrintNbrBase(-125, "01") + z01.PrintRune('\n') + piscine.PrintNbrBase(125, "0123456789ABCDEF") + z01.PrintRune('\n') + piscine.PrintNbrBase(-125, "choumi") + z01.PrintRune('\n') + piscine.PrintNbrBase(125, "aa") + z01.PrintRune('\n') +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +125 +-1111101 +7D +-uoi +NV +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printparams.en.md b/subjects/printparams.en.md new file mode 100644 index 00000000..1697e284 --- /dev/null +++ b/subjects/printparams.en.md @@ -0,0 +1,18 @@ +## printparams + +### Instructions + +Write a **program** that prints the arguments received in the command line. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./printparams choumi is the best cat +choumi +is +the +best +cat +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printparams.fr.md b/subjects/printparams.fr.md new file mode 100644 index 00000000..8cbc719f --- /dev/null +++ b/subjects/printparams.fr.md @@ -0,0 +1,18 @@ +## printparams + +### Instructions + +Écrire un **programme** qui affiche les arguments en ligne de commande. + +Exemple de résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./printparams choumi is the best cat +choumi +is +the +best +cat +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printprogramname.en.md b/subjects/printprogramname.en.md new file mode 100644 index 00000000..114c0b61 --- /dev/null +++ b/subjects/printprogramname.en.md @@ -0,0 +1,14 @@ +## printprogramname + +### Instructions + +Write a **program** that prints the name of the program. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build main.go +student@ubuntu:~/piscine/test$ ./main +./main +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printprogramname.fr.md b/subjects/printprogramname.fr.md new file mode 100644 index 00000000..6888887e --- /dev/null +++ b/subjects/printprogramname.fr.md @@ -0,0 +1,14 @@ +## printprogramname + +### Instructions + +Écrire un **programme** qui affiche le nom du programme. + +Exemple de résultat : + +```console +student@ubuntu:~/piscine/test$ go build main.go +student@ubuntu:~/piscine/test$ ./main +./main +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printreversealphabet.en.md b/subjects/printreversealphabet.en.md new file mode 100755 index 00000000..cbaf35b6 --- /dev/null +++ b/subjects/printreversealphabet.en.md @@ -0,0 +1,16 @@ +## printreversealphabet + +### Instructions + +Write a [program](TODO-LINK) that prints the Latin alphabet in lowercase in reverse order (from `'z'` to `'a'`) on a single line. + +A line is a sequence of characters preceding the [end of line](https://en.wikipedia.org/wiki/Newline) character (`'\n'`). + +### Usage + +```console +student@ubuntu:~/piscine/printreversealphabet$ go build +student@ubuntu:~/piscine/printreversealphabet$ ./printreversealphabet +zyxwvutsrqponmlkjihgfedcba +student@ubuntu:~/piscine/printreversealphabet$ +``` diff --git a/subjects/printreversealphabet.fr.md b/subjects/printreversealphabet.fr.md new file mode 100755 index 00000000..bce51820 --- /dev/null +++ b/subjects/printreversealphabet.fr.md @@ -0,0 +1,16 @@ +## printreversealphabet + +### Instructions + +Écrire un [programme](TODO-LINK) qui affiche l'alphabet latin en minuscule dans l'ordre inverse (de `'z'` à `'a'`) sur une seule ligne. + +Une ligne est une suite de caractères précédant le caractère [fin de ligne](https://en.wikipedia.org/wiki/Newline) (`'\n'`). + +### Utilisation + +```console +student@ubuntu:~/piscine/printreversealphabet$ go build +student@ubuntu:~/piscine/printreversealphabet$ ./printreversealphabet +zyxwvutsrqponmlkjihgfedcba +student@ubuntu:~/piscine/printreversealphabet$ +``` diff --git a/subjects/printstr.en.md b/subjects/printstr.en.md new file mode 100755 index 00000000..93896033 --- /dev/null +++ b/subjects/printstr.en.md @@ -0,0 +1,37 @@ +## printstr + +### Instructions + +- Write a function that prints one by one the characters of a string on the screen. + +### Expected function + +```go +func PrintStr(str string) { + +} +``` + +### Hints + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + str := "Hello World!" + piscine.PrintStr(str) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello World!% +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printstr.fr.md b/subjects/printstr.fr.md new file mode 100755 index 00000000..5f02e1c1 --- /dev/null +++ b/subjects/printstr.fr.md @@ -0,0 +1,37 @@ +## putstr + +### Instructions + +- Écrire une fonction qui affiche un à un les caractères d'une chaîne à l'écran. + +### Fonction attendue + +```go +func PrintStr(str string) { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + str := "Hello World!" + piscine.Putstr(str) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello World!% +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printwordstables.en.md b/subjects/printwordstables.en.md new file mode 100644 index 00000000..248af853 --- /dev/null +++ b/subjects/printwordstables.en.md @@ -0,0 +1,44 @@ +## printwordstables + +### Instructions + +Write a function that prints the words of a `string` array that will be returned a function `SplitWhiteSpaces`. (the testing will be done with ours) + +Each word is on a single line. + +Each word ends with a `\n`. + +### Expected function + +```go +func PrintWordsTables(table []string) { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + str := "Hello how are you?" + table := piscine.SplitWhiteSpaces(str) + piscine.PrintWordsTables(table) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build main.go +student@ubuntu:~/piscine/test$ ./main +Hello +how +are +you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printwordstables.fr.md b/subjects/printwordstables.fr.md new file mode 100644 index 00000000..b040b60a --- /dev/null +++ b/subjects/printwordstables.fr.md @@ -0,0 +1,45 @@ +## printwordstables + +### Instructions + +Écrire une fonction qui affiche les mots d'un tableau de `string` qui sera le resultat d'une fonction `SplitWhiteSpaces`. (les tests seront effectués avec la notre) + +Chaque mot est sur une seule ligne. + +Chaque mot fini avec un `\n`. + +### Fonction attendue + +```go +func PrintWordsTables(table []string) { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + + str := "Hello how are you?" + table := piscine.SplitWhiteSpaces(str) + piscine.PrintWordsTables(table) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build main.go +student@ubuntu:~/piscine/test$ ./main +Hello +how +are +you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/public.en.md b/subjects/public.en.md new file mode 100644 index 00000000..7f8d501a --- /dev/null +++ b/subjects/public.en.md @@ -0,0 +1 @@ +## public diff --git a/subjects/rectangle.md b/subjects/rectangle.en.md similarity index 68% rename from subjects/rectangle.md rename to subjects/rectangle.en.md index 15598624..44b38808 100644 --- a/subjects/rectangle.md +++ b/subjects/rectangle.en.md @@ -1,6 +1,6 @@ -# Rectangle +## Rectangle -## Instructions +### Instructions Consider that a point is defined by its coordinates and that a rectangle is defined by the points of the upper left and lower right corners. @@ -13,29 +13,29 @@ is defined by the points of the upper left and lower right corners. - Our main task is to make a program that: - - Given a slice of points of size `n` returns the smallest rectangle that contains all the points in the vector of points. The name of that function is `defineRectangle` + - Given a slice of points of size `n` returns the smallest rectangle that contains all the points in the vector of points. The name of that function is `defineRectangle` - - And calculates and prints the area of that rectangle you define. + - And calculates and prints the area of that rectangle you define. -## Expected main and function for the program +### Expected main and function for the program ```go func defineRectangle(ptr *point, n int) *rectangle { - //complete here + } func calArea(ptr *rectangle) int { - //complete here + } func main() { - vPoint := []point{} + vPoint := []point{} rectangle := &rectangle{} n := 7 for i := 0; i < n; i++ { val := point{ - x: i%2 + 1, + x: i%2 + 1, y: i + 2, } vPoint = append(vPoint, val) @@ -45,8 +45,7 @@ func main() { } ``` - -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build diff --git a/subjects/recursivefactorial.en.md b/subjects/recursivefactorial.en.md new file mode 100644 index 00000000..fa267a35 --- /dev/null +++ b/subjects/recursivefactorial.en.md @@ -0,0 +1,42 @@ +## recursivefactorial + +### Intructions + +Write a **recursive** function that returns the factorial of the `int` passed as parameter. + +Errors (non possible values or overflows) will return `0`. + +`for` is **forbidden** for this exercise. + +### Expected function + +```go +func RecursiveFactorial(int nb) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arg := 4 + fmt.Println(piscine.RecursiveFactorial(arg)) +} +``` + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +24 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/recursivefactorial.fr.md b/subjects/recursivefactorial.fr.md new file mode 100644 index 00000000..fba6dfaf --- /dev/null +++ b/subjects/recursivefactorial.fr.md @@ -0,0 +1,44 @@ +## recursivefactorial + +### Intructions + +Écrire une fonction **récursive** qui renvoie la factorielle d'un `int` passé en paramètre. + +Les erreurs (valeurs non possibles ou overflows) renverront `0`. + +`for` est **interdit** pour cet exercice. + +### Fonction attendue + +```go +func RecursiveFactorial(int nb) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arg := 4 + fmt.Println(piscine.RecursiveFactorial(arg)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +24 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/recursivepower.en.md b/subjects/recursivepower.en.md new file mode 100644 index 00000000..90c58c67 --- /dev/null +++ b/subjects/recursivepower.en.md @@ -0,0 +1,45 @@ +## recursivepower + +### Intructions + +Write an **recursive** function that returns the power of the `int` passed as parameter. + +Negative powers will return `0`. Overflows do **not** have to be dealt with. + +`for` is **forbidden** for this exercise. + +### Expected function + +```go +func RecursivePower(int nb, int power) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.RecursivePower(arg1, arg2)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +64 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/recursivepower.fr.md b/subjects/recursivepower.fr.md new file mode 100644 index 00000000..b47509c8 --- /dev/null +++ b/subjects/recursivepower.fr.md @@ -0,0 +1,45 @@ +## recursivepower + +### Intructions + +Écrire une fonction **récursive** qui renvoie la puissance de deux `int` passés en paramètre. + +Les puissances négatives renverront `0`. Les overflows **ne doivent pas** être gérés. + +`for` est **interdit** pour cet exercice. + +### Fonction attendue + +```go +func RecursivePower(int nb, int power) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.RecursivePower(arg1, arg2)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~$ go build +student@ubuntu:~$ ./recursivepower +64 +student@ubuntu:~$ +``` diff --git a/subjects/repeatalpha.md b/subjects/repeatalpha.en.md similarity index 83% rename from subjects/repeatalpha.md rename to subjects/repeatalpha.en.md index 321f5134..558123b9 100644 --- a/subjects/repeatalpha.md +++ b/subjects/repeatalpha.en.md @@ -1,11 +1,12 @@ -# repeatalpha -## Instructions +## repeatalpha + +### Instructions Write a program called repeat_alpha that takes a string and display it repeating each alphabetical character as many times as its alphabetical index, followed by a newline. -'a' becomes 'a', 'b' becomes 'bb', 'e' becomes 'eeeee', etc... +`'a'` becomes `'a'`, `'b'` becomes `'bb'`, `'e'` becomes `'eeeee'`, etc... Case remains unchanged. @@ -25,5 +26,5 @@ student@ubuntu:~/student/repeatalpha$ ./repeatalpha | cat -e $ student@ubuntu:~/student/repeatalpha$ ./repeatalpha "" | cat -e $ -student@ubuntu:~/student/repeatalpha$ +student@ubuntu:~/student/repeatalpha$ ``` diff --git a/subjects/reversebits.md b/subjects/reversebits.en.md similarity index 67% rename from subjects/reversebits.md rename to subjects/reversebits.en.md index c0b9e01c..886af231 100644 --- a/subjects/reversebits.md +++ b/subjects/reversebits.en.md @@ -1,20 +1,27 @@ -# reversebits -## Instructions +## reversebits + +### Instructions Write a function that takes a byte, reverses it, bit by bit (like the example) and returns the result. Your function must be declared as follows: +```go func ReverseBits(octet byte) byte { - ... + } +``` Example: - 1 byte -_____________ - 00100110 - || - \/ - 01100100 +1 byte + +--- + +``` +00100110 + || + \/ +01100100 +``` diff --git a/subjects/reverserange.en.md b/subjects/reverserange.en.md new file mode 100644 index 00000000..6e3a92b4 --- /dev/null +++ b/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. diff --git a/subjects/reversestrcap.en.md b/subjects/reversestrcap.en.md new file mode 100644 index 00000000..3dc04544 --- /dev/null +++ b/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$ +``` diff --git a/subjects/revparams.en.md b/subjects/revparams.en.md new file mode 100644 index 00000000..d387913a --- /dev/null +++ b/subjects/revparams.en.md @@ -0,0 +1,18 @@ +## revparams + +### Instructions + +Write a **program** that prints the arguments received in the command line in a reverse order. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./revparams choumi is the best cat +cat +best +the +is +choumi +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/revparams.fr.md b/subjects/revparams.fr.md new file mode 100644 index 00000000..7c775531 --- /dev/null +++ b/subjects/revparams.fr.md @@ -0,0 +1,18 @@ +## revparams + +### Instructions + +Écrire un **programme** qui affiche les arguments en ligne de commande en ordre inverse. + +Exemple de résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./revparams choumi is the best cat +cat +best +the +is +choumi +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/rot13.md b/subjects/rot13.en.md similarity index 86% rename from subjects/rot13.md rename to subjects/rot13.en.md index cb493970..56619229 100644 --- a/subjects/rot13.md +++ b/subjects/rot13.en.md @@ -1,6 +1,6 @@ -# rot13 +## rot13 -## Instructions +### Instructions Write a program that takes a string and displays it, replacing each of its letters by the letter 13 spaces ahead in alphabetical order. @@ -11,7 +11,7 @@ letters by the letter 13 spaces ahead in alphabetical order. - If the number of arguments is not 1, the program displays a newline. -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build @@ -21,5 +21,5 @@ student@ubuntu:~/piscine/test$ ./test "hello there" uryyb gurer student@ubuntu:~/piscine/test$ ./test -student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/rot14.md b/subjects/rot14.en.md similarity index 91% rename from subjects/rot14.md rename to subjects/rot14.en.md index be897cfc..ca3fe12b 100644 --- a/subjects/rot14.md +++ b/subjects/rot14.en.md @@ -1,19 +1,20 @@ -# ROT 14 +## ROT 14 -## Instructions +### Instructions Write a function `rot14` that returns the string within the parameter but transformed into a rot14 string. - If you not certain what we are talking about, there is a rot13 already. -## Expected function +### Expected function ```go func rot14(str string) string { } ``` -## Usage + +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -33,7 +34,6 @@ func main() { } z01.PrintRune('\n') } - ``` And its output : diff --git a/subjects/searchreplace.md b/subjects/searchreplace.en.md similarity index 65% rename from subjects/searchreplace.md rename to subjects/searchreplace.en.md index 20a09d10..861667ad 100644 --- a/subjects/searchreplace.md +++ b/subjects/searchreplace.en.md @@ -1,14 +1,14 @@ -# searchreplace +## searchreplace -## Instructions +### Instructions -Write a program that takes 3 arguments, the first arguments is a string in which to replace a letter (2nd argument) by another one (3rd argument). +Write a program that takes 3 arguments, the first arguments is a string in which to replace a letter (2nd argument) by another one (3rd argument). - If the number of arguments is not 3, just display a newline. - If the second argument is not contained in the first one (the string) then the program simply rewrites the string followed by a newline. -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build @@ -18,5 +18,5 @@ student@ubuntu:~/piscine/test$ ./test "abcd" "z" "l" abcd student@ubuntu:~/piscine/test$ ./test "something" "a" "o" "b" "c" -student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/set.en.md b/subjects/set.en.md new file mode 100644 index 00000000..ef45e24f --- /dev/null +++ b/subjects/set.en.md @@ -0,0 +1,12 @@ +## set + +### Setting up your development workspace + +[GitHub account](TODO-VIDEO-LINK) + +#### Choose your code editor + +- [VS Code](TODO-LINK) +- [Sublime Text](TODO-LINK) + +#### [How to submit your code with Git](TODO-VIDEO-LINK) diff --git a/subjects/sortedlistmerge.md b/subjects/sortedlistmerge.en.md similarity index 65% rename from subjects/sortedlistmerge.md rename to subjects/sortedlistmerge.en.md index aac3f2ed..7653c3e0 100644 --- a/subjects/sortedlistmerge.md +++ b/subjects/sortedlistmerge.en.md @@ -1,27 +1,27 @@ -# listpushback +## listpushback -## Instructions +### Instructions -Write a function `SortedListMerge` that mereges two lists, `l1` and `l2`, but you have to join them in ascending order. +Write a function `SortedListMerge` that mereges two lists, `l1` and `l2`, but it as to join them in ascending order. -- Tip each list as to be already sorted, and initialized with 0. +- Tip each list as to be already sorted. - Use pointers when ever you can. -## Expected function and structure +### Expected function and structure ```go -type Nodee struct { - Data interface{} - Next *Nodee +type node struct { + data interface{} + next *node } -func SortedListMerge(l1 *Nodee, l2 *Nodee) *Nodee { +func SortedListMerge(l1 *node, l2 *node) *node { } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -33,11 +33,11 @@ import ( piscine ".." ) -func PrintList(l *Nodee) { - m := l +func PrintList(l *list) { + m := l.head for m != nil { - fmt.Print(m.Data, " -> ") - m = m.Next + fmt.Print(m.data, " -> ") + m = m.next } fmt.Print(nil) @@ -45,8 +45,8 @@ func PrintList(l *Nodee) { } func main() { - link := &Nodee{} - link2 := &Nodee{} + link := &list{} + link2 := &list{} piscine.ListPushBack(link, "5") piscine.ListPushBack(link, "3") diff --git a/subjects/sortedlistmerge.fr.md b/subjects/sortedlistmerge.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/sortedlistmerge.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortintegertable.en.md b/subjects/sortintegertable.en.md new file mode 100755 index 00000000..ca2ff301 --- /dev/null +++ b/subjects/sortintegertable.en.md @@ -0,0 +1,41 @@ +## sortintegertable + +### Instructions + +- Write a function that reorder an array of `int` in ascending order. + +### Expected function + +```go +func SortIntegerTable(table []int) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := []int{5,4,3,2,1,0} + piscine.SortIntegerTable(s) + fmt.Println(s) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[0,1,2,3,4,5] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortintegertable.fr.md b/subjects/sortintegertable.fr.md new file mode 100755 index 00000000..3c92b2f0 --- /dev/null +++ b/subjects/sortintegertable.fr.md @@ -0,0 +1,41 @@ +## sortintegertable + +### Instructions + +- Écrire une fonction qui trie un tableau d'`int` (entier) par ordre croissant. + +### Fonction attendue + +```go +func SortIntegerTable(table []int) { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := []int{5,4,3,2,1,0} + piscine.SortIntegerTable(s) + fmt.Println(s) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[0,1,2,3,4,5] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortlistinsert.md b/subjects/sortlistinsert.en.md similarity index 61% rename from subjects/sortlistinsert.md rename to subjects/sortlistinsert.en.md index 6f79c199..b84a35b9 100644 --- a/subjects/sortlistinsert.md +++ b/subjects/sortlistinsert.en.md @@ -1,27 +1,27 @@ -# listpushback +## listpushback -## Instructions +### Instructions -Write a function `SortListInsert` that inserts `Data_ref` in the linked list, but it as to remain sorted in ascending order. +Write a function `SortListInsert` that inserts `data_ref` in the linked list, but it as to remain sorted in ascending order. -- The list as to be alredy sorted. +- The list as to be alredy sorted. - Use pointers when ever you can. -## Expected function and structure +### Expected function and structure ```go -type Nodee struct { - Data int - Next *Nodee +type node struct { + data int + next *node } -func SortListInsert(l *Nodee, Data_ref int) *Nodee{ +func SortListInsert(l *node, data_ref int) *node{ } ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -34,34 +34,34 @@ import ( ) //Prints the list -func PrintList(l *Nodee) { +func PrintList(l *node) { m := l for m != nil { - fmt.Print(m.Data, " -> ") - m = m.Next + fmt.Print(m.data, " -> ") + m = m.next } fmt.Print(nil) fmt.Println() } //insert elements -func listPushBack(l *Nodee, Data int) { - n := &Nodee{} - n.Data = Data - n.Next = nil +func listPushBack(l *node, data int) { + n := &node{} + n.data = data + n.next = nil if l == nil { l = n return } iterator := l - for iterator.Next != nil { - iterator = iterator.Next + for iterator.next != nil { + iterator = iterator.next } - iterator.Next = n + iterator.next = n } func main() { - link := &Nodee{} + link := &node{} listPushBack(link, 1) listPushBack(link, 4) diff --git a/subjects/sortlistinsert.fr.md b/subjects/sortlistinsert.fr.md new file mode 100644 index 00000000..7db913a6 --- /dev/null +++ b/subjects/sortlistinsert.fr.md @@ -0,0 +1,44 @@ +## countif + +### Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +### Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortparams.en.md b/subjects/sortparams.en.md new file mode 100644 index 00000000..bd482d0a --- /dev/null +++ b/subjects/sortparams.en.md @@ -0,0 +1,21 @@ +## sortparams + +### Instructions + +Write a **program** that prints the arguments received in the command line in ASCII order. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./sortparams 1 a 2 A 3 b 4 C +1 +2 +3 +4 +A +C +a +b +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortparams.fr.md b/subjects/sortparams.fr.md new file mode 100644 index 00000000..f5c6e5ca --- /dev/null +++ b/subjects/sortparams.fr.md @@ -0,0 +1,21 @@ +## sortparams + +### Instructions + +Écrire un **programme** qui affiche les arguments en ligne de commande en ordre asscii. + +Exemple de résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./sortparams 1 a 2 A 3 b 4 C +1 +2 +3 +4 +A +C +a +b +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortwordarr.en.md b/subjects/sortwordarr.en.md new file mode 100644 index 00000000..f1e10c7c --- /dev/null +++ b/subjects/sortwordarr.en.md @@ -0,0 +1,42 @@ +## sortwordarr + +### Instructions + +Write a function `SortWordArr` that sorts by `ascii` a `string` array. + +### Expected function + +```go +func SortWordArr(array []string) { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} + piscine.SortWordArr(result) + + fmt.Println(result) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[1 2 3 A B C a b c] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortwordarr.fr.md b/subjects/sortwordarr.fr.md new file mode 100644 index 00000000..6a0d81d7 --- /dev/null +++ b/subjects/sortwordarr.fr.md @@ -0,0 +1,42 @@ +## sortwordarr + +### Instructions + +Écrire une fonction `SortWordArr` qui trie par ordre `ascii` un tableau de `string`. + +### Fonction attendue + +```go +func SortWordArr(array []string) { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} + piscine.SortWordArr(result) + + fmt.Println(result) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[1 2 3 A B C a b c] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/split.en.md b/subjects/split.en.md new file mode 100644 index 00000000..f1c3366c --- /dev/null +++ b/subjects/split.en.md @@ -0,0 +1,40 @@ +## split + +### Instructions + +Write a function that seperates the words of a `string` and puts them in a `string` array. + +The separators are the characters of the charset `string` given in parameter. + +### Expected function + +```go +func Split(str, charset string) []string { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "HelloHAhowHAareHAyou?" + fmt.Println(piscine.Split(str, charset, "HA")} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[Hello how are you?] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/split.fr.md b/subjects/split.fr.md new file mode 100644 index 00000000..efa7f9d4 --- /dev/null +++ b/subjects/split.fr.md @@ -0,0 +1,40 @@ +## split + +### Instructions + +Écrire une fonction qui sépare les mots d'une `string` et les met dans un tableau de `string`. + +Les séparateurs sont les charactéres de la `string` charset donnée en paramétre. + +### Fonction attendue + +```go +func Split(str, charset string) []string { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "HelloHAhowHAareHAyou?" + fmt.Println(piscine.Split(str, "HA")} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[Hello how are you?] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/splitwhitespaces.en.md b/subjects/splitwhitespaces.en.md new file mode 100644 index 00000000..e358921e --- /dev/null +++ b/subjects/splitwhitespaces.en.md @@ -0,0 +1,40 @@ +## splitwhitespaces + +### Instructions + +Write a function that separates the words of a `string` and puts them in a `string` array. + +The separators are spaces, tabs and newlines. + +### Expected function + +```go +func SplitWhiteSpaces(str string) []string { +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "Hello how are you?" + fmt.Println(piscine.SplitWhiteSpaces(str)} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[Hello how are you?] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/splitwhitespaces.fr.md b/subjects/splitwhitespaces.fr.md new file mode 100644 index 00000000..0f9776e1 --- /dev/null +++ b/subjects/splitwhitespaces.fr.md @@ -0,0 +1,40 @@ +## splitwhitespaces + +### Instructions + +Écrire une fonction qui sépare les mots d'une `string` et les met dans un tableau de `string`. + +Les séparateurs sont les espaces, les tabulations et les retours à la ligne. + +### Fonction attendue + +```go +func SplitWhiteSpaces(str string) []string { +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "Hello how are you?" + fmt.Println(piscine.SplitWhiteSpaces(str)} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[Hello how are you?] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sqrt.en.md b/subjects/sqrt.en.md new file mode 100644 index 00000000..c6a5373c --- /dev/null +++ b/subjects/sqrt.en.md @@ -0,0 +1,44 @@ +## sqrt + +### Intructions + +Write a function that returns the square root of the `int` passed as parameter if that square root is a whole number. Otherwise it returns `0`. + +### Expected function + +```go +func Sqrt(int nb) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.Sqrt(arg1)) + fmt.Println(piscine.Sqrt(arg2)) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +2 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sqrt.fr.md b/subjects/sqrt.fr.md new file mode 100644 index 00000000..076385ed --- /dev/null +++ b/subjects/sqrt.fr.md @@ -0,0 +1,44 @@ +## sqrt + +### Intructions + +Écrire une fonction qui renvoie la racine carré d'un `int` passé en paramètre as parameter si cette racine carré est un nombre entier. Autrement elle renvoie `0`. + +### Fonction attendue + +```go +func Sqrt(int nb) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.Sqrt(arg1)) + fmt.Println(piscine.Sqrt(arg2)) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +2 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/strlen.en.md b/subjects/strlen.en.md new file mode 100755 index 00000000..9e3e5dee --- /dev/null +++ b/subjects/strlen.en.md @@ -0,0 +1,41 @@ +## strlen + +### Instructions + +- Write a function that counts the characters of a string and that returns that count. + +### Expected function + +```go +func StrLen(str string) int { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "Hello World!" + nb := Piscine.StrLen(str) + fmt.Println(nb) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/strlen.fr.md b/subjects/strlen.fr.md new file mode 100755 index 00000000..a880e7ae --- /dev/null +++ b/subjects/strlen.fr.md @@ -0,0 +1,41 @@ +## strlen + +### Instructions + +- Écrire une fonction qui compte le nombre de caractères d'une chaîne et qui retourne le nombre trouvé. + +### Fonction attendue + +```go +func StrLen(str string) int { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "Hello World!" + nb := Piscine.StrLen(str) + fmt.Println(nb) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/strlen.md b/subjects/strlen.md deleted file mode 100644 index 2bae4d4d..00000000 --- a/subjects/strlen.md +++ /dev/null @@ -1,24 +0,0 @@ -# strlen - -## Instructions - -Write a function that returns the length of a string. - - - `len` is forbidden - -## Expected function and structure - -```go -func Strlen(str string) int { - -} -``` - -And its output : - -```console -student@ubuntu:~/piscine/test$ go build -student@ubuntu:~/piscine/test$ ./test -4 -student@ubuntu:~/piscine/test$ -``` diff --git a/subjects/strrev.en.md b/subjects/strrev.en.md new file mode 100755 index 00000000..a5ee9cd8 --- /dev/null +++ b/subjects/strrev.en.md @@ -0,0 +1,43 @@ +## strrev + +### Instructions + +- Write a function that reverses a `string`. + +- This function will **return** the s `string`. + +### Expected function + +```go +func StrRev(s string) string { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "Hello World!" + s = piscine.StrRev(s) + fmt.Println(s) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +!dlroW olleH +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/strrev.fr.md b/subjects/strrev.fr.md new file mode 100755 index 00000000..e8b34f35 --- /dev/null +++ b/subjects/strrev.fr.md @@ -0,0 +1,43 @@ +## strrev + +### Instructions + +- Écrire une fonction qui inverse une chaîne de caractères(`string`). + +- Cette fonction **retournera** la chaîne de caractères s(`string`). + +### Fonction attendue + +```go +func StrRev(s string) string { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "Hello World!" + s = piscine.StrRev(s) + fmt.Println(s) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +!dlroW olleH +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/swap.en.md b/subjects/swap.en.md new file mode 100755 index 00000000..82d0d04f --- /dev/null +++ b/subjects/swap.en.md @@ -0,0 +1,44 @@ +## swap + +### Instructions + +- Write a function that swaps the contents of two **pointers to an int** (`*int`). + +### Expected function + +```go +func Swap(a *int, b *int) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 0 + b := 1 + piscine.Swap(&a, &b) + fmt.Println(a) + fmt.Println(b) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/swap.fr.md b/subjects/swap.fr.md new file mode 100755 index 00000000..42fdc85f --- /dev/null +++ b/subjects/swap.fr.md @@ -0,0 +1,44 @@ +## swap + +### Instructions + +- Écrire une fonction qui échange les contenus de deux **pointeurs sur entier** (`*int`). + +### Fonction attendue + +```go +func Swap(a *int, b *int) { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 0 + b := 1 + piscine.Swap(&a, &b) + fmt.Println(a) + fmt.Println(b) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/swapbits.md b/subjects/swapbits.en.md similarity index 64% rename from subjects/swapbits.md rename to subjects/swapbits.en.md index cffe7d56..2e5bfafb 100644 --- a/subjects/swapbits.md +++ b/subjects/swapbits.en.md @@ -1,20 +1,27 @@ -# swapbits -## Instructions +## swapbits + +### Instructions Write a function that takes a byte, swaps its halves (like the example) and returns the result. Your function must be declared as follows: +```go func SwapBits(octet byte) byte { - ... + } +``` Example: - 1 byte -_____________ - 0100 | 0001 - \ / - / \ - 0001 | 0100 \ No newline at end of file +1 byte + +--- + +``` +0100 | 0001 + \ / + / \ +0001 | 0100 +``` diff --git a/subjects/switchcase.md b/subjects/switchcase.en.md similarity index 72% rename from subjects/switchcase.md rename to subjects/switchcase.en.md index d5602164..ef836406 100644 --- a/subjects/switchcase.md +++ b/subjects/switchcase.en.md @@ -1,8 +1,8 @@ -# switchcase +## switchcase -## Instructions +### Instructions -Write a program that takes a string and reverses the case of all its letters. +Write a program that takes a string and reverses the case of all its letters. - Other characters remain unchanged. @@ -10,13 +10,13 @@ Write a program that takes a string and reverses the case of all its letters. - If the number of arguments is not 1, the program displays '\n'. -## Expected output +### Expected output ```console student@ubuntu:~/piscine/test$ go build student@ubuntu:~/piscine/test$ ./test "SometHingS iS WronG" sOMEThINGs Is wRONg -student@ubuntu:~/piscine/test$ ./test +student@ubuntu:~/piscine/test$ ./test -student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/to-git-or-not-to-git.en.md b/subjects/to-git-or-not-to-git.en.md new file mode 100644 index 00000000..c312c410 --- /dev/null +++ b/subjects/to-git-or-not-to-git.en.md @@ -0,0 +1,15 @@ +## to-git-or-not-to-git-? + +### Instructions + +Write in a file `to-git-or-not-to-git.sh` the command that isolates your `gitHub id`. +Only the numbers will appears. + +### Usage + +```console +$ ./to-git-or-not-to-git.sh +231748 +$ +` +``` diff --git a/subjects/to-git-or-not-to-git.fr.md b/subjects/to-git-or-not-to-git.fr.md new file mode 100644 index 00000000..7e9c5ba7 --- /dev/null +++ b/subjects/to-git-or-not-to-git.fr.md @@ -0,0 +1,15 @@ +## to-git-or-not-to-git-? + +### Instructions + +Écrire dans un fichier `to-git-or-not-to-git.sh` la commande qui isoles votre `gitHub id`. +Seulement les chiffres apparaitront. + +### Utilisation + +```console +$ ./to-git-or-not-to-git.sh +231748 +$ +` +``` diff --git a/subjects/tolower.en.md b/subjects/tolower.en.md new file mode 100644 index 00000000..0f366d8a --- /dev/null +++ b/subjects/tolower.en.md @@ -0,0 +1,39 @@ +## tolower + +### Instructions + +Write a function that lowercases each letter of `string`. + +### Expected function + +```go +func ToLower(s string) string { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.ToLower("Hello! How are you?")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +hello! how are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/tolower.fr.md b/subjects/tolower.fr.md new file mode 100644 index 00000000..b709621b --- /dev/null +++ b/subjects/tolower.fr.md @@ -0,0 +1,39 @@ +## tolower + +### Instructions + +Écrire une fonction qui met en minuscule chaque lettre d'une `string`. + +### Fonction attendue + +```go +func ToLower(s string) string { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.ToLower("Hello! How are you?")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +hello! how are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/toupper.en.md b/subjects/toupper.en.md new file mode 100644 index 00000000..62aad29c --- /dev/null +++ b/subjects/toupper.en.md @@ -0,0 +1,39 @@ +## toupper + +### Instructions + +Write a function that capitalizes each letter of `string`. + +### Expected function + +```go +func ToUpper(s string) string { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.ToUpper("Hello! How are you?")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +HELLO! HOW ARE YOU? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/toupper.fr.md b/subjects/toupper.fr.md new file mode 100644 index 00000000..2750bf08 --- /dev/null +++ b/subjects/toupper.fr.md @@ -0,0 +1,39 @@ +## toupper + +### Instructions + +Écrire une fonction qui met en majuscule chaque lettre d'une `string`. + +### Fonction attendue + +```go +func ToUpper(s string) string { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.ToUpper("Hello! How are you?")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +HELLO! HOW ARE YOU? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ultimatedivmod.en.md b/subjects/ultimatedivmod.en.md new file mode 100755 index 00000000..0f07bd8c --- /dev/null +++ b/subjects/ultimatedivmod.en.md @@ -0,0 +1,48 @@ +## ultimatedivmod + +### Instructions + +- Write a function that will be formatted as below. + +### Expected function + +```go +func UltimateDivMod(a *int, b *int) { + +} +``` + +- This function will divide the int **a** and **b**. +- The result of this division will be stored in the int pointed by **a**. +- The remainder of this division will be stored in the int pointed by **b**. + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 13 + b := 2 + piscine.UltimateDivMod(&a, &b) + fmt.Println(a) + fmt.Println(b) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +6 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ultimatedivmod.fr.md b/subjects/ultimatedivmod.fr.md new file mode 100755 index 00000000..c4fe57c9 --- /dev/null +++ b/subjects/ultimatedivmod.fr.md @@ -0,0 +1,48 @@ +## ultimatedivmod + +### Instructions + +- Écrire une fonction qui aura le format ci-dessous. + +### Fonction attendue + +```go +func UltimateDivMod(a *int, b *int) { + +} +``` + +- Cette fonction divisera les int pointés par **a** et **b**. +- Le résultat de la division sera stocké dans l'int pointé par **a**. +- Le reste de cette division sera stocké dans l'int pointé par **b**. + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 13 + b := 2 + piscine.UltimateDivMod(&a, &b) + fmt.Println(a) + fmt.Println(b) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +6 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ultimatepointone.en.md b/subjects/ultimatepointone.en.md new file mode 100755 index 00000000..acbdb7e2 --- /dev/null +++ b/subjects/ultimatepointone.en.md @@ -0,0 +1,43 @@ +## ultimatepointone + +### Instructions + +- Write a function that takes a **pointer to a pointer to a pointer to an int** as argument and gives to this int the value of 1. + +### Expected function + +```go +func UltimatePointOne(n ***int) { + +} +``` + +### Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 0 + b := &a + n := &b + piscine.UltimatePointOne(&n) + fmt.Println(a) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ultimatepointone.fr.md b/subjects/ultimatepointone.fr.md new file mode 100755 index 00000000..8b4bdaad --- /dev/null +++ b/subjects/ultimatepointone.fr.md @@ -0,0 +1,43 @@ +## ultimatepointone + +### Instructions + +- Écrire une fonction qui prend un **pointeur sur pointeur sur pointeur sur int** en argument et qui assignes à cet int la valeur 1. + +### Fonction attendue + +```go +func UltimatePointOne(n ***int) { + +} +``` + +### Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 0 + b := &a + n := &b + piscine.UltimatePointOne(&n) + fmt.Println(a) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/union.md b/subjects/union.en.md similarity index 96% rename from subjects/union.md rename to subjects/union.en.md index ceeba1f8..6348bc42 100644 --- a/subjects/union.md +++ b/subjects/union.en.md @@ -1,5 +1,6 @@ -# union -## Instructions +## union + +### Instructions Write a program that takes two strings and displays, without doubles, the characters that appear in either one of the strings. diff --git a/subjects/unmatch.md b/subjects/unmatch.en.md similarity index 81% rename from subjects/unmatch.md rename to subjects/unmatch.en.md index 26c61a8b..b8ce76e7 100644 --- a/subjects/unmatch.md +++ b/subjects/unmatch.en.md @@ -1,21 +1,20 @@ -# join -## Instructions +## join + +### Instructions Write a function, Unmatch, that returns the element of the slice (arr) that does not have a correspondent pair. The function must have the next signature. -## Expected function +### Expected function ```go - func Unmatch(arr []int) int { } - ``` -## Usage +### Usage Here is a possible [program](TODO-LINK) to test your function : @@ -23,8 +22,8 @@ Here is a possible [program](TODO-LINK) to test your function : package main import ( - "fmt" - student ".." + "fmt" + student ".." ) func main() { @@ -40,5 +39,5 @@ And its output : student@ubuntu:~/student/unmatch$ go build student@ubuntu:~/student/unmatch$ ./unmatch 4 -student@ubuntu:~/student/unmatch$ +student@ubuntu:~/student/unmatch$ ``` diff --git a/subjects/wdmatch.md b/subjects/wdmatch.en.md similarity index 51% rename from subjects/wdmatch.md rename to subjects/wdmatch.en.md index abe62560..8eb821c5 100644 --- a/subjects/wdmatch.md +++ b/subjects/wdmatch.en.md @@ -1,19 +1,18 @@ -# switchcase +# wdmatch ## Instructions +Write a program that takes two strings and checks whether it is possible to write the first string with characters from the second string, while respecting the order in which these characters appear in the second string. -Write a program that takes two strings and checks whether it's possible to write the first string with characters from the second string, while respecting the order in which these characters appear in the second string. - -- If it's possible, the program displays the string followed by a `\n`, otherwise it simply displays a `\n`. +- If it is possible, the program displays the string followed by a `\n`, otherwise it simply displays a `\n`. - If the number of arguments is not 2, the program displays `\n`. -## Expected output +Example of output : ```console student@ubuntu:~/piscine/test$ go build -student@ubuntu:~/piscine/test$ ./test "faya" "fgvvfdxcacpolhyghbreda" +student@ubuntu:~/piscine/test$ ./test "faya" "fgvvfdxcacpolhyghbreda" faya student@ubuntu:~/piscine/test$ ./test "faya" "fgvvfdxcacpolhyghbred" @@ -21,7 +20,8 @@ student@ubuntu:~/piscine/test$ ./test "error" rrerrrfiiljdfxjyuifrrvcoojh student@ubuntu:~/piscine/test$ ./test "quarante deux" "qfqfsudf arzgsayns tsregfdgs sjytdekuoixq " quarante deux -student@ubuntu:~/piscine/test$ ./test -student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +student@ubuntu:~/piscine/test$ ./test + +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/who-are-you.en.md b/subjects/who-are-you.en.md new file mode 100644 index 00000000..f6e29717 --- /dev/null +++ b/subjects/who-are-you.en.md @@ -0,0 +1,13 @@ +## who-are-you + +### Instructions + +"You just woke up in a dark alley... +You can not remember who you are... +The only though that comes to your mind is a tag that says: `subjet Id: 70`" + +Create the file `who-are-you.sh` which will remind you who you are by showing your name only. + +- Where to look : https://raw.githubusercontent.com/kigiri/superhero-api/master/api/all.json + +- What to use : `curl` and `jq` diff --git a/subjects/who-are-you.fr.md b/subjects/who-are-you.fr.md new file mode 100644 index 00000000..0b6aa9dd --- /dev/null +++ b/subjects/who-are-you.fr.md @@ -0,0 +1,13 @@ +## who-are-you + +### Instructions + +"Vous venez de vous réveillez dans une allée sombre... +Vous n'arrivez pas à vous souvenir qui vous êtes... +Tout ce qui vous vient à l'esprit est une étiquette sur laquelle est écrite: `subjet Id: 70`" + +Créer le fichier `who-are-you.sh` qui vous rappellera qui vous êtes en affichant votre Nom. + +- Où chercher : https://raw.githubusercontent.com/kigiri/superhero-api/master/api/all.json + +- Quoi utiliser : `curl` et `jq` diff --git a/subjects/ztail.md b/subjects/ztail.en.md similarity index 94% rename from subjects/ztail.md rename to subjects/ztail.en.md index 8c7c424a..015a9c5d 100644 --- a/subjects/ztail.md +++ b/subjects/ztail.en.md @@ -1,5 +1,6 @@ -# ztail -## Instructions +## ztail + +### Instructions Write a program called ztail that does the same thing as the system command tail, but witch takes at least one file as argument. @@ -10,4 +11,3 @@ For this program you can use the "os" package. For the program to pass the test you should follow the convention for the return code of program in Unix sistems (see os.Exit) For more information consult the man page for tail. -