0.1.3 palindrome

This commit is contained in:
Rob Tillaart 2023-11-14 17:12:20 +01:00
parent d57d47b40c
commit 74ced9f875
7 changed files with 51 additions and 13 deletions

View File

@ -6,12 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.3] - 2023-11-14
- update readme.md
## [0.1.2] - 2022-11-19
- add RP2040 in build-CI
- add changelog.md
- update keywords.txt
## [0.1.1] - 2021-12-03
- add palindromeCount()
- add palindromePercentage()

View File

@ -5,10 +5,12 @@ palindrome KEYWORD1
# Methods and Functions (KEYWORD2)
isPalindrome KEYWORD2
findPalindrome KEYWORD2
findEvenPalindrome KEYWORD2
findOddPalindrome KEYWORD2
isPalindrome KEYWORD2
palindromeCount KEYWORD2
palindromePercentage KEYWORD2

View File

@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/palindrome.git"
},
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "palindrome.h"
}

View File

@ -1,5 +1,5 @@
name=palindrome
version=0.1.2
version=0.1.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Palindrome library

View File

@ -1,7 +1,7 @@
//
// FILE: palindrome.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library to do palindrome experiments.
// URL: https://github.com/RobTillaart/palindrome
@ -139,10 +139,10 @@ float palindrome::palindromePercentage(const char * str)
if (str == NULL) return 0;
int sl = strlen(str);
if (sl == 0) return 0;
if (sl % 2 == 1) sl++; // correction for odd length strings
if (sl % 2 == 1) sl++; // correction for odd length strings
return (200.0 * palindromeCount(str)) / sl;
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,7 +2,7 @@
//
// FILE: palindrome.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library to do palindrome experiments.
// URL: https://github.com/RobTillaart/palindrome
//
@ -10,7 +10,7 @@
#include "Arduino.h"
#define PALINDROME_LIB_VERSION (F("0.1.2"))
#define PALINDROME_LIB_VERSION (F("0.1.3"))
class palindrome
@ -32,6 +32,6 @@ class palindrome
};
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/palindrome/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/palindrome/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/palindrome/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/palindrome/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/palindrome/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/palindrome.svg)](https://github.com/RobTillaart/palindrome/issues)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/palindrome/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/palindrome.svg?maxAge=3600)](https://github.com/RobTillaart/palindrome/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/palindrome.svg)](https://registry.platformio.org/libraries/robtillaart/palindrome)
# Palindrome
@ -16,17 +19,30 @@ Library for palindrome search
The palindrome library can test if a string is a palindrome and is able to find
the longest palindrome within a character string.
This library is written mainly for some educational purpose, however other
applications are possible. Please share your ideas.
#### tests
The library is tested with an Arduino UNO, random string of 1600 characters.
(TODO performance compare)
## Interface
```cpp
#include "palindrome.h"
```
- **palindrome()** constructor.
- **int findPalindrome(const char \* str, int & position, int & length)** find the longest palindrome in a string. (first occurrence).
- **int findEvenPalindrome(const char \* str, int & position, int & length)** find the longest palindrome in a string with even length. (first occurrence).
- **int findOddPalindrome(const char \* str, int & position, int & length)** find the longest palindrome in a string with odd length. (first occurrence).
- **bool isPalindrome(const char \* str)** checks if a string is a palindrome.
- **int palindromeCount(const char \* str)** returns the count of matching pairs in a string. This is at most the ```length / 2 + 1```.
- **int palindromeCount(const char \* str)** returns the count of matching pairs in a string.
This is at most the ```length / 2 + 1```.
- **float palindromePercentage(const char \* str)** returns the count as percentage 0.0 .. 100.0 %
@ -42,8 +58,14 @@ The examples show the basic working of the functions.
## Future
#### Must
- update documentation
- should this be a class?
#### Should
#### Could
- function names?
- palindromeCount -- symmetryCount?
- palindromePercentage -- symmetryPercentage?
@ -54,3 +76,14 @@ The examples show the basic working of the functions.
- investigate case (in)sensitive flag?
- investigate ignore spaces flag?
#### Wont
## Support
If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.
Thank you,