Informatics1-2019/HW3

A MathWikiből
(Változatok közti eltérés)
(Example)
 
(egy szerkesztő 3 közbeeső változata nincs mutatva)
6. sor: 6. sor:
 
= Leap years (2 points)=
 
= Leap years (2 points)=
  
Match the leap years in this specific way: a positive integer divisible by 4, except multiples of 100.
+
Match the leap years in this specific way: a positive integer divisible by 4, except multiples of 100. And it shouldn't have a trailing zero on the beginning.
  
 
== Example==
 
== Example==
  
These should be '''match'''ed:
+
These should be '''matched''':
  
 
* 4
 
* 4
28. sor: 28. sor:
 
* 2
 
* 2
 
* 3
 
* 3
 +
* 004
 
* 5
 
* 5
 
* 9
 
* 9
37. sor: 38. sor:
 
* 100
 
* 100
 
* 0
 
* 0
 +
* 00
 +
* 0240
 
* 2000
 
* 2000
 
* 1600
 
* 1600
63. sor: 66. sor:
 
== Example==
 
== Example==
  
These should be ''match''ed:
+
These should be '''matched''':
  
 
* mammal
 
* mammal

A lap jelenlegi, 2019. október 7., 14:12-kori változata

REGEX

You have to write regular expressions matching specific patterns. Use this page: https://regex101.com/ and don't forget to set python flavor.

Tartalomjegyzék

Leap years (2 points)

Match the leap years in this specific way: a positive integer divisible by 4, except multiples of 100. And it shouldn't have a trailing zero on the beginning.

Example

These should be matched:

  • 4
  • 8
  • 12
  • 16
  • 160
  • 164
  • 1024
  • 2008
  • 2056
  • 20080
  • 1048576

These should not match:

  • 1
  • 2
  • 3
  • 004
  • 5
  • 9
  • 11
  • 13
  • 21
  • 22
  • 23
  • 100
  • 0
  • 00
  • 0240
  • 2000
  • 1600
  • 200800

Vowel harmony (2 points)

The expression should find words containing only lowercase, latin characters.

  • A word should be matched if it uses only the same vowel every time
  • contains at least two vowels
  • It can start with any number of consonants, or a vowel.
  • two vowels should not be next to each other.
  • it should match a whole word

Hint

For vowels you can use:

   [aeiou]

And for consonants:

   [^aeiou\s]

Also put \b in front and to the end, to make sure it matches a whole word.

Example

These should be matched:

  • mammal
  • mama
  • uru
  • chlorophorm
  • oppo
  • imimi
  • xerxes
  • these

These should not match:

  • mammut
  • url
  • choroid
  • opponent
  • coop
  • iii

Handing in

Write the two regular expressions in an email to info1hazi@gmail.com from your math account. The subject should be:

   A1_HW3_<username>

Deadline

2019. October 13th 23:59

Személyes eszközök