├── .gitignore ├── LICENSE ├── README.md ├── documents ├── days │ ├── d00.en.pdf │ ├── d01.en.pdf │ ├── d02.en.pdf │ ├── d03.en.pdf │ ├── d04.en.pdf │ ├── d05.en.pdf │ ├── d06.en.pdf │ ├── d07.en.pdf │ ├── d08.en.pdf │ ├── d09 │ │ ├── ex00.pdf │ │ ├── ex01.pdf │ │ ├── ex02.pdf │ │ ├── ex03.pdf │ │ ├── ex04.pdf │ │ ├── ex05.en.pdf │ │ ├── ex06.en.pdf │ │ ├── ex07.pdf │ │ ├── ex08.en.pdf │ │ ├── ex09.pdf │ │ ├── ex10.pdf │ │ ├── ex11.en.pdf │ │ ├── ex12.en.pdf │ │ ├── ex13.en.pdf │ │ ├── ex14.en.pdf │ │ ├── ex15.en.pdf │ │ ├── ex16.en.pdf │ │ ├── ex17.en.pdf │ │ ├── ex18.en.pdf │ │ ├── ex19.en.pdf │ │ ├── ex20.en.pdf │ │ ├── ex21.en.pdf │ │ ├── ex22.en.pdf │ │ └── ex23.pdf │ ├── d10.en.pdf │ ├── d11.en.pdf │ ├── d12.en.pdf │ └── d13.en.pdf ├── norme.en.pdf └── projects │ ├── bsq.en.pdf │ ├── group │ ├── colle00.en.pdf │ ├── colle01.en.pdf │ └── colle02.en.pdf │ └── individual │ ├── proj00.en.pdf │ ├── proj01.en.pdf │ └── proj02.en.pdf ├── images ├── marvin.jpg └── russian_dolls.jpg └── solutions ├── d00 ├── ex01 │ └── testDay00.tar ├── ex02 │ └── exo2.tar ├── ex03 │ └── klist.txt ├── ex04 │ └── who_am_i.sh ├── ex05 │ └── people.sh ├── ex06 │ └── mobile-phone.ldif ├── ex07 │ └── midLS ├── ex08 │ └── z ├── ex09 │ └── b ├── ex10 │ └── clean └── ex11 │ └── ft_magic ├── d01 ├── ex01 │ └── print_groups.sh ├── ex02 │ └── find_sh.sh ├── ex03 │ └── count_files.sh ├── ex04 │ └── MAC.sh ├── ex05 │ └── "\?$*'KwaMe'*$?\" ├── ex06 │ └── skip.sh ├── ex07 │ └── r_dwssap.sh ├── ex08 │ └── bon.sh └── ex09 │ └── add_chelou.sh ├── d02 ├── ex00 │ └── ft_print_alphabet.c ├── ex01 │ └── ft_print_reverse_alphabet.c ├── ex02 │ └── ft_print_numbers.c ├── ex03 │ └── ft_is_negative.c ├── ex04 │ └── ft_print_comb.c ├── ex05 │ └── ft_print_comb2.c ├── ex06 │ └── ft_putnbr.c └── ex07 │ └── ft_print_combn.c ├── d03 ├── ex00 │ └── ft_ft.c ├── ex01 │ └── ft_ultimate_ft.c ├── ex02 │ └── ft_swap.c ├── ex03 │ └── ft_div_mod.c ├── ex04 │ └── ft_ultimate_div_mod.c ├── ex05 │ └── ft_putstr.c ├── ex06 │ └── ft_strlen.c ├── ex07 │ └── ft_strrev.c ├── ex08 │ └── ft_atoi.c └── ex09 │ └── ft_sort_integer_table.c ├── d04 ├── ex00 │ └── ft_iterative_factorial.c ├── ex01 │ └── ft_recursive_factorial.c ├── ex02 │ └── ft_iterative_power.c ├── ex03 │ └── ft_recursive_power.c ├── ex04 │ └── ft_fibonacci.c ├── ex05 │ └── ft_sqrt.c ├── ex06 │ └── ft_is_prime.c ├── ex07 │ └── ft_find_next_prime.c ├── ex08 │ └── ft_eight_queens_puzzle.c └── ex09 │ └── ft_eight_queens_puzzle_2.c ├── rush00 └── ex00 │ ├── ft_putchar.c │ ├── main.c │ ├── rush00.c │ ├── rush01.c │ ├── rush02.c │ ├── rush03.c │ └── rush04.c └── sastantua └── ex00 └── sastantua.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.obj 7 | 8 | # Linker output 9 | *.map 10 | 11 | # Precompiled Headers 12 | *.gch 13 | 14 | # Libraries 15 | *.lib 16 | *.a 17 | *.la 18 | 19 | # Executables 20 | *.out 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # LICENSE :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: gicamerl +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2018/03/04 10:42:00 by gicamerl #+# #+# # 9 | # Updated: 2018/03/04 10:42:00 by gicamerl ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | This is a free work delivered for educational purposes during the main course 14 | at 42 <42.fr>. 15 | 16 | Feel free to use it, change it, give advices, send me a pull request or 17 | just slack me if you want to share some thoughts. 18 | 19 | In jurisdictions that recognize copyright laws, the author or authors 20 | of this software dedicate any and all copyright interest in the 21 | software to the public domain. We make this dedication for the benefit 22 | of the public at large and to the detriment of our heirs and 23 | successors. We intend this dedication to be an overt act of 24 | relinquishment in perpetuity of all present and future rights to this 25 | software under copyright law. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 29 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 30 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 31 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 32 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 33 | OTHER DEALINGS IN THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **Bootcamp C** 2 | 3 | 42 Piscine (Paris) 4 | 5 | ![Marvin](images/marvin.jpg) 6 | 7 | ### **Description** 8 | 9 | This project is based on 2 main sections: 10 | 11 | + **Documents** 12 | 13 | + Days 14 | + Projects 15 | 16 | + Group 17 | + Individual 18 | + Special (BSQ) 19 | 20 | + Norme 21 | 22 | + **Solutions** 23 | 24 | This is a **gift** for you, after **week 01** you have to swim on your own ;) 25 | 26 | *** 27 | 28 | The entire **bootcamp** lasts **25 days** and is divided as follows: 29 | 30 | | Week | Day | Group | Individual | Special | 31 | |------|---------|--------|-------------|---------| 32 | | 01 | 00 - 04 | Rush00 | Sastantua | - | 33 | | 02 | 05 - 09 | Rush01 | MatchnMatch | - | 34 | | 03 | 10 - 13 | Rush02 | Evalexpr | BSQ | 35 | 36 | Each week there will be a **4 hour exam**. The final exam lasts **8 hours**. Each exam is completely in an **offline** mode. 37 | 38 | **Day 09** is a special day and lasts **24 hours**, one exercise per hour. 39 | 40 | Stay **focus** and enjoy the time! 41 | 42 | ### **Credits** 43 | 44 | All the shared documents were prepared by **Staff 42**. 45 | 46 | ### **License** 47 | 48 | This work is published under the terms of **[42 Unlicense](https://github.com/gcamerli/42unlicense)**. 49 | 50 | ### **Donations** 51 | 52 | Donations are accepted at: 53 | 54 | + **BTC**: 152pyNwPRr22XWYdTuyHormznzu4PvPrWg 55 | -------------------------------------------------------------------------------- /documents/days/d00.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d00.en.pdf -------------------------------------------------------------------------------- /documents/days/d01.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d01.en.pdf -------------------------------------------------------------------------------- /documents/days/d02.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d02.en.pdf -------------------------------------------------------------------------------- /documents/days/d03.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d03.en.pdf -------------------------------------------------------------------------------- /documents/days/d04.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d04.en.pdf -------------------------------------------------------------------------------- /documents/days/d05.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d05.en.pdf -------------------------------------------------------------------------------- /documents/days/d06.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d06.en.pdf -------------------------------------------------------------------------------- /documents/days/d07.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d07.en.pdf -------------------------------------------------------------------------------- /documents/days/d08.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d08.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex00.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex00.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex01.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex02.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex02.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex03.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex03.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex04.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex04.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex05.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex05.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex06.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex06.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex07.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex07.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex08.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex08.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex09.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex09.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex10.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex11.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex11.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex12.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex12.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex13.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex13.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex14.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex14.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex15.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex15.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex16.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex16.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex17.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex17.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex18.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex18.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex19.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex19.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex20.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex20.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex21.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex21.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex22.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex22.en.pdf -------------------------------------------------------------------------------- /documents/days/d09/ex23.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d09/ex23.pdf -------------------------------------------------------------------------------- /documents/days/d10.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d10.en.pdf -------------------------------------------------------------------------------- /documents/days/d11.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d11.en.pdf -------------------------------------------------------------------------------- /documents/days/d12.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d12.en.pdf -------------------------------------------------------------------------------- /documents/days/d13.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/days/d13.en.pdf -------------------------------------------------------------------------------- /documents/norme.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/norme.en.pdf -------------------------------------------------------------------------------- /documents/projects/bsq.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/projects/bsq.en.pdf -------------------------------------------------------------------------------- /documents/projects/group/colle00.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/projects/group/colle00.en.pdf -------------------------------------------------------------------------------- /documents/projects/group/colle01.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/projects/group/colle01.en.pdf -------------------------------------------------------------------------------- /documents/projects/group/colle02.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/projects/group/colle02.en.pdf -------------------------------------------------------------------------------- /documents/projects/individual/proj00.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/projects/individual/proj00.en.pdf -------------------------------------------------------------------------------- /documents/projects/individual/proj01.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/projects/individual/proj01.en.pdf -------------------------------------------------------------------------------- /documents/projects/individual/proj02.en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/documents/projects/individual/proj02.en.pdf -------------------------------------------------------------------------------- /images/marvin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/images/marvin.jpg -------------------------------------------------------------------------------- /images/russian_dolls.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcamerli/bootcamp_c/a0dafde05b21730e75ffc87e6abbab1621d66528/images/russian_dolls.jpg -------------------------------------------------------------------------------- /solutions/d00/ex01/testDay00.tar: -------------------------------------------------------------------------------- 1 | testDay000000455000175000017500000000005012723653250011566 0ustar vihatvihat -------------------------------------------------------------------------------- /solutions/d00/ex02/exo2.tar: -------------------------------------------------------------------------------- 1 | test0/0000715000175000017500000000000013114060444011116 5ustar vihatvihattest10000714000175000017500000000000413114067370011043 0ustar vihatvihattest2/0000504000175000017500000000000013114076314011117 5ustar vihatvihattest30000404000175000017500000000000113114105240011023 0ustar vihatvihattest40000641000175000017500000000000213114105144011033 0ustar vihatvihattest50000404000175000017500000000000013114105240012010 1test3ustar vihatvihattest60000777000175000017500000000000013114073360012033 2test0ustar vihatvihat -------------------------------------------------------------------------------- /solutions/d00/ex03/klist.txt: -------------------------------------------------------------------------------- 1 | Credentials cache: API:C89F56D7-82B7-48A7-9356-F183E2C4C81D 2 | Principal: gicamerl@42.FR 3 | 4 | Issued Expires Principal 5 | Jul 3 13:23:30 2017 Jul 10 13:23:30 2017 krbtgt/42.FR@42.FR 6 | -------------------------------------------------------------------------------- /solutions/d00/ex04/who_am_i.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh who_am_i.sh 3 | 4 | ldapwhoami -Q | cut -c 4- 5 | # SASL Quiet mode 6 | -------------------------------------------------------------------------------- /solutions/d00/ex05/people.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh people.sh 3 | 4 | ldapsearch -Q "(uid=z*)" | grep "cn: " | sort -r | cut -c 5- 5 | -------------------------------------------------------------------------------- /solutions/d00/ex06/mobile-phone.ldif: -------------------------------------------------------------------------------- 1 | dn: uid=gicamerl,ou=2017_paris,ou=2017,ou=paris,ou=people,dc=42,dc=fr 2 | changetype: modify 3 | add: mobile 4 | mobile: +42 424242 5 | -------------------------------------------------------------------------------- /solutions/d00/ex07/midLS: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh midLS 3 | 4 | ls -mUp 5 | -------------------------------------------------------------------------------- /solutions/d00/ex08/z: -------------------------------------------------------------------------------- 1 | Z 2 | -------------------------------------------------------------------------------- /solutions/d00/ex09/b: -------------------------------------------------------------------------------- 1 | Episode V, A NEW H0PE It is a period of civil war 2 | Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. 3 | During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the STAR DEATH, an armored space station with enough power to destroy an entire planet. 4 | 5 | 6 | Pursued by the Empire's sinister agents, 7 | Princess Mehdi races home aboard her starship, custodian of the stolen plans that can save her people and restore the dictatorship to the galaxie.. 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /solutions/d00/ex10/clean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh clean 3 | 4 | find . \( -name "*~" -o -name "*#" -o -name "#*" \) -print -delete 5 | -------------------------------------------------------------------------------- /solutions/d00/ex11/ft_magic: -------------------------------------------------------------------------------- 1 | #------------------------------------------ 2 | # $File$ 3 | # ft_magic: file(1) magic for 42 file type 4 | # 5 | 6 | # 42 File Type Format 7 | +42 string 42 42 file 8 | -------------------------------------------------------------------------------- /solutions/d01/ex01/print_groups.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh print_groups.sh 3 | 4 | if [ "$FT_USER" ]; then 5 | groups $FT_USER | tr " " "," | tr -d "\n" 6 | fi 7 | -------------------------------------------------------------------------------- /solutions/d01/ex02/find_sh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh find_sh.sh | cat -e 3 | 4 | find . -name "*.sh" | rev | cut -c 4- | cut -d / -f 1 | rev 5 | -------------------------------------------------------------------------------- /solutions/d01/ex03/count_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh count_files.sh | cat -e 3 | 4 | find . -type f -o -type d | wc | awk '{print $1}' 5 | -------------------------------------------------------------------------------- /solutions/d01/ex04/MAC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh MAC.sh 3 | 4 | ifconfig | grep "ether" | awk '{print $2}' 5 | -------------------------------------------------------------------------------- /solutions/d01/ex05/"\?$*'KwaMe'*$?\": -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /solutions/d01/ex06/skip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh skip.sh 3 | 4 | ls -l | sed -n 'p;n' 5 | -------------------------------------------------------------------------------- /solutions/d01/ex07/r_dwssap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh r_dwssap.sh 3 | 4 | if ([ "FT_LINE1" ] && [ "FT_LINE2" ]); then 5 | cat /etc/passwd | grep -v "#" | awk 'NR%2==0' | cut -d : -f 1 | rev | sort -r |\ 6 | awk '{if (NR >= '$FT_LINE1' && NR <= '$FT_LINE2') print}' |\ 7 | tr '\n' ',' | sed 's/,/, /g' | rev | cut -c 3- | rev | tr '\n' '.' 8 | fi 9 | -------------------------------------------------------------------------------- /solutions/d01/ex08/bon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh bon.sh 2> /dev/null | cat -e 3 | 4 | ldapsearch -Q "sn=*bon*" | grep "sn: " | cut -c 5- | grep -i "bon" | wc | awk '{print $1}' 5 | -------------------------------------------------------------------------------- /solutions/d01/ex09/add_chelou.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # sh add_chelou.sh 3 | 4 | # Set 1 5 | #FT_NBR1=\\\'\?\"\\\"\'\\ 6 | #FT_NBR2=rcrdmddd 7 | 8 | # Set 2 9 | #FT_NBR1=\\\"\\\"\!\\\"\\\"\!\\\"\\\"\!\\\"\\\"\!\\\"\\\"\!\\\"\\\" 10 | #FT_NBR2=dcrcmcmooododmrrrmorcmcrmomo 11 | 12 | if ([ "$FT_NBR1" ] && [ "$FT_NBR2" ]); then 13 | echo $FT_NBR1 + $FT_NBR2 | tr "mrdoc" "01234" | tr "'\"?\!\\" "02341" | xargs echo "obase=13; ibase=5;" | bc |\ 14 | tr '0123456789ABC' 'gtaio luSnemf' 15 | fi 16 | -------------------------------------------------------------------------------- /solutions/d02/ex00/ft_print_alphabet.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_alphabet(void) 4 | { 5 | char c; 6 | 7 | c = 'a'; 8 | while (c <= 'z') 9 | { 10 | ft_putchar(c); 11 | c++; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /solutions/d02/ex01/ft_print_reverse_alphabet.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_reverse_alphabet(void) 4 | { 5 | char c; 6 | 7 | c = 'z'; 8 | while (c >= 'a') 9 | { 10 | ft_putchar(c); 11 | c--; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /solutions/d02/ex02/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_numbers(void) 4 | { 5 | char c; 6 | 7 | c = '0'; 8 | while (c <= '9') 9 | { 10 | ft_putchar(c); 11 | c++; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /solutions/d02/ex03/ft_is_negative.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_is_negative(int n) 4 | { 5 | if (n < 0) 6 | ft_putchar('N'); 7 | if (n >= 0) 8 | ft_putchar('P'); 9 | } 10 | -------------------------------------------------------------------------------- /solutions/d02/ex04/ft_print_comb.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_comb(void) 4 | { 5 | char i; 6 | char j; 7 | char k; 8 | 9 | i = '/'; 10 | while (i <= '9') 11 | { 12 | j = ++i; 13 | while (j <= '9') 14 | { 15 | k = ++j + 1; 16 | while (k <= '9') 17 | { 18 | ft_putchar(i); 19 | ft_putchar(j); 20 | ft_putchar(k); 21 | k++; 22 | if (i != '7') 23 | { 24 | ft_putchar(','); 25 | ft_putchar(' '); 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /solutions/d02/ex05/ft_print_comb2.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_putnbr(int nb) 4 | { 5 | if (nb >= 10) 6 | { 7 | ft_putnbr(nb / 10); 8 | ft_putnbr(nb % 10); 9 | } 10 | else 11 | { 12 | ft_putchar(nb + '0'); 13 | } 14 | } 15 | 16 | void ft_put_comb(int a, int b) 17 | { 18 | if (a < 10) 19 | { 20 | ft_putchar('0'); 21 | } 22 | ft_putnbr(a); 23 | ft_putchar(' '); 24 | if (b < 10) 25 | { 26 | ft_putchar('0'); 27 | } 28 | ft_putnbr(b); 29 | if (a != 98 || b != 99) 30 | { 31 | ft_putchar(','); 32 | ft_putchar(' '); 33 | } 34 | } 35 | 36 | void ft_print_comb2(void) 37 | { 38 | int a; 39 | int b; 40 | 41 | a = 0; 42 | while (a < 99) 43 | { 44 | b = a + 1; 45 | while (b <= 99) 46 | { 47 | ft_put_comb(a, b); 48 | b++; 49 | } 50 | a++; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /solutions/d02/ex06/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_putnbr(int nb) 4 | { 5 | if (nb > -2147483648 || nb <= 2147483647) 6 | { 7 | if (nb == -2147483648) 8 | { 9 | ft_putchar('-'); 10 | ft_putchar('2'); 11 | ft_putnbr(147483647); 12 | return ; 13 | } 14 | else if (nb >= 10) 15 | { 16 | ft_putnbr(nb / 10); 17 | ft_putnbr(nb % 10); 18 | } 19 | else if (nb < 0) 20 | { 21 | nb = -nb; 22 | ft_putchar('-'); 23 | ft_putnbr(nb); 24 | } 25 | else 26 | ft_putchar(nb + '0'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /solutions/d02/ex07/ft_print_combn.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_tab(int *tab, int n) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (i < n) 9 | { 10 | ft_putchar(tab[i] + '0'); 11 | i++; 12 | } 13 | } 14 | 15 | void ft_set_out(int *tab, int col, int n) 16 | { 17 | int i; 18 | 19 | while (1) 20 | { 21 | while (tab[col] == (9 + col - (n - 1)) && col >= 0) 22 | col--; 23 | if (col < 0) 24 | break ; 25 | tab[col]++; 26 | i = col + 1; 27 | while (i <= n) 28 | { 29 | tab[i] = tab[i - 1] + 1; 30 | i++; 31 | } 32 | col = n - 1; 33 | ft_putchar(','); 34 | ft_putchar(' '); 35 | ft_print_tab(tab, n); 36 | } 37 | } 38 | 39 | void ft_print_combn(int n) 40 | { 41 | int tab[n]; 42 | int i; 43 | int col; 44 | 45 | col = n - 1; 46 | if (n > 10) 47 | return ; 48 | i = 0; 49 | while (i <= n) 50 | { 51 | tab[i] = i; 52 | i++; 53 | } 54 | ft_print_tab(tab, n); 55 | ft_set_out(tab, col, n); 56 | } 57 | -------------------------------------------------------------------------------- /solutions/d03/ex00/ft_ft.c: -------------------------------------------------------------------------------- 1 | void ft_ft(int *nbr) 2 | { 3 | *nbr = 42; 4 | } 5 | -------------------------------------------------------------------------------- /solutions/d03/ex01/ft_ultimate_ft.c: -------------------------------------------------------------------------------- 1 | void ft_ultimate_ft(int *********nbr) 2 | { 3 | *********nbr = 42; 4 | } 5 | -------------------------------------------------------------------------------- /solutions/d03/ex02/ft_swap.c: -------------------------------------------------------------------------------- 1 | void ft_swap(int *a, int *b) 2 | { 3 | int temp; 4 | 5 | temp = *a; 6 | *a = *b; 7 | *b = temp; 8 | } 9 | -------------------------------------------------------------------------------- /solutions/d03/ex03/ft_div_mod.c: -------------------------------------------------------------------------------- 1 | void ft_div_mod(int a, int b, int *div, int * mod) 2 | { 3 | *div = a / b; 4 | *mod = a % b; 5 | } 6 | -------------------------------------------------------------------------------- /solutions/d03/ex04/ft_ultimate_div_mod.c: -------------------------------------------------------------------------------- 1 | void ft_ultimate_div_mod(int *a, int *b) 2 | { 3 | int temp; 4 | 5 | temp = *a; 6 | *a /= *b; 7 | *b = temp % *b; 8 | } 9 | -------------------------------------------------------------------------------- /solutions/d03/ex05/ft_putstr.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_putstr(char *str) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (str[i] != '\0') 9 | { 10 | ft_putchar(str[i]); 11 | i++; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /solutions/d03/ex06/ft_strlen.c: -------------------------------------------------------------------------------- 1 | int ft_strlen(char *str) 2 | { 3 | int i; 4 | 5 | i= 0; 6 | while (str[i] != '\0') 7 | { 8 | i++; 9 | } 10 | return (i); 11 | } 12 | -------------------------------------------------------------------------------- /solutions/d03/ex07/ft_strrev.c: -------------------------------------------------------------------------------- 1 | char *ft_strrev(char *str) 2 | { 3 | int i; 4 | int j; 5 | char temp; 6 | 7 | i = 0; 8 | j = 0; 9 | while (str[i] != '\0') 10 | { 11 | i++; 12 | } 13 | i = i - 1; 14 | while (i > j) 15 | { 16 | temp = str[i]; 17 | str[i] = str[j]; 18 | str[j] = temp; 19 | i--; 20 | j++; 21 | } 22 | return (str); 23 | } 24 | -------------------------------------------------------------------------------- /solutions/d03/ex08/ft_atoi.c: -------------------------------------------------------------------------------- 1 | int ft_atoi(char *str) 2 | { 3 | int i; 4 | int sign; 5 | int result; 6 | 7 | i = 0; 8 | sign = 1; 9 | result = 0; 10 | while ((str[i] >= 9 && str[i] <= 13) || (str[i] == 32)) 11 | i++; 12 | if (str[i] == '-' || str[i] == '+') 13 | { 14 | if (str[i + 1] >= '0' && str[i + 1] <= '9') 15 | { 16 | sign = (str[i] == '-') ? -1 : 1; 17 | i++; 18 | } 19 | else 20 | return (0); 21 | } 22 | while (str[i] >= '0' && str[i] <= '9') 23 | { 24 | result = result * 10 + str[i] - '0'; 25 | i++; 26 | } 27 | return (sign * result); 28 | } 29 | -------------------------------------------------------------------------------- /solutions/d03/ex09/ft_sort_integer_table.c: -------------------------------------------------------------------------------- 1 | void ft_sort_integer_table(int *tab, int size) 2 | { 3 | int i; 4 | int j; 5 | int temp; 6 | 7 | i = 1; 8 | while (i < size) 9 | { 10 | j = i; 11 | while (j > 0) 12 | { 13 | if (tab[j] < tab[j - 1]) 14 | { 15 | temp = tab[j]; 16 | tab[j] = tab[j - 1]; 17 | tab[j - 1] = temp; 18 | } 19 | j--; 20 | } 21 | i++; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /solutions/d04/ex00/ft_iterative_factorial.c: -------------------------------------------------------------------------------- 1 | int ft_iterative_factorial(int nb) 2 | { 3 | int i; 4 | int result; 5 | 6 | i = 1; 7 | result = 1; 8 | if (nb < 0 || nb >= 13) 9 | { 10 | return (0); 11 | } 12 | while (i <= nb && nb <= 12) 13 | { 14 | result *= i; 15 | i++; 16 | } 17 | return (result); 18 | } 19 | -------------------------------------------------------------------------------- /solutions/d04/ex01/ft_recursive_factorial.c: -------------------------------------------------------------------------------- 1 | int ft_recursive_factorial(int nb) 2 | { 3 | int result; 4 | 5 | if (nb >= 1 && nb <= 12) 6 | { 7 | result = nb * ft_recursive_factorial(nb - 1); 8 | return (result); 9 | } 10 | if (nb == 0) 11 | return (1); 12 | else 13 | return (0); 14 | } 15 | -------------------------------------------------------------------------------- /solutions/d04/ex02/ft_iterative_power.c: -------------------------------------------------------------------------------- 1 | int ft_iterative_power(int nb, int power) 2 | { 3 | int i; 4 | int result; 5 | 6 | i = 0; 7 | result = 1; 8 | if (nb >= 1 && power >= 1) 9 | { 10 | while (i < power) 11 | { 12 | result = nb * result; 13 | i++; 14 | } 15 | } 16 | else if (power == 0) 17 | return (1); 18 | else 19 | return (0); 20 | return (result); 21 | } 22 | -------------------------------------------------------------------------------- /solutions/d04/ex03/ft_recursive_power.c: -------------------------------------------------------------------------------- 1 | int ft_recursive_power(int nb, int power) 2 | { 3 | int result; 4 | 5 | if (nb != 0 && power >= 1) 6 | { 7 | result = nb * ft_recursive_power(nb, power - 1); 8 | return (result); 9 | } 10 | else if (power == 0) 11 | return (1); 12 | else 13 | return (0); 14 | } 15 | -------------------------------------------------------------------------------- /solutions/d04/ex04/ft_fibonacci.c: -------------------------------------------------------------------------------- 1 | int ft_fibonacci(int index) 2 | { 3 | int result; 4 | 5 | if (index == 0) 6 | return (0); 7 | else if (index == 1 || index == 2) 8 | return (1); 9 | else if (index >= 3 && index < 47) 10 | { 11 | result = ft_fibonacci(index - 1) + ft_fibonacci(index - 2); 12 | return (result); 13 | } 14 | else 15 | return (-1); 16 | } 17 | -------------------------------------------------------------------------------- /solutions/d04/ex05/ft_sqrt.c: -------------------------------------------------------------------------------- 1 | int ft_sqrt(int nb) 2 | { 3 | int root; 4 | 5 | root = 1; 6 | while (root * root != nb) 7 | { 8 | if (root / 2 > nb) 9 | break ; 10 | root++; 11 | } 12 | if (root * root == nb) 13 | return (root); 14 | else 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /solutions/d04/ex06/ft_is_prime.c: -------------------------------------------------------------------------------- 1 | int ft_is_prime(int nb) 2 | { 3 | int i; 4 | int max; 5 | 6 | i = 2; 7 | max = 2147483647; 8 | if (nb <= 1) 9 | return (0); 10 | while (i <= (nb / 2) && nb < max) 11 | { 12 | if (nb % i == 0) 13 | return (0); 14 | i++; 15 | } 16 | return (1); 17 | } 18 | -------------------------------------------------------------------------------- /solutions/d04/ex07/ft_find_next_prime.c: -------------------------------------------------------------------------------- 1 | int ft_is_prime(int nb) 2 | { 3 | int i; 4 | int max; 5 | 6 | i = 2; 7 | max = 2147483647; 8 | if (nb <= 1) 9 | return (0); 10 | while (i <= (nb / 2) && nb < max) 11 | { 12 | if (nb % i == 0) 13 | return (0); 14 | i++; 15 | } 16 | return (1); 17 | } 18 | 19 | int ft_find_next_prime(int nb) 20 | { 21 | if (nb <= 2) 22 | return (2); 23 | nb += (nb % 2) ? 0 : 1; 24 | while (!ft_is_prime(nb)) 25 | nb += 2; 26 | return (nb); 27 | } 28 | -------------------------------------------------------------------------------- /solutions/d04/ex08/ft_eight_queens_puzzle.c: -------------------------------------------------------------------------------- 1 | #define DIFF(a, b) ((a < b) ? (b - a) : (a - b)) 2 | 3 | int ft_solve(int n, int col, int *hist) 4 | { 5 | int i; 6 | int j; 7 | int count; 8 | 9 | count = 0; 10 | if (col == n) 11 | count++; 12 | i = 0; 13 | while (i < n) 14 | { 15 | j = 0; 16 | while (j < col && !(hist[j] == i) && !(DIFF(hist[j], i) == col - j)) 17 | j++; 18 | if (j < col) 19 | { 20 | i++; 21 | continue; 22 | } 23 | hist[col] = i; 24 | count += ft_solve(n, col + 1, hist); 25 | i++; 26 | } 27 | return (count); 28 | } 29 | 30 | int ft_eight_queens_puzzle(void) 31 | { 32 | int hist[8]; 33 | 34 | return (ft_solve(8, 0, hist)); 35 | } 36 | -------------------------------------------------------------------------------- /solutions/d04/ex09/ft_eight_queens_puzzle_2.c: -------------------------------------------------------------------------------- 1 | #define DIFF(a, b) ((a < b) ? (b - a) : (a - b)) 2 | 3 | void ft_putchar(char c); 4 | 5 | void ft_print_layout(int *list) 6 | { 7 | int i; 8 | 9 | i = 0; 10 | while (i < 8) 11 | ft_putchar((char)list[i++] + 48 + 1); 12 | ft_putchar('\n'); 13 | } 14 | 15 | int ft_solve_2(int n, int col, int *hist) 16 | { 17 | int i; 18 | int j; 19 | int count; 20 | 21 | count = 0; 22 | if (col == n) 23 | count++; 24 | if (col == n) 25 | ft_print_layout(hist); 26 | i = 0; 27 | while (i < n) 28 | { 29 | j = 0; 30 | while (j < col && !(hist[j] == i) && !(DIFF(hist[j], i) == col - j)) 31 | j++; 32 | if (j < col) 33 | i++; 34 | if (j < col) 35 | continue ; 36 | hist[col] = i; 37 | count += ft_solve_2(n, col + 1, hist); 38 | i++; 39 | } 40 | return (count); 41 | } 42 | 43 | int ft_eight_queens_puzzle_2(void) 44 | { 45 | int hist[8]; 46 | 47 | return (ft_solve_2(8, 0, hist)); 48 | } 49 | -------------------------------------------------------------------------------- /solutions/rush00/ex00/ft_putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void ft_putchar(char c) 4 | { 5 | write(1, &c, 1); 6 | } 7 | -------------------------------------------------------------------------------- /solutions/rush00/ex00/main.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | char rush(int x, int y); 3 | 4 | int main(void) 5 | { 6 | rush(42, 42); 7 | return (0); 8 | } 9 | -------------------------------------------------------------------------------- /solutions/rush00/ex00/rush00.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_row(int x, char a, char b, char c) 4 | { 5 | int i; 6 | 7 | if (x == 1) 8 | { 9 | ft_putchar(a); 10 | ft_putchar('\n'); 11 | } 12 | if (x > 1) 13 | { 14 | i = 2; 15 | ft_putchar(a); 16 | while (i < x) 17 | { 18 | ft_putchar(b); 19 | i++; 20 | } 21 | ft_putchar(c); 22 | ft_putchar('\n'); 23 | } 24 | } 25 | 26 | void rush(int x, int y) 27 | { 28 | int i; 29 | int min; 30 | 31 | min = 0; 32 | if ((x > min) && (y > min)) 33 | { 34 | if (y == 1) 35 | ft_print_row(x, 'o', '-', 'o'); 36 | if (y > 1) 37 | { 38 | i = 2; 39 | ft_print_row(x, 'o', '-', 'o'); 40 | while (i < y) 41 | { 42 | ft_print_row(x, '|', ' ', '|'); 43 | i++; 44 | } 45 | ft_print_row(x, 'o', '-', 'o'); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /solutions/rush00/ex00/rush01.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_row(int x, char a, char b, char c) 4 | { 5 | int i; 6 | 7 | if (x == 1) 8 | { 9 | ft_putchar(a); 10 | ft_putchar('\n'); 11 | } 12 | if (x > 1) 13 | { 14 | i = 2; 15 | ft_putchar(a); 16 | while (i < x) 17 | { 18 | ft_putchar(b); 19 | i++; 20 | } 21 | ft_putchar(c); 22 | ft_putchar('\n'); 23 | } 24 | } 25 | 26 | void rush(int x, int y) 27 | { 28 | int i; 29 | int min; 30 | 31 | min = 0; 32 | if ((x > min) && (y > min)) 33 | { 34 | if (y == 1) 35 | ft_print_row(x, '/', '*', '\\'); 36 | if (y > 1) 37 | { 38 | i = 2; 39 | ft_print_row(x, '/', '*', '\\'); 40 | while (i < y) 41 | { 42 | ft_print_row(x, '*', ' ', '*'); 43 | i++; 44 | } 45 | ft_print_row(x, '\\', '*', '/'); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /solutions/rush00/ex00/rush02.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_row(int x, char a, char b, char c) 4 | { 5 | int i; 6 | 7 | if (x == 1) 8 | { 9 | ft_putchar(a); 10 | ft_putchar('\n'); 11 | } 12 | if (x > 1) 13 | { 14 | i = 2; 15 | ft_putchar(a); 16 | while (i < x) 17 | { 18 | ft_putchar(b); 19 | i++; 20 | } 21 | ft_putchar(c); 22 | ft_putchar('\n'); 23 | } 24 | } 25 | 26 | void rush(int x, int y) 27 | { 28 | int i; 29 | int min; 30 | 31 | min = 0; 32 | if ((x > min) && (y > min)) 33 | { 34 | if (y == 1) 35 | ft_print_row(x, 'A', 'B', 'A'); 36 | if (y > 1) 37 | { 38 | i = 2; 39 | ft_print_row(x, 'A', 'B', 'A'); 40 | while (i < y) 41 | { 42 | ft_print_row(x, 'B', ' ', 'B'); 43 | i++; 44 | } 45 | ft_print_row(x, 'C', 'B', 'C'); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /solutions/rush00/ex00/rush03.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_row(int x, char a, char b, char c) 4 | { 5 | int i; 6 | 7 | if (x == 1) 8 | { 9 | ft_putchar(a); 10 | ft_putchar('\n'); 11 | } 12 | if (x > 1) 13 | { 14 | i = 2; 15 | ft_putchar(a); 16 | while (i < x) 17 | { 18 | ft_putchar(b); 19 | i++; 20 | } 21 | ft_putchar(c); 22 | ft_putchar('\n'); 23 | } 24 | } 25 | 26 | void rush(int x, int y) 27 | { 28 | int i; 29 | int min; 30 | 31 | min = 0; 32 | if ((x > min) && (y > min)) 33 | { 34 | if (y == 1) 35 | ft_print_row(x, 'A', 'B', 'C'); 36 | if (y > 1) 37 | { 38 | i = 2; 39 | ft_print_row(x, 'A', 'B', 'C'); 40 | while (i < y) 41 | { 42 | ft_print_row(x, 'B', ' ', 'B'); 43 | i++; 44 | } 45 | ft_print_row(x, 'A', 'B', 'C'); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /solutions/rush00/ex00/rush04.c: -------------------------------------------------------------------------------- 1 | void ft_putchar(char c); 2 | 3 | void ft_print_row(int x, char a, char b, char c) 4 | { 5 | int i; 6 | 7 | if (x == 1) 8 | { 9 | ft_putchar(a); 10 | ft_putchar('\n'); 11 | } 12 | if (x > 1) 13 | { 14 | i = 2; 15 | ft_putchar(a); 16 | while (i < x) 17 | { 18 | ft_putchar(b); 19 | i++; 20 | } 21 | ft_putchar(c); 22 | ft_putchar('\n'); 23 | } 24 | } 25 | 26 | void rush(int x, int y) 27 | { 28 | int i; 29 | int min; 30 | 31 | min = 0; 32 | if ((x > min) && (y > min)) 33 | { 34 | if (y == 1) 35 | ft_print_row(x, 'A', 'B', 'C'); 36 | if (y > 1) 37 | { 38 | i = 2; 39 | ft_print_row(x, 'A', 'B', 'C'); 40 | while (i < y) 41 | { 42 | ft_print_row(x, 'B', ' ', 'B'); 43 | i++; 44 | } 45 | ft_print_row(x, 'C', 'B', 'A'); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /solutions/sastantua/ex00/sastantua.c: -------------------------------------------------------------------------------- 1 | int ft_putchar(char c); 2 | 3 | void ft_put_line(int space, int length) 4 | { 5 | int i; 6 | 7 | i = 0; 8 | while (i++ < space) 9 | ft_putchar(' '); 10 | i = 0; 11 | ft_putchar('/'); 12 | while (i++ < length) 13 | ft_putchar('*'); 14 | ft_putchar('\\'); 15 | ft_putchar('\n'); 16 | } 17 | 18 | void ft_put_line_door(int space, int length, int door_size) 19 | { 20 | int i; 21 | int y; 22 | 23 | i = 0; 24 | y = door_size; 25 | while (i++ < space) 26 | ft_putchar(' '); 27 | i = 0; 28 | ft_putchar('/'); 29 | while (i++ < length) 30 | ft_putchar('*'); 31 | i = 0; 32 | while (y--) 33 | { 34 | if (y == 1 && door_size / 2 == space && door_size > 3) 35 | ft_putchar('$'); 36 | else 37 | ft_putchar('|'); 38 | } 39 | while (i++ < length) 40 | ft_putchar('*'); 41 | ft_putchar('\\'); 42 | ft_putchar('\n'); 43 | } 44 | 45 | void ft_put_sastantua(int length_total, int size, int start_door) 46 | { 47 | int current_floor; 48 | int current_line; 49 | int length; 50 | int shift; 51 | int space; 52 | 53 | current_floor = 0; 54 | length = -1; 55 | shift = 2; 56 | while (current_floor++ < size) 57 | { 58 | current_line = 1; 59 | while (current_line++ <= (current_floor + 2)) 60 | { 61 | length += 1; 62 | space = ((length_total / 2) - length - 1); 63 | if (current_floor == size && current_line > (size + 3) - start_door) 64 | ft_put_line_door(space, length - (start_door / 2), start_door); 65 | else 66 | ft_put_line(space, (length * 2) + 1); 67 | } 68 | if (current_floor % 2 && current_floor > 1) 69 | shift++; 70 | length += shift; 71 | } 72 | } 73 | 74 | void sastantua(int size) 75 | { 76 | int current_floor; 77 | int current_line; 78 | int length; 79 | int shift; 80 | int start_door; 81 | 82 | current_floor = 0; 83 | length = -1; 84 | shift = 2; 85 | while (current_floor++ < size) 86 | { 87 | current_line = 1; 88 | while (current_line++ <= (current_floor + 2)) 89 | length += 1; 90 | if (current_floor % 2 && current_floor > 1) 91 | shift++; 92 | length += shift; 93 | } 94 | start_door = size - 1; 95 | if (size % 2) 96 | start_door++; 97 | ft_put_sastantua(((length - shift) * 2) + 3, size, start_door); 98 | } 99 | --------------------------------------------------------------------------------