File: Tutorial_3.sor

package info (click to toggle)
libnumbertext 1.0.11-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,380 kB
  • sloc: python: 439; cpp: 395; java: 244; javascript: 108; makefile: 101; xml: 84; sh: 40
file content (94 lines) | stat: -rw-r--r-- 2,011 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Soros Tutorial Three πŸ› οΈ Hello, Real World!
#
# Using the simplest regex reference
# we solve a typical Soros problem, converting
# numbers to ordinal abbreviations.
#
#
# INTRODUCTION
#
# Syntax of a Soros program line:
#
# regex_pattern regex replacement
#
# The \0 (backslash zero) in the regex replacement
# is a reference for the input number.
#
# For example, the following program line match every
# input number and replace it by ownself, i.e. we get
# back the input number without any changes, as you can
# see in the right output list window after removing
# the # at the beginning of the line:

#.* \0

# TASK 1
#
# It’s possible to refer the input number multiple times
# in the same regex_replacement, combined with arbitrary
# text.
#
# Modify the *previous program line* to greet the input
# number double, as follows!
#
# 1 -> Hello, 1! Hi, 1!
# 2 -> Hello, 2! Hi, 2!



# TASK 2
#
# Complete the program of Tutorial 1 to handle all
# English ordinal abbreviations!
#
# Rules:
#
# I  Every word ending with 1, 2, 3 has got an
#    abbreviation ending with 1st, 2nd, 3rd,
#    for example, 1 -> 1st (first), 22 -> 22nd
#    (twenty-second), 103 -> 103rd (one hundred third).
#
# Ib Exception: numbers ending with 11, 12 or 13.
#    Example: 11 -> 11th (eleventh), 112 -> 112th
#    (one hundred twelfth), 1013 -> 1013th
#    (one thousand and thirteenth).
#
# II Other numbers get β€œth”. Example: 4 -> 4th (fourth).




SCROLL DOWN FOR SOLUTIONS
⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩








# SOLUTION – TASK 1
#
# .* HELLO, \0! HI, \0!



# SOLUTION – TASK 2
#
# The trick is there in the first line,
# a pattern to match all input
# ending with 1., for example, 10, 11, .. 19,
# 110, 111 etc.:
#
# .*1.  \0th
# .*1   \0st
# .*2   \0nd
# .*3   \0rd
# .*    \0th



########################################################
# CONGRATULATIONS – You have finished Tutorial Three! πŸ™‚
########################################################