Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -1,6 +1,6 @@
|
|||
A [[wp:Palindrome|palindrome]] is a phrase which reads the same backward and forward.
|
||||
|
||||
{{task heading}}
|
||||
{{task heading|Task}}
|
||||
|
||||
Write a function or program that checks whether a given sequence of characters (or, if you prefer, bytes)
|
||||
is a palindrome.
|
||||
|
|
|
|||
19
Task/Palindrome-detection/Ed/palindrome-detection.ed
Normal file
19
Task/Palindrome-detection/Ed/palindrome-detection.ed
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# by Artyom Bologov
|
||||
H
|
||||
,p
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
g/^(.)(.*)\1$/s//\2/
|
||||
v/^(.)(.+)\1$|^.?$/s/.*/Not a palindrome!/
|
||||
g/^.?$/s//Palindrome!/
|
||||
,p
|
||||
Q
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
isPalin1=: 0:`($:@(}.@}:))@.({.={:)`1:@.(1>:#)
|
||||
|
||||
isPalin2=: monad define
|
||||
if. 1>:#y do. 1 return. end.
|
||||
if. ({.={:)y do. isPalin2 }.}:y else. 0 end.
|
||||
)
|
||||
inexact=: [: (-:|.)@tolower [ ([-.-.) a. {~ 65 97 +"0 _ i.@26
|
||||
inexact 'A man, a plan, a canal: Panama!'
|
||||
1
|
||||
inexact 'Not palindrome...'
|
||||
0
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
foo=: foo,|.foo=:2000$a.
|
||||
ts=:6!:2,7!:2 NB. time and space required to execute sentence
|
||||
ts 'isPalin0 foo'
|
||||
2.73778e_5 5184
|
||||
ts 'isPalin1 foo'
|
||||
0.0306667 6.0368e6
|
||||
ts 'isPalin2 foo'
|
||||
0.104391 1.37965e7
|
||||
'isPalin1 foo' %&ts 'isPalin0 foo'
|
||||
1599.09 1164.23
|
||||
'isPalin2 foo' %&ts 'isPalin0 foo'
|
||||
3967.53 2627.04
|
||||
isPalin1=: 0:`($:@}.@}:)@.({.={:)`1:@.(1>:#)
|
||||
|
||||
isPalin2=: monad define
|
||||
if. 1>:#y do. 1 return. end.
|
||||
if. ({.={:)y do. isPalin2 }.}:y else. 0 end.
|
||||
)
|
||||
|
|
|
|||
12
Task/Palindrome-detection/J/palindrome-detection-5.j
Normal file
12
Task/Palindrome-detection/J/palindrome-detection-5.j
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
foo=: foo,|.foo=:2000$a.
|
||||
ts=:6!:2,7!:2 NB. time and space required to execute sentence
|
||||
ts 'isPalin0 foo'
|
||||
2.73778e_5 5184
|
||||
ts 'isPalin1 foo'
|
||||
0.0306667 6.0368e6
|
||||
ts 'isPalin2 foo'
|
||||
0.104391 1.37965e7
|
||||
'isPalin1 foo' %&ts 'isPalin0 foo'
|
||||
1599.09 1164.23
|
||||
'isPalin2 foo' %&ts 'isPalin0 foo'
|
||||
3967.53 2627.04
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
palindrome templates
|
||||
[$...] -> # !
|
||||
when <|=$(..:-1)> do '$...;' !
|
||||
end palindrome
|
||||
|
||||
[['rotor', 'racecar', 'level', 'rosetta']... -> palindrome ] !
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
!yamlscript/v0
|
||||
|
||||
defn main(n=31337):
|
||||
not =: when((n:S != n:S:reverse) ' not')
|
||||
say: "$n is$not a palindrome."
|
||||
Loading…
Add table
Add a link
Reference in a new issue