YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
|
|
@ -0,0 +1,32 @@
|
|||
* Reverse b string 25/06/2018
|
||||
PALINDRO CSECT
|
||||
USING PALINDRO,R13 base register
|
||||
B 72(R15) skip savearea
|
||||
DC 17F'0' savearea
|
||||
STM R14,R12,12(R13) prolog
|
||||
ST R13,4(R15) "
|
||||
ST R15,8(R13) "
|
||||
LR R13,R15 "
|
||||
LA R8,BB @b[1]
|
||||
LA R9,AA+L'AA-1 @a[n-1]
|
||||
LA R6,1 i=1
|
||||
LOOPI C R6,=A(L'AA) do i=1 to length(a)
|
||||
BH ELOOPI leave i
|
||||
MVC 0(1,R8),0(R9) substr(b,i,1)=substr(a,n-i+1,1)
|
||||
LA R8,1(R8) @b=@b+1
|
||||
BCTR R9,0 @a=@a-1
|
||||
LA R6,1(R6) i=i+1
|
||||
B LOOPI end do
|
||||
ELOOPI XPRNT AA,L'AA print a
|
||||
CLC BB,AA if b=a
|
||||
BNE SKIP
|
||||
XPRNT MSG,L'MSG then print msg
|
||||
SKIP L R13,4(0,R13) epilog
|
||||
LM R14,R12,12(R13) "
|
||||
XR R15,R15 "
|
||||
BR R14 exit
|
||||
AA DC CL32'INGIRUMIMUSNOCTEETCONSUMIMURIGNI' a
|
||||
BB DS CL(L'AA) b
|
||||
MSG DC CL23'IT IS A TRUE PALINDROME'
|
||||
YREGS
|
||||
END PALINDRO
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
;; Project : Palindrome detection
|
||||
;; Date : 2018/03/06
|
||||
;; Author : Gal Zsolt [~ CalmoSoft ~]
|
||||
;; Email : <calmosoft@gmail.com>
|
||||
|
||||
(defun palindrome(x)
|
||||
(if (string= x (reverse x))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
def palindrome(s)
|
||||
s == s.reverse
|
||||
end
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
def palindrome_imperative(s) : Bool
|
||||
mid = s.size / 2
|
||||
last = s.size - 1
|
||||
(0...s.size).each do |i|
|
||||
if s[i] != s[last - i]
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
require "benchmark"
|
||||
Benchmark.ips do |x|
|
||||
x.report("declarative") { palindrome("hannah") }
|
||||
x.report("imperative") { palindrome_imperative("hannah")}
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
declarative 21.96M ( 45.54ns) (± 6.90%) 32 B/op 1.49× slower
|
||||
imperative 32.8M ( 30.49ns) (± 3.29%) 0 B/op fastest
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
proc reverse(s): string =
|
||||
proc reverse(s: string): string =
|
||||
result = newString(s.len)
|
||||
for i,c in s:
|
||||
result[s.high - i] = c
|
||||
|
||||
proc isPalindrome(s): bool =
|
||||
proc isPalindrome(s: string): bool =
|
||||
s == reverse(s)
|
||||
|
||||
echo isPalindrome("FoobooF")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
REBOL [
|
||||
Title: "Palindrome Recognizer"
|
||||
Date: 2010-01-03
|
||||
Author: oofoe
|
||||
URL: http://rosettacode.org/wiki/Palindrome
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue