Skip to content

Commit dcc526c

Browse files
committed
Fix challenge ordinal years
1 parent dd3a87d commit dcc526c

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/data/challenge/info.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,24 @@ export const info = {
9999
}
100100
})(),
101101
}
102+
103+
/// Get ordinal representation of challenge year
104+
export function nthYear(year) {
105+
const n = year - 2008 + 1
106+
const s = n % 100;
107+
if (s > 3 && s < 21) {
108+
return <>{n}<sup>th</sup></>;
109+
}
110+
switch (s % 10) {
111+
case 1: {
112+
return <>{n}<sup>st</sup></>;
113+
}
114+
case 2: {
115+
return <>{n}<sup>nd</sup></>;
116+
}
117+
case 3: {
118+
return <>{n}<sup>rd</sup></>;
119+
}
120+
}
121+
return <>{n}<sup>th</sup></>;
122+
}

src/pages/challenge/2023/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ on any questions that arise during the competition.
8484

8585
### Feedback
8686

87-
This is the 15th time this challenge is being run, and there are many possibilities for comparing CP
87+
This is the 16th time this challenge is being run, and there are many possibilities for comparing CP
8888
solvers. The rules try to make a sensible set of choices for the comparison. We welcome any comments
8989
or suggestions regarding the running of this challenge.
9090

src/pages/challenge/2024/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ on any questions that arise during the competition.
8686

8787
### Feedback
8888

89-
This is the 15th time this challenge is being run, and there are many possibilities for comparing CP
89+
This is the 17th time this challenge is being run, and there are many possibilities for comparing CP
9090
solvers. The rules try to make a sensible set of choices for the comparison. We welcome any comments
9191
or suggestions regarding the running of this challenge.
9292

src/pages/challenge/2025/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { info } from '@/data/challenge/info'
1+
import { info, nthYear} from '@/data/challenge/info'
22
import { Container } from '@/components/Container'
33
import { Footer } from '@/components/Footer'
44
import { Link } from '@/components/Link'
@@ -86,7 +86,7 @@ on any questions that arise during the competition.
8686

8787
### Feedback
8888

89-
This is the 15th time this challenge is being run, and there are many possibilities for comparing CP
89+
This is the {nthYear(year)} time this challenge is being run, and there are many possibilities for comparing CP
9090
solvers. The rules try to make a sensible set of choices for the comparison. We welcome any comments
9191
or suggestions regarding the running of this challenge.
9292

0 commit comments

Comments
 (0)