Skip to content

Instantly share code, notes, and snippets.

@maelfosso
Last active April 7, 2018 10:48
Show Gist options
  • Select an option

  • Save maelfosso/139844d7b28e2ee07b4afbf03efa4598 to your computer and use it in GitHub Desktop.

Select an option

Save maelfosso/139844d7b28e2ee07b4afbf03efa4598 to your computer and use it in GitHub Desktop.

Revisions

  1. maelfosso revised this gist Apr 7, 2018. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions frk.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    ```
    import sys

    chef_sub_str = [
    @@ -29,5 +28,4 @@
    result = result + 1

    # Print results
    print(result)
    ```
    print(result)
  2. maelfosso revised this gist Apr 7, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    # Introduction
    The problem comes from [**codechef**](https://www.codechef.com/problems/FRK)

    It is an example of how we will work in **GDG Yaounde**

    # My Solution
  3. maelfosso revised this gist Apr 7, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Introduction
    The problem comes from (codechef)[https://www.codechef.com/problems/FRK]
    The problem comes from [**codechef**](https://www.codechef.com/problems/FRK)
    It is an example of how we will work in **GDG Yaounde**

    # My Solution
  4. maelfosso revised this gist Apr 7, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    # Introduction
    The problem comes from (**codechef**)[https://www.codechef.com/problems/FRK]
    The problem comes from (codechef)[https://www.codechef.com/problems/FRK]
    It is an example of how we will work in **GDG Yaounde**

    # My Solution
    1. I create a vector containing substrings of length upper than 2 from the word `chef`.
  5. maelfosso revised this gist Apr 7, 2018. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # Introduction
    The problem comes from (**codechef**)[https://www.codechef.com/problems/FRK]

    # My Solution
    1. I create a vector containing substrings of length upper than 2 from the word `chef`.
    2. After reading all the username, I loop through them and and if an username contains one of the substring inside the vector create above then I will increment the result

    # Testing
    * Install `Python 3`
    * Run `python3 frk.py`
  6. maelfosso renamed this gist Apr 7, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion python → frk.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ```
    import sys

    chef_sub_str = [
    @@ -28,4 +29,5 @@
    result = result + 1

    # Print results
    print(result)
    print(result)
    ```
  7. maelfosso created this gist Apr 7, 2018.
    31 changes: 31 additions & 0 deletions python
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    import sys

    chef_sub_str = [
    'ch', 'che', 'chef',
    'he', 'hef',
    'ef'
    ]

    # Read the number of potential friends
    N = int(input())
    if not(1 <= N and N <= 5000):
    print("Error - ", N)

    # Read each friend and put it into the array
    users = []
    for i in range(N):
    u = str(input())

    if not(3 <= len(u) and len(u) <= 20) :
    sys.exit("Erreur ", u)

    users.append(u)

    # Find connections
    result = 0
    for u in users:
    if any(s in u for s in chef_sub_str):
    result = result + 1

    # Print results
    print(result)