Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Z Replacement #78

Open
WhiteFangs opened this issue Nov 29, 2021 · 2 comments
Open

The Z Replacement #78

WhiteFangs opened this issue Nov 29, 2021 · 2 comments

Comments

@WhiteFangs
Copy link

The Z Replacement

This year, not much time nor inspiration to create something complex so I went with a simple and short submission. I hope you'll like it!

The Concept

A program that replaces random letters in the text by the letter Z. The more it progresses through the text, the higher the probability of replacement of the letters. It doesn't change the casing and doesn't modify the punctuation.

The Context

Nowadays in France, a proper fascist whose name starts with Z is growing in popularity in the wake of the next presidential election. Out of all his hateful positions, he is also famous for popularizing the "Great Replacement" conspiracy theory into the mainstream conversation. Now all the media and politics talk about are his ideas and nothing else really. Thus, the Z replacement.

The Algorithm

27 lines of PHP code that I run on my local server. You can change the location of the file to suit your need.

<?php
$root = $_SERVER['DOCUMENT_ROOT'];
$string = file_get_contents($root . "/divers/z-replacement/rhino.txt");
$lines = preg_split("/\n/", $string);
$totalCount = strlen($string);
$currentCount = 0;
foreach ($lines as $keyLine => $line) {
	$firstChars = array_slice(mb_str_split($line, 1, "UTF-8"), 0, strlen($line) > 5 ? 6 : 3);
	$isText = count(array_filter($firstChars, function($v) { return $v !== strtoupper($v); })) > 0;
	if ($isText) {
		$words = explode(" ", $line);
		foreach ($words as $keyWord => $word) {
			$characters = mb_str_split($word, 1, "UTF-8");
			foreach ($characters as $keyChar => $char) {
				if (preg_match("/[a-zA-Z\u00C0-\u00FF]/", $char) && mt_rand(0, 100) / 100 < $currentCount / $totalCount) {
					$characters[$keyChar] = $char === strtoupper($char) ? "Z" : "z";
				}
			}
			$words[$keyWord] = implode("", $characters);
		}
		$lines[$keyLine] = implode(" ", $words);
	}
	$currentCount += strlen($line);
}
$final = implode("<br>", $lines);
echo $final;
?>

The Execution

I ran the algorithm on Eugene Ionesco's play Rhinoceros. I am aware it is not in the public domain but I found it was the most fitting for the case. If you don't know the story, it's about more and more people being turned into rhinos as the plot progresses. It is a parabol about the spread of fascism.

Applying the algorithm on this play makes the whole thing more "meta" while also reminding of how fascism operates into the consciousness of everyone.

The result is called Rhinozeros.
rhinoceros.txt
rhinozeros.txt

@hugovk
Copy link
Member

hugovk commented Nov 29, 2021

Simple but I like it! Using satire and adding an extra layer of satire on top.


The adjudication panel found that rhinozeros.txt is only 32 976 words long, but after much deliberation were content with the idea that the original rhinoceros.txt is an appendix which doubles the count to the required 50k+.

@WhiteFangs
Copy link
Author

Thanks!

Ah yes, the text is not long enough but that's because of the original work I applied it on. I figured the algorithm works with a text of any length so I thought the number of words requirement didn't really make sense in this case...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants