How would you design a program that will take in a string of lower case letters and produce the string upside down?
so if I type in home
i get ǝɯoɥ upside down.
I've tried looking for in the book to get started, but nothing.
Try this, a bit of a brute-force approach but works quite well for uppercase, lowercase and number characters - all other characters are presented just as they come:
(define upside-map '#hash(
(#\a . #\ɐ) (#\b . #\q) (#\c . #\ɔ) (#\d . #\p) (#\e . #\ǝ) (#\f . #\ɟ)
(#\g . #\ƃ) (#\h . #\ɥ) (#\i . #\ı) (#\j . #\ɾ) (#\k . #\ʞ) (#\l . #\ן)
(#\m . #\ɯ) (#\n . #\u) (#\o . #\o) (#\p . #\d) (#\q . #\b) (#\r . #\ɹ)
(#\s . #\s) (#\t . #\ʇ) (#\u . #\n) (#\v . #\ʌ) (#\w . #\ʍ) (#\x . #\x)
(#\y . #\ʎ) (#\z . #\z) (#\A . #\∀) (#\B . #\𐐒) (#\C . #\Ɔ) (#\D . #\◖)
(#\E . #\Ǝ) (#\F . #\Ⅎ) (#\G . #\⅁) (#\H . #\H) (#\I . #\I) (#\J . #\s)
(#\K . #\⋊) (#\L . #\˥) (#\M . #\W) (#\N . #\N) (#\O . #\O) (#\P . #\Ԁ)
(#\Q . #\Ό) (#\R . #\ᴚ) (#\S . #\S) (#\T . #\⊥) (#\U . #\∩) (#\V . #\Λ)
(#\W . #\M) (#\X . #\X) (#\Y . #\⅄) (#\Z . #\Z) (#\0 . #\0) (#\1 . #\Ɩ)
(#\2 . #\ᄅ) (#\3 . #\Ɛ) (#\4 . #\ㄣ) (#\5 . #\ϛ) (#\6 . #\9) (#\7 . #\ㄥ)
(#\8 . #\8) (#\9 . #\6)))
(define (flip-string str)
(list->string
(map (lambda (c)
(hash-ref upside-map c (const c)))
(reverse (string->list str)))))
For example:
(flip-string "Hello World")
=> "pןɹoM oןןǝH"
For reference, I used this conversion table taken from Wikipedia. The above solution has a little wrinkle: I couldn't manage to make it work for the 𐐒 character (flipped B), with unicode value of #\u10412 - because it won't fit in a 16-bit unicode character, so it can't be represented. I wasn't aware that Racket doesn't support characters with an encoding requiring more than 16 bits.
first of all your website must support Unicode, Unicode consists thousands of characters, the first 127 of Unicode are ASCII. It is possible to create text that appears to be upside down by converting character by character to a Unicode sign that looks like the upside down version of the character, for example to convert "6" you can use "9" but the flipped version of "f" is "ɟ", which is a Latin character with Unicode number 607 (hex code 025F)
technically, you need two text area boxes, one for the original text and the other one for the flipped text, also you need a Javascript, use the onkeyup Javascript hook in the first text box to call an upsideDownText() function each time a key is released like this:
<textarea rows="5" cols="70" id="src" onkeyup="upsideDownText()"></textarea>
then do the text processing in the upsideDownText() Javascript function like this:
<script type="text/javascript">
function upsideDownText() {
var srcText = document.getElementById( 'src' ).value.toLowerCase();
var out = '';
for( var i = srcText.length - 1; i >= 0; --i ) {
var ch = srcText.charAt( i );
if( ch == 'a' ) {
out += '\u0250' }
} else if( ch == 'b' ) {
out += 'q' }
} else if( ch == 'c' ) {
out += '\u0254'
// etc....
} else {
out += ch
}
}
document.getElementById( 'dest' ).value = out;
}
</script>
get the content of the text box identified by id="src" and convert the string to lowercase using the toLowerCase() method. Then loop through the string, character by character, starting from the end of the string. A big if-then-else-if block handles the character conversion. finally push the converted string into the text box identified by id="dest", which is the lower text box.
you can find the full list of how doing this step by step from Source twiki.org
Related
Thanks for the reaching out to my question, but i have got a problem, I'm trying to Import an excel file with multiple sheets.
Find sheets by some cell-value validation, like if on cell E7, i have a value, store this sheet as separate file. I'm doing mapping() for cell values, and then trying to use Excel::store to save each individual sheet separately. Can't receive any data for individual sheets
Also store the original file. This works!
The issue is, i can't receive any data for storing individual-sheets as excel files, i can create the individual excel files, but no data is being received, or maybe i'm not using the right data-format mentioned on documentation.
Please also check the code. Any help would be appreciated.
public function mapping(): array
{
return [
'altafit_id' => 'E7',
'year' => 'B3',
'initial_month' => 'B4',
'final_month' => 'B5',
];
}
public function model(array $row)
{
// dd($row);
$name = $row['altafit_id'];
$year = $row['year'];
$initial_month = $row['initial_month'];
$final_month = $row['final_month'];
$file_type = 'club';
// dd(collect((object) $row));
Excel::store(collect((object) $row), 'P&L_' . $name . '_' . $year . '_' . $initial_month . '_06' . ',clubs' . ',' . $initial_month . ',' . $final_month . '.' . 'xls', 'public');
return new Files([
//'user_id' => $row['user_id'],
'file_name' => 'P&L_' . $name . '_' . $year . '_' . $initial_month . '_06' . ',clubs' . ',' . $initial_month . ',' . $final_month . '.' . 'xls',
'file_type' => $file_type
]);
}
Already check the documentation, but doesn't work for me.
https://docs.laravel-excel.com/3.1/getting-started/
I have a CSV file with name,area,city fieds and I'm expecting that CSV with following fields name,area,city,latitude,longitude
Can any one suggest which API is best for these,
I already tried
Google API's
Textsearch: this is giving overall city wise. Not particular
eg: kfc, in jp nagar 1st phase, bangalore it throws all over bangalore kfc list
I want exactly
echo $url = "https://maps.googleapis.com/maps/api/geocode/json?address=" . $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;
Which API will fulfill my requirement?
I tried this also
$url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=". $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;
I'm working with CI and it is successfully echoing the proper expire date, but I am also getting this error:
A non well formed numeric value encountered
$expire_datetime = date('g:ia \o\n l jS F Y',strtotime($row->created, "+2weeks"));
echo $expire_datetime;
All you coding is correct. problem is with +2weeks. When you use strtotime() function you need to keep <space> on between text(+2<SPACE>weeks).
Examples(from W3Schools)
<?php
echo(strtotime("now") . "<br>");
echo(strtotime("3 October 2005") . "<br>");
echo(strtotime("+5 hours") . "<br>");
echo(strtotime("+1 week") . "<br>");
echo(strtotime("+1 week 3 days 7 hours 5 seconds") . "<br>");
echo(strtotime("next Monday") . "<br>");
echo(strtotime("last Sunday"));
?>
So your Final Well form code is
$expire_datetime = date('g:ia \o\n l jS F Y',strtotime($row->created, "+2 weeks"));
strtotime() function requires relative date format in first argument. Second argument is optional and can be unix time stamp.
Ive got the error below
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\xampp\htdocs\suitecrm\include\Smarty\Smarty_Compiler.class.php on line 268
I have changed the PHP.ini file to stop showing deprecated errors, but it still shows up
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
I've also changed the line in the Smarty_Compiler.class
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);
But its not working..
Please advise
I found that and it seems working:
Replace lines from line 262 with:
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search,
function($m) {
return "{php ".str_repeat("\n", substr_count($m[0], "\n"))."}";
},
$source_content);
I have resolved this issue by replacing the code in include/Smarty/Smarty_Compiler.class.php file. I replaced the code on line numbers from 262 to 268 with the below mentioned code. After that delete all the files which are in the cache folder and reload the page. This issue will be resolved.
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);
My solution:
$source_content = preg_replace_callback($search,
function($m) {
return $this->_quote_replace($this->left_delimiter) .
"php ".str_repeat("\n", substr_count($m[0], "\n")) .
$this->_quote_replace($this->right_delimiter);
},
$source_content);
In solution from Axel De Acetis I miss using of function $this->_quote_replace.
In solution from Sandeep Shivhare I dont like the number 1 in $matches[1], it references wrong string.
this is the dds for my screen:
<pre>
<code>
A DSPSIZ(27 132 *DS4)
A R ASSUME
A ASSUME
A OVERLAY
A 1 3' '
A R SFLSEL SFL
A SFLNXTCHG
A SEL 1A B 4 2VALUES(' ' '1')
A 43 DSPATR(ND)
A 43 DSPATR(PR)
A FLDFET 8Y 0O 4 5EDTWRD(' / / ')
A FLDUSE 10A O 4 37
A FLDHOR 6Y 0O 4 28EDTWRD(' : : ')
A FLDFEC 8Y 0O 4 17EDTWRD(' / / ')
A FLDPER 20A H
A R CTRSEL SFLCTL(SFLSEL)
A CF03(03 'Salir')
A KEEP
A OVERLAY
A SFLCSRRRN(&RRN)
A 80 SFLDSP
A 81 SFLDSPCTL
A 82 SFLINZ
A 83 SFLCLR
A 40 SFLEND(*MORE)
A SFLSIZ(9999)
A SFLPAG(0008)
A WINDOW(*DFT 13 50)
A WDWBORDER((*COLOR BLU))
A WDWTITLE((*TEXT 'Intro = Continuar -
A F3 = Salir') *CENTER *BOTTOM)
A WDWTITLE((*TEXT 'CONSULTAR REVISION-
A ES PASADAS') *CENTER)
A NBR 4S 0H SFLRCDNBR(CURSOR)
A RRN 5S 0H
A 1 2'Op. 1=Seleccionar'
A COLOR(BLU)
A 2 2'Op Fecha Trab Fecha Gen Hora -
A Usuario '
A 3 2'==================================-
A =============='
A COLOR(WHT)
A MSGERR 30A O 1 20COLOR(RED)
</code>
</pre>
but for any razon always delete te background screen, i need to show the select but not delete the before screen.
i try several way to do that KEEP on control, ASSUME, OVERLAY, PUTOVR, RSTDSP *YES, and nothing work, please help me.
You might verify if the background screen was compiled with RSTDSP(*YES) or not. If not, try setting the attribute with the CHGDSPF command.
The problem is you require a separate record the uses OVERLAY and ASSUME. You do not have to display this record or reference it at all, it just has to be in the display file.
For example:
0017.70 A*--------------------------------------------------------------*
0017.80 A . . . . . . R BLKLN24
0018.00 A . . . . . . . . . . . . . . . . . . ASSUME
0018.10 A . . . . . . . . . . . . . . . . . . OVERLAY
should work.