Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/main/java/io/zipcoder/Problem1.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
package io.zipcoder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Problem1 {

// Input = “The Farmer went to the store to get 1 dollar’s worth of fertilizer”
// Output = “The 7@rmer went to the $tore to get ! doll@r’$ worth of 7ertilizer”

//break it down "The Farmer" to "The 7@rmer" no change for the first word
// but I need to change F to 7 and a to @ for the second word.
//where to scan in input? in unit test?
// write unit test
//key is f, value is 7, how to replace key with value?
//{ ‘f’ : ‘7’,
// ‘s’:’$’,
// ‘1’:’!’,
// ‘a’.:’@’} map?
//change the word.. substring
//toString back to a sentence

public static void main(String[] args)throws Exception {

// String s2 = "The Farmer went to the store to get 1 dollar’s worth of fertilizer";
// String[] t = s2.split("(?= )");
// for (String e : t)
// System.out.println(e);

StringBuilder pattern = new StringBuilder();


String input = "The Farmer went to the store to get 1 dollar’s worth of fertilizer";
Matcher m = Pattern.compile(pattern.substring(1)).matcher(input);

}

}
23 changes: 23 additions & 0 deletions src/main/java/io/zipcoder/WordParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.zipcoder;

import java.util.ArrayList;
import java.util.Arrays;

public class WordParser {

public void parseFirstWord(){

String firstInput = "";

for (String word : firstInput.split(" ")){

}

}






}
6 changes: 6 additions & 0 deletions src/test/java/io/zipcoder/Problem1Test.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
package io.zipcoder;


public class Problem1Test {




}

41 changes: 41 additions & 0 deletions src/test/java/io/zipcoder/WordParserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.zipcoder;


import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import static org.junit.Assert.*;

public class WordParserTest {

private String nothing = "";
private String inputSentenceFinal = "The Farmer went to the store to get 1 dollar’s worth of fertilizer";
private String inputSentenceTwoWords = "The Farmer";
private WordParser woodparser;

//
// @Before
// public void setUp(){
//
// }

// @Test
// public void parseFirstWordTest{
// woodparser = new WordParser();
// String expected = "The";
// String actual = woodparser.parseFirstWord(inputSentenceTwoWords);
// Assert.assertEquals(expected, actual);
// }








}